Hacker News new | past | comments | ask | show | jobs | submit login
Programming in Scala - (Beta Book from Artima) (artima.com)
13 points by raju on Dec 13, 2007 | hide | past | favorite | 5 comments



Scala's Java compatibility is pretty nice. Just realize that using an imperative language's libraries when you're programming in a functional style doesn't lead to beautiful code. The whole rigamarole of

    val blah = new SomeLameJavaClass
    blah setSomething ...
    blah setSomethingElse ...
    blah yetMoreFuckingSettersUgh ...
stands out like a sore thumb in code where you're otherwise using a clean functional style.


Scala has some very nice features for making Java's libraries much nicer to deal with. The most useful are probably implicit definitions and parameters, operators (any method may be used as an infix or postfix operator), and target typing. You can often "Scalify" a library using these features. See [1] and [2] to see what I mean. These features are also great for creating DSLs.

The recent Scala 2.6 compiler brought some other niceties like structural types (imagine duck typing with a static type system), existential types, and lazy values.

All in all, I've been thoroughly impressed with Scala.

[1] Pimp my Library: http://www.artima.com/weblogs/viewpost.jsp?thread=179766

[2] Simplifying JDBC: http://scala.sygneca.com/code/simplifying-jdbc


Yes, you definitely can Scalify things. But having to write boilerplate facades for every library you want to use in a nice way significantly diminishes the utility of Java compatibility.

I meant to say that this is one of the biggest drawbacks of using Scala (along with slightly immature docs). It has an excellent design; it feels like a much bigger language than Java, yet the Scala spec is a fraction of Java's. It is overall an extremely nice thing.


After spending some time with it, I personally can't find a way to make OO and functional mix in a nice way. I know some people say OO can be functional (in the sense that objects don't mutate) but that just looks aweful to me. Fortunately you can avoid the use of a lot of objects in scala anyway, so its not too much of a problem in practice.


And, by the way, I'm definitely going to buy this book.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: