Java8: Loops Not required

So, during my job-hunt, I spent at least an hour a day on HackerRank.  I highly recommend the site for anyone learning to code, sharpening their skills, or learning a new language.

Anyway, so at my new job we use Java8 extensively.  I'd had cursory exposure to Java at my last gig, but mostly in the "Why won't this frigging library run with my Java 1.7 JVM?!" variety.  So, it was time to learn something new.  Narturally, I thought of HackerRank and it's Java tutorials.

So here's one that's interesting: Java List.


Some things of note:

  • One can eschew loops completely now.  The new Streams API + lambdas make it possible to mimic the expressiveness of Ruby, with Stream.forEach( ) feeling awfully similar to Ruby's each {}
  • The Stream parallelStream() is pretty much as easy as concurrency on JVM is likely to get.  The only downside is the global JVM fork/join pool for the streams.
  • It's awfully easy to get sucked into multiple transforms that seem to make code harder to read.  As I gain experience with the Collectors, this seems to be getting better. 



Popular posts from this blog

Monday Mope

RegisterForPrintAsyncNotifications

The reality of the next car purchase