And even clojure-py is miles behind stock python. One of the problems with Clojure as it stands now is that there is just way too much init work that has to be done on every startup. Just as a comparison, let's compare how python code and clojure code is loaded:
Python: 1) look for a pyc file (often exists for library code) 2) load pyc code, and "parse". This parsing is basically creating C structs that line up with the file. That is to say, pyc code is basically a memory dump of a module. The actual format of this code is interpreter specific. At this point, all literals are instantiated and ready to go. 4) run the loaded bytecode. Since all literals are loaded and ready, very little extra work needs to be done. Clojure: 1) Load the clojure compiler 2) Parse a .clj text file 3) analyze and compile the resulting code 4) generate classes for the code. 5) call the init method for each namespace. 6) sometime in here all the functions you're are going to need are init-ed. This means all static members need to be fulfilled. This means that every var in every function has to be resolved and interned. Every constant needs to be created. 7) Now the code can run. 8) ... somewhere in here JITing happens. What makes this worse is that parts of Clojure may not be properly profiled by the JIT. In one benchmark I ran I saw a 2x speed-up loading files after the compiler was properly warmed up. What we see here is the difference between a VM designed for a language, and one designed for a different language. In Python constants are just dumped to/from disk during compilation and loading. In Clojure these constants have to be recreated each time. In order to avoid cross platform issues, many people avoid AOT compilation at all costs (and rightfully so, it's a ugly beast), but this then adds parse/analyzer/compiler costs to the entire process. All this results in the following: time python -c "1" real 0m0.019s user 0m0.011s sys 0m0.007s time java -jar clojure-1.6.0-alpha3.jar -e "1" 1 real 0m1.135s user 0m1.525s sys 0m0.086s Now most of the time I really don't care, I have a beefy dev machine, and so I simply load up a repl and keep it up all day. But I understand that these limitations also keep Clojure from reaching into other more constrained environments. Anyway, that's my personal take on the subject. It's a trade-off. The JVM is nice, but it's dang hard to get fast startup times with it. Timothy On Wed, Jan 8, 2014 at 8:56 AM, Jim - FooBar(); <jimpil1...@gmail.com>wrote: > Anyone who owns a RPi can go into the Pi-store and download MultiSnake > to get a feeling of the problem...MultiSnake is basically a polished > version of Stuart Halloway's snake game first featured in the book > "Programming Clojure", with the major features you would expect from a > snake game included and no reflection (well there is one place where I > cannot get rid of reflection)... > > If I remember correctly `lein repl` takes close to 55 seconds to > show...clojure-py beats everything, hands down with respect to startup > times... > > Jim > > > > > On 08/01/14 15:46, Timothy Baldridge wrote: > > That's actually a major issue for those wanting to use Clojure to work on > a RPi or similar low end system. These systems are also so memory > constrained, that last I checked, the CLJS compiler wouldn't run too well > on them either. Now that doesn't stop people from using Node.js to run CLJS > code once it's compiled and copied to the device, but still, not exactly > the ideal solution. > > Timothy > > > On Wed, Jan 8, 2014 at 8:43 AM, Jim - FooBar(); <jimpil1...@gmail.com>wrote: > >> On 08/01/14 14:38, John Gabriele wrote: >> >>> For a tiny Clojure uberjar, startup time on my desktop is about a >>> second. Tolerable. >>> >> >> well, a tiny Clojure/Swing uberjar on the raspberry-pi (oracle-java7) >> takes 9-12 seconds to start!!! not so tolerable... >> in fact, in the absence of a splash screen, the user has the quite >> convincing illusion that nothing is happening!!! >> >> this of course doesn't mean anything, I just thought it is worth >> mentioning... >> >> Jim >> >> >> >> -- >> -- >> You received this message because you are subscribed to the Google >> Groups "Clojure" group. >> To post to this group, send email to clojure@googlegroups.com >> Note that posts from new members are moderated - please be patient with >> your first post. >> To unsubscribe from this group, send email to >> clojure+unsubscr...@googlegroups.com >> For more options, visit this group at >> http://groups.google.com/group/clojure?hl=en >> --- You received this message because you are subscribed to the Google >> Groups "Clojure" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to clojure+unsubscr...@googlegroups.com. >> For more options, visit https://groups.google.com/groups/opt_out. >> > > > > -- > “One of the main causes of the fall of the Roman Empire was that–lacking > zero–they had no way to indicate successful termination of their C > programs.” > (Robert Firth) > -- > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with > your first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en > --- > You received this message because you are subscribed to the Google Groups > "Clojure" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to clojure+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. > > > -- > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with > your first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en > --- > You received this message because you are subscribed to the Google Groups > "Clojure" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to clojure+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. > -- “One of the main causes of the fall of the Roman Empire was that–lacking zero–they had no way to indicate successful termination of their C programs.” (Robert Firth) -- -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.