Scala isn’t complicated; it’s clever

I’ve been away from Scala for a long while now — a little more than three years.  v2.7.1 was the last rev I used significantly, if memory serves.  I enjoyed my time with it, but it just wasn’t the best fit for me.

Anyway, I’ve learned that sometime in that era, Scala added support for the use of Unicode arrows as optional alternatives to the usual ASCII approximations it’s always had.  For example, this:

for (x <- 1 to 10) { ... }

is equivalent to this:

for (x ← 1 to 10) { ... }

The second example uses a Unicode instead of the ASCII <-; other arrows (corresponding to -> and =>) also have Unicode equivalents in Scala.  There are various other Unicode characters that have been proposed to serve similar roles, generally with positive discussion around them, including , , , , , , and .  This syntactic flexibility isn’t defined in a library, or in private code, but in the language itself.

I’m aghast.  This blog now sports a “WTF” category.

An early Scala-specific keyboard design.
An early Scala-specific keyboard design.

In the ticket that suggested the addition of one of these equivalencies, various potential problems are pointed out, and presumably ignored.  Perhaps people yearn for APL; unfortunately, suitable keyboards are not widely available.

I’ve no issue with Unicode identifiers: I work with a language that imposes no restrictions at all on the characters used, so programmers that want to use Japanese, Cherokee, Sanskrit or Greek characters in their identifiers can have at it.  Being able to opt in to such things is unequivocally good.  However, that language wisely tries to avoid doing clever things, like aliasing the core anonymous function operator to the λ character for everyone1.

There’s been various discussions, controversy, and gnashing of teeth about whether Scala is a complicated programming language.  I won’t get into that; that’s an argument over semantics that I don’t think is framed properly to begin with.

Maybe, though, most of us can agree that, if Scala isn’t complicated, it is at least clever, and things like this are just the most facile examples of that nature.  We are left to our personal biases as to whether or not that is commendable, desirable, or good.


1Discussions like this must mention Fortess, and its duality of language representation: one writes Fortress in ASCII, but the language defines a sort of markup within that character set so as to produce quite elegant renderings of code suitable for publishing.  See an example here.