I need some code samples (and I also really curious about them) of Scala and Java code which show that Scala code is more simple and concise then code written in Java (of course both samples should solve the same problem).
If there is only Scala sample with comment like “this is abstract factory in Scala, in Java it will look much more cumbersome” then this is also acceptable.
Thanks!
I like most of all accepted and this answers
Let’s improve stacker’s example and use Scala’s case classes:
The above Scala class contains all features of the below Java class, and some more – for example it supports pattern matching (which Java doesn’t have). Scala 2.8 adds named and default arguments, which are used to generate a copy method for case classes, which gives the same ability as the with* methods of the following Java class.
Then, in usage we have (of course):
Against