|
|
|
|
|
by seanmcdirmid
4481 days ago
|
|
Scala's type system computations themselves are expensive, even if you ignore dependency recompilation. Typers is doing lots of heavy lifting if you've ever looked at the code. Definitely type inference also leads to volatile member signatures, but if the compiler could reach the 1 million lines/second level, then it wouldn't be such a big deal. |
|
In Scala you get things like this:
Or like this: And because immutable sequences are covariant, it has no problem in doing this (i.e. in Scala types usually have a natural flow, no need for explicit castings or shoving round pegs in square holes): Actually, traits can be used as tags, so say you wanted to model the states of a state-machine, instead of having something like this, which is error prone: You could do this: And then you could have a pattern matcher definition, for you know, convenience: Question: what would be the inferred return type of the above unapply function? That's right, it's Option[IsOperational with IsDispatched].Basically Scala is the type of static language with which you can enforce correctness of the business logic with types. Yes, the compiler is slow, but it's slow because it does so much and IMHO, that's time well spent.
Now I also like dynamic languages and on the issue of static versus dynamic, I think David Pollak said it better than I could - static type systems work better if the shape of the data you're working with is well defined, whereas dynamic type systems work better if the shape of the data is not well defined. So usually people are on either side of this debate depending on what they are working on ;-)