4 ms·
Scala's build times are legendarily horrible. Kotlin has similar compile times to Javac.
by grabcocque 10y ago
Scala's build times are legendarily horrible. Kotlin has similar compile times to Javac.
- pjmlp 10y agoThey are working on improving them though, specially with Dotty. In any case they aren't as bad as C++ (at least until modules arrive).
- smitherfield 10y ago> In any case they aren't as bad as C++ Speaking as a fan of Scala, I find that scalac takes a noticeable amount of time even to compile trivial Hello World-type programs. Huge C++ codebases like Chromium or Boost take ages to compile, but I seriously doubt a comparable Scala codebase would be faster.
- pjmlp 10y agoI only dabbled a few times in Scala, but I do regularly use C++ on some side projects. Do Scala compilation times get measured in hours? Just the other day I gave up compiling Cocos2D-X, after it crossed the one hour threshold on my humble dual core, 8GB.
- brianwawok 10y agoWell Scala programs only get half compiled at command time, the other half is JIT at runtime. But no not hours bad.. but say a 3 minute partial compile for a 1 line change is enough to kill your dev cycle. (Not sure it is 3 minutes bad for most projects these days, but its very hard to have a 2 second Scala compile)
- pkolaczk 10y agoYou get much better compile times if you keep scala compiler running in daemon mode (in SBT or IDEA; AFAIK Gradle can't do this yet), so it gets more benefits from JVM HotSpot. It makes a tremendous difference (up to 10x) on larger code bases and in fact, I often get 1-5s incremental compile times on a 20 kLOC codebase. Another trick is to modularize the project and enable parallel compilation to speed up compiling everything from scratch. As for C++ compile times, the major culprit are templates. Changing a single line of the implementation of a template requires to recompile all code using that template. Scala does not have this problem, because it has generics for most of the things that C++ templates are used, and generics support separate compilation.
- brianwawok 10y agoDaemon does help a bit. Gradle definitely has a daemon: https://docs.gradle.org/current/userguide/gradle_daemon.html https://docs.gradle.org/current/userguide/gradle_daemon.html I think in Scala you can do similar "must recompile all" if you do things like change a global implicit. > I often get 1-5s incremental compile times on a 20 kLOC codebase 20k is still toy project size though. Try incremental compile with 100k or 200k LOC. It gets bad.
- pkolaczk 10y agoGradle has a daemon, but I have some doubts if it really keeps scalac hot in memory. Last time I tried Gradle was weirdly slow with scala incremental compilation, while SBT worked like a breeze. As for compiling 200k LOC - just split it into modules with sane dependencies and then you don't have that problem. > I think in Scala you can do similar "must recompile all" if you do things like change a global implicit. But there is a world of a difference between changing a signature of an implicit than changing an implementation of a template. If you change the implementation of an implicit, the only thing that needs recompiling is the class defining the implicit, nothing more.
- pjmlp 10y agoSo it is not Delphi, but I still find it quite fast.
- smitherfield 10y agoI also haven't used Scala at scale enough to say; the incremental compilation story is much better than templated C++ but I think compiling a large codebase from scratch would be quite slow, and slower than templated C++. I think any design for generics that provides the same guarantees as C++ templates (type-safe, resolved at compile-time, value types aren't boxed) is necessarily going to cause long compilation times. The only other implementation I know of that checks all three boxes is Rust's, and so far generic Rust is even slower to compile than templated C++.
- pkolaczk 10y ago> I think compiling a large codebase from scratch would be quite slow, and slower than templated C++ It very much depends on which features of Scala you use. If you restrict yourself to the features available in Kotlin or other "better Java" languages, Scala compiler isn't much slower. Where Scala compiler gets really slow are implicits - so if you try to write Scala as if it were Haskell then you are probably in trouble.
- pjmlp 10y ago> I think any design for generics that provides the same guarantees as C++ templates (type-safe, resolved at compile-time, value types aren't boxed) is necessarily going to cause long compilation times. This isn't true of Ada, Modula-3 or Eiffel generics. As for Rust, yes their compilation story still needs some improvements, but they still need to enable incremental compilation and cargo is yet to be able to handle binary dependencies across projects. Where I suffered more in C++ compilation times was building the latest versions from either Swift or Rust, LLVM just takes ages to compile. Thankfully I mostly use C++ as helping hand for Java/.NET.
- smitherfield 10y ago> This isn't true of Ada, Modula-3 or Eiffel generics. I'm not familiar with those languages, but it appears that Eiffel and Modula-3 generics only work with boxed (implemented as pass-by-reference) types, and Eiffel doesn't have pass-by-value types at all. It does look like Ada generics fulfil those three conditions.
- robertlagrant 10y agoI get what you're saying, but I wouldn't refer to that as a performance issue without any context.