In the real world, this is mainly used in development, and, like many other functions, its only value comes down to confusion in the right context.
- personal enlightener for programmers *
- True continuous deployment.
- zero planned downtime Service Level Agreements.
- debugging servers.
* not a guarantee.
for me, and I suspect that some of the others here, the real advantage of this
REPL driven development is that it can be
indescribably fun. addictive even. This can sometimes make sense of the code. give it a try ... come try, first REPL is always free :)
currently one big draw is
continuous deployment.Currently, the idea of continuous deployment is that you change one thing, build everything (or pack it faster), and then deploy. with the lisp model, you can actually edit a deployed one (usually a box that receives a mirror of real client sessions) when it is in deployment.
just a pedantic note. you are not actually editing running classes. you compile a new copy of the class and leave it in a known place (var), then the next time it is used, a new copy will be found and used. its not really editing at startup and more like new code takes effect immediately , this reduces the volume of the devlopment process from programs to expressions (usually functions).
another drooling point is the idea of getting bennefit from
security fixes without having to declare downtime . you can upgrade without it, which would cost your SLA any of your precious “planned outages.” If you need to plan your planned downtime six months in advance, and you only get two hours after that (for these poor souls), this can really make them drool.
If you have replicated access to your running application, since it is deployed (potentially (with permission) on the client’s site), you can connect to the application during its launch and run tests on the existing code
in the existing context without stopping and connecting the debugger. You also won’t get any speed loss from the debugger. This can be done using REPL, although when you get a replica there, you can easily create new code (some will say that injecting dynamic class loaders through the debugger is simple) and then correct the situation. Thus, you can connect to a running server. find that after a short failure the function was unable to reconnect to the database, and then reconnect it back and forth.
as with all programming constructs, it
will never be a silver mark , and this constant deployment / development has an interesting drawback: the program may be correct in memory and incorrect on disk. if you compile a function, then you break it and save it, then only a working copy of the code will work. It’s useful for me to know about this and re-update files immediately after saving them.
This might seem fancy, so see how to
Embed Clojure REPL in your production application.