3 ms·
REPLs make a lot of sense in the functional world where everything is an expression. These languages tend to encourage writing lots of small, referentially tran
by lolinder 4y ago
REPLs make a lot of sense in the functional world where everything is an expression. These languages tend to encourage writing lots of small, referentially transparent functions, which are easy to write and test in a REPL. Because the referentially transparent, when you're happy with them, you can copy what you wrote directly into your code.
I think you don't see it used as much in the imperative world because each line of code tends to depend a lot on context that isn't immediately available. When you make a mistake in the REPL, you probably altered state, which means you have to run everything again from scratch to know if your corrected flow actually works. If you're going to run everything again anyway, you may as well just be working in a file with a proper text editor and a good test framework.
(An exception to this might be Ruby, whose Smalltalk heritage gives it a good interactive programming legacy to build on.)