CHAMP an improvement on HAMT?

2017-08-13 Thread Alexander Hudek
I figured this would end up here eventually, so may as well cross post from HN: https://michael.steindorfer.name/publications/phd-thesis-efficient-immutable-collections.pdf It directly compares to and improves on Clojure's HAMT based data structures. -- You received this message because you

Re: Why is Clojure slow? (fibonacci)

2017-08-13 Thread Didier
Keep in mind Clojure can be made as fast as Java, it is not by default. What it is by default is one of the fastest dynamic programming language. On Sunday, 13 August 2017 11:46:31 UTC-7, Daniel Gerlach wrote: > > Thx, > > that was it :) > > I used the boxed int version ^Integer as a type hint,

Re: Why is Clojure slow? (fibonacci)

2017-08-13 Thread Daniel Gerlach
Thx, that was it :) I used the boxed int version ^Integer as a type hint, so it had not the expected effect. I also only "type hinted" the input function parameter not the return value. Greeting Daniel Gerlach On Sunday, August 13, 2017 at 2:28:13 PM UTC+2, James Reeves wrote: > > With

Re: Why is Clojure slow? (fibonacci)

2017-08-13 Thread Daniel Gerlach
Thx for the answers, but my point is not to make it run faster. I know i could use memoization or use a loop with an accumulator variable. Rather i want to find out why java is so much faster. Here my java implementation (the same naive algorithm like the clojure version): public static int

Re: Why is Clojure slow? (fibonacci)

2017-08-13 Thread Matching Socks
Avoiding boxed Longs as James suggested reduces the run time to about one-tenth that of the original. "memoize" avoids some additions, but it again boxes the longs. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email

Re: Why is Clojure slow? (fibonacci)

2017-08-13 Thread Kevin Baldor
You could also memoize. Sent from my iPad > On Aug 13, 2017, at 7:27 AM, James Reeves wrote: > > With type hints your implementation should run faster: > > (defn fib ^long [^long n] > (if (< n 2) > n > (+ (fib (- n 2)) (fib (- n 1) > > What does your Java

Re: Why is Clojure slow? (fibonacci)

2017-08-13 Thread James Reeves
With type hints your implementation should run faster: (defn fib ^long [^long n] (if (< n 2) n (+ (fib (- n 2)) (fib (- n 1) What does your Java code look like? Is it also recursive? On 13 August 2017 at 10:54, Daniel Gerlach wrote: > Hey, > > out

Why is Clojure slow? (fibonacci)

2017-08-13 Thread Daniel Gerlach
Hey, out of curiosity i did some benchmarking on my Macbook Pro 13 i5 2,7 GHz. I chose a simple naive fibonacci implementation as a candidate (i know that is not a good comparison value for real-world cases) The implementation looks like this: (defn fib [n] (if (< n 2) n (+ (fib (-