The only thing I've ever seen in Clojure that is "slow" is tight loops on primitives. Most of the time that people bring up Clojure performance, it's usually about tight loops on primitives. For starters, this isn't even something you could really optimize in popular dynamic languages like Python or Ruby.
If you realize your particular application needs fast loops use loop/recur, use type hints (yes they work), be aware which operations get inlined, use Java data structures. There are so many posts on the mailing list now about performance, the answer is just a search away. Early on I converted a boid simulation from Java to Clojure (the Java version could render each frame in about 5ms, but it was not functional, it used a mutable vector data structure) So I spent a couple of days optimizing my Clojure version, I got it down to about 20ms per frame in Clojure. This was down from 40ms-45ms initially using pure Clojure data structures without type hints. A few days ago I changed less than 10 lines of code and split the operations across two cores. _10_ lines. Let me repeat, I spent about 30 minutes to get the same level of performance boost that I got spending more than a couple days understanding type hints and primitive array support. The rendering time dropped to about 8ms-10ms per frame. That's not 5 ms, but the difference was now just too little for me to care. The Clojure version is simple to maintain, and it's trivial to add logic that simple looks up the number of available cores to split the work, if there are say, 4 or 8 cores. Perhaps my point is, Clojure, to me, offers more clear and simple routes to optimization than other languages should you need it. While writing parallel computations in most popular languages is a bear, writing it in Clojure is a gleeful stroll in the park. Once you're programming in a functional style, you'll probably discover there are many places where you could write a macro for saying, I have 100,000 things to do, lets just split this into 4 agents, do 25,000 things efficiently on 4 cores, await, and then be on your merry way. On Mon, Aug 10, 2009 at 6:06 PM, Raoul Duke <rao...@gmail.com> wrote: > > hi, > > while i realize the real answer is "it depends!", are there any > current rules of thumb based on experience about how to tackle > performance tweaking in Clojure? (e.g. as a small random example, i > think i've heard at times that type notes should speed things up, but > then other times have heard they didn't change things much at all. or > i wonder when/how should transients best be used. etc.) > > thanks. > > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---