3 ms·
I think this is caused because of the disconnect between the source in files and an environment in a REPL. There are alternatives: You can keep your source ins
by klibertp 6y ago
I think this is caused because of the disconnect between the source in files and an environment in a REPL. There are alternatives:
You can keep your source inside your environment, like in Smalltalk. Whatever state you modified, it stays modified as long as you use the same image.
You can ignore hot reloading and have short-lived REPL sessions for testing and debugging. This works with Scala, OCaml, Idris, and similar. You don't need to track state too much, as it's frequently reset to known-good defaults.
Erlang allows hot reloading, but of whole modules only. You can only evaluate expressions in the REPL, not definitions. It's a good strategy, because the state in Erlang is rarely shared across modules, and having to reload the whole module ensures that it's always initialized correctly.
I think Clojure model is very close to what Racket has: you can switch between modules in the REPL and mutate their namespaces without ever reloading them from disk. Common Lisp is also close, the difference being that CL is image based, so there's a way for persisting the state changes... even if it's not the best of ideas :)
I like the Erlang model, but they all have advantages if used correctly. Pervasive immutability and sane reloading strategy help a lot, but even without those, you can use the REPL effectively. On the other hand, "living in the REPL" all the time is maybe going too far.