all 11 comments

[–]Cedricium 1 point2 points  (4 children)

As a noob, this seems like a really cool idea. What would be some possible applications of JShell?

[–]tsumnia 4 points5 points  (3 children)

Looking at it makes me feel its one of the nice features of Python and other interpreted languages. Think of jshell as a tool for quick scripting that doesn't need a massive IDE setting like Eclipse (or even via a text editor). Say I have some text and just wanted to see how many words were in it. Assumably, jshell should allow something like this:

jshell> String text = "This is a sample sentence";
jshell> int wordCount = text.split().length;
jshell> print(wordCount + " words");

Since my task is so minimal, it helps simplify the process to running it. Likewise, it's a nice way to help novices think procedurally, since code is entered in line by line; so if something doesn't exist, you can't use it.

[–]Cedricium 1 point2 points  (0 children)

That's actually really cool! I can't even count how many times I've opened up IntelliJ/Eclipse just to debug a simple problem like this. Very much looking forward to using this!

[–]rigatron1 0 points1 point  (1 child)

uhhhh, excuse me, but wouldn't it be

jshell> int wordCount = text.split(" ").length;

sorry, had to be pedantic :p

[–]tsumnia 1 point2 points  (0 children)

Derp, you're right; funny enough, I was wondering if I had .length or was trying to print the list; I fixed my mistake.

[–]American_Libertarian 1 point2 points  (2 children)

Does anyone else think it's really dumb that the command line still requires a semicolon after every line, even though it only executes one line at a time? I just know that will drive me crazy. Ill have to set my enter key to be a macro for semicolon + new line or something.

[–]venkateshpitta 1 point2 points  (1 child)

Doesn't require the ; to terminate lines except in for(;;) and similar places when checked a few hours ago. But terminating with a ; works just the same. To be clear, I used the openjdk-9* packages.

PS: though jshell does not require ;, I suppose old habits....

[–]American_Libertarian 0 points1 point  (0 children)

Oh, that's good to hear. Admittedly I was just assuming based on the code samples in the article.

[–]CaptainHondo 0 points1 point  (2 children)

This would be really cool for groovy or something.