Daniel Harrison's Personal Blog

Personal blog for daniel harrison

Scala lesson for the day: concurrency will always be a hard problem to solve, but it’s getting easier March 15, 2010

Filed under: Uncategorized — danielharrison @ 11:24 am

Scala makes concurrent programming patterns easier, however; concurrency is and will be for the foreseeable future be a hard fundamental computer science problem to solve.  For most interesting cases, at some point there’s a shared resource (datastore, database, file) and you’re back in the land of dining philosophers.   I found Scala’s actors approach easier than threads, locks etc approach of Java, but having solved problems like these in Java for many years, and toyed with Erlang, the lessons transferred directly across so it could be that I think concurrently better now, or at least I hope so 😉

I found one thing that hadn’t been really covered in scala books and actor tutorials is the use of futures, promises and reply etc.  Most consume, generate (ping-pong cough!) examples are actor to actor “!” which while conceptually easier to understand don’t really reflect in my view the more common, many readers, few writers problem “!!”.  Looking through my copy of programming in scala for example doesn’t have futures in the index.  I think the approach of scala by example of going through the concurrent features and then explaining how actors are built on top of this would be a good approach.  I can see the problem though, some of Scala is conceptually difficult and different and making it a mainstream programming language means conveying this level of detail and making it engaging and readable would be difficult.   I had only the Scala by example when I first came across Scala and at that stage I didn’t find it very accessible.  Rereading it now for some of the neater features makes me think like most languages, Scala is a language you’ve got to grow into and it’s starting to feel comfortable.

I guess this is the first production Scala code that I’ve written and I feel like it’s conciseness with static-ness is the killer feature.

My biggest frustration at the moment is tool support. I’ve been a big intellij idea fan (just bought 9) and unfortunately the scala plugin feels to have gone backwards since 8.  Apparently it’s being worked on.  The compile, fix cycle for typos is a bit painful but not too bad.  I do think one of the most important and difficult problems still out there to be solved is debugging concurrent code and I think whoever solves it well will have developers throwing money at them.

Advertisements
 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s