Hacker News new | ask | show | jobs
by jrockway 5971 days ago
Here's a Java IDE question: why doesn't Eclipse have a REPL in the default install? That's the one thing I use most in other languages. It's nice to be able to right click to rename things (although a perl oneliner works just as well in practice), but it's nicer to be able to know that your mini-algorithm works before you design a class around it. Why is the focus on "rename" and "extract method" instead of "write code that actually works"?
3 comments

IntelliJ does actually have a "REPL" built in. Although lately, I've simply been using the Scala REPL and/or Clojure+Slime to verify whether a Java library works the way I expect it to.

(I also use "perl -d" as a REPL for Perl, which it does quite well)

Devel::REPL is a better Perl REPL.
Instead of writing throw-away code in your REPL you can write a unit test around your function and you get a permanent unit test as a bonus.
I would generally say the same thing, but most of the experimentation I do in the REPL is "is this crazy thing possible", not "is f(4) = 3.23432198"?

And sometimes it's just not worth testing, because it's something like ``hmm, I wonder if 'intercalate ", " ["foo", "bar", "baz"]' returns 'foo, bar, baz'; ahh yes, it does.'' The only reason to test that is because you want your test suite to run slower.

As jrockway says in this thread. The REPL is most useful for exploratory coding, which a unit test is not good for.

Why write a unit test for a feature of the language? The Language designer probably already did that and all you need to do is write unit tests for your own code. I do a fair amount of clojure code now and find it highly useful for just running java code to see how it behaves. Which then helps me figure out how to code my actual code, which then will pass the test that I've already written.

I use the Jython (or Scala) REPL to explore Java.