Hacker News new | ask | show | jobs
by fooker 2920 days ago
>Swift compile times have been improving as time goes on.

Swift compile times will never be close to ObjC or C compile times, no matter how much engineering goes into it. This is because of how the language is designed, it requires a typechecker which solves an NP hard constraint solving problem.

2 comments

There is a whole bunch of low hanging fruit in the swift compiler as far as compile speed goes.

What swift compiler devs complain most about is about how operator overloading causes some sort of O(n^k) or worse check, because things like the '+' operator has dozens of implementers.

If your really worried about type inference slowing you down, you can write out all of your types like you didn't have type inference. You could even do it in an automated fashion like your source code was some sort of cache.

Unlike C compilers which have no NP-hard problems to solve /s
You can write a C compiler without solving NP hard problems. You can even have pretty good optimizations.