The simpler parts of Scala

There's a constant discussion about Scala being a complex language. In this post I'll try to show the simple parts of Scala that make coding easier.


My favorite article about why Scala is not complex is by Martin Odersky, the father of Scala: But there's one problem with it, it appeals to those already in favor of Scala.


I think Scala *is* complex. Some due to the functional concepts that are foreign to the Java world, some due to the requirement to work inside the JVM (and CLR). In fact, I was against Scala since 2006, because then I tried to learn it and found the syntax awkward. I recently had to start using it because a client required me to and haven't looked back since.


Ok, so now to the actual post, why should you use Scala: because some parts of it make programming easier even for novices:

  • no need for parenthesis for argumentless methods
  • usually no need for semicolon at the end of the line
  • automatic getter and setter generation: declare a field as 'val' and the compiler generates a getter method for you. Declare the field as 'var' and a setter is also generated (these setters are according to Scala's idioms. If you want getXXX and setXXX, annotate the field with @BeanProperty)
  • methods are public by default
  • the constructor is part of the class definition - no need to declare 'class Foo' and then also 'public Foo(....)' constructor
  • no need for 'return' (but you can use it if you want)
  • type inference - no need to declare the type of a variable if the compiler can infer it (but you can if you want to)
  • case classes - compiler automatically generates fields, accessor methods, hashCode(), equals() for you, no need for 'new' to create instances
  • == is null safe and calls equals() (use eq for reference equality)

All these mechanisms are not hard to grasp I think, and there are more (auto generated fields, lazy vals). Using these features you can code "Java style", but write less code:

case class Person(name: String, age: Int)

val first = Person("first", 30) 
val second = Person("second", 20)

if (first == second) {
  println("first and second are the same"


Try writing the same code in java: class with two fields, accessor methods, hashCode, equals, creating two instances, calling methods, comparing instances. You can immediately see you write much more "boring" code. In Scala, the compiler does the grunt work for you.


Some other more advanced (but still simple concepts):

  • traits allow to mix in several implementations. An example is a Logging trait tha declares a 'log' field. To use it you simply "mix" it into your class, so that you no longer need to declare 'private static Logger log = Logger.getLogger(MyLog.class)'.
  • pattern matchers provide a better mechanism than if...else if...else if...
  • collection classes that are much richer than Java's


As you become more and more proficient with Scala, you can use the more advanced mechanisms.


Some counter arguments may be:

  • In a team, one developer can use advanced concepts and confuse the rest: That may be true, but then a developer can write complex and hard to understand code in any language. Such a developer needs to understand the coding standards in the team and "simplify" his code
  • Scala 3rd party libraries are comples: true, usually Scala libraries are written to use the more advanced features of Scala. The solution is easy: don't use them. Any Java library can be used from Scala.


To summarise: Scala has a lot of features that will increase your development productivity. Start with these and learn the rest later.

Thank you for your interest!

We will contact you as soon as possible.


Please leave your details and we’ll get back to you as soon as possible

Oops, something went wrong
Please try again or contact us by email at
Thank you for your interest!

We will contact you as soon as possible.

Send us a message

Oops, something went wrong
Please try again or contact us by email at