Tuesday, 20 August 2013

JVM-Language for Comfortable Hot-Code Swapping?

JVM-Language for Comfortable Hot-Code Swapping?

I really like the way you can reload code in some languages (or just load
new code, that isn't bound by any type restrictions), like in
Smalltalk/Python/Erlang/JavaScript/etc. The Problem however is that I have
become heavily reliant on the JVM (not a bad thing imho - I do love the
Syntax/Semantics of Java, when contrasting it with those other languages).
But Java/JVM can't really do this code swapping thing on the same level
without restarting. The main reason for wanting to do it without
restarting is to maintain the state of GUIs, sockets, etc. while changing
the code underneath.
I know JRebel does something similar, but they themselves claim their
solution to not be production-grade (.. and it costs money). I guess I
could whip up something similar myself, for the limited use-case that I'm
looking at .. One MetaObjectInterface that calls Runnables/Callables
through a HashMap and then just keep on loading classes that implement
this interface every time I want to reload anything - but obviously
performance would be horrible, since the JVM can't devirtualize these
calls when JITing.
Languages/Implementations like Groovy have solved this partly by using
invokedynamic, but they don't really seem to offer any reasonable way of
loading new code, other than using eval .. which doesn't really swap out
anything, seeing how it is run in a new interpreer context/scope (or am I
wrong here?).
My question now is what you're experiences have been. Specifically, what
do you believe is the most comfortable way/language of doing
Smalltalk/Python-esque code reloading on the JVM that offers
"production-grade" performance (i.e. somewhere within one order of
magnitude of Java code).
(Sidenote: I know how dangerous this might be and how unmaintainable the
code may end up. I also am aware that the JVM has problems with GC'ing
classes. Both of these discussions are off-topic in the context of this
question though.)

No comments:

Post a Comment