Draft JEP: Launch Single-File Source-Code Programs
Brian Goetz
brian.goetz at oracle.com
Fri Feb 9 19:06:59 UTC 2018
This is a natural (and common) thought, but it turns out to not be the
best answer. The design of JShell is heavily influenced by the goal of
offering a good interactive experience. When we were first designing
JShell, we considered whether we also wanted to ask it to do double-duty
as a batch runner (i.e., this was our first thought too), and went
through the process of enumerating some of the tradeoffs that would
entail -- and concluded that doing so risked compromising the primary
(interactive) mission.
And, we already have a means of running whole Java programs -- the
launcher -- which can already accept its input in multiple forms (single
classfile, JAR file, module). Better to teach it how to accept one more
variant input. New users can run programs with
java HelloWorld.java
and can later learn that if they want to amortize compilation cost over
multiple runs, they can do
javac HelloWorld.java
java HelloWorld
On 2/9/2018 7:32 AM, Lennart Börjeson wrote:
> One comment, though: As a linux/unix user, I'd expect the jshell executable to be the processor for jshell scripts, not the compiler ("java"). This would tie in with the established pattern of other shell script processors/repl, e.g. groovysh, or even plain bash.
More information about the compiler-dev
mailing list