I think Scala is very large compared to languages like Python or Java, but smaller than C++.By “large” I mean there are a lot of concepts in the language. Just to list a few that aren’t in Java…
Here’s a discussion of the other features you mention, in comparison to Java.
- Higher kinded types
Yes, that’s definitely beyond Java. This is the one feature where for a long time I was not sure whether it is worth the weight. I have been leaning recently more towards believing that it will probably turn out to be quite useful.
- by-name method parameters
- companion objects
- case classes
- structural types
- closures / first-class functions
- for comprehensions
- mixin composition / multiple inheritence
- self types
- type inference
<> notation in Java 7? How is that simpler?
OK I concede, it’s a yes.
- pattern matching (and associated unapply etc support machinery)
- loose syntax for some language constructs, e.g. dropping parenthesis
- operator overloading
- multiple parameter lists for methods
- parameter lists that come before the method name (colon prefixed operators)
- implicits (parameters, conversions, values)
- stable ids vs non-stable ids
- default arguments
- lazy values
- added access qualifiers (e.g. private[this])
- XML as-a-language construct
- …and I’m probably forgeting some…So what does it drop from Java:
- static members
- field / method dichotomy
- object / primitive dichotomy
– 4 namespaces (methods/fields/types/packages) instead of two.
– different name resolution rules for each namespace.
– annotations (yes Scala has them as well but they are much, much simpler than Java’s)
– some tricky syntactic corner cases to disambiguate between casts and expressions.
– nasty explicit parameterization. Does anyone even know how to pass a type parameter to a method in Java?
– over-reliance on wildcards, leading to very hard to diagnose type errors.
– restrictions on arrays with generics.
– raw types(!)
– restrictions that inner classes can only acces final members.
– super constructors.
– dataflow analyses for definite assigment and termination (these are actually useful, but burn about 20 pages in the spec).
– throws clauses and the rules governing them
– complicated rules what kind of casts are allowed where
A lot of these points look simple, but start to read up on their precise rules, they are anything but.
I don’t want to get into a feature to feature comparison between languages. My main point is, that, if you draw up a list of bullet points you can make any language look forbiddingly complex.
Some measures: The grammar of Scala is actually smaller than the grammar of Java. The typechecker of Scala is about the same length in lines of code as the type checker for Java, or the type checker for Haskell. Of course, every type checker is written in its own language, so you can draw an infinite number of conclusions form that, all of the form:
Scala’s type system is X-times more complicated than Java’s or Haskell’s, but code written in the language
is X-times more compact
where X ranges from 0 to infinity.