?

Log in

No account? Create an account
Previous Entry Share Next Entry
Programming as art: Scala's new Collections API
device
jducoeur
Okay, this one's for the hardcore code geeks in the audience; anybody else will find it eye-glazing. But if you really love code, check out the Scala 2.8 Collections API. It's a thing of beauty, and a really good illustration of why I so love Scala -- they systematically deconstructed every major collection type, figured out exactly what they have in common and what makes each one different, and rebuilt the libraries to be about as consistent and sensible as is humanly possible. (They were already way better than average in 2.7, but they nonetheless rewrote it under the hood to make it all *right*.)

The result looks about as close to perfect as you can get: as many common base traits as possible (making everything more learnable and robust); focused on immutable collections (for safety and scalability) while allowing you to work with mutable ones whenever you feel the need; lots of consistent operations, so very-high-level functional programming Just Works; abstractions that let you seamlessly work with infinite collections exactly the same way you do finite ones; thoroughly type-safe from top to bottom, using Scala's type inference to catch programming errors without you needing to state types explicitly. I could go on, but you get the idea.

I sometimes talk about programming as my artform, and I mean that quite seriously: I perceive the aesthetics of code just as clearly as I do for painting or music. The Scala project has won me as an adherent on that basis, perhaps more than any other -- there is a common devotion to crystalline elegance in both the language and its tools. That lets me program *better* on a practical level, but beyond that, it's just plain more *satisfying* a language to work in...

  • 1
I wouldn't recommend worrying too much about the changes. Suffice it to say, the previous version was unusually good, but there were a lot of corner cases and edges that didn't quite meet up right. So they decided to take the best ideas, and do a complete housecleaning to make it all more consistent.

(And I generally commend Scala to you. I find it the most pragmatic language around, remarkably strong in both the OO and functional paradigms. Frankly, just learning the language top-to-bottom is an education in programming by itself: while you can usually ignore most of its complexities, really learning the whole thing necessarily teaches nearly every deep programming concept, from OO generics to functional monads...)

  • 1