3 ms·
I 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 fro
by smitherfield 10y ago
I 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.
- pjmlp 10y agoIn Eiffel, a value type is known as an expanded class and it can be given as default class attribute, or when declaring a variable. So generic instantiation will do the right thing depending on the class attributes. Modula-3 supports value types just like any Algol language, you just need to provide the types you want when instatiating a generic module interface. Modula-3 generics work at module level. Here is an example for numeric types, with a generic module for all numeric operations: https://github.com/modula3/cm3/blob/d31f6ca184c66755317ba990a2bd6fb2f0af7f0c/m3-libs/m3core/src/word/GenWord.ig https://github.com/modula3/cm3/blob/d31f6ca184c66755317ba990... Specialized to LONGINT. https://github.com/modula3/cm3/blob/d31f6ca184c66755317ba990a2bd6fb2f0af7f0c/m3-libs/m3core/src/word/Long.i3 https://github.com/modula3/cm3/blob/d31f6ca184c66755317ba990... https://github.com/modula3/cm3/blob/d31f6ca184c66755317ba990a2bd6fb2f0af7f0c/m3-libs/m3core/src/word/LongRep.i3 https://github.com/modula3/cm3/blob/d31f6ca184c66755317ba990... It is a bit convoluted, but it isn't easy to track down a simple example.