BT

JEP 286 Survey Results for Local Variable Type Inference

| by Alex Blewitt Follow 4 Followers on Mar 22, 2016. Estimated reading time: 1 minute |

Brian Goetz has published the results of the local variable type inference survey and the results point to enthusiasm for adopting the feature. InfoQ looks at the results. The survey includes all of the data from the questions, including the other commentary and the information entered in the identity question.

Respondents seem very keen on adopting the feature for the language, with over 86% saying that they are in favour of adding local type inference to Java, which will see the ability to let the JVM infer the type of local variables, similar to the auto keyword in C/C++ or var in languages like Swift and Scala:

public void aMethod() {
  var count = 0; // infers an int type
  var name = "Alex"; // infers String
}

Around 84% of the responses indicated that var is the correct choice for defining a local variable with mutable content, with only a few percent suggesting that using auto would be preferable.

There was more variation in responses regarding whether a separate keyword should be introduced indicating that the inferred value type is to be immutable. Here, other languages influenced the choices such as let (from modern languages such as Swift and Rust) and var (from Scala), or whether to just use the existing final modifier to indicate an immutable value. There was no majority here, and opinions were split between the three choices, with Scala's influence pushing the use of val ahead of the others. 80% of responses would support the introduction of var only, at least initially, with other options resulting in greater levels of distaste. It seems likely that using var alone will provide the maximal benefit with the minimal dislike while leaving options open in the future.

A follow-up survey has been created to allow individuals to offer additional feedback based on earlier results.

Rate this Article

Adoption Stage
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Discuss

Login to InfoQ to interact with what matters most to you.


Recover your password...

Follow

Follow your favorite topics and editors

Quick overview of most important highlights in the industry and on the site.

Like

More signal, less noise

Build your own feed by choosing topics you want to read about and editors you want to hear from.

Notifications

Stay up-to-date

Set up your notifications and don't miss out on content that matters to you

BT