I agree that the problem is immutable/functional constructs per se., but I don't think the problem is the lack of VM support either. It is possible to get *very* fast code on the JVM.
In Clojure the issue is more that the dynamic nature of many Clojure constructs and lack of static type inference make it impossible for some of the more advanced JVM optimisations to be applied. This isn't really a VM problem, it is more of a compiler problem. When I optimise Clojure code, I always get the feeling that I am doing something that a "sufficiently smart compiler" should be able to do (forcing use of primitives rather than boxed numbers, adding type hints etc.) On Friday, 15 May 2015 03:01:57 UTC+8, tbc++ wrote: > > I think it false view that immutable/functional constructs are slow by > default. Instead, a lot of it comes down to lack of support in the popular > VMs for these constructs. For example the following code: > > (defn add-fn [& args] > (reduce -add 0 args)) > > (loop [x 0] > (if (eq x 10000) > x > (recur (add-fn x 1)))) > > Is never going to be super fast in Clojure, but it compiles down to a loop > with 4 assembly operations in Pixie (https://github.com/pixie-lang/pixie) > all while remaining fully dynamic. But that's because the VM is tuned to > optimize things like varargs and reduce. You can't really tap into the VM > at that level on the CLR or the JVM. > > That's not to say that Pixie is always faster than these platforms, on the > contrary, it's often much slower on GC heavy operations. But hopefully > someday we'll reach the holy grail of a VM that aggressively optimizes > dynamic languages without requiring hinting or rewriting into less > idiomatic forms. > > Timothy > > On Thu, May 14, 2015 at 12:36 PM, Raoul Duke <rao...@gmail.com > <javascript:>> wrote: > >> Ditto F# vs. C#. >> >> One has to wonder when / where / if functional-pure-immutable >> approaches will ever under the covers get "fast enough"? >> >> -- >> You received this message because you are subscribed to the Google >> Groups "Clojure" group. >> To post to this group, send email to clo...@googlegroups.com >> <javascript:> >> Note that posts from new members are moderated - please be patient with >> your first post. >> To unsubscribe from this group, send email to >> clojure+u...@googlegroups.com <javascript:> >> 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+u...@googlegroups.com <javascript:>. >> For more options, visit https://groups.google.com/d/optout. >> > > > > -- > “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/d/optout.