Re: recursive call boxing primitives?

2010-03-10 Thread John Lawrence Aspden
Oops, sorry, I thought my post was stuck in the moderation queue and have only just noticed the replies while browsing through the list history! Thanks to everyone who replied. Your version looks to be about six times faster than mine was. Thanks ever so much! In fact I wouldn't have noticed the

Re: recursive call boxing primitives?

2010-03-04 Thread Stuart Sierra
On Mar 1, 5:33 pm, John Lawrence Aspden aspd...@googlemail.com wrote: Is the reason the Clojure version is slow that recursive calls to draw- tree are boxing and unboxing primitive types? Recursive calls, like all Clojure function calls, force boxing. This may or may not have anything to do

recursive call boxing primitives?

2010-03-02 Thread John Lawrence Aspden
Hi, the other day I was at a conference in London and learned Scala. As my first program I translated a favourite fractal tree program (which I stole from: http://marblemice.com/2009/04/26/clojure-fractal-tree/). The programs are almost exactly the same in the two languages. The Scala version

Re: recursive call boxing primitives?

2010-03-02 Thread David Nolen
How are you measuring the difference between these two programs? What settings are you passing to the JVM when running the Clojure version? David On Mon, Mar 1, 2010 at 5:33 PM, John Lawrence Aspden aspd...@googlemail.com wrote: Hi, the other day I was at a conference in London and learned

Re: recursive call boxing primitives?

2010-03-02 Thread Stuart Halloway
Hi John, You can get some speedup by using unboxed math in draw-tree (see below). What kind of speed difference are you seeing? Stu (import '(javax.swing JFrame JPanel ) '(java.awt Color Graphics Graphics2D)) (defn draw-tree [ #^Graphics g2d angle x y length branch-angle depth]