On Mon, Mar 26, 2012 at 3:37 AM, Sergey Didenko <sergey.dide...@gmail.com>wrote:
> Hi, > > I believe I've heard claims that nothing stops Clojure 1.3 code to be > made very close to Java in terms of execution speed. > > My personal experience is that it is very difficult to get Java execution speed. On high-level code, where you spend a lot of time building and passing around objects and calling functions, the speed of Clojure is pretty good. Especially if you are actually taking advantage of Clojure's persistent data structures and/or concurrency features, it would be hard to get those features in Java in a way that performs significantly better than how Clojure does it. When writing something low-level that depends on primitive arithmetic and/or arrays and/or pointer manipulation, *sometimes* you can rewrite some very tight loop in Clojure and get similar performance. But I personally have found that the set of problems that lend themselves to that sort of rewriting is very small. In practice, even within low-level code you need to store numbers in data structures and cross function boundaries in ways that ruin Clojure's ability to emit optimized bytecode. Furthermore, if your performance depends on mutating data structures, Clojure makes this difficult. In summary, on high-level code, Clojure's performance is good enough. If it's not good enough, you should probably expect that you'll have to rewrite in Java. In my personal experience, attempts to get Java performance in Clojure usually don't succeed. Despite the occasional blog post that shows successful speed optimizations on some very tiny chunk of code, on "real-world" low-level code, I have never been able to get it fast enough in Clojure. -- 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