4 ms·
I don't think they are referring to Go, a lot of languages avoid adding features that inevitably would add to compile times... Java for example (which I think i
by brabel 6y ago
I don't think they are referring to Go, a lot of languages avoid adding features that inevitably would add to compile times... Java for example (which I think is more likely what the author had in mind)... it requires you to end every statement with a semi-colon. Kotlin removes that restriction, but that costs compilation time (Kotlin seems to use a heuristic that if it's possible to terminate an expression when a new-line is reached without it being a compile error, then it does it... in some cases, a new-line is required even if it "looks like" it shouldn't be needed, e.g. `val func = {} val x = 0` doesn't compile). There are many features like this in Kotlin, and it shows as the Kotlin compiler is nowhere near the speed of the Java compiler if you don't use a freaking compiler daemon.
I had a test suite that used `StringSpec` to make tests prettier to write, but after a few hundreds of those, my Kotlin tests started taking visibly longer to compile than the Java source code (which was much larger)! So I had to re-write the tests to use plain Kotlin functions instead.
All languages I know that have "advanced features" have notably slow compilers: Rust, Scala, Haskell. I would be happy to know if there's any counter-examples (I might almost include Kotlin as a counter-example, actually, as it's not so bad if you let it run the Gradle daemon to use the techniques mentioned in the article - but that feels a little bit like cheating as you're getting fast by just avoiding compiling everything).
So while I think the trade-off is worth it most of the time, it's something to be aware of and consider in your decision when choosing a language.
- dwohnitmok 6y agoDepends what you mean by advanced features, but OCaml has very fast compile times (usually faster than Go IIRC).
- brabel 6y agoThat would be truly impressive, given how OCaml has global type inference IIRC!
- wilsonthewhale 6y agoOCaml is usually compiled by module, and module-module interfaces mostly all have explicitly declared types (in the .mli), so it's usually not very global, just within the module.
- dwohnitmok 6y agoNot many language have cross-module type inference. For example I'm pretty sure Haskell does not have cross-module type inference (you need `.hs-boot` files to help it along if you want cyclic modules for example). So in that sense OCaml's type inference is no weaker than other languages with global type inference. And in fact type inference is generally not what slows down compilation. It is often barely any more expensive than type checking (and indeed for languages with global type inference a viable way to implement type checking is to run type inference and then compare the generated type signature with the annotated signature). This is especially true for OCaml which requires definitions to be in order or otherwise explicitly marked as recursive (so the type inferencing algorithm can immediately add a term's inferred type to the current typing judgment as a known type). What's slow is usually recursive implicit definitions and optimizations. This means typeclass-heavy signatures for Haskell and frequent use of recursive implicits in Scala.