InfoQ

News

Project Coin Announces Second Candidate List

Posted by Charles Humble on Jun 17, 2009

Community
Java
Topics
Programming
Tags
Java SE

Project Coin aims to make small language changes for Java 7 which simplify day to day coding for developers. In a previous InfoQ article we looked at the first "for further consideration" cut that had been made for the project comprising: strings in switch, improved exception handling, Automatic Resource Management, improved type inference for generic instance creation, Elvis and other null-safe operators, and simplified Varargs method invocation. Since then a further five proposals have been added to the list.

1. A combined proposal for better integer literals. This is a composite of three separate proposals. Byte and Short Integer Literal Suffixes submitted by Bruce Chapman adds support for byte and short integer literals by introducing 4 new integer type suffixes 'y' & 'Y' for bytes, 's' & 'S' for shorts. Binary Literals is one of a pair of proposals from Derek Foster which adds a new "0b1" (binary) form to the existing "1" (decimal), "01" (octal) and "0x1" (hexadecimal) forms of specifying numeric literals. Foster has also proposed support for underscores in numbers so that long numeric sequences can be broken up to improve readability - for example long creditCardNumber = 1234_5678_9012_3456L;

2. Language support for JSR 292 (wiki). Proposed by John Rose, this will create source-code syntax for using the new JVM features from JSR 292. These are invokeDynamic instructions, method handle invocation, certain relaxed conversions, and exotic identifiers. This change allows Java to interoperate with new JVM languages that rely on the invokeDynamic instruction. It also reduces the dependency on bytecode manipulation techniques when using javac and the JVM as a platform for developing new programming languages and language runtimes. As such is should be a useful spur for developers looking to develop DSLs on top of the Java language.

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 of myList.get(0) and
myMap["key"] instead of myMap.get("key")

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:

"Here is a code fragment to create an immutable map as it would be done today:

    final Map<Integer, String> platonicSolids;
    static {
        solids = new LinkedHashMap<Map<Integer, String>;
        solids.put(4,  "tetrahedron");
        solids.put(6,  "cube");
        solids.put(8,  "octahedron");
        solids.put(12, "dodecahedron");
        solids.put(20, "icosahedron");
        platonicSolids = Collections.immutableMap(solids);
    }

Here’s how it would look with map literals:

    final Map<Integer, String> platonicSolids = { 4 : "tetrahedron", 
      6 : "cube", 8 : "octahedron", 12 : "dodecahedron", 20 : "icosahedron" };"

Bloch's proposal differs from Imam's in that it only produces immutable collections, is somewhat more concise, and should make the compiler's job of optimisation for small collections easier. The trade-off is that you cannot specify the implementation type, making it inherently less flexible.

5. Large arrays (revised). Arrays are currently indexed by an int which is a limitation that developers are starting to reach. James Lowden's proposal allows longs to be used as array indices in place of 32-bit ints. Two variants have been looked at - a language level change which would be ideal but is somewhat invasive and may therefore be beyond the scope of Project Coin, and a library-based change that could act as a temporary solution and take advantage of JVM level changes if and when they get added to the language.

Project Coin received around 70 proposals in total from which this final short list of 11 candidates was drawn up. Of these, 5 or 6 are expected to make it into Java 7 and should be available in the milestone 6 release. Once the final cut is made a JSR will be submitted to formalise the changes into the language.

No comments

Watch Thread Reply

Educational Content

Brian Marick on 4 Challenges and 5 Guiding Values of Agile Software Development

Brian Marick takes us through a quick tour of the most important values and challenges to adopting Agile successfully (they aren't the typical challenges and values we hear in the community).

Are You a Software Architect?

The line between development and architecture is tricky. Does it exist at all? Is an ivory tower actually needed? There's a balance in the middle, but how do you move from developer to architect?

Agile – A Way of Life and Pragmatic Use of Authority

The word 'authority' sometimes produces an allergic response in hard-line agilists. Freedom and authority – both are bad if misused and both are good if used in right spirit for a noble cause.

Getting Started with Grails, Second Edition

"Getting Started with Grails" brings you up to speed on this modern web framework. Companies as varied as LinkedIn, Wired, and Taco Bell are all using Grails. Are you ready to get started as well?

Using ITIL V3 as a Foundation for SOA Governance

Those familiar with only ITIL V2 often scoff at the thought that ITIL could serve as a governance framework for SOA. With ITIL V3, the focus of the framework shifted towards service-orientation.

Adrian Colyer on AspectJ, tc Server and dm Server

SpringSource CTO Adrian Colyer discusses AspectJ, SpringSource's dm Server and tc Server products, OSGi and Scrum.

Adam Wiggins on Heroku

Heroku's Adam Wiggins talks about Rails, Background Jobs, Add-Ons, Ruby, and how Heroku manages to work around Ruby's inefficiencies using Erlang and other languages.

SOA as an Architectural Pattern: Best Practices in Software Architecture

For Grady Booch the foundation of a good architecture is patterns, SOA being just one of many patterns. In this Second Life presentation, Booch attempts to bring more clarity on what architecture is.