Fun - The undersold benefit of Scala

I've seen a lot of arguments lately comparing Scala to [insert any language here]. The arguments are normally based on some mix of conciseness, static typing, functional programming and the actor model. However, I've yet to see anyone arguing for the main reason I'm drawn to Scala: it's fun to work in.

Some of this fun factor is a result of the above arguments but I'm going to illustrate 3 ways in which I find Scala more enjoyable than my normal language: Java.

Functional Programming is Fun

There. I said it.

I don't mean the brain-bending functional programming examples you often get at university. I mean the practical sort:

val totalAge = list.foldLeft(0)(_ + _.age)

The Java alternatives to this are full of boiler plate: interfaces and anonymous inner classes or iterating over the list and summing. However, writing all that boiler plate code isn't fun. Writing only the code that you want to write is way more fun than writing the code you want to write surrounded by a load of dross.

Forgetting multi-threading woes is Fun

The actor model allows you to remove a lot of your multi-threading woes as you can rely on the message-passing model to be safe. This removes all that boring time spent pondering whether each synchronized block is valid. It also removes a lot of the boring time spent debugging multi-threading bugs.

Explaining actors is even fun in itself. You can get a group of people together and they can be the actors and you can act out a scenario. Far more fun than trying to explain multi-threading.

Getters/setters are dull, dull, dull

public void setAge(int age) {
  this.age = age;

public int getAge() {
  return this.age;  

yawn I know this can be auto-generated by any decent IDE. However, I shouldn't have to auto-generate it. I shouldn't even have to see this stuff unless it is doing something exciting. In Scala you can do this in one line:

var age

If I need to do something more exciting in the getters/setters then I can. That option is still there. However, the default 90% case is covered off in one line. Goodbye dull code that offends my eyes every time I see it.


So, there we have it. 3 examples of why I find Scala more fun than Java - but, there are many more! I welcome any more examples of why Scala is more fun :-)


blog comments powered by Disqus

Colin Howe

I'm Colin. I like coding, ultimate frisbee and startups. I am VP of engineering at Conversocial