Hacker News new | ask | show | jobs
by Kaali 4757 days ago
Clojure has excellent support for hot swapping functions and data; which in my experience is far ahead of anything that Java has. The system introduced in this article is for reloading code but with a consistent state.

For example, if your application includes some state from previous actions. Then you change a function that acts on that state, but with a different protocol (e.g. data structure expectations changed in the function). Then your application would not work, as the old state is invalid for the new function. With techniques like explained in the article, you can quickly "reboot" your state to be consistent with your new code by reseeding your system.

2 comments

This is equivalent to restarting the JVM along with your application but only quicker?

I really don't see a good pain/gain ratio here. Clojure being a lisp you are already good for reloading functions. Only if you change data structures or macros you need to reboot. That I would think is a much less frequent operation for which a JVM restart is acceptable. (You also know that absolutely everything got reset.)

Note it's not just restarting the JVM, it's also restarting your repl as well, which can be as big a PITA as restarting your JVM.

If restarting your JVM is ok with you, go for it! But I like what Stuart has presented and find it interesting, I'm all about minimizing interruptions while I'm working on something and will be trying to adapt his workflow to mine.

Try JRebel.
JRebel seems a big improvement over normal JVM hot swapping, but it still doesn't seem to be quite as comprehensive as the capabilities a dynamic language like Clojure offers.