Hacker Newsnew | past | comments | ask | show | jobs | submit | J446's commentslogin

I don't know whether to laugh or cry...


don't forgot to add Hibernate to that for everyone still living in 2004


That depends if you mean Java the language or Java the platform. Java the language is to include immutable collection literals in JDK8:

http://jcp.org/en/jsr/detail?id=337

Today Java lets you do the following:

List<String> myList = Arrays.asList("one", "two", "three");

Scala and Groovy which target the JVM let you do things like:

Scala: val myList = List("one", "two", "three")

Groovy: def myList = ["one", "two", "three"]

Then there's JRuby, Jython etc.


> List<String> myList = Arrays.asList("one", "two", "three");

This is often not good enough, as Arrays.asList returns some internal immutable List type. If you then tried to do something like myList.add("four"); you'd get an exception.

What you'd actually need to do is something more like:

> List<String> myList = new ArrayList<String>(Arrays.asList("one", "two", "three"));

Compare that to more dynamic languages, where that example would be:

> myList = ["one", "two", "three"]

Yes, it's a trivial example, but it's something many programs involve all over the place, and the boilerplate adds up a tedious task.


Collection literals for inclusion in JDK8:

http://jcp.org/en/jsr/detail?id=337


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: