Control structures, in my functional language?

In other words, Scala — first impressions (though a lot of this also applies to F#). Don’t get me wrong, the idea of a functional language on the JVM appeals to me (and not Clojure, due to Lisp hate). It’s a major problem for me, though, that the JVM doesn’t support tail packing at all (the CLR might with F# becoming a first-class language, but if so, I’ve heard nothing about it), which makes recursion the way it’s normally used sort of a problem. While somewhat offset by the fact that Scala can utilize pretty much any Java library out there. Groovy and JRuby can, too, and they feel more natural. JRuby, at least, doesn’t clutter the code with Java-isms (for lack of a better term). I don’t want to type MyClass extends SomeOtherClass in a functional language.

I want first-class support for map instead of it being a metaphor for for. Function composition is neat and all, but it’s there in every functional language (and other than map and foldl/r, I haven’t found a lot of use for it). I don’t want to import scala.collection.mutable.Hashmap. I don’t want mutable variables at all. Lists and tuples are enough. I want pattern matching to function the way it does in Haskell, OCaml, SML, F#, Erlang, and probably more rather than using a gussied up case statement. I’d rather not see for, while, foreach, et al in there. If I wanted them, I’d write them myself:

-module(for)
-export([for/3])
 
for(Maxval, Maxval, Function) -> [Function(Maxval)]
for(I, Maxval, Function) -> [Function(I) | for(I+1, Maxval, Function)]

Tough.

Those, though, are really just complaints about the way Scala does functional programming. What I like? Actors. However, actors are a first-class feature in Erlang. In Scala, they ride on top of locking/thread semantics in the JVM. In Scala, objects which don’t implement .receive() silently discard messages. In Scala, I can’t swap out modules without bringing down the service, and it’s nontrivial (unlike Erlang) to pass messages between identical codebases, say, Solaris, AIX, Linux, and OSX. Sure, Erlang isn’t as fast as the JVM, but it scales out a hell of a lot better without assloads of XML and clusters.

I also really like the fact that unlike some languages (-cough- Erlang -cough-), string handling doesn’t, well, suck. I like the fact that I can use JDBC bindings and Swing. I like that it can be compiled to a .war and deployed. Frankly though, in that case, I’d rather just use JRuby.

I don’t like the ludicrous method chaining it inherits from .Java. something.length.toString.length to align text? Really? Same goes for F#, though. Thanks, Scala team, and I look forward to revisiting your language sometime in the future. Until then, I’m sticking with Erlang/OCaml/F#, depending on my needs.