Java 9 for Competitive Programming

Revision en1, by limed, 2017-09-23 14:15:29

As Java 9 has been released few days ago, I went through the What's New to see if there is something useful in the context of Competitive Programming. And I didn't find much, just these 2 enhancements:

  • new static factory methods on the List, Set, and Map interfaces (returning immutable instances of those collections), for example: Set<String> alphabet = Set.of("a", "b", "c");

  • internal String representation as array of bytes (8 bit) instead of array of chars (16 bit) in case the string contains only Latin-1 characters (which is normally the case in Competitive Programming); this would reduce memory consumption almost by half in String problems, and I wonder what would be the impact on performance.

As a personal note, I feel like Java is still light years behind Scala (which unfortunately is broken on CF for 2 months already) for writing CP code, even though both of them run on the same JVM. Just please, don't start language flame wars, unless you have tried both :)

Tags java, string, scala

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en3 English limed 2017-09-23 22:20:52 1173 Added some more Java 9 features relevant to CP.
en2 English limed 2017-09-23 14:22:00 153 Tiny change: 'h :)\n\nP.S. If some' -> 'h :)\n\nP. S. If some'
en1 English limed 2017-09-23 14:15:29 1082 Initial revision (published)