We can reload any function and/or variable in Clojure at runtime almost instantly. We can even change method signatures. The most we can do with Scala or Java is to use JRebel which is slow, commercial, and restricted. What is the difference that allows Clojure to be so interactive? Reading about this in Slack, I have found the following comments, but I wish to know more about it. Links to papers/articles clarifying the issue further is also appreciated (though not required).
It’s mostly because the language is set up to be reloadable. Clojure has a var indirection for every function or top level variable definition which you can mutate, so you can redefine just one function while keeping the rest of your environment the same and carry on
.
following up on that - there's indirection when the function name is in the code, but for a long running function that took another function as an argument (eg. you passed a handler function to an http server process startup) you can get the benefits of var indirection by hand - by passing #'handler instead of handler but otherwise you don't get the reloading (without restarting the process that took that arg)
.
kind of
direct linking replaces var calls being compiled with direct calls (edited) the var path however still exists and NEW code can still invoke via the vars