Given Scala’s type inference, in a real code base [0, 1, 0]
would appear without obvious type ascriptions.
- It is shorter, but less readable for beginners because they would have no idea what the type is. Is it a Vector? List? Set? Some other esoteric datatype?
- This is the return of the infamous
CanBuildFrom
in a sheep’s skin, or Pythonic skin. The open aspect makes this hard to read/understand. - It makes Scala harder to learn, because this breaks the regularity of Scala that parenthesis is for terms, and bracket is for types.
Side note: tooling support
Tooling is somewhat open-ended so concretely, I’m thinking about formatting, linting, code completion, syntax highlighting on partially edited code. Scala 3.6 rolled out (partly accidentally) without coordination with IntelliJ, Metals, tree-sitter-scala etc working.
I’ve defended Scala 3.6 syntax changes by implementing tree-sitter-scala changes in a hurry, but the syntax change should come with environmental impact analysis (if not actual pull requests) to the tooling ecosystem, assuming people care to have Scala code highlighted correctly on GitHub and editors, and IDEs to function.
Summary
With or without tooling, I personally think the proposed syntax change makes Scala 3.x harder to learn because it adds yet another way of doing the same thing Vector(0, 1, 0)
, and the semantics is completely opaque, which is harder for beginners.
Neither Python nor Rust does this.