With 8, Java is distancing itself from the ‘new Cobol’

Java 8 has introduced a lot of welcome improvements, justifying that I take back my earlier statement that it was ‘the new Cobol’, but I see there is room for improvement.

It is time to amend a post I made a while back, where I supported the idea that Java was the new Cobol. At that time I had given up any hope to see a decent modernisation of the language in a foreseeable future. That future is here and Java has been modernised.

If you look at Oracle’s site, a few points stick out:

  1. Lambda Expressions: this improves some of the building blocks considerably.
  2. Nashorn and Javascript: this is a nod to the success of NodeJS

To me, those two points justify a new blog post to adjust my earlier statement. I still see opportunities for improvement in the syntax itself, take the following example (from the same Oracle article linked above):

Set artists =
        albums.stream()
            .filter(album -> album.getTracks().size() < 8)
            .map(album -> album.getArtist())
            .collect(toSet());

Wouldn’t this read better in the following way?

Set artists =
        albums ->
            stream
                filter tracks.size < 8 
                map artist Set

Notice a lot of the unnecessary characters removed, because the compiler would be able to infer them. This isn't far off from the language's current standard, yet it could have dramatically improved the code readability. I know, there's a huge legacy to cater for and language design requires serious work. This type of simplification wasn't out of reach, it is what you typically see in the attractive programming languages like Haskell, OCaml and others.

So, Java 8 has introduced a lot of welcome improvements, justifying that I take back my earlier statement that it was 'the new Cobol', but I see there is room for improvement.

Leave a Reply

Your email address will not be published. Required fields are marked *