Will increasing the use of dynamic dispatch reduce compile time?

379 Views Asked by At

In swift the compilation time is really slow the amount of code in your project increases. So i was looking for ways to reduce that time. One approach maybe is to use language keywords like final or static to change the way the compiler handles the code in this case using static and dynamic dispatch.

But as far i read is better to avoid runtime overhead reducing dynamic dispatch

So my first doubt is if doing all i can in runtime using more dynamic dispatch reduce compile times at cost of the runtime overhead.

My second doubt is runtime overhead is so bad? that you could sacrifice compile time in order to reduce the overhead?

1

There are 1 best solutions below

1
On BEST ANSWER

To the title question:

Compilation time is a function of:

  • Scanning
  • Parsing
  • Symbol Management
  • Semantic Verification
  • Type Checking (as @Ron Napier pointed out)
  • Code path optimizations
  • Emitting machine code or LLVM-IR

Each one of the steps above will be a function of what techniques are used to accomplish each of the results for the step and the size/complexity of your source file. The is some flexibility in the order and number of steps.

Using dynamic dispatch is a run-time function and worthy of another question.