Project Coin Updates
At the JavaPosse Roundup a few months ago I got the chance to hear more about Project Coin, Sun’s “small change” additions to Java. I also got the chance to annoy the project’s leader, Joe Darcy, about the fact that BigDecimal math operators were off the table for Java 7. That still hurts but the latest updates to potential changes to be included in Java 7 takes quite a bit of the sting out. This is some cool stuff.
3. Indexing access syntax for Lists and Maps. Shams Mahmood Imam’s proposal aims to provide a consistent syntax for access elements of Arrays, Lists and Maps, so you could write:
myList[0]
instead ofmyList.get(0)
andmyMap["key"]
instead ofmyMap.get("key")
I love this change. Much more readable and in line with how other languages do things. I’m always afraid when I say I like things because they’re more Perl-like that it will scare people away or they’ll change it just because of that but this does match my Perl biases from my former life so I like it. :)
4. Collection Literals. Intended to coexist with indexing access syntax for lists and maps and similar to a second proposal from Imam, Josh Bloch adds support for immutable list, set and map literals with a syntax similar to that of array initialisers. An example from the spec:
final Map<integer , String> platonicSolids = { 4 : "tetrahedron", 6 : "cube", 8 : "octahedron", 12 : "dodecahedron", 20 : "icosahedron"};</integer>
Same with this change, I like it a lot. Much less code for the same thing and it’s just as readable. Again, more like Perl without losing readability == good stuff.
Large arrays is a good change to give people flexibility, same with byte and short suffixes and using _ as a comma substitute in long numbers. Perfect “small change” inclusions.
It of course still depends on how much of this stuff gets in but just based on these lists of proposals, it seems like Project Coin will be a success. Everybody running the project and making proposals should be proud of themselves and be congratulated. Java 7 will be quite a bit nicer language because of their efforts.