specialized generics. this is a huge one, too, less boxing is always a win.
JEP-286 less typing.
Maybe Project Panama and maybe a even better AOT.
Compared to what JDK 9 brings, this is huge. JDK 9 brings a Module system which was already possible (and a lot of stuff around it which didn't exist), a new GC algorithm, Tiff Image I/O, jshell, ALPN, http2 client, reactive-streams. (P.S.: not everything is complete here, but this stuff will probably be used by most)
JDK9 mostly brings stuff that was already missing and provided by other libraries. JDK10 will probably change a lot of more things in the JVM ecosystem.
public class something(String name, int age) {
...
}Say you want a POJO with accessors, mutators along with equals and hashcode. Let it generate the methods by defining a class like:
@Data
public class something {
String name;
int age;
}
Lombok generates: public String getName() { ... }
public void setName(String name) { ... }
public int getAge() { ... }
public void setAge(int age) { ... }
public boolean equals(Something other) { ... }
public int hashcode() { ... }
public String toString() { ... }For lombok specifically, other languages have these types of features built in which of course people need to learn in order to use it.
I agree it isn't a perfect solution, but java is in dire need of boilerplate reduction features like this and lombok fills this need well.
https://projectlombok.org/features/val.html
I've been doing C# for while... soo nice to have this. Coming back to java was like "why am I repeating myself". They already did the diamond operator on the right hand side, this makes the left just as nice.
now let the flames begin!!!
Oh also found a use for SneakyThrows today... I'm bootstrapping a test server in my unit test, where all of the code and interfaces are designed for safety and no-crash... and this lets me short circuit right out of it when something bad happens, which in a test setup is what I want.
Getters and Setters are verbose, but usually model classes are contained in a single class anyway, and can be generated automatically with any IDE. I can glance at a typical bean and ignore the code bloat without any problem.
The real issue is that Lombok generated classes don't play well with the dozens of libraries that expect Java bean style methods for auto marshaling and serialization: json generators, commons bean utils, binding libs, etc.
The savings aren't worth the trouble.
You can argue against Lombok for other reasons but was wondering about this specific one.
Also, I don't think this falls under Valhalla (and I'm not sure if it's been committed yet), but the possibility of reasonable type inference in Java 10 would make me rather happy.
Valhalla is pretty big. Goetz described it as pulling on a very long string. It's going to touch everything in the JVM, including reifing generics, although as I understand it, erasure of Objects may be here to stay for the language.
What's broken in the JVM isn't erased generics but instead runtime reflection that is a lie due to erasure. Type erasure though is definitely an example of Java getting something very right for the wrong reasons.
Furthermore, runtime specialization (as opposed to compile-time) would seem to require reified types. So that further confuses things. But you can definitely have reified types without specialization, which I think is the point that you are trying to convey.
Either way, CLR and C# did it a long time ago, and in the same time period when Java acquired its type-erased generics.
Why would native be any better? I would think that as long as the implementation matches the reference it wouldn't matter.