Log in

No account? Create an account
Previous Entry Share Next Entry
Programming in Scala (kind of) available online
For those curious about my frequent rhapsodies about Scala, you may want to check out the bible of the subject, which has just been published online for free.

There is, of course, a gotcha: this is the first edition of the book, not the second, so it doesn't talk about the fairly major improvements in the current 2.8 release of the language, much less the soon-to-be-released 2.9. But it's still 95% accurate and covers 90% of the interesting topics, so it's a convenient way to check out all of the ins and outs of the language for free...

  • 1

I've started working through this. I was delighted to realize that a Map could be used as a function:

val m=Map("foo" -> "bar", "baz" -> "quux", "fred" -> "barney")


One of the things I am fondest of about Scala is that it DWIMs more than any other language I know. It's downright surprising how often I say, "I wonder if this would work?" and it turns out that it does. They put a lot of effort into figuring out the abstractions behind a lot of common constructs, and generalizing how you can use them.

I will admit that I didn't know you could do that with a Map, but I'm not surprised -- it's a very Functional way of looking at things, and Scala tries to enable as much functional programming as is feasible...

Python does a lot of DWIM (e.g., for-loop over arbitrary collections, [] into anything that makes sense), but all within its paradigm; it's pretty sparse on functional features.

That's pretty much par for the course. I mean, *any* serious language nowadays has to have basic functional features -- there are too many useful patterns that you just plain can't do without first-class functions and closures. Even Java has them nowadays (if very, very badly designed).

But Scala is very deliberately trying to walk the hybrid line, with all of the full-bore power of both OO and Functional. They wind up with some compromises here and there, and we had a fascinating argument recently on scala-debate that you can't really *learn* functional programming in Scala (because it's too easy to cheat), but it does a surprisingly good job of doing well on both sides...

  • 1