3 ms·
Clojure, being a Lisp, uses the tradition of a REPL (Read-Eval-Print-Loop). The REPL handles all of the command line parsing and printing for you. All you do is
by chongli 13y ago
Clojure, being a Lisp, uses the tradition of a REPL (Read-Eval-Print-Loop). The REPL handles all of the command line parsing and printing for you. All you do is load up your program and start calling functions with it. It makes for a great interactive development tool, as it can be used within most editors/IDEs which tend to have commands for automatically reloading all your code in the REPL.
- elwell 13y agoFair enough, but then the difference between the two languages is not linear across the development of the larger program. The largest difference in code size is displayed, but it focuses on boilerplate code being the inflating factor of Java.
- chongli 13y agoYeah, focusing on boilerplate is not all that interesting in the long term. For large applications (which both languages aspire to), it makes more sense to compare things such as static vs dynamic types, mutable vs immutable, etc. Though I guess there is some merit in having less boilerplate, as fewer lines written mean fewer lines to modify during a refactor/debug session.
- ytdtty 13y agoThat would be a good excuse for the apples to oranges comparison if people always ran production server code via the REPL.
- chongli 13y agoIt's actually possible to connect to your production server through a REPL and hot-swap code.
- grogenaut 13y agoIt's possible to connect to a production java server and hot swap code via eclipse. What's your point? Probbably not a good idea to do this for any real production system.
- babs474 13y agoOne of the big features of erlang is intelligent hotswapping for building robust telecom systems that never go down, but can be bug fixed/upgraded on the fly. Just because something is not commonly done with current tools doesn't mean its a bad idea, just that it is a bad idea with current tools. My understanding is that built in java hot swapping is very limited, and indeed would be a bad idea to try hotswapping in production. If the clojure repl brings us closer to the erlang world isn't that a good thing?
- grogenaut 13y agoThe type of code swapping you are doing with the repl, eg coding on the fly in the prod systems, and the type you are doing with erlang are completely different. Erlang does have a much better deployment story than jvms as far as code swapping. But AFAIK Clojure is compiling to bytecode and is under the same constraints as the JVM that it is hosted in.
- technomancy 13y ago> But AFAIK Clojure is compiling to bytecode and is under the same constraints as the JVM that it is hosted in. This is true for certain features (protocols, records, and gen-class, which are easy to avoid for everything but high-performance bottlenecks and legacy interop), but vanilla Clojure functions are built around vars, which are specifically designed to support reloading. edit: it's still primitive compared to Erlang, but it's miles beyond Java.
- grogenaut 13y agoTrue good point. I still maintain that it's not a great idea in production and it really doesn't scale. I did stuff like this in single host servers in rails as well. Turns out to not be so repeatable and not a great idea in prod. Also isn't great if you bring down one node of prod or if you have a load that takes more than one box worth of processing.