Tuesday, January 24, 2012

On Why Scala is The Perl of JVM Languages

One of my first technical jobs was to develop a system in APL.  There are two lessons I still carry from that experience: one, I can write any program with fewer characters and two, that doesn't make it a better program.   The mark of a great programming language is not the number of characters you can write a program in (see: APL) but how well the language allows the program author communicate with program readers.  Is the meaning of sentences and paragraphs of the language obvious or do I have to "work it out."

Unfortunately, Scala (and most other modern JVM languages) seems to have learned all the wrong lessons from Perl.  When I hear programmers make fun of Perl, I understand that they are really making fun of all those unreadable Perl programs they've had the misfortune to have to have read.  You didn't have to write programs that way in Perl (and I didn't) but it sure seemed like there were too many $s, @s, bless this, and optional parameters that defaulted to $_ and just what did that evaluate to in the middle of a map.

And Scala does all of that.  Implicit conversions.  Methods that use symbols for method names.  A type system that used + and -, :< and >: to differentiate covariant and contravariant type and upper and lower type bounds and who even understands what those things are.  Semicolons are optional except when they're not.  Braces are optional except where they are not and sometimes they become parenthesis.  And too many nifty ideas like case classes that don't work with the rest of the language.

Look, we can all agree that Java suck.  I learned object oriented programming in Smalltalk.  Java really sucks.  And collection classes require functional programming techniques to really work well.  I am certain that you can write code in Scala that is more elegant and more expressive than Java.  And I am equally certain that you can write code in Scala that makes the typical CPAN library seem like a beacon of clarity.  Scala may be a better choice than Java, but that doesn't make it a good language.

And I like programming in Perl.

No comments:

Post a Comment