Chas Emerick is the founder of Snowtide, a small software company specializing in document content extraction service sand libraries for Java and .NET, and a co-author of the forthcoming "Clojure Programming" book from O'Reilly Chas is a DZone MVB and is not an employee of DZone and has posted 17 posts at DZone. You can read more from them at their website. View Full User Profile

Scala isn’t complicated; it’s clever

  • submit to reddit

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.



Published at DZone with permission of Chas Emerick, author and DZone MVB.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)


Jilles Van Gurp replied on Tue, 2011/07/26 - 1:36am

The danger with languages like scala is that they might start turning into a modern day version C++ where loads of language features are bolted on and things get needlessly complicated. Having too many options to do one thing means needless complexity. Also, there's a difference between syntactic sugar and proper language features. Scala has a lot of the both but ultimately it is merely Java++ in the sense that it allows for some pretty damn unreadable and obfuscated code to be written thanks to a lot of flexibility that probably doesn't add a whole lot of value. I'm more in favor of minimalistic approaches where things are as complicated as they need to be rather than the "pimp my compiler" type approach in Scala.

Mason Mann replied on Tue, 2011/07/26 - 7:50am

Unicode identifiers has always been idiotic, and Scala should never have introduced them. It's going to hamper adoption because people go wild with new fancy ass operators and identifiers, which are not easily edited or read by others.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.