Friday, February 9, 2018

What I like about Java 9

I had started to play with Java 9 a month or 2 before its production release but actually missed its release by a couple weeks I guess.

I've not tested many features but what I did quickly try out was the REPL (Read, Eval, Print Loop) which you can access via the command 'jshell'.

In the past when needed, I used Groovy to quickly try out some piece of code I was trying to sort out.  This was handy when working with regular expressions and/or some parsing/splitting of complex strings.

Well, I should need Groovy much less now - jshell provides a nice alternative.  Another plus is that my lambda/stream samples run fine in jshell where I had trouble with Groovy in the past.  

I know it is pretty easy to put together a small project in Eclipse and incrementally do the same type of operations but sometimes you just want to run a real fast check of something - cut/paste some data in and check a regular expression against it.  Other times, you are on a server and a command line tool is just convenient.

Below I started jshell in a directory containing a property file I want to process data out of.  I will note that on output it does replace data with "..." to shorten it to be more readable at a line level. 



There are some things that are ignored by jshell (use of 'final' at the top-level) but so far the simple items I have tried work. Here is small snippet that includes stream/lambda.


Anyways, I find it worthwhile to have jshell around.  I don't expect to see Java 9 in the wild at work for some time yet but it certainly seems like a fine time to start figuring out what pain points it may remove/reduce.

Always fun to try out and learn something new.

Proverbs 18:15 English Standard Version (ESV)

15 An intelligent heart acquires knowledge,
    and the ear of the wise seeks knowledge.

3 comments:

  1. Thanks for all of your work on this web page. My mother really
    likes doing research and it is easy to understand why.
    A lot of people know all relating to the powerful method you provide sensible information through this blog and even cause contribution from
    other people about this content plus our simple princess has always been being
    taught a whole lot. Have fun with the rest of
    the year. You have been doing a stunning job.[X-N-E-W-L-I-N-S-P-I-N-X]I'm extremely
    inspired with your writing talents and also with the structure for your
    weblog. Is this a paid topic or did you customize it your self?
    Either way keep up the excellent high quality writing, it is uncommon to look a nice blog like this one today.

    ReplyDelete
  2. Excellent blog you've got here.. It?s difficult to find
    quality writing like yours nowadays. I seriously appreciate
    people like you! Take care!!

    ReplyDelete
  3. Some really wondrous work on behalf of the owner of
    this web site, perfectly outstanding subject material.

    ReplyDelete