Hacker News new | ask | show | jobs
by drmeister 2080 days ago
Hey - props to the developers of Java for bringing automatic memory management into the mainstream. But it's not quite what I'm looking for when I want to do exploratory programming.
2 comments

Indeed, the lack of a real "REPL" experience is quite limiting with the Java language (you can kinda sorta simulate it with bytecode manipulation, but please don't). However, you can get the full REPL experience on the JVM, along with a gc, if you run Clojure! (Which is itself a bit of an oddball language, since it's dynamic code, immutable data Lisp written for a vm that likes static code and mutable data...)
Q? did you ever try the jShell that comes with java11+. Curious what a REPL power user thinks about it.
Haven't used it, but I can't imagine it would be great. Java's issue is that you can't do anything outside of a class. So there really is no outside context in which a REPL makes conceptual sense.
Well it is not that rigid. You can do code outside of a class/method

  jshell> var x=8
  x ==> 8

  jshell> x*3
  $2 ==> 24
etc.

But I haven't used it either as I never worked with a REPL other than SQL clients.

The REPL in CL allows you to redefine running code, even code compiled with high optimization levels. This is a feature of the language rather than a feature of the REPL but it's in the REPL that such features shine. In the best case in Java you can redefine methods when running under a debugger, using a framework such as JRebel or leveraging an application server/framework ( Play for example). When changes are too radical you have to recompile and redeploy. In CL this is only rarely needed. In short a REPL in Java will never be able to reach the level of interactivity provided by a CL REPL simply because interactive development is not built in the language as in the case of CL.
Agreed - on both fronts.