I frequently hear claims that Scala is much more "complex" than Java.
Can anyone therefore provide an example of Java code that can't be improved by writing it in Scala, or Scala code that can be improved by writing it in Java (but not by just rewriting within Scala)
By "improve", I mean that the code is better with regards to one (or more) of the following characteristics:
- readability - how quickly can another developer, familiar with the language, understand the code
- maintainability - how much work is involved in a simple refactoring
- thread safety
... but doesn't sacrifice any of the above qualities.
It must be a plausible example, something that could potentially exist in a real program.
I also don't expect the API to match 100% after the transformation, and would prefer that Scala code sticks to Scala idioms, while Java sticks to Java idioms.