News for hackers. Stuff that matters.
Re:Only fast languages are interesting by skew on Wednesday November 30, 2011 @05:38AM (#3294584)
All the clojure examples test linked lists!

The first example lets lazy evaluation of the random numbers leak into the timing, toss a (dorun tmp) before the timing for a little more sense.

The type annotation ^doubles is useless - it's telling Clojure to expect the definition to get an array of doubles, but then binds it to the same old linked lists.

Re:Only fast languages are interesting by rbanffy on Wednesday November 30, 2011 @05:49AM (#3294605)
I was going to point this out. As always, if you aim for high performance, you should know your data structures. And use the right ones.
Re:Only fast languages are interesting by bretthoerner on Wednesday November 30, 2011 @07:17AM (#3294786)
Can you fix his code and paste it? Why not have him run the bench and post it as an update?
Re:Only fast languages are interesting by rjn945 on Wednesday November 30, 2011 @07:49AM (#3294848)
Based on the work of a previous commenter, I posted this code in the blog comments:

  (defn add-rands []
    (let [ds (double-array 30000000)]
      (dotimes [i 30000000] (aset ds i (Math/random)))
      (time (areduce ds i res 0.0 (+ res (aget ds i))))))
This adds 30,000,000 numbers in 73ms on my machine. His Lush code added 30,000,000 in 180ms. I estimate my computer is twice as fast as his, putting them on par. Hopefully he will run the code so we can see all the run times on the same machine. (I never could get his Lush code running.)

Of course, the Clojure code here is fairly involved to do some basic stuff, but if you did things like this often it would not be hard to add some nice syntactic sugar over it.