Re: Struct vs. Record: Now and Future

2011-01-28 Thread Chas Emerick

On Jan 27, 2011, at 10:41 PM, Ben Mabey wrote:

 On 1/27/11 7:24 PM, Ken Wesson wrote:
 On Thu, Jan 27, 2011 at 6:24 PM, Mark Engelberg
 mark.engelb...@gmail.com  wrote:
 Records don't have serialization yet, do they?
 user=  (defrecord Foo [n])
 user.Foo
 user=  ((supers Foo) java.io.Serializable)
 java.io.Serializable
 
 Looks like they do.
 
 I've been serializing/serializing records in my current project quite a bit.  
 The one caveat is that for java to serialize the record a class file needs to 
 be compiled for the record.  In my case that just meant I had to introduce 
 AOT via leiningen (which does complicate things TBH).
 
 While this serialization has been fine for most of my needs I have quite 
 often wanted to be able to use *print-dup* since binary serialization seemed 
 overkill in those cases.  Hopefully something like defrecord2 gets added to 
 clojure at some point to make dealing with records more pleasant.

I don't think it's obvious whether any particular serialization mechanism is 
generally better or worse than another without knowing details about a 
particular context.  *print-dup*'s (and others') generally human-readable 
representations and dynamic nature are definitely nice and helpful in some 
cases; binary serialization mechanisms – including java.io.Serialization – that 
are generally static will usually be a few orders of magnitude faster.

The above is FWIW.  I just wanted to offer something tangible in response to 
overkill. :-)

- Chas

-- 
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


Re: Struct vs. Record: Now and Future

2011-01-28 Thread Meikel Brandmeyer
Hi,

On 28 Jan., 13:46, Chas Emerick cemer...@snowtide.com wrote:

 I don't think it's obvious whether any particular serialization
 mechanism is generally better or worse than another without knowing
 details about a particular context.  *print-dup*'s (and others')
 generally human-readable representations and dynamic nature are
 definitely nice and helpful in some cases; binary serialization
 mechanisms – including java.io.Serialization – that are generally
 static will usually be a few orders of magnitude faster.

Another point is that *print-dup* is not really serialisation, is it?

(let [x (list 1 2 3)]
  [(conj x 4) (conj x 5) (conj x 6)])

With *print-dup* the structure uses a little more memory after reading
back.

Sincerely
Meikel

-- 
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


ANN: clj-facebook-graph

2011-01-28 Thread Max Weber
Hey if you like to do something with the (relatively new) Facebook
Graph API (http://developers.facebook.com/docs/api/) give clj-facebook-
graph a try. It's a simple Clojure client for the Facebook Graph API
based on clj-http (https://github.com/getwoven/clj-http) and Ring
(https://github.com/mmcgrana/ring). It offers some convenience when
you are working with the Facebook Graph API. Furthermore clj-facebook-
graph provides a simple authentication flow in the form of some Ring
middleware. The project is at an early stage, but feel free to extend
it and use it as a foundation for your Facebook integration. You can
find it on my github account:

https://github.com/maxweber/clj-facebook-graph

Best regards

Max

-- 
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


Ridiculously massive slowdown when working with images

2011-01-28 Thread Robert McIntyre
I tried to convert this java code line for line to clojure to compare
the speed differences, and boy was I surprised!

public static void ConvertToAWT(byte[] cpuArray){
// Given an array of bytes representing a c-style bgra image,
// converts to a java style abgr image
int len = java.lang.reflect.Array.getLength(cpuArray);
for (int i = 0; i  len; i+=4){
byte b = cpuArray[i+0];
byte g = cpuArray[i+1];
byte r = cpuArray[i+2];
byte a = cpuArray[i+3];
cpuArray[i+0] = a;
cpuArray[i+1] = b;
cpuArray[i+2] = g;
cpuArray[i+3] = r;  }}

(defn java-like []
  (loop [i (int 0)] (if ( i buffer-size)
  (let [ + clojure.core/unchecked-add
b (aget cpuArray i)
g (aget cpuArray (+ 1 i))
r (aget cpuArray (+ 2 i))
a (aget cpuArray (+ 3 i))]
(aset-byte cpuArray i a)
(aset-byte cpuArray (+ 1 i) b)
(aset-byte cpuArray (+ 2 i) g)
(aset-byte cpuArray (+ 3 i) r)
(recur (int (+ i 4)))

(defn clojure-like []
  (doall (flatten (map (fn [[b g r a]] [a b g r]) (partition 4 4
cpuArray)


for a byte-array of size 192, the java-like clojure function, a
line for line translation, takes several minutes, while the java
method takes around 3 milliseconds.
the clojure-like one takes 6 seconds.

Why is the clojure function so much more obnoxiously slow than its
java counterpart?
Can anyone shed some light on what I'm doing wrong?

sincerely,
--Robert McIntyre

-- 
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


Re: Ridiculously massive slowdown when working with images

2011-01-28 Thread Ken Wesson
On Fri, Jan 28, 2011 at 10:48 AM, Robert McIntyre r...@mit.edu wrote:
 I tried to convert this java code line for line to clojure to compare
 the speed differences, and boy was I surprised!

        public static void ConvertToAWT(byte[] cpuArray){
                // Given an array of bytes representing a c-style bgra image,
                // converts to a java style abgr image
                int len = java.lang.reflect.Array.getLength(cpuArray);
                for (int i = 0; i  len; i+=4){
                        byte b = cpuArray[i+0];
                        byte g = cpuArray[i+1];
                        byte r = cpuArray[i+2];
                        byte a = cpuArray[i+3];
                        cpuArray[i+0] = a;
                        cpuArray[i+1] = b;
                        cpuArray[i+2] = g;
                        cpuArray[i+3] = r;  }}

 (defn java-like []
  (loop [i (int 0)] (if ( i buffer-size)
                      (let [ + clojure.core/unchecked-add
                            b (aget cpuArray i)
                            g (aget cpuArray (+ 1 i))
                            r (aget cpuArray (+ 2 i))
                            a (aget cpuArray (+ 3 i))]
                        (aset-byte cpuArray i a)
                        (aset-byte cpuArray (+ 1 i) b)
                        (aset-byte cpuArray (+ 2 i) g)
                        (aset-byte cpuArray (+ 3 i) r)
                        (recur (int (+ i 4)))

 (defn clojure-like []
  (doall (flatten (map (fn [[b g r a]] [a b g r]) (partition 4 4
 cpuArray)


 for a byte-array of size 192, the java-like clojure function, a
 line for line translation, takes several minutes, while the java
 method takes around 3 milliseconds.
 the clojure-like one takes 6 seconds.

 Why is the clojure function so much more obnoxiously slow than its
 java counterpart?
 Can anyone shed some light on what I'm doing wrong?

Boxing, most likely, and/or reflection. Your cpuArray needs to be
produced with (int-array ...) and hinted with ^ints to get top
performance.

-- 
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


Re: Ridiculously massive slowdown when working with images

2011-01-28 Thread David Nolen
On Fri, Jan 28, 2011 at 10:48 AM, Robert McIntyre r...@mit.edu wrote:

 I tried to convert this java code line for line to clojure to compare
 the speed differences, and boy was I surprised!

public static void ConvertToAWT(byte[] cpuArray){
// Given an array of bytes representing a c-style bgra
 image,
// converts to a java style abgr image
int len = java.lang.reflect.Array.getLength(cpuArray);
for (int i = 0; i  len; i+=4){
byte b = cpuArray[i+0];
byte g = cpuArray[i+1];
byte r = cpuArray[i+2];
byte a = cpuArray[i+3];
cpuArray[i+0] = a;
cpuArray[i+1] = b;
cpuArray[i+2] = g;
cpuArray[i+3] = r;  }}

 (defn java-like []
  (loop [i (int 0)] (if ( i buffer-size)
  (let [ + clojure.core/unchecked-add
b (aget cpuArray i)
g (aget cpuArray (+ 1 i))
r (aget cpuArray (+ 2 i))
a (aget cpuArray (+ 3 i))]
(aset-byte cpuArray i a)
(aset-byte cpuArray (+ 1 i) b)
(aset-byte cpuArray (+ 2 i) g)
(aset-byte cpuArray (+ 3 i) r)
(recur (int (+ i 4)))

 (defn clojure-like []
  (doall (flatten (map (fn [[b g r a]] [a b g r]) (partition 4 4
 cpuArray)


I'm assuming you're using 1.2.0. cpuArray needs to be hinted. All the
literals also need to be hinted. Don't use aset-byte, use aset.

In 1.3.0 you no longer have to hint the literals and you can use the
*unchecked-math* compiler flag instead of redefining unchecked-add as a
local.

David

-- 
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

Help with Java arrays

2011-01-28 Thread WoodHacker
Hi,

I'm trying to get the midi sound class in Java to work in Clojure.
Everything seems to work fine except for the conversion of the
following Java code:

 MidiChannel[] channels = synthesizer.getChannels;

I've tried just dumping the channels into a Clojure object -
  (let [channels (.getChannels @synthesizer)]
but I get the following error:

Exception in thread main java.lang.IllegalArgumentException: Can't
call public method of non-public class: public
javax.sound.midi.MidiChannel[]
com.sun.media.sound.AbstractPlayer.getChannels()

There seems to be no way to find out how many channels there are
beforehand.

I'm sure there's a solution, but I can't figure it out.   Any ideas?

Bill

-- 
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


Re: Clojure Conj 2011?

2011-01-28 Thread Alex Miller
Arg, wrong link. Should be:

http://thestrangeloop.com/blog/11/01/27/strange-loop-2011

On Jan 27, 11:25 pm, Alex Miller a...@puredanger.com wrote:
 Strange Loop 2011 will be Sept. 18-20th in St. Louis.

 More info:http://thestrangeloop.com/blog/10/11/05/strange-loop-video-schedule

 (send-off conj-agent (not (schedule ([[9 18 2011] [9 20 2011]]

 On Dec 28 2010, 6:20 pm, Alex Miller alexdmil...@yahoo.com wrote:







  I have not yet set a date forStrangeLoop(although I am talking to
  venues now).  I'm currently looking at Sept 29-30 as the target date.
  JavaOne is the following week.

  Alex

  On Dec 28, 1:50 pm, scott jscotthic...@gmail.com wrote:

   fwiw - there was a number of lucky folks who I met atStrangeLoopin
   St. Louis the week before Conj 2010 who were able to go to both. It
   seemed like there was quite a bit of overlap in interest of those two
   events. I could have probably gone to both if there was at least a few
   weeks time between the two.

   Scott Hickey (no relation)

   On Dec 27, 8:07 pm, Alan Dipert a...@dipert.org wrote:

Hi,

On Mon, Dec 27, 2010 at 7:41 PM, Sean Corfield seancorfi...@gmail.com 
wrote:
 Now that videos are being posted for the 2010 conj, I figured it might
 be worth asking if there has been any discussion about when/where the
 2011 conj might happen?

Conj 2011 will most likely be in either Raleigh or Durham, North
Carolina, and probably will happen around the same time of year as the
last Conj.  We've reviewed all the feedback we've gotten, and are
looking for a venue.  Our hope is to announce the time and place as
soon as possible.

Sorry you couldn't make it to the last one, but looking forward to
seeing you at the next one!
Alan

 I had a schedule conflict last year (actually a double conflict) so
 I'd like to get this year's event on my calendar as early as possible
 so I don't miss it again :)
 --
 Sean A Corfield -- (904) 302-SEAN
 Railo Technologies, Inc. --http://getrailo.com/
 An Architect's View --http://corfield.org/

 If you're not annoying somebody, you're not really alive.
 -- Margaret Atwood

 --
 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-Hidequotedtext -

- Show quoted text -

-- 
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


Re: Struct vs. Record: Now and Future

2011-01-28 Thread David McNeil
 While this serialization has been fine for most of my needs I have quite
 often wanted to be able to use *print-dup* since binary serialization
 seemed overkill in those cases.  Hopefully something like defrecord2
 gets added to clojure at some point to make dealing with records more
 pleasant.

This is a snapshot of a defrecord2 implementation that I have been
using. Among other things it makes records print in an eval'able form.

https://github.com/david-mcneil/defrecord2

-David

-- 
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


Re: Ridiculously massive slowdown when working with images

2011-01-28 Thread Benny Tsai
Combining Ken and David's tips, this version processes a byte-array of
sizd 192 in about 13 milliseconds on my machine:

(def buffer-size 192)
(def array (byte-array buffer-size))

(defn java-like [^bytes cpuArray]
  (loop [i (int 0)]
(if ( i buffer-size)
  (let [b (aget cpuArray i)
g (aget cpuArray (unchecked-add i (int 1)))
r (aget cpuArray (unchecked-add i (int 2)))
a (aget cpuArray (unchecked-add i (int 3)))]
(aset cpuArray i a)
(aset cpuArray (unchecked-add i (int 1)) b)
(aset cpuArray (unchecked-add i (int 2)) g)
(aset cpuArray (unchecked-add i (int 3)) r)
(recur (unchecked-add i (int 4)))

user= (time (java-like array))
Elapsed time: 13.648662 msecs

Found something interesting when I tried to emulate how Robert's
version aliased 'unchecked-add' as '+':

(defn java-like [^bytes cpuArray]
  (loop [i (int 0)]
(if ( i buffer-size)
  (let [+ unchecked-add
b (aget cpuArray i)
g (aget cpuArray (+ i (int 1)))
r (aget cpuArray (+ i (int 2)))
a (aget cpuArray (+ i (int 3)))]
(aset cpuArray i a)
(aset cpuArray (+ i (int 1)) b)
(aset cpuArray (+ i (int 2)) g)
(aset cpuArray (+ i (int 3)) r)
(recur (+ i (int 4)))

When I try to compile this, Clojure complains that I'm trying to
rebind i, a primitive local, with a value of the wront type in
'recur'.

It seems that 'unchecked-add' returns a primitive (note that in the
first version, 'recur' happily accepts the return from 'unchecked-add'
without coercion), but when 'unchecked-add' is bound to a new name,
the return gets boxed.

Is this the correct interpretation, or am I missing something?

On Jan 28, 9:06 am, David Nolen dnolen.li...@gmail.com wrote:
 On Fri, Jan 28, 2011 at 10:48 AM, Robert McIntyre r...@mit.edu wrote:
  I tried to convert this java code line for line to clojure to compare
  the speed differences, and boy was I surprised!

         public static void ConvertToAWT(byte[] cpuArray){
                 // Given an array of bytes representing a c-style bgra
  image,
                 // converts to a java style abgr image
                 int len = java.lang.reflect.Array.getLength(cpuArray);
                 for (int i = 0; i  len; i+=4){
                         byte b = cpuArray[i+0];
                         byte g = cpuArray[i+1];
                         byte r = cpuArray[i+2];
                         byte a = cpuArray[i+3];
                         cpuArray[i+0] = a;
                         cpuArray[i+1] = b;
                         cpuArray[i+2] = g;
                         cpuArray[i+3] = r;  }}

  (defn java-like []
   (loop [i (int 0)] (if ( i buffer-size)
                       (let [ + clojure.core/unchecked-add
                             b (aget cpuArray i)
                             g (aget cpuArray (+ 1 i))
                             r (aget cpuArray (+ 2 i))
                             a (aget cpuArray (+ 3 i))]
                         (aset-byte cpuArray i a)
                         (aset-byte cpuArray (+ 1 i) b)
                         (aset-byte cpuArray (+ 2 i) g)
                         (aset-byte cpuArray (+ 3 i) r)
                         (recur (int (+ i 4)))

  (defn clojure-like []
   (doall (flatten (map (fn [[b g r a]] [a b g r]) (partition 4 4
  cpuArray)

 I'm assuming you're using 1.2.0. cpuArray needs to be hinted. All the
 literals also need to be hinted. Don't use aset-byte, use aset.

 In 1.3.0 you no longer have to hint the literals and you can use the
 *unchecked-math* compiler flag instead of redefining unchecked-add as a
 local.

 David

-- 
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


Re: Ridiculously massive slowdown when working with images

2011-01-28 Thread Ken Wesson
On Fri, Jan 28, 2011 at 12:55 PM, Benny Tsai benny.t...@gmail.com wrote:
 It seems that 'unchecked-add' returns a primitive (note that in the
 first version, 'recur' happily accepts the return from 'unchecked-add'
 without coercion), but when 'unchecked-add' is bound to a new name,
 the return gets boxed.

 Is this the correct interpretation, or am I missing something?

It's correct. Clojure's compiler inlines certain functions, including
clojure.core/unchecked-foo and, when the arity is 2, clojure.core/+ --
but not a bare, un-qualified +, which might (or might not) at runtime
refer to clojure.core/+ or clojure.core/unchecked-add or whatever.

-- 
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


Re: Ridiculously massive slowdown when working with images

2011-01-28 Thread Robert McIntyre
And the plot thickens:

This:

(defn convert-image [#^bytes cpuArray]
  (let [unchecked-add clojure.core/unchecked-add
len (int (count cpuArray))]
(loop [i (int 0)] (if ( i len)
(let [
  b (byte (aget cpuArray i))
  g (byte (aget cpuArray (unchecked-add 1
i)))
  r (byte (aget cpuArray (unchecked-add 2
i)))
  a (byte (aget cpuArray (unchecked-add 3
i)))]
  (aset-byte cpuArray i a)
  (aset-byte cpuArray (unchecked-add 1 i) b)
  (aset-byte cpuArray (unchecked-add 2 i) g)
  (aset-byte cpuArray (unchecked-add 3 i) r)
(recur (int (unchecked-add i 4

vs this.


(defn convert-image [#^bytes cpuArray]
  (let [len (java.lang.reflect.Array/getLength cpuArray)]
(loop [i (int 0)] (if ( i len)
(let [i2 (unchecked-add 1 i)
  i3 (unchecked-add 2 i)
  i4 (unchecked-add 3 i)
  b (byte (aget cpuArray i))
  g (byte (aget cpuArray i2))
  r (byte (aget cpuArray i3))
  a (byte (aget cpuArray i4))]
  (aset-byte cpuArray i a)
  (aset-byte cpuArray i2 b)
  (aset-byte cpuArray i3 g)
  (aset-byte cpuArray i4 r)
(recur (unchecked-add i 4)))

The first function takes forever; the second MUCH faster.
Upon disassembling the byte-code of the two compiled functions, it
does seem like the + was not being inlined.
Since the method of reassignment doesn't preserve the metadata, this
makes sense.

However, my new, modified function is still around 20 times slower
than the java version :(

I still don't understand what's slowing me down, but I'm much happier
that I can get within 20x of java instead of 2x

thanks everyone.

sincerely,
--Robert McIntyre






On Fri, Jan 28, 2011 at 1:07 PM, Ken Wesson kwess...@gmail.com wrote:
 On Fri, Jan 28, 2011 at 12:55 PM, Benny Tsai benny.t...@gmail.com wrote:
 It seems that 'unchecked-add' returns a primitive (note that in the
 first version, 'recur' happily accepts the return from 'unchecked-add'
 without coercion), but when 'unchecked-add' is bound to a new name,
 the return gets boxed.

 Is this the correct interpretation, or am I missing something?

 It's correct. Clojure's compiler inlines certain functions, including
 clojure.core/unchecked-foo and, when the arity is 2, clojure.core/+ --
 but not a bare, un-qualified +, which might (or might not) at runtime
 refer to clojure.core/+ or clojure.core/unchecked-add or whatever.

 --
 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

-- 
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


Re: REQUEST for feedback on http://clojure.org

2011-01-28 Thread Aaron Cohen
On Sat, Oct 30, 2010 at 10:38 PM, Alex Miller alexdmil...@yahoo.com wrote:
 Hi all,

 I'm doing a bit of doc cleanup on http://clojure.org and I'd welcome
 your feedback on things that are broken or could be improved.  I'm not
 looking (or likely authorized :) to make any drastic changes but if
 there are things that you have run into, please drop a line here or in
 email to alexdmiller at yahoo.com.  Ideally, I'd like people to be
 logging tickets in jira, but I'm not sure it's quite ready for that
 yet.

 Some recent changes I've already made:
 - switched all of the old richhickey github references to clojure
 - cleaned up some factually wrong or out of date stuff on getting
 started and download pages
 - added Protocol and Datatypes pages to left nav (the pages have
 existed for 6 months)
 - added a page on starting a user group (still in review, not yet
 linked)
 - currently working on updating the cheat sheet to the 1.2 version
 (and adding links!)

 I'm particularly interested in:
 - new user groups or suggestions for the community page
 - stuff that is just wrong or out of date

 This DOES NOT include stuff in the API or Contrib autodoc pages.
 Please raise those issues or file tickets on those but that's not what
 I'm focusing on at the moment.

 Alex

I don't know how important this is, but the copyright statement at the
bottom of the page now says 2007-2010 rather than through 2011.

Probably be good to grep through all the source for copyright years at
the same time.

--Aaron

-- 
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


Re: Ridiculously massive slowdown when working with images

2011-01-28 Thread David Nolen
(ns atest)

(set! *warn-on-reflection* true)

(def buffer-size 192)
(def array (byte-array buffer-size))
(defn java-like [^bytes cpuArray]
  (loop [i (int 0)]
(if ( i (int buffer-size))
  (let [b (byte (aget cpuArray i))
g (byte (aget cpuArray (unchecked-add i (int 1
r (byte (aget cpuArray (unchecked-add i (int 2
a (byte (aget cpuArray (unchecked-add i (int 3]
(aset cpuArray i a)
(aset cpuArray (unchecked-add i (int 1)) b)
(aset cpuArray (unchecked-add i (int 2)) g)
(aset cpuArray (unchecked-add i (int 3)) r)
(recur (unchecked-add i (int 4)))

(dotimes [_ 10]
  (time
   (dotimes [_ 1]
 (java-like array

On my machine this takes 9ms.

As a comparison, the following accomplishes the same thing in 1.3.0.

(ns test)

(set! *unchecked-math* true)
(set! *warn-on-reflection* true)

(def buffer-size 192)
(def array (byte-array buffer-size))
(defn java-like [^bytes cpuArray]
 (loop [i (int 0)]
   (if ( i buffer-size)
 (let [b (aget cpuArray i)
   g (aget cpuArray (+ i 1))
   r (aget cpuArray (+ i 2))
   a (aget cpuArray (+ i 3))]
   (aset cpuArray i a)
   (aset cpuArray (+ i 1) b)
   (aset cpuArray (+ i 2) g)
   (aset cpuArray (+ i 3) r)
   (recur (+ i 4))

(dotimes [_ 10]
  (time
   (dotimes [_ 1]
 (java-like array

-- 
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

Re: Ridiculously massive slowdown when working with images

2011-01-28 Thread Benny Tsai
Try replacing 'aset-byte' with 'aset' and hinting all literals (change
1 to (int 1), etc.) as per David's suggestions.  That should reduce
the gap even further.

On Jan 28, 11:31 am, Robert McIntyre r...@mit.edu wrote:
 And the plot thickens:

 This:

 (defn convert-image [#^bytes cpuArray]
   (let [unchecked-add clojure.core/unchecked-add
         len (int (count cpuArray))]
     (loop [i (int 0)] (if ( i len)
                         (let [
                               b (byte (aget cpuArray i))
                               g (byte (aget cpuArray (unchecked-add 1
 i)))
                               r (byte (aget cpuArray (unchecked-add 2
 i)))
                               a (byte (aget cpuArray (unchecked-add 3
 i)))]
                           (aset-byte cpuArray i a)
                           (aset-byte cpuArray (unchecked-add 1 i) b)
                           (aset-byte cpuArray (unchecked-add 2 i) g)
                           (aset-byte cpuArray (unchecked-add 3 i) r)
                         (recur (int (unchecked-add i 4

 vs this.

 (defn convert-image [#^bytes cpuArray]
   (let [len (java.lang.reflect.Array/getLength cpuArray)]
     (loop [i (int 0)] (if ( i len)
                         (let [i2 (unchecked-add 1 i)
                               i3 (unchecked-add 2 i)
                               i4 (unchecked-add 3 i)
                               b (byte (aget cpuArray i))
                               g (byte (aget cpuArray i2))
                               r (byte (aget cpuArray i3))
                               a (byte (aget cpuArray i4))]
                           (aset-byte cpuArray i a)
                           (aset-byte cpuArray i2 b)
                           (aset-byte cpuArray i3 g)
                           (aset-byte cpuArray i4 r)
                         (recur (unchecked-add i 4)))

 The first function takes forever; the second MUCH faster.
 Upon disassembling the byte-code of the two compiled functions, it
 does seem like the + was not being inlined.
 Since the method of reassignment doesn't preserve the metadata, this
 makes sense.

 However, my new, modified function is still around 20 times slower
 than the java version :(

 I still don't understand what's slowing me down, but I'm much happier
 that I can get within 20x of java instead of 2x

 thanks everyone.

 sincerely,
 --Robert McIntyre







 On Fri, Jan 28, 2011 at 1:07 PM, Ken Wesson kwess...@gmail.com wrote:
  On Fri, Jan 28, 2011 at 12:55 PM, Benny Tsai benny.t...@gmail.com wrote:
  It seems that 'unchecked-add' returns a primitive (note that in the
  first version, 'recur' happily accepts the return from 'unchecked-add'
  without coercion), but when 'unchecked-add' is bound to a new name,
  the return gets boxed.

  Is this the correct interpretation, or am I missing something?

  It's correct. Clojure's compiler inlines certain functions, including
  clojure.core/unchecked-foo and, when the arity is 2, clojure.core/+ --
  but not a bare, un-qualified +, which might (or might not) at runtime
  refer to clojure.core/+ or clojure.core/unchecked-add or whatever.

  --
  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

-- 
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


Re: Ridiculously massive slowdown when working with images

2011-01-28 Thread Aaron Cohen
On Fri, Jan 28, 2011 at 1:55 PM, David Nolen dnolen.li...@gmail.com wrote:
 As a comparison, the following accomplishes the same thing in 1.3.0.
 (ns test)
 (set! *unchecked-math* true)
 (set! *warn-on-reflection* true)
 (def buffer-size 192)
 (def array (byte-array buffer-size))
 (defn java-like [^bytes cpuArray]
  (loop [i (int 0)]

Is this hint still necessary on 1.3.0?

-- 
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


Re: Ridiculously massive slowdown when working with images

2011-01-28 Thread Benny Tsai
Ah I see.  Thank you Ken.

On Jan 28, 11:07 am, Ken Wesson kwess...@gmail.com wrote:
 On Fri, Jan 28, 2011 at 12:55 PM, Benny Tsai benny.t...@gmail.com wrote:
  It seems that 'unchecked-add' returns a primitive (note that in the
  first version, 'recur' happily accepts the return from 'unchecked-add'
  without coercion), but when 'unchecked-add' is bound to a new name,
  the return gets boxed.

  Is this the correct interpretation, or am I missing something?

 It's correct. Clojure's compiler inlines certain functions, including
 clojure.core/unchecked-foo and, when the arity is 2, clojure.core/+ --
 but not a bare, un-qualified +, which might (or might not) at runtime
 refer to clojure.core/+ or clojure.core/unchecked-add or whatever.

-- 
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


Re: Ridiculously massive slowdown when working with images

2011-01-28 Thread David Nolen
On Fri, Jan 28, 2011 at 2:01 PM, Aaron Cohen aa...@assonance.org wrote:

 On Fri, Jan 28, 2011 at 1:55 PM, David Nolen dnolen.li...@gmail.com
 wrote:
  As a comparison, the following accomplishes the same thing in 1.3.0.
  (ns test)
  (set! *unchecked-math* true)
  (set! *warn-on-reflection* true)
  (def buffer-size 192)
  (def array (byte-array buffer-size))
  (defn java-like [^bytes cpuArray]
   (loop [i (int 0)]

 Is this hint still necessary on 1.3.0?


The int cast on 0 was an oversight on my part. It's not necessary.

David

-- 
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

Re: Ridiculously massive slowdown when working with images

2011-01-28 Thread Robert McIntyre
David, thanks for your suggestions.

I copied your code and tested it out, but on my machine it takes 230
milliseconds while the java version takes about 3.

If it's not too much trouble, how long does the java implementation
take on your machine?

sincerely,
--Robert McIntyre

On Fri, Jan 28, 2011 at 2:11 PM, David Nolen dnolen.li...@gmail.com wrote:
 On Fri, Jan 28, 2011 at 2:01 PM, Aaron Cohen aa...@assonance.org wrote:

 On Fri, Jan 28, 2011 at 1:55 PM, David Nolen dnolen.li...@gmail.com
 wrote:
  As a comparison, the following accomplishes the same thing in 1.3.0.
  (ns test)
  (set! *unchecked-math* true)
  (set! *warn-on-reflection* true)
  (def buffer-size 192)
  (def array (byte-array buffer-size))
  (defn java-like [^bytes cpuArray]
   (loop [i (int 0)]

 Is this hint still necessary on 1.3.0?

 The int cast on 0 was an oversight on my part. It's not necessary.
 David

 --
 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

-- 
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


Re: Help with Java arrays

2011-01-28 Thread Robert McIntyre
On my computer this seemed to work.

(import 'javax.sound.midi.Synthesizer)

(seq (.getChannels (MidiSystem/getSynthesizer)))

(#MixerMidiChannel com.sun.media.sound.MixerMidiChannel@1b793ee
#MixerMidiChannel com.sun.media.sound.MixerMidiChannel@15109cf
#MixerMidiChannel com.sun.media.sound.MixerMid\
iChannel@15b0933 #MixerMidiChannel
com.sun.media.sound.MixerMidiChannel@1b910b0 #MixerMidiChannel
com.sun.media.sound.MixerMidiChannel@f696c6 #MixerMidiChannel
com.sun.medi\
a.sound.MixerMidiChannel@124a4bc #MixerMidiChannel
com.sun.media.sound.MixerMidiChannel@bb46b7 #MixerMidiChannel
com.sun.media.sound.MixerMidiChannel@11fc4dd #MixerMidiChan\
nel com.sun.media.sound.MixerMidiChannel@b59a28 #MixerMidiChannel
com.sun.media.sound.MixerMidiChannel@9bcf06 #MixerMidiChannel
com.sun.media.sound.MixerMidiChannel@134b721 \
#MixerMidiChannel com.sun.media.sound.MixerMidiChannel@1e2e788
#MixerMidiChannel com.sun.media.sound.MixerMidiChannel@1ceb175
#MixerMidiChannel com.sun.media.sound.MixerMidi\
Channel@e4b7d3 #MixerMidiChannel
com.sun.media.sound.MixerMidiChannel@1e09de7 #MixerMidiChannel
com.sun.media.sound.MixerMidiChannel@19eb5f6)

Maybe that's helpful :P

I hope.

good luck,
--Robert McIntyre

On Fri, Jan 28, 2011 at 11:59 AM, Ken Wesson kwess...@gmail.com wrote:
 On Fri, Jan 28, 2011 at 11:30 AM, WoodHacker ramsa...@comcast.net wrote:
 Hi,

 I'm trying to get the midi sound class in Java to work in Clojure.
 Everything seems to work fine except for the conversion of the
 following Java code:

     MidiChannel[] channels = synthesizer.getChannels;

 I've tried just dumping the channels into a Clojure object -
          (let [channels (.getChannels @synthesizer)]
 but I get the following error:

 Exception in thread main java.lang.IllegalArgumentException: Can't
 call public method of non-public class: public
 javax.sound.midi.MidiChannel[]
 com.sun.media.sound.AbstractPlayer.getChannels()

 I don't think this is an array issue at all, but one to do with
 overload resolution and Clojure's use of reflection.

 Try hinting @synthesizer like this:

 (let [channels (.getChannels ^Synthesizer @synthesizer)] ...)

 and see if that makes it work.

 --
 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

-- 
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


VerifyError trouble

2011-01-28 Thread Eduardo Julian
Hi guys.

I was working on a macro for easily defining mutable classes without
having to previously define a protocol for the methods in them (the
macro takes care of that for you) and providing basic get-set
operations.

However, I have trouble when defining classes, cause I get the
following error:
java.lang.VerifyError: (class: x/y/Z, method: clinit signature: ()V)
Incompatible argument to function

You can check out the code here: https://gist.github.com/800813

I'm using Clojure 1.2 on this one.

Am I doing something wrong or is this a bug in Clojure?

I think the problem comes when I add the metadata to the variables in
the class.

BTW: The switch macro that appears there is my version of 'case' and
it works mostly the same.

-- 
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


Re: Help with Java arrays

2011-01-28 Thread Robert McIntyre
oh and of course

(import 'javax.sound.midi.MidiSystem)

before everything.

sorry about that.

sincerely,
--Robert McIntyre

On Fri, Jan 28, 2011 at 2:47 PM, Robert McIntyre r...@mit.edu wrote:
 On my computer this seemed to work.

 (import 'javax.sound.midi.Synthesizer)

 (seq (.getChannels (MidiSystem/getSynthesizer)))

 (#MixerMidiChannel com.sun.media.sound.MixerMidiChannel@1b793ee
 #MixerMidiChannel com.sun.media.sound.MixerMidiChannel@15109cf
 #MixerMidiChannel com.sun.media.sound.MixerMid\
 iChannel@15b0933 #MixerMidiChannel
 com.sun.media.sound.MixerMidiChannel@1b910b0 #MixerMidiChannel
 com.sun.media.sound.MixerMidiChannel@f696c6 #MixerMidiChannel
 com.sun.medi\
 a.sound.MixerMidiChannel@124a4bc #MixerMidiChannel
 com.sun.media.sound.MixerMidiChannel@bb46b7 #MixerMidiChannel
 com.sun.media.sound.MixerMidiChannel@11fc4dd #MixerMidiChan\
 nel com.sun.media.sound.MixerMidiChannel@b59a28 #MixerMidiChannel
 com.sun.media.sound.MixerMidiChannel@9bcf06 #MixerMidiChannel
 com.sun.media.sound.MixerMidiChannel@134b721 \
 #MixerMidiChannel com.sun.media.sound.MixerMidiChannel@1e2e788
 #MixerMidiChannel com.sun.media.sound.MixerMidiChannel@1ceb175
 #MixerMidiChannel com.sun.media.sound.MixerMidi\
 Channel@e4b7d3 #MixerMidiChannel
 com.sun.media.sound.MixerMidiChannel@1e09de7 #MixerMidiChannel
 com.sun.media.sound.MixerMidiChannel@19eb5f6)

 Maybe that's helpful :P

 I hope.

 good luck,
 --Robert McIntyre

 On Fri, Jan 28, 2011 at 11:59 AM, Ken Wesson kwess...@gmail.com wrote:
 On Fri, Jan 28, 2011 at 11:30 AM, WoodHacker ramsa...@comcast.net wrote:
 Hi,

 I'm trying to get the midi sound class in Java to work in Clojure.
 Everything seems to work fine except for the conversion of the
 following Java code:

     MidiChannel[] channels = synthesizer.getChannels;

 I've tried just dumping the channels into a Clojure object -
          (let [channels (.getChannels @synthesizer)]
 but I get the following error:

 Exception in thread main java.lang.IllegalArgumentException: Can't
 call public method of non-public class: public
 javax.sound.midi.MidiChannel[]
 com.sun.media.sound.AbstractPlayer.getChannels()

 I don't think this is an array issue at all, but one to do with
 overload resolution and Clojure's use of reflection.

 Try hinting @synthesizer like this:

 (let [channels (.getChannels ^Synthesizer @synthesizer)] ...)

 and see if that makes it work.

 --
 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


-- 
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


Re: Ridiculously massive slowdown when working with images

2011-01-28 Thread David Nolen
On Fri, Jan 28, 2011 at 2:36 PM, Robert McIntyre r...@mit.edu wrote:

 David, thanks for your suggestions.

 I copied your code and tested it out, but on my machine it takes 230
 milliseconds while the java version takes about 3.

 If it's not too much trouble, how long does the java implementation
 take on your machine?

 sincerely,
 --Robert McIntyre


The Java version takes about 0.65ms for me. If I switch the Java loop
operations to be long arithmetic, the Java version takes 1.1ms-1.2ms. The
Clojure version under 1.3.0 takes 8ms.

David

-- 
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

Re: VerifyError trouble

2011-01-28 Thread Eduardo Julian
I think I have the same error as in this post:
http://groups.google.com/group/clojure/browse_thread/thread/8257e4ec8a652b23/e94df8077ecb1ac4

-- 
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


Re: Ridiculously massive slowdown when working with images

2011-01-28 Thread Benny Tsai
Hi Robert,

Just out of curiosity, are you running Clojure with the -server
option?  When I run David's code, -server mode cuts the time for the
first run by half, and the time for subsequent runs by a factor of 5.

On Jan 28, 12:36 pm, Robert McIntyre r...@mit.edu wrote:
 David, thanks for your suggestions.

 I copied your code and tested it out, but on my machine it takes 230
 milliseconds while the java version takes about 3.

 If it's not too much trouble, how long does the java implementation
 take on your machine?

 sincerely,
 --Robert McIntyre







 On Fri, Jan 28, 2011 at 2:11 PM, David Nolen dnolen.li...@gmail.com wrote:
  On Fri, Jan 28, 2011 at 2:01 PM, Aaron Cohen aa...@assonance.org wrote:

  On Fri, Jan 28, 2011 at 1:55 PM, David Nolen dnolen.li...@gmail.com
  wrote:
   As a comparison, the following accomplishes the same thing in 1.3.0.
   (ns test)
   (set! *unchecked-math* true)
   (set! *warn-on-reflection* true)
   (def buffer-size 192)
   (def array (byte-array buffer-size))
   (defn java-like [^bytes cpuArray]
    (loop [i (int 0)]

  Is this hint still necessary on 1.3.0?

  The int cast on 0 was an oversight on my part. It's not necessary.
  David

  --
  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

-- 
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


Re: Getting http-agent to throw an exception if url doesn't exist?

2011-01-28 Thread Stuart Sierra
There are a handful of Clojure HTTP libraries on Github, but I do not have 
one in particular to recommend.

It's not hard to use Java's HttpUrlConnection directly.

-S

-- 
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

Re: How does pmap partition its work?

2011-01-28 Thread Stuart Sierra
David Liebke gave a talk at Clojure-Conj 2010 titled From Concurrency to 
Parallelism with detailed performance comparisons of map, pmap, and 
Fork/Join-style iteration.  Look for it on clojure.blip.tv in the near 
future!

-Stuart Sierra
clojure.com

-- 
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

Re: Struct vs. Record: Now and Future

2011-01-28 Thread Stuart Sierra
defrecord is preferred over structmap in all cases going forward.

Neither defrecords nor structmaps can be printed and read back by the 
Clojure reader.  You can work around this by converting them to plain maps 
or using a custom printer that prints the constructor forms.

Many people have requested printable/readable defrecords and/or constructor 
macros. These features may make it into a future release, if we can agree on 
a consistent design.

-Stuart Sierra
clojure.com

-- 
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

Re: VerifyError trouble

2011-01-28 Thread Stuart Sierra
Hi Eduardo,

Are you aware of the :volatile-mutable and :unsynchronized-mutable options 
in deftype?
http://clojure.github.com/clojure/clojure.core-api.html#clojure.core/deftype

-Stuart Sierra
clojure.com

-- 
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

Re: I'm doing something wrong with gen-class

2011-01-28 Thread Ken Wesson
On Fri, Jan 28, 2011 at 5:20 PM, Andy Fingerhut
andy.finger...@gmail.com wrote:
 --
 (ns try
  (:gen-class))

Try using a two-component (or more) namespace name. I think gen-class
in a one-component namespace will try to create the class in the
default package, which Java does not like.

-- 
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


Re: I'm doing something wrong with gen-class

2011-01-28 Thread Andy Fingerhut
Thanks for the suggestion.  I'm not sure I implemented it correctly.   
Still no joy.  Here is exactly what I tried:


% ls -R
andy

./andy:
try.clj

% cat andy/try.clj

(ns andy.try
  (:gen-class))

(gen-class
 :name  andy.try.ReversibleByteArray
 :prefix rba-)

(defn rba-reverse [this]
  (println In rba-reverse))

(defn -main [ args]
  (let [N (. Integer valueOf (nth args 0) 10)]
(println N= N)
(let [buf (new andy.try.ReversibleByteArray)]
  (println (class buf)= (class buf))
  (println (. buf (rba-reverse)) returns  (. buf (rba- 
reverse))


% java -Dclojure.compile.path=. -classpath $HOME/lein/clj-1.2.0/lib/ 
clojure-1.2.0.jar:. clojure.lang.Compile andy.try


Compiling andy.try to .

% ls -R
andy

./andy:
try try.class
try$_main.class try.clj
try$loading__4410__auto__.class try__init.class
try$rba_reverse.class

./andy/try:
ReversibleByteArray.class

% java -server -classpath $HOME/lein/clj-1.2.0/lib/clojure-1.2.0.jar:.  
andy.try 5

N= 5
(class buf)= andy.try.ReversibleByteArray
Exception in thread main java.lang.IllegalArgumentException: No  
matching method found: rba_reverse for class  
andy.try.ReversibleByteArray

at clojure.lang.Reflector.invokeMatchingMethod(Reflector.java:50)
at clojure.lang.Reflector.invokeInstanceMethod(Reflector.java:28)
at andy.try$_main.doInvoke(try.clj:16)
at clojure.lang.RestFn.applyTo(RestFn.java:138)
at andy.try.main(Unknown Source)


Andy


On Jan 28, 2011, at 2:46 PM, Ken Wesson wrote:


On Fri, Jan 28, 2011 at 5:20 PM, Andy Fingerhut
andy.finger...@gmail.com wrote:

--
(ns try
 (:gen-class))


Try using a two-component (or more) namespace name. I think gen-class
in a one-component namespace will try to create the class in the
default package, which Java does not like.

--
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


--
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


Re: I'm doing something wrong with gen-class

2011-01-28 Thread Andy Fingerhut

Woops.

I meant to have both occurrences of (rba-reverse) in defn -main  
replaced with just (reverse).  I made that replacement, and still get  
nearly the same error message:


Exception in thread main java.lang.IllegalArgumentException: No  
matching method found: reverse for class andy.try.ReversibleByteArray


Andy


On Jan 28, 2011, at 3:04 PM, Andy Fingerhut wrote:

Thanks for the suggestion.  I'm not sure I implemented it  
correctly.  Still no joy.  Here is exactly what I tried:


% ls -R
andy

./andy:
try.clj

% cat andy/try.clj

(ns andy.try
 (:gen-class))

(gen-class
:name  andy.try.ReversibleByteArray
:prefix rba-)

(defn rba-reverse [this]
 (println In rba-reverse))

(defn -main [ args]
 (let [N (. Integer valueOf (nth args 0) 10)]
   (println N= N)
   (let [buf (new andy.try.ReversibleByteArray)]
 (println (class buf)= (class buf))
 (println (. buf (rba-reverse)) returns  (. buf (rba- 
reverse))


% java -Dclojure.compile.path=. -classpath $HOME/lein/clj-1.2.0/lib/ 
clojure-1.2.0.jar:. clojure.lang.Compile andy.try


Compiling andy.try to .

% ls -R
andy

./andy:
try try.class
try$_main.class try.clj
try$loading__4410__auto__.class try__init.class
try$rba_reverse.class

./andy/try:
ReversibleByteArray.class

% java -server -classpath $HOME/lein/clj-1.2.0/lib/ 
clojure-1.2.0.jar:. andy.try 5

N= 5
(class buf)= andy.try.ReversibleByteArray
Exception in thread main java.lang.IllegalArgumentException: No  
matching method found: rba_reverse for class  
andy.try.ReversibleByteArray

at clojure.lang.Reflector.invokeMatchingMethod(Reflector.java:50)
at clojure.lang.Reflector.invokeInstanceMethod(Reflector.java:28)
at andy.try$_main.doInvoke(try.clj:16)
at clojure.lang.RestFn.applyTo(RestFn.java:138)
at andy.try.main(Unknown Source)


Andy


On Jan 28, 2011, at 2:46 PM, Ken Wesson wrote:


On Fri, Jan 28, 2011 at 5:20 PM, Andy Fingerhut
andy.finger...@gmail.com wrote:

--
(ns try
(:gen-class))


Try using a two-component (or more) namespace name. I think gen-class
in a one-component namespace will try to create the class in the
default package, which Java does not like.

--
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




--
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


Re: Struct vs. Record: Now and Future

2011-01-28 Thread Mark Engelberg
On Fri, Jan 28, 2011 at 2:09 PM, Stuart Sierra
the.stuart.sie...@gmail.comwrote:

 Neither defrecords nor structmaps can be printed and read back by the
 Clojure reader.  You can work around this by converting them to plain maps
 or using a custom printer that prints the constructor forms.


So if I don't care about human readability or readability by the Clojure
reader, what is the recipe for writing an arbitrary Clojure data structure
to a file, and reading it back in?

-- 
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

Re: I'm doing something wrong with gen-class

2011-01-28 Thread Carson


Haven't tried this, but some ideas/questions in my mind:

Is it not better to use the (:gen-class :name ... :prefix ...) inside (ns) 
instead of having a separate (gen-class  ...)  outside (ns ...)?  Maybe it 
makes no difference? (dunno, but the documentation for ns suggests 
otherwise)

Where you have (reverse), you are calling a no-argument function named 
reverse, no?  I don't see such a function defn'ed.

Where you have :prefix rba-.  Should there be quotes around *rba-*?  Or 
does that not matter?

Sorry can't be of more help.

Carson

-- 
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

Re: I'm doing something wrong with gen-class

2011-01-28 Thread Aaron Cohen
On Fri, Jan 28, 2011 at 6:13 PM, Andy Fingerhut
andy.finger...@gmail.com wrote:

 (ns andy.try
  (:gen-class))

 (gen-class
 :name  andy.try.ReversibleByteArray
 :prefix rba-)

I find it confusing that you have both of :gen-class in the ns macro
(I guess you're using this to get -main) and (gen-class) at the top
level.

The class you are creating extends no interfaces and defines no
methods. (Note, the only reason that you get a main method in one of
your generated classes is because the :gen-class option to ns
automatically specifies (:main true). If you add (:methods [[reverse
[] void]) to your gen-class statement, it will add a reverse method to
the generated class which calls your rba-reverse function and returns
void.

I would look into combining the two gen-classes though.

Here's a great blog post that goes into gen-class some more:
http://kotka.de/blog/2010/02/gen-class_how_it_works_and_how_to_use_it.html

--Aaron

-- 
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


Re: I'm doing something wrong with gen-class

2011-01-28 Thread Andy Fingerhut

That was what I was missing.  Thanks, Aaron.

Regarding using :gen-class in the ns macro, and also (gen-class) at  
the top level, I am using the first because I know it works for AOT  
compilation (important for the shootout web site to avoid measuring  
compilation as part of the run time).  If there is another way to do  
AOT compilation without that, I'm all ears if it has important  
technical advantages, and/or would be a better example for people  
reading these sample programs and learning from them.


I am using the (gen-class) at the top level because I want to extend  
another class, and then use that from -main or from a function that - 
main calls.


I understand that most people would probably define these classes in  
separate files, but for the shootout web site it is advantageous  
(perhaps even required -- I'm not sure) that it all fits in one file.


Thanks,
Andy

On Jan 28, 2011, at 4:07 PM, Aaron Cohen wrote:


On Fri, Jan 28, 2011 at 6:13 PM, Andy Fingerhut
andy.finger...@gmail.com wrote:


(ns andy.try
 (:gen-class))

(gen-class
:name  andy.try.ReversibleByteArray
:prefix rba-)


I find it confusing that you have both of :gen-class in the ns macro
(I guess you're using this to get -main) and (gen-class) at the top
level.

The class you are creating extends no interfaces and defines no
methods. (Note, the only reason that you get a main method in one of
your generated classes is because the :gen-class option to ns
automatically specifies (:main true). If you add (:methods [[reverse
[] void]) to your gen-class statement, it will add a reverse method to
the generated class which calls your rba-reverse function and returns
void.

I would look into combining the two gen-classes though.

Here's a great blog post that goes into gen-class some more:
http://kotka.de/blog/2010/02/gen-class_how_it_works_and_how_to_use_it.html

--Aaron

--
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


--
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


Re: Struct vs. Record: Now and Future

2011-01-28 Thread Ken Wesson
On Fri, Jan 28, 2011 at 6:50 PM, Mark Engelberg
mark.engelb...@gmail.com wrote:


 On Fri, Jan 28, 2011 at 2:09 PM, Stuart Sierra the.stuart.sie...@gmail.com
 wrote:

 Neither defrecords nor structmaps can be printed and read back by the
 Clojure reader.  You can work around this by converting them to plain maps
 or using a custom printer that prints the constructor forms.

 So if I don't care about human readability or readability by the Clojure
 reader, what is the recipe for writing an arbitrary Clojure data structure
 to a file, and reading it back in?

In a word, ObjectOutputStream.

-- 
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


Re: Ridiculously massive slowdown when working with images

2011-01-28 Thread Robert McIntyre
I'm running my JVM with:

-verbose:gc -Xmn500M -Xms2000M -Xmx2000M -server


sincerely,
--Robert McIntyre

On Fri, Jan 28, 2011 at 4:24 PM, Benny Tsai benny.t...@gmail.com wrote:
 Hi Robert,

 Just out of curiosity, are you running Clojure with the -server
 option?  When I run David's code, -server mode cuts the time for the
 first run by half, and the time for subsequent runs by a factor of 5.

 On Jan 28, 12:36 pm, Robert McIntyre r...@mit.edu wrote:
 David, thanks for your suggestions.

 I copied your code and tested it out, but on my machine it takes 230
 milliseconds while the java version takes about 3.

 If it's not too much trouble, how long does the java implementation
 take on your machine?

 sincerely,
 --Robert McIntyre







 On Fri, Jan 28, 2011 at 2:11 PM, David Nolen dnolen.li...@gmail.com wrote:
  On Fri, Jan 28, 2011 at 2:01 PM, Aaron Cohen aa...@assonance.org wrote:

  On Fri, Jan 28, 2011 at 1:55 PM, David Nolen dnolen.li...@gmail.com
  wrote:
   As a comparison, the following accomplishes the same thing in 1.3.0.
   (ns test)
   (set! *unchecked-math* true)
   (set! *warn-on-reflection* true)
   (def buffer-size 192)
   (def array (byte-array buffer-size))
   (defn java-like [^bytes cpuArray]
    (loop [i (int 0)]

  Is this hint still necessary on 1.3.0?

  The int cast on 0 was an oversight on my part. It's not necessary.
  David

  --
  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

 --
 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

-- 
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


Re: I'm doing something wrong with gen-class

2011-01-28 Thread Andy Fingerhut
And if anyone is curious, I've now got a Clojure program that works  
pretty much exactly like this Java program, including using gen-class  
to extend java.io.ByteArrayOutputStream with a new method, and access  
two protected (non-static) fields of the superclass:


http://shootout.alioth.debian.org/u32/program.php?test=revcomplang=javaid=4

The Clojure program is here:

http://github.com/jafingerhut/clojure-benchmarks/blob/master/revcomp/revcomp.clj-13.clj

I don't consider it to be a prime example of easily readable Clojure  
code, but it is pretty darn fast compared to the previous fastest  
Clojure program I had for this problem.  It should be up on the  
Shootout web site in a day or two.


Thanks,
Andy


On Jan 28, 2011, at 4:20 PM, Andy Fingerhut wrote:


That was what I was missing.  Thanks, Aaron.

Regarding using :gen-class in the ns macro, and also (gen-class) at  
the top level, I am using the first because I know it works for AOT  
compilation (important for the shootout web site to avoid measuring  
compilation as part of the run time).  If there is another way to do  
AOT compilation without that, I'm all ears if it has important  
technical advantages, and/or would be a better example for people  
reading these sample programs and learning from them.


I am using the (gen-class) at the top level because I want to extend  
another class, and then use that from -main or from a function that - 
main calls.


I understand that most people would probably define these classes in  
separate files, but for the shootout web site it is advantageous  
(perhaps even required -- I'm not sure) that it all fits in one file.


Thanks,
Andy

On Jan 28, 2011, at 4:07 PM, Aaron Cohen wrote:


On Fri, Jan 28, 2011 at 6:13 PM, Andy Fingerhut
andy.finger...@gmail.com wrote:


(ns andy.try
(:gen-class))

(gen-class
:name  andy.try.ReversibleByteArray
:prefix rba-)


I find it confusing that you have both of :gen-class in the ns  
macro

(I guess you're using this to get -main) and (gen-class) at the top
level.

The class you are creating extends no interfaces and defines no
methods. (Note, the only reason that you get a main method in one  
of

your generated classes is because the :gen-class option to ns
automatically specifies (:main true). If you add (:methods [[reverse
[] void]) to your gen-class statement, it will add a reverse method  
to

the generated class which calls your rba-reverse function and returns
void.

I would look into combining the two gen-classes though.

Here's a great blog post that goes into gen-class some more:
http://kotka.de/blog/2010/02/gen-class_how_it_works_and_how_to_use_it.html

--Aaron

--
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




--
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

Re: What is the difference between a tail-recursive function and a recursive function using recur?

2011-01-28 Thread AlexM
I think what you're talking about is continuation passing style -
http://en.wikipedia.org/wiki/Continuation-passing_style

I think there was a thread on it a few months back, but from what I
remember its not supported (its dependent on TCO to prevent the stack
from exploding as explained above).

On Jan 26, 4:48 pm, Armando Blancas armando_blan...@yahoo.com wrote:
 These last posts cleared it up. Thanks.

 Which remind me, I think one of the SICP lectures on youtube mentions
 tail calls to *other* functions, which I totally forgot, with an
 example of a person doing something for another doing something for
 another... and the last one just gives the result to the first. That
 ain't no internal loop.

 On Jan 26, 1:23 pm, Laurent PETIT laurent.pe...@gmail.com wrote:







  2011/1/26 Alan a...@malloys.org:

   Now try writing two mutually-recursive functions. In Scheme (as I
   understand it) that will get optimized into a jump from one function
   to the other, while in Clojure it will use the stack.

  And that's why Rich introduced clojure.core/trampoline.

  Cheers,

  --
  Laurent

   On Jan 26, 1:10 pm, Armando Blancas armando_blan...@yahoo.com wrote:
   From SICP: With a tail-recursive implementation, iteration can be
   expressed using the ordinary procedure call mechanism. As I
   understand this, a tail call is a loop with functional notation but
   not actually a function call. That's why I find this issue difficult
   to follow, since loops are internal details of a function/method and
   don't get involved with calls, stack frames, access security, or how
   the jit-compiled code may or may not be optimized. So there's
   something key here that I'm missing.

   In a little project of mine I plan on doing this (hand-coded with ASM
   as my compiler doesn't do TCO yet). That seems to work but I wonder
   what issues may come up.

   int fact(int n, int r) {
     if (n == 0) return r;
     else return fact(n-1, n*r);}

      0:   iload_0
      1:   ifne    6
      4:   iload_1
      5:   ireturn
      6:   iload_0
      7:   istore_2 // temp for n
      8:   iload_2
      9:   iconst_1
      10:  isub
      11:  istore_0
      12:  iload_2
      13:  iload_1
      14:  imul
      15:  istore_1
      16:  goto    0

   On Jan 26, 11:20 am, Luc Prefontaine lprefonta...@softaddicts.ca
   wrote:

From what I recall from a previous thread it would require so much 
byte code tweaking that
Hot Spot optimizations would become useless.

You can search the mailing list, you will find a couple of instructive 
discussions
about this.

Luc P.

On Wed, 26 Jan 2011 10:01:04 -0800

Raoul Duke rao...@gmail.com wrote:
 On Wed, Jan 26, 2011 at 7:41 AM, Michael Gardner
 gardne...@gmail.com wrote:
  However, the JVM does not support tail-call optimization.
  Apparently Clojure can't support implicit TCO without support from
  the JVM

 always wondered about that also wrt scala etc., am under the
 impression that it is implementable, but it would be too slow?

--
Luc P.


The rabid Muppet

   --
   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-Hide quoted text -

  - Show quoted text -

-- 
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


Re: Ridiculously massive slowdown when working with images

2011-01-28 Thread Benny Tsai
On my home computer, using the same options, the java version runs in
1.5 milliseconds, and David's 1.2 Clojure version in 16 milliseconds.
I'm at a loss as to why you're still seeing such a large gap between
the two versions.

On Jan 28, 6:16 pm, Robert McIntyre r...@mit.edu wrote:
 I'm running my JVM with:

 -verbose:gc -Xmn500M -Xms2000M -Xmx2000M -server

 sincerely,
 --Robert McIntyre







 On Fri, Jan 28, 2011 at 4:24 PM, Benny Tsai benny.t...@gmail.com wrote:
  Hi Robert,

  Just out of curiosity, are you running Clojure with the -server
  option?  When I run David's code, -server mode cuts the time for the
  first run by half, and the time for subsequent runs by a factor of 5.

  On Jan 28, 12:36 pm, Robert McIntyre r...@mit.edu wrote:
  David, thanks for your suggestions.

  I copied your code and tested it out, but on my machine it takes 230
  milliseconds while the java version takes about 3.

  If it's not too much trouble, how long does the java implementation
  take on your machine?

  sincerely,
  --Robert McIntyre

  On Fri, Jan 28, 2011 at 2:11 PM, David Nolen dnolen.li...@gmail.com 
  wrote:
   On Fri, Jan 28, 2011 at 2:01 PM, Aaron Cohen aa...@assonance.org wrote:

   On Fri, Jan 28, 2011 at 1:55 PM, David Nolen dnolen.li...@gmail.com
   wrote:
As a comparison, the following accomplishes the same thing in 1.3.0.
(ns test)
(set! *unchecked-math* true)
(set! *warn-on-reflection* true)
(def buffer-size 192)
(def array (byte-array buffer-size))
(defn java-like [^bytes cpuArray]
 (loop [i (int 0)]

   Is this hint still necessary on 1.3.0?

   The int cast on 0 was an oversight on my part. It's not necessary.
   David

   --
   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

  --
  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

-- 
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