Hacker News new | past | comments | ask | show | jobs | submit login

In one of the video lectures the author of Clojure seemed to claim that Clojure is as fast as Java. IME though that's not quite the case.



Clojure can be as fast as Java on benchmark-type code using type hints, Java interop and unchecked math. Idiomatic Clojure code will be slower on benchmarks. Operations on persistent data structures are slower than mutation. Reflection takes time.

Back in the real world, Clojure actually does pretty well for itself. As an example, it seems to be fairly common to generate collections of various types and then only use part of them. In Clojure, most of the time those collections would be lazy, saving computations every time the whole thing isn't needed. Also, using clojure.parallel, many operations can be parallelized trivially. I got a 50% speedup running a genetic algorithm on a dual-core machine just by changing a sort to psort.

Of course, hand-optimized Java may still be faster, but Clojure makes it easier.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: