Java developers are slated to get REPL (Read-Eval-Print-Loop) capability via the JShell API with next year's planned Java 9 release.
In a recent blog post, Oracle's Jim Connors cited the ease of use enabled by REPL and Java's setback with the lack of this capability. "Instead of having to construct and compile complete syntactically correct programs before feedback can be achieved, REPLs allow much more interactivity, enabling the student/programmer to enter small snippets of code and receive immediate feedback."
Schools, in fact, have cited the lack of REPL when moving away from Java as a teaching language, Connors said: "With the introduction of
jshell in the upcoming Java 9 release, this shortcoming will be eliminated." Languages like Python already have had the capability, he stressed.
Code for the REPL capability has been featured in the Kulia project, and users were speculating on the addition of a REPL into Java last year. The JEPdetailing JShell says it offers an API and tool to provide a way to interactively evaluate declarations, statements, and expressions of the Java language. "The
jshell state includes an evolving code and execution state. To facilitate rapid investigation and coding, statements and expressions need not occur within a method, expressions need not have side-effects, variables need not occur within a class, and methods need not occur within a class or interface."
jshell tool will be a command-line tool offering ease of interaction via features like tab completion, automatic addition of needed terminal semicolons, and configurable, predefined imports and definitions. Previously, observers have given REPL mixed reviews for Java, praising it for enabling real-time interactivity with code but questioning its usefulness in a statement-oriented language like Java.
This story, "Java 9 plays catch-up, adds REPL for faster feedback" was originally published by InfoWorld.