Saturday, March 13, 2010

Scala Revisited

I've gone over my love-hate relationship with Scala on these pages before but it's skewed toward love now that I've seen it in action for more than prototypes and poking around (it's used increasingly on the server-side with the products developed at my current client).

I want to be clear that I'll always have reservations about any language that tries to straddle the divide and be both object oriented and functional: it makes the language too big and too complex.  Scala's approach toward operator overloading (really, just allowing operator characters such as + and / and == as valid method names) has me flashing back to the nightmare of C++ debugging while having so many ways to shortcut different expression idioms bothers me as well; it allows you to write Perl-like self obfuscating code.  It's a positive trade-off for people with an aversion to typing but I'm sick: I enjoy writing and don't mind verbose expressions if they make things clearer, though I'm happy to be done with extraneous type declarations, parens and semi-colons.

The thing I'm digging with Scala is the relative simplicity in reasoning about concurrent operations and the power of being able to pass around little chunks of functionality.  Now I know these aren't necessarily limited to functional languages: Ruby provides blocks/lambdas/closures and with Java 7's fork/join framework, the concurrency library of the JDK itself is helping to drain some of the unnecessary complexity out of concurrent programming with Java.  But the elegant and immutable nature of functional programming brings out the beauty of software development like I haven't experienced in a while. And all this from just perusing the stuff.

I guess I'm lucky with my first taste of Scala in a real project.  It seems most of it is written pretty well.  That means not as a "better Java" ignoring the functional and Scala conventions and idioms.  It also means not using all the language bells and whistles - it's damn complex enough on its own.  You can write shitty code in any language and Scala will give you more than your share of rope in that regard - we haven't yet.  Then again, I haven't taken my first crack at it yet here.  :-)

Speaking of things functional, there's some good info in this InfoQ talk with Stuart Holloway on Clojure,  a more purely functional Lisp-like language for the JVM (and the CLR).   Makes me want to learn Clojure, but my brain's already full.  Besides, I'm more English Lit than I am Comp Sci and I need to get back to my roots again (I haven't picked up a non-techie book in a few weeks and think I'm going through some sort of withdrawal).  Then there are those two non-techie blogs I've been neglecting of late.  Thank god for the rain today so I can catch up ...

No comments:

Post a Comment