3 ms·
JVM Notebook: Basic Clojure, Java and JVM Language performance
- jm4 17y agoHere is a seemingly relevant thread from the Clojure group: http://groups.google.com/group/clojure/browse_thread/thread/289904c1a5deb8d8/07326af651db0ef8?lnk=gst&q=berlin+brown#07326af651db0ef8 http://groups.google.com/group/clojure/browse_thread/thread/... It was pointed out on there that this is not only a language comparison but a data structure comparison as well. Also, there are no type hints in the Clojure code. Without type hints it would be expected to run significantly slower. It's still an interesting comparison because you would generally only use type hints in performance bottlenecks. I'd be especially interested in seeing what kind of difference it would make in this case.
- babo 17y agoOK, let's write the performance critical part in Java or Scala and Clojure wins hands down for the rest, where we spend our development time at most.
- icey 17y agoOr write the whole thing in Clojure and drop to Java / Scala when you find bottlenecks. (In the same spirit of Python & Ruby people 'dropping to C' for performance when needed.) It seems to me that Scala is becoming the de facto Java replacement; which strikes me as nothing but a good thing.
- MartinMond 17y agoI know it's a controversial question but why do you prefer Clojure over Scala?
- icey 17y agoI don't think it's controversial at all. I prefer lisps in general, and that's pretty much the extent of it. I think Scala is a fine language, but it's not a lisp.
- MartinMond 17y agoI see. I expected some technical reason, but obviously personal preference is fine too :)
- icey 17y agoWell... I guess you could say preference for lisps is a technical reason; but only if you are into macrology.
- radu_floricica 17y agoPersistent data structures are a lot slower then mutable ones, so this was no surprise. I wonder how clojure would have done with the new transients syntax (http://clojure.org/transients http://clojure.org/transients).
- macnod 17y agoOut of curiosity, I wrote a simple non-optimized quicksort function in Common Lisp (SBCL) and timed a 180,000-element sort at 567ms, about half as much as the Java version. I'm sure that could be improved greatly with better coding and type hints. Here's the code http://donnieknows.com/blog/sbcl-fast http://donnieknows.com/blog/sbcl-fast