Java 10 has been released a few days ago, just six months after Java 9. In this version, I found only one new feature which is useful for competitive programming: Local-Variable Type Inferrence. It works similarly to auto
keyword in C++. So now you can write something like this:
var map = new HashMap<Integer, List<String>>();
for (var entry : map.entrySet()) {
var key = entry.getKey();
for (var element : entry.getValue()) {
System.out.println(key + " " + element);
}
}
If you find any other relevant enhancements, please post them here.
your username is lit ;)
What about cool features which is useful for competitive programming in Java 9?
I've found only one blog about this, and it also contains only few features ((
Does Codeforces already support Java 10? I can only find the Java 1.8.0_131 (Java 8) as available compiler. And I expect that most of the other platforms also still use an old version.
The Java feature what should make the most impact in competitive programming is Ahead-of-time compilation. That should make Java solutions almost as fast as C++ solutions. JIT compiler needs a lot of warmup, and simply can't compile most programs in 2 seconds. That means, currently Java solutions are interpreted, thus very slow.
Unfortunately, AOT compilation is still experimental in Java 10.
This is awesome to hear for the future. Are we seriously talking about Java being as fast as C++ ?
Almost as fast as C++ :) At least, magnitude faster than interpreted Java.
I don't think so.
"It’s possible that the use of pre-compiled code could result in less-than-optimal code being used, resulting in a loss of performance. Performance testing shows that some applications benefit from AOT-compiled code, while others clearly show regressions." from http://openjdk.java.net/jeps/295
You are talking about JIT-compiled vs AOT-compiled. And I agree that JIT-compiled programs are generally more performant in the case of long running applications than AOT-compiled programs, because JIT compiler is able to use execution profile data.
But the truth is that in programming competitions we never run JIT-compiled programs. JIT-compiler does its job at runtime, and simply can't compile anything during 1-3 second time limit. Before Java bytecode is compiled by JIT, it has to be interpreted, and execution by interpretation is much much slower than execution of machine code.
On the other hand, AOT-compiler works at build step (like C++ compiler), so the code doesn't have to be interpreted.