When Scala is discussed, the type system is always mentioned as one of the primary features. It is referred to as powerful, and the primary reason for the language moniker (Scala being short for “scalable language”). Could someone please explain how Scala typing works/why this unique, and how that contributes to the language being scalable?
Share
I don’t think the existing answers are appropriate. Scala has a lot of conveniences, but they are not related to the type system being powerful just because they relate to types. In fact, type inference is in direct conflict with the power of the type system — were it less powerful, one could have full type inference (like in Haskell).
So,
Next, there are features related to Scala’s implicits, which is what merit their inclusion above.
Related to the last comment, implicits and type inference, together, make Scala’s type system turing complete. That is, you codify arbitrary programs as types, that will be “run” at compile time by the compiler. Proof here, by way of SKI Calculus, with a “buggy” infinite loop in the types as further demonstration.
The list of features above is quite big and impressive on many points. It is, however, the way Scala combines implicits and type inference to produce static proofs at compile time (such as view bounds and context bounds) that make Scala’s type system unique. AFAIK, there is no other language doing that, though there are certainly other languages providing proof capabilities through other means.