Java loses its explicitness with each release. And it's still much worse as a language than Scala, Kotlin, Groovy, Ceylon (and probably always will be behind). I don't see much value in those improvements. If one wants a better Java, he can use it right now. What Java needs is JVM improvements, like value types or full support for bytecode hot reload. Java 1.4 was very minimalistic and beautiful language. I liked it…
> it's still much worse as a language than Scala, Kotlin, Groovy, Ceylon Some of those languages are better than each other, and they are much worse languages than Clojure, another JVM-hosted language you ignored.
JEP 286: Local-Variable Type Inference
71–80 of 132 posts
Re: JEP 286: Local-Variable Type Inference
#72Earlier quoted context omitted.
All we need is higher kinded types and implicits.
Higher Kinded Types, yes, but implicits... Yuck. Scala has definitely proven them as a failed experiment, I hope we will never seem them again in languages going forward.
Re: JEP 286: Local-Variable Type Inference
#73"The identifier var will not be made into a keyword; instead it will be a reserved type name. This means that code that uses var as a variable, method, or package name will not be affected; code that uses var as a class or interface name will be affected (but these names violate the naming conventions.)"
I didn't know there were such things as "reserved type names", but I'm guessing `var` will be treated sort of like `String` or `Object` (always available without an explicit import) and maybe it'll be a class in `java.lang`?
Seems like a much "nicer" approach than when Enum types were introduced with the `enum` keyword, but I guess that was slightly different.
Re: JEP 286: Local-Variable Type Inference
#74The approach taken to preserve backwards compatibility with existing code that already uses `var` as an identifier is interesting: "The identifier var will not be made into a keyword; instead it will be a reserved type name. This means that code that uses var as a variable, method, or package name will not be affected; code that uses var as a class or interface name will be affected (but these names violate the namin…
And it seems we were right to reduce the scope of it. PHP 7 prohibiting "String" as a class name ended up being a significant BC break affecting several projects. I imagine it might have been worse still if `string` was a reserved word.
Re: JEP 286: Local-Variable Type Inference
#75This is pretty nice. Hope it goes through. It's about time that we had local-variable inference in Java. It does mean that the diamond can't be used this way: var list = new ArrayList (); There is no way to infer the type of the generic parameter. So we will go back to doing: var list = new ArrayList (); Which isn't a big deal IMO because the generic parameters had to be specified on the LHS anyway to use the diamond…
Re: JEP 286: Local-Variable Type Inference
#76var + val would be great.
Yeah, let's spread the nonsense further! There are constants and variables; values are something else. Just because "val" is a short abbreviation everybody gets, it doesn't mean we should abuse it!
Re: JEP 286: Local-Variable Type Inference
#77Earlier quoted context omitted.
All we need is higher kinded types and implicits.
Higher Kinded Types, yes, but implicits... Yuck. Scala has definitely proven them as a failed experiment, I hope we will never seem them again in languages going forward.
Re: JEP 286: Local-Variable Type Inference
#78Earlier quoted context omitted.
All we need is higher kinded types and implicits.
Higher Kinded Types, yes, but implicits... Yuck. Scala has definitely proven them as a failed experiment, I hope we will never seem them again in languages going forward.
They are also quite useful for wiring up context (take Akka's ActorSystem, for example) at the declaration level, so that the bodies of your classes and functions only explicitly talk about your domain objects, rather than framework machinery.
They're also a big part of the power behind projects like Shapeless, which are quite useful for scrapping boilerplate.
Most controversially, they are also used to implement implicit type conversions. Modern idiomatic Scala discourages this, but it can sometimes be helpful.
Re: JEP 286: Local-Variable Type Inference
#79Welcome to 2007? C# added implicitly typed local variables (and the var statement) to the language 9 years ago. https://msdn.microsoft.com/en-us/library/bb308966.aspx
Re: JEP 286: Local-Variable Type Inference
#80Java has been super slow to adopt things that are more or less the norm in other popular languages. Why bother at this point? Isn't Kotlin a pretty good sugared-up Java, anyway?
Lightbend (caretakers of Scala, Play Framework, Akka, Spark, Slick, SBT, and others) wisely announced their dedication to both Scala and Java. It's caused a big stir in the community, but it kind of seems like that should make everybody happy. They're two ecosystems geared to serious software, built on a solid platform, but with very different constituencies. Lightbend realized there's no point in pressuring people to adopt Scala. People will do it on their own, if they want to. But with strong support of both languages, they can address a very broad swath of the development world.