Re: Clojure performance question

2014-03-01 Thread bob
Case :

clojure verison:

(time (dotimes [n 1000] (str n "another word"))) ;; take about 5000msec

java version

long time = System.nanoTime();

for(int i=0 ; i<1000 ;i++){
String a=i+"another word";
}
  System.out.println(System.nanoTime()-time); 
 

The java version take about 500 msecs, I thought it might be caused by the 
str implementation which is using string builder, and it might not be the 
best choice in the case of no much string to concat, and then I replace 
"another word" with 5 long strings as the parameter, however no surprise.

I just wonder what make the difference, or how to find the difference.

Thanks



On Saturday, March 1, 2014 1:26:38 PM UTC+8, Shantanu Kumar wrote:
>
> I have seen (and I keep seeing) a ton of Java code that performs poorly. 
> Empirically, it's equally easy to write a slow Java app. You always need a 
> discerning programmer to get good performance from any language/tool.
>
> Numbers like 1/4 or 1/10 can be better discussed in presence of the 
> use-cases and perf test cases. Most of the problems you listed can be 
> mitigated by `-server` JIT, avoiding reflection, transients, loop-recur, 
> arrays, perf libraries and some Java code.
>
> Shantanu
>

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Looking for a Rich Hickey quotation

2014-03-01 Thread Kashyap CK
Hi,
In one of the talks, Rich Hickey had mentioned something to the effect -

"Programs are meant to state the intention of your computation to other 
programmers/humans - as opposed to instructions for a machine"

He was quoting someone else actually (perhaps Knuth). I just cant seem to 
get my hands on that video. Could someone please remind me what that 
quotation was?

Regards,
Kashyap

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[Video] The case for Clojure

2014-03-01 Thread James Trunk
Hi everyone,

I made a new video about Clojure that I wanted to share with you all. It's 
a sales pitch for choosing Clojure as the language for your next project:

The case for Clojure 

I realise that if you're reading this discussion group there's a good 
chance that you've already made that choice, and don't need me to convince 
you. You guys aren't actually the target audience for the video, but, if 
you have the time, I'd love it if you'd watch it anyway. Then, if you think 
it's good enough, you can pass it on to any friends or colleagues who 
you're trying to convince to take a look at Clojure.

Cheers,
James

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Looking for a Rich Hickey quotation

2014-03-01 Thread t x
Thus, programs must be written for people to read, and only
incidentally for machines to execute. --
http://mitpress.mit.edu/sicp/front/node3.html


On Sat, Mar 1, 2014 at 2:48 AM, Kashyap CK  wrote:
> Hi,
> In one of the talks, Rich Hickey had mentioned something to the effect -
>
> "Programs are meant to state the intention of your computation to other
> programmers/humans - as opposed to instructions for a machine"
>
> He was quoting someone else actually (perhaps Knuth). I just cant seem to
> get my hands on that video. Could someone please remind me what that
> quotation was?
>
> Regards,
> Kashyap
>
> --
> 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 unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: ace / codemirror in cljs

2014-03-01 Thread Dave Sann
have you considered reading the LightTable code? There is probably some 
cljs and editor in there

On Saturday, 1 March 2014 17:26:18 UTC+11, t x wrote:
>
> Hi, 
>
>   Is there anything like http://codemirror.net/ or 
> http://ace.c9.io/#nav=about in cljs ? 
>
>   The goal is not to use codemirror/ace in a cljs project. The goal is 
> to read some interesting cljs code on how to write an editor. 
>
> 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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Looking for a Rich Hickey quotation

2014-03-01 Thread Kashyap CK
Thank you so much,
Regards,
Kashyap

On Saturday, March 1, 2014 4:27:05 PM UTC+5:30, t x wrote:
>
> Thus, programs must be written for people to read, and only 
> incidentally for machines to execute. -- 
> http://mitpress.mit.edu/sicp/front/node3.html 
>
>
> On Sat, Mar 1, 2014 at 2:48 AM, Kashyap CK > 
> wrote: 
> > Hi, 
> > In one of the talks, Rich Hickey had mentioned something to the effect - 
> > 
> > "Programs are meant to state the intention of your computation to other 
> > programmers/humans - as opposed to instructions for a machine" 
> > 
> > He was quoting someone else actually (perhaps Knuth). I just cant seem 
> to 
> > get my hands on that video. Could someone please remind me what that 
> > quotation was? 
> > 
> > Regards, 
> > Kashyap 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> > Groups "Clojure" group. 
> > To post to this group, send email to clo...@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+u...@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 unsubscribe from this group and stop receiving emails from it, send 
> an 
> > email to clojure+u...@googlegroups.com . 
> > For more options, visit https://groups.google.com/groups/opt_out. 
>

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


ANN: Events in Scotland

2014-03-01 Thread Adrian Mowat
Hi All,

Just a quick note to let everyone know about events in Scotland over the 
coming weeks.

First up the inaugural meeting of the Glasgow Clojurians with be this 
Thursday (6th March) at Spaarks, 70 W Regent St, Glasgow at 7pm.  We'll be 
running a Clojure Dojo based on what the guys in London are doing.  If you 
are interested, please join our group at 
https://groups.google.com/forum/#!forum/glasgow-clojurians.

Second, Malcolm Sparks and I will be re-running the Clojure Launchpad 
course for beginners and improvers on the 22nd of March at NCR in 
Edinburgh.  Tickets are £10 at 
http://www.eventbrite.co.uk/e/clojure-launchpad-tickets-10626788009?aff=estw

Finally, the monthly Code Craft group are covering the functional language 
chapters from 7 languages in 7 weeks on the 20th of March in Glasgow. More 
info at http://www.codecraftuk.org/events/2014/02/seven-languages-part-2/

Cheers

Adrian


-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: ace / codemirror in cljs

2014-03-01 Thread t x
No, it appears lighttable uses CodeMIrror.

See:
  * https://github.com/LightTable/LightTable/search?q=codemirror&ref=cmdform
  * http://www.chris-granger.com/2012/04/15/light-tables-numbers/


On Sat, Mar 1, 2014 at 3:02 AM, Dave Sann  wrote:
> have you considered reading the LightTable code? There is probably some cljs
> and editor in there
>
>
> On Saturday, 1 March 2014 17:26:18 UTC+11, t x wrote:
>>
>> Hi,
>>
>>   Is there anything like http://codemirror.net/ or
>> http://ace.c9.io/#nav=about in cljs ?
>>
>>   The goal is not to use codemirror/ace in a cljs project. The goal is
>> to read some interesting cljs code on how to write an editor.
>>
>> 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
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Clojure performance question

2014-03-01 Thread dennis zhuang
The "String a=i+"another word";" is also compiled into using
 StringBuilder, see the byte code by javap -v:

   Code:
  stack=5, locals=5, args_size=1
 0: invokestatic  #2  // Method
java/lang/System.nanoTime:()J
 3: lstore_1
 4: iconst_0
 5: istore_3
 6: iload_3
 7: ldc   #3  // int 1000
 9: if_icmpge 39
12: new   #4  // class
java/lang/StringBuilder
15: dup
16: invokespecial #5  // Method
java/lang/StringBuilder."":()V
19: iload_3
20: invokevirtual #6  // Method
java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
23: ldc   #7  // String another word
25: invokevirtual #8  // Method
java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
28: invokevirtual #9  // Method
java/lang/StringBuilder.toString:()Ljava/lang/String;
31: astore4
33: iinc  3, 1
36: goto  6
39: getstatic #10 // Field
java/lang/System.out:Ljava/io/PrintStream;
42: invokestatic  #2  // Method
java/lang/System.nanoTime:()J
45: lload_1
46: lsub
47: l2d
48: ldc2_w#11 // double 1.0E9d
51: ddiv
52: invokevirtual #13 // Method
java/io/PrintStream.println:(D)V


I think the performance hotspot in this simple example is the object
allocate/gc  and function calling overhead.The str function create
an anonymous function every time to concat argument strings:

(^String [x & ys]
 ((fn [^StringBuilder sb more]
  (if more
(recur (. sb  (append (str (first more (next more))
(str sb)))
  (new StringBuilder (str x)) ys)))

And we all know that a function in clojure is a java object allocated in
heap.And another overhead is calling the function,it's virtual method.

By watching the gc statistics using 'jstat -gcutil  2000', i found
that the clojure sample ran about 670 minor gc,but the java sample is only
120 minor gc.

A improved clojure version,it's performance is closed to java sample:

user=> (time (dotimes [n 1000] (-> (StringBuilder.) (.append n)
(.append "another word") (.toString
"Elapsed time: 1009.942 msecs"




2014-03-01 18:02 GMT+08:00 bob :

> Case :
>
> clojure verison:
>
> (time (dotimes [n 1000] (str n "another word"))) ;; take about 5000msec
>
> java version
>
> long time = System.nanoTime();
>
> for(int i=0 ; i<1000 ;i++){
> String a=i+"another word";
> }
>   System.out.println(System.nanoTime()-time);
>
>
> The java version take about 500 msecs, I thought it might be caused by the
> str implementation which is using string builder, and it might not be the
> best choice in the case of no much string to concat, and then I replace
> "another word" with 5 long strings as the parameter, however no surprise.
>
> I just wonder what make the difference, or how to find the difference.
>
> Thanks
>
>
>
> On Saturday, March 1, 2014 1:26:38 PM UTC+8, Shantanu Kumar wrote:
>>
>> I have seen (and I keep seeing) a ton of Java code that performs poorly.
>> Empirically, it's equally easy to write a slow Java app. You always need a
>> discerning programmer to get good performance from any language/tool.
>>
>> Numbers like 1/4 or 1/10 can be better discussed in presence of the
>> use-cases and perf test cases. Most of the problems you listed can be
>> mitigated by `-server` JIT, avoiding reflection, transients, loop-recur,
>> arrays, perf libraries and some Java code.
>>
>> Shantanu
>>
>  --
> 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 unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>



-- 
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

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

Re: Clojure performance question

2014-03-01 Thread dennis zhuang
I forgot to note hat i test the java sample and clojure sample code with
the same jvm options '-server'.



2014-03-01 20:03 GMT+08:00 dennis zhuang :

> The "String a=i+"another word";" is also compiled into using
>  StringBuilder, see the byte code by javap -v:
>
>Code:
>   stack=5, locals=5, args_size=1
>  0: invokestatic  #2  // Method
> java/lang/System.nanoTime:()J
>  3: lstore_1
>  4: iconst_0
>  5: istore_3
>  6: iload_3
>  7: ldc   #3  // int 1000
>  9: if_icmpge 39
> 12: new   #4  // class
> java/lang/StringBuilder
> 15: dup
> 16: invokespecial #5  // Method
> java/lang/StringBuilder."":()V
> 19: iload_3
> 20: invokevirtual #6  // Method
> java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
> 23: ldc   #7  // String another word
> 25: invokevirtual #8  // Method
> java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
> 28: invokevirtual #9  // Method
> java/lang/StringBuilder.toString:()Ljava/lang/String;
> 31: astore4
> 33: iinc  3, 1
> 36: goto  6
> 39: getstatic #10 // Field
> java/lang/System.out:Ljava/io/PrintStream;
> 42: invokestatic  #2  // Method
> java/lang/System.nanoTime:()J
> 45: lload_1
> 46: lsub
> 47: l2d
> 48: ldc2_w#11 // double 1.0E9d
> 51: ddiv
> 52: invokevirtual #13 // Method
> java/io/PrintStream.println:(D)V
>
>
> I think the performance hotspot in this simple example is the object
> allocate/gc  and function calling overhead.The str function create
> an anonymous function every time to concat argument strings:
>
> (^String [x & ys]
>  ((fn [^StringBuilder sb more]
>   (if more
> (recur (. sb  (append (str (first more (next more))
> (str sb)))
>   (new StringBuilder (str x)) ys)))
>
> And we all know that a function in clojure is a java object allocated in
> heap.And another overhead is calling the function,it's virtual method.
>
> By watching the gc statistics using 'jstat -gcutil  2000', i found
> that the clojure sample ran about 670 minor gc,but the java sample is only
> 120 minor gc.
>
> A improved clojure version,it's performance is closed to java sample:
>
> user=> (time (dotimes [n 1000] (-> (StringBuilder.) (.append n)
> (.append "another word") (.toString
> "Elapsed time: 1009.942 msecs"
>
>
>
>
> 2014-03-01 18:02 GMT+08:00 bob :
>
> Case :
>>
>> clojure verison:
>>
>> (time (dotimes [n 1000] (str n "another word"))) ;; take about
>> 5000msec
>>
>> java version
>>
>> long time = System.nanoTime();
>>
>> for(int i=0 ; i<1000 ;i++){
>> String a=i+"another word";
>> }
>>   System.out.println(System.nanoTime()-time);
>>
>>
>> The java version take about 500 msecs, I thought it might be caused by
>> the str implementation which is using string builder, and it might not be
>> the best choice in the case of no much string to concat, and then I replace
>> "another word" with 5 long strings as the parameter, however no surprise.
>>
>> I just wonder what make the difference, or how to find the difference.
>>
>> Thanks
>>
>>
>>
>> On Saturday, March 1, 2014 1:26:38 PM UTC+8, Shantanu Kumar wrote:
>>>
>>> I have seen (and I keep seeing) a ton of Java code that performs poorly.
>>> Empirically, it's equally easy to write a slow Java app. You always need a
>>> discerning programmer to get good performance from any language/tool.
>>>
>>> Numbers like 1/4 or 1/10 can be better discussed in presence of the
>>> use-cases and perf test cases. Most of the problems you listed can be
>>> mitigated by `-server` JIT, avoiding reflection, transients, loop-recur,
>>> arrays, perf libraries and some Java code.
>>>
>>> Shantanu
>>>
>>  --
>> 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 unsubscribe from this group and stop receiving emails from it, send an
>> email to clojure+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>
>
> --
> 庄晓丹
> Email:killme2...@gmail.com xzhu...@avos.com
> Site:   http://fnil.net
> Twitter:  @killme2008
>

Re: Clojure performance question

2014-03-01 Thread dennis zhuang
I think the remaining overhead of clojure sample code is that operators in
java such as '++' and '<" etc.They are just an instrument of JVM -- iinc
and if_icmpge. But they are both functions in clojure,and they will be
called by invokevirtual instrument.It cost much more performance.




2014-03-01 20:07 GMT+08:00 dennis zhuang :

> I forgot to note hat i test the java sample and clojure sample code with
> the same jvm options '-server'.
>
>
>
> 2014-03-01 20:03 GMT+08:00 dennis zhuang :
>
> The "String a=i+"another word";" is also compiled into using
>>  StringBuilder, see the byte code by javap -v:
>>
>>Code:
>>   stack=5, locals=5, args_size=1
>>  0: invokestatic  #2  // Method
>> java/lang/System.nanoTime:()J
>>  3: lstore_1
>>  4: iconst_0
>>  5: istore_3
>>  6: iload_3
>>  7: ldc   #3  // int 1000
>>  9: if_icmpge 39
>> 12: new   #4  // class
>> java/lang/StringBuilder
>> 15: dup
>> 16: invokespecial #5  // Method
>> java/lang/StringBuilder."":()V
>> 19: iload_3
>> 20: invokevirtual #6  // Method
>> java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
>> 23: ldc   #7  // String another word
>> 25: invokevirtual #8  // Method
>> java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
>> 28: invokevirtual #9  // Method
>> java/lang/StringBuilder.toString:()Ljava/lang/String;
>> 31: astore4
>> 33: iinc  3, 1
>> 36: goto  6
>> 39: getstatic #10 // Field
>> java/lang/System.out:Ljava/io/PrintStream;
>> 42: invokestatic  #2  // Method
>> java/lang/System.nanoTime:()J
>> 45: lload_1
>> 46: lsub
>> 47: l2d
>> 48: ldc2_w#11 // double 1.0E9d
>> 51: ddiv
>> 52: invokevirtual #13 // Method
>> java/io/PrintStream.println:(D)V
>>
>>
>> I think the performance hotspot in this simple example is the object
>> allocate/gc  and function calling overhead.The str function create
>> an anonymous function every time to concat argument strings:
>>
>> (^String [x & ys]
>>  ((fn [^StringBuilder sb more]
>>   (if more
>> (recur (. sb  (append (str (first more (next more))
>> (str sb)))
>>   (new StringBuilder (str x)) ys)))
>>
>> And we all know that a function in clojure is a java object allocated in
>> heap.And another overhead is calling the function,it's virtual method.
>>
>> By watching the gc statistics using 'jstat -gcutil  2000', i found
>> that the clojure sample ran about 670 minor gc,but the java sample is only
>> 120 minor gc.
>>
>> A improved clojure version,it's performance is closed to java sample:
>>
>> user=> (time (dotimes [n 1000] (-> (StringBuilder.) (.append n)
>> (.append "another word") (.toString
>> "Elapsed time: 1009.942 msecs"
>>
>>
>>
>>
>> 2014-03-01 18:02 GMT+08:00 bob :
>>
>> Case :
>>>
>>> clojure verison:
>>>
>>> (time (dotimes [n 1000] (str n "another word"))) ;; take about
>>> 5000msec
>>>
>>> java version
>>>
>>> long time = System.nanoTime();
>>>
>>> for(int i=0 ; i<1000 ;i++){
>>> String a=i+"another word";
>>> }
>>>   System.out.println(System.nanoTime()-time);
>>>
>>>
>>> The java version take about 500 msecs, I thought it might be caused by
>>> the str implementation which is using string builder, and it might not be
>>> the best choice in the case of no much string to concat, and then I replace
>>> "another word" with 5 long strings as the parameter, however no surprise.
>>>
>>> I just wonder what make the difference, or how to find the difference.
>>>
>>> Thanks
>>>
>>>
>>>
>>> On Saturday, March 1, 2014 1:26:38 PM UTC+8, Shantanu Kumar wrote:

 I have seen (and I keep seeing) a ton of Java code that performs
 poorly. Empirically, it's equally easy to write a slow Java app. You always
 need a discerning programmer to get good performance from any 
 language/tool.

 Numbers like 1/4 or 1/10 can be better discussed in presence of the
 use-cases and perf test cases. Most of the problems you listed can be
 mitigated by `-server` JIT, avoiding reflection, transients, loop-recur,
 arrays, perf libraries and some Java code.

 Shantanu

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

Re: [ANN] clojure.test.check (previously, simple-check)

2014-03-01 Thread keeds
Reid,
Thank you kindly. That makes sense. Your help is much appreciated, as are 
your efforts with this library.

Thanks,
Andrew

On Thursday, 27 February 2014 17:22:44 UTC, Reid Draper wrote:
>
> I'm happy to announce the first release of the newest Clojure contrib 
> library:
> test.check [1]. Previously named simple-check [1], test.check is a
> property-based testing library, based on QuickCheck. The README has a 
> guide for
> migrating from simple-check, as well as some getting-started 
> documentation. I'm
> happy to answer any questions here as well. Or, stop by my Clojure/West 
> talk in
> March.
>
> [1] https://github.com/clojure/test.check
> [2] https://github.com/reiddraper/simple-check
>
>

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Clojure performance question

2014-03-01 Thread Jozef Wagner
Clojure math functions compile down to the same JVM 'instruction' as from
java. See http://galdolber.tumblr.com/post/77153377251/clojure-intrinsics


On Sat, Mar 1, 2014 at 1:23 PM, dennis zhuang  wrote:

> I think the remaining overhead of clojure sample code is that operators in
> java such as '++' and '<" etc.They are just an instrument of JVM -- iinc
> and if_icmpge. But they are both functions in clojure,and they will be
> called by invokevirtual instrument.It cost much more performance.
>
>
>
>
> 2014-03-01 20:07 GMT+08:00 dennis zhuang :
>
> I forgot to note hat i test the java sample and clojure sample code with
>> the same jvm options '-server'.
>>
>>
>>
>> 2014-03-01 20:03 GMT+08:00 dennis zhuang :
>>
>> The "String a=i+"another word";" is also compiled into using
>>>  StringBuilder, see the byte code by javap -v:
>>>
>>>Code:
>>>   stack=5, locals=5, args_size=1
>>>  0: invokestatic  #2  // Method
>>> java/lang/System.nanoTime:()J
>>>  3: lstore_1
>>>  4: iconst_0
>>>  5: istore_3
>>>  6: iload_3
>>>  7: ldc   #3  // int 1000
>>>  9: if_icmpge 39
>>> 12: new   #4  // class
>>> java/lang/StringBuilder
>>> 15: dup
>>> 16: invokespecial #5  // Method
>>> java/lang/StringBuilder."":()V
>>> 19: iload_3
>>> 20: invokevirtual #6  // Method
>>> java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
>>> 23: ldc   #7  // String another word
>>> 25: invokevirtual #8  // Method
>>> java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
>>> 28: invokevirtual #9  // Method
>>> java/lang/StringBuilder.toString:()Ljava/lang/String;
>>> 31: astore4
>>> 33: iinc  3, 1
>>> 36: goto  6
>>> 39: getstatic #10 // Field
>>> java/lang/System.out:Ljava/io/PrintStream;
>>> 42: invokestatic  #2  // Method
>>> java/lang/System.nanoTime:()J
>>> 45: lload_1
>>> 46: lsub
>>> 47: l2d
>>> 48: ldc2_w#11 // double 1.0E9d
>>> 51: ddiv
>>> 52: invokevirtual #13 // Method
>>> java/io/PrintStream.println:(D)V
>>>
>>>
>>> I think the performance hotspot in this simple example is the object
>>> allocate/gc  and function calling overhead.The str function create
>>> an anonymous function every time to concat argument strings:
>>>
>>> (^String [x & ys]
>>>  ((fn [^StringBuilder sb more]
>>>   (if more
>>> (recur (. sb  (append (str (first more (next more))
>>> (str sb)))
>>>   (new StringBuilder (str x)) ys)))
>>>
>>> And we all know that a function in clojure is a java object allocated in
>>> heap.And another overhead is calling the function,it's virtual method.
>>>
>>> By watching the gc statistics using 'jstat -gcutil  2000', i found
>>> that the clojure sample ran about 670 minor gc,but the java sample is only
>>> 120 minor gc.
>>>
>>> A improved clojure version,it's performance is closed to java sample:
>>>
>>> user=> (time (dotimes [n 1000] (-> (StringBuilder.) (.append n)
>>> (.append "another word") (.toString
>>> "Elapsed time: 1009.942 msecs"
>>>
>>>
>>>
>>>
>>> 2014-03-01 18:02 GMT+08:00 bob :
>>>
>>> Case :

 clojure verison:

 (time (dotimes [n 1000] (str n "another word"))) ;; take about
 5000msec

 java version

 long time = System.nanoTime();

 for(int i=0 ; i<1000 ;i++){
 String a=i+"another word";
 }
   System.out.println(System.nanoTime()-time);


 The java version take about 500 msecs, I thought it might be caused by
 the str implementation which is using string builder, and it might not be
 the best choice in the case of no much string to concat, and then I replace
 "another word" with 5 long strings as the parameter, however no surprise.

 I just wonder what make the difference, or how to find the difference.

 Thanks



 On Saturday, March 1, 2014 1:26:38 PM UTC+8, Shantanu Kumar wrote:
>
> I have seen (and I keep seeing) a ton of Java code that performs
> poorly. Empirically, it's equally easy to write a slow Java app. You 
> always
> need a discerning programmer to get good performance from any 
> language/tool.
>
> Numbers like 1/4 or 1/10 can be better discussed in presence of the
> use-cases and perf test cases. Most of the problems you listed can be
> mitigated by `-server` JIT, avoiding reflection, transients, loop-recur,
> arrays, perf libraries and some Java code.
>
> Shantanu
>
  --
 You received this message because you are subscribed to the 

Re: Clojure performance question

2014-03-01 Thread dennis zhuang
Yep, you are right, inspecting the byte code generated by the clojure code:

 (loop [n 0]
(when (< n 1000)
  (-> (StringBuilder.) (.append n) (.append "another word")
(.toString))
  (recur (unchecked-inc n

It is:


L4
LINENUMBER 4 L4
LLOAD 1
LDC 1000
LCMP
IFGE L5
   L6
LINENUMBER 5 L6
   L7
LINENUMBER 5 L7
   L8
LINENUMBER 5 L8
NEW java/lang/StringBuilder
DUP
INVOKESPECIAL java/lang/StringBuilder. ()V
CHECKCAST java/lang/StringBuilder
LLOAD 1
INVOKEVIRTUAL java/lang/StringBuilder.append
(J)Ljava/lang/StringBuilder;
CHECKCAST java/lang/StringBuilder
LDC "another word"
CHECKCAST java/lang/String
INVOKEVIRTUAL java/lang/StringBuilder.append
(Ljava/lang/String;)Ljava/lang/StringBuilder;
CHECKCAST java/lang/StringBuilder
INVOKEVIRTUAL java/lang/StringBuilder.toString ()Ljava/lang/String;
POP
   L9
LINENUMBER 6 L9
LLOAD 1
LCONST_1
LADD
LSTORE 1
GOTO L2
GOTO L10
   L11
POP
   L5
ACONST_NULL


It's almost the same with java compiled byte code,except using long type's
instruments (LCMP and LADD etc) and some CHECKCAST (cast type) instruments.





2014-03-01 21:00 GMT+08:00 Jozef Wagner :

> Clojure math functions compile down to the same JVM 'instruction' as from
> java. See http://galdolber.tumblr.com/post/77153377251/clojure-intrinsics
>
>
>
> On Sat, Mar 1, 2014 at 1:23 PM, dennis zhuang wrote:
>
>> I think the remaining overhead of clojure sample code is that operators
>> in java such as '++' and '<" etc.They are just an instrument of JVM -- iinc
>> and if_icmpge. But they are both functions in clojure,and they will be
>> called by invokevirtual instrument.It cost much more performance.
>>
>>
>>
>>
>> 2014-03-01 20:07 GMT+08:00 dennis zhuang :
>>
>> I forgot to note hat i test the java sample and clojure sample code with
>>> the same jvm options '-server'.
>>>
>>>
>>>
>>> 2014-03-01 20:03 GMT+08:00 dennis zhuang :
>>>
>>> The "String a=i+"another word";" is also compiled into using
  StringBuilder, see the byte code by javap -v:

Code:
   stack=5, locals=5, args_size=1
  0: invokestatic  #2  // Method
 java/lang/System.nanoTime:()J
  3: lstore_1
  4: iconst_0
  5: istore_3
  6: iload_3
  7: ldc   #3  // int 1000
  9: if_icmpge 39
 12: new   #4  // class
 java/lang/StringBuilder
 15: dup
 16: invokespecial #5  // Method
 java/lang/StringBuilder."":()V
 19: iload_3
 20: invokevirtual #6  // Method
 java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
 23: ldc   #7  // String another word
 25: invokevirtual #8  // Method
 java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
 28: invokevirtual #9  // Method
 java/lang/StringBuilder.toString:()Ljava/lang/String;
 31: astore4
 33: iinc  3, 1
 36: goto  6
 39: getstatic #10 // Field
 java/lang/System.out:Ljava/io/PrintStream;
 42: invokestatic  #2  // Method
 java/lang/System.nanoTime:()J
 45: lload_1
 46: lsub
 47: l2d
 48: ldc2_w#11 // double 1.0E9d
 51: ddiv
 52: invokevirtual #13 // Method
 java/io/PrintStream.println:(D)V


 I think the performance hotspot in this simple example is the object
 allocate/gc  and function calling overhead.The str function create
 an anonymous function every time to concat argument strings:

 (^String [x & ys]
  ((fn [^StringBuilder sb more]
   (if more
 (recur (. sb  (append (str (first more (next more))
 (str sb)))
   (new StringBuilder (str x)) ys)))

 And we all know that a function in clojure is a java object allocated
 in heap.And another overhead is calling the function,it's virtual method.

 By watching the gc statistics using 'jstat -gcutil  2000', i found
 that the clojure sample ran about 670 minor gc,but the java sample is only
 120 minor gc.

 A improved clojure version,it's performance is closed to java sample:

 user=> (time (dotimes [n 1000] (-> (StringBuilder.) (.append n)
 (.append "another word") (.toString
 "Elapsed time: 1009.942 msecs"




 2014-03-01 18:02 GMT+08:00 bob :

 Case :
>
> clojure verison:
>
> (time (dotimes [n 1000] (str n "another word"))) ;; take about
> 5000msec
>
> java version
>>>

Re: Clojure performance question

2014-03-01 Thread Jozef Wagner
>From my experience, you can get 1/1.2 performance (20% slower) with Clojure 
by following these steps:

* Choose right clojure idioms

That means to never use lazy seqs if you care for java-like performance. 
For fast looping, use reducers, for fast inserts, use transients. 
Postpone the data creation until the last step. Compose functions instead 
of piping collections containing intermediate results.
Know the tradeoffs between similar functions (e.g. rseq and reverse)
Use custom datatype with ^:unsynchronized-mutable for performance critical 
mutations, instead of atoms or vars.

* Use domain knowledge for your advantage 

Collection has a random access? Use it to your advantage. 
Is it backed by array? Do a bulk copy instead of one element per iteration.
Is memory killing you? Use subcollections which share underlying data with 
original ones.
If shooting for performance, you do not want the most generic solution. 
Search for more performant solutions which have trade-offs you can live 
with.
Do not use polymorphic dispatch if you have a closed set of options. If you 
do, prefer protocols to multimethods.

* Trade between memory and CPU (and precision)

Have a CPU intensive pure function? Memoize.
Using too much memory? Use lazy seqs, delays, dropping caches.
(Do not care for precision? Round, truncate and approximate. Use decayed 
collections, frugal streaming, ...)

* Paralellize

Clojure's approach to the concurrency allows you to focus on the problem 
and not fight much with the synchronization details. 
Using and customizing fold idiom is a good start.
(What would be a good addition to the clojure is a simple abstraction on 
top of executors and forkjoin pool for even more fine tuning.)

* Know your host

Use type hints to get rid of reflection and boxing. Most of time you can 
eliminate all reflections, but it is very hard to eliminate every automatic 
boxing/unboxing without dropping down to java.
Heavy IO use? Build your abstractions around java.nio.Buffer.
Looping with ints is faster than with longs.


While any part of your code should be idiomatic and with good design 
behind, use heavy optimization 'tricks' only to those parts of the code 
which bring the most effect. Your time can be spent on more useful things 
than optimizing some auxilliary functionality.

Best,
Jozef


On Saturday, March 1, 2014 6:02:26 AM UTC+1, bob wrote:
>
> Hi,
>
> Can I ask a newbie question about clojure performance?
>
> What make clojure performance slow than java?, it seems clojure has the 
> 1/4 performance compared to java in general, according to  tests, some 
> cases it might be 1/10. the reasons I can think out are 
>
> - the byte code is not efficient sometimes
> - the byte code might not enjoy the jvm optimization
> - the reflection 
> - the immutable data structure
> - the abstract interface design
>
> The abstract interface like seq offers its power, but it is easy to drop 
> in the performance trap.
>
> And it seems to me that it is easy to write a slow clojure program, I know 
> the efficiency of code depends on coder, you can write the code faster than 
> java sometimes,but  need to know a lot of deep thing and tricky, and 
> clojure is not the funny clojure any more.
>
>
> 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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


What is the right way to create dynamic var in another namespace?

2014-03-01 Thread Эльдар Габдуллин
I expected the following to work, but it doesn't:

(defn declare-foo []
  (intern *ns*
  (with-meta '*foo* {:dynamic true :private true})
  "foo"))

Although it creates a var, it is not dynamic. We can mark it 
dynamic ourselves,
but it seems that such ability is an implementation detail.

(defn declare-foo []
  (.setDynamic (intern *ns*
   (with-meta '*foo* {:private true})
   "foo")))

May be it's a Clojure bug and the first variant is supposed to 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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Clojure performance question

2014-03-01 Thread Shantanu Kumar


On Saturday, 1 March 2014 15:32:41 UTC+5:30, bob wrote:
>
> Case :
>
> clojure verison:
>
> (time (dotimes [n 1000] (str n "another word"))) ;; take about 5000msec
>
> java version
>
> long time = System.nanoTime();
>
> for(int i=0 ; i<1000 ;i++){
> String a=i+"another word";
> }
>   System.out.println(System.nanoTime()-time); 
>  
>
> The java version take about 500 msecs, I thought it might be caused by the 
> str implementation which is using string builder, and it might not be the 
> best choice in the case of no much string to concat, and then I replace 
> "another word" with 5 long strings as the parameter, however no surprise.
>
> I just wonder what make the difference, or how to find the difference.
>

Others have added useful points to this thread. Java string concatenation 
internally uses StringBuilder, so if you replace (str n "another word") 
with the following:

(let [sb (StringBuilder.)]
 (.append sb n)
 (.append sb "another word")
 (.toString sb))

..then the perf improves 1/4 to 1/3. Further, with the following tweak:

(let [sb (StringBuilder. 20)]  ; because StringBuilder allocates only 16 
chars by default on Oracle JRE
 (.append sb n)
 (.append sb "another word")
 (.toString sb))

..the perf improves from 1/3 to less than 1/2. Here we simply avoid double 
allocation in StringBuilder.

Other things I made sure were:

1. I used Criterium to measure
2. I used `-server` option
3. Made sure reflection warning was on

Shantanu

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


I want to get sha1 of a string

2014-03-01 Thread action
do like this:
(ns clojurewerkz.support.hashing
  (:require [clojurewerkz.support.internal :as i])
  (:import [com.google.common.hash Hashing HashFunction HashCode]))
but:
FileNotFoundException Could not locate clojurewerkz/support__init.class or 
cloju
rewerkz/support.clj on classpath:   clojure.lang.RT.load (RT.java:443)
how to set the dependencies, or other solution?

Think you


-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: I want to get sha1 of a string

2014-03-01 Thread JPH
I've had good experiences with https://github.com/xsc/pandect.

You can also use Java interop like this:
https://gist.github.com/prasincs/827272

JPH


On 03/02/2014 12:26 AM, action wrote:
> do like this:
> (ns clojurewerkz.support.hashing
>   (:require [clojurewerkz.support.internal :as i])
>   (:import [com.google.common.hash Hashing HashFunction HashCode]))
> but:
> FileNotFoundException Could not locate clojurewerkz/support__init.class or 
> cloju
> rewerkz/support.clj on classpath:   clojure.lang.RT.load (RT.java:443)
> how to set the dependencies, or other solution?
>
> Think you
>
>

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Latest web framework for clojure

2014-03-01 Thread Devin Walters
Have you checked out Http://hoplon.io?

'(Devin Walters)

> On Feb 28, 2014, at 12:55, Daniel  wrote:
> 
> Long story short.  You should be learning Pedestal, but the app component is 
> "on pause" at the moment.  My advice is to learn pedestal-service and Om. 
> When Pedestal-app gets going again, learning Om will have given you a good 
> context for transitioning to Pedestal 100%.
> 
> -- 
> 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 unsubscribe from this group and stop receiving emails from it, send an 
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: ANN: rx-cljs, A ClojureScript wrapper for Reactive Extensions

2014-03-01 Thread Michael Marsh
Awesome! I've been addicted to Rx lately and this is just what I need for 
one of my projects. I'll definitely check this out and let you know how it 
goes.

On Tuesday, May 21, 2013 4:01:46 AM UTC-4, Leonardo Borges wrote:
>
> Hey guys,
>
> Given some recent work I've been doing with RxJS [1], I ended up writing a 
> small Clojurescript wrapper for it.
>
> The idea of being familiar with a common API in multiple environments 
> (Java, Javascript and Clojurescript) is what triggered this approach.
>
> The README contains sample snippets and a link to an example app, as well 
> as a list of what's been implemented. 
> But be warned: it's very early days and this wrapper is still very much 
> incomplete.
>
> I'm keen on spending more time on it if there is enough interest - at the 
> moment I've only implemented what I needed.
>
> Where to find it:
>
> Github: https://github.com/leonardoborges/rx-cljs
> Clojars: https://clojars.org/com.leonardoborges/rx-cljs
>
> [1]: https://github.com/Reactive-Extensions/RxJS
>
>
> Cheers,
> Leonardo Borges
> www.leonardoborges.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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Reagent: ReactCSSTransitionGroup

2014-03-01 Thread Chris Sutela
Thanks so much Dan, that was a great help!

the code ends up being:* (def ctg (-> js/React (aget "addons") (aget 
"CSSTransitionGroup"))) *

but yeah, you were totally correct :)

On Friday, February 28, 2014 5:34:34 AM UTC-8, Dan Holmsand wrote:
>
> Yes, Reagent doesn't know about React components that don't live in 
> React.DOM (ReactCSSTransitionGroup is in React.addons).
>
> So what you would need to do is to get hold of the component 
> "constructor", with something like
>
> (def ctg (-> js/React (aget "addons") (aget "ReactCSSTransitionGroup")))
>
> and then call that with e.g
>
> [ctg {:transitionName "foo"} [:p "child1"] [:p "child2"]]
>
> or somesuch (I'm probably messing something up here, being away from Emacs 
> for the moment, but you get the idea...).
>
> /dan
>
> On 28 feb 2014, at 14:10, Chris Sutela > 
> wrote:
>
> is there a recommended way of accessing the ReactCSSTransitionGroup tag 
> that is a part of react-wtih-add-ons.js?  
>
> Specifically I am having trouble avoiding an Uncaught Error: Assert 
> failed: Unknown tag: ':ReactCSSTransitionGroup'
>
> -- 
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clo...@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+u...@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 unsubscribe from this group and stop receiving emails from it, send an 
> email to clojure+u...@googlegroups.com .
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: I want to get sha1 of a string

2014-03-01 Thread Zach Oakes
You can use java.security.MessageDigest. For example:

(defn create-hash
  [data-barray]
  (.digest (java.security.MessageDigest/getInstance "SHA1") data-barray))

It takes and returns a byte array, but converting from/to a string is 
fairly straight-forward:

(->> "Hello, World!"
 .getBytes
 create-hash
 java.math.BigInteger.
 (format "%x")
 println)

On Saturday, March 1, 2014 11:26:29 AM UTC-5, action wrote:

> do like this:
> (ns clojurewerkz.support.hashing
>   (:require [clojurewerkz.support.internal :as i])
>   (:import [com.google.common.hash Hashing HashFunction HashCode]))
> but:
> FileNotFoundException Could not locate clojurewerkz/support__init.class or 
> cloju
> rewerkz/support.clj on classpath:   clojure.lang.RT.load (RT.java:443)
> how to set the dependencies, or other solution?
>
> Think you
>
>
>

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [ANN] - purnam 0.4.3 released - Javascript Language Extensions for Clojurescript

2014-03-01 Thread zcaudate
I'm also looking for collaborators as it is getting to a stage where I'm 
having trouble managing it by myself.

 if anybody is interested. Please send me a message

Chris

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Clojure performance question

2014-03-01 Thread bob

Good point, Thanks a lot. 

Shall we improve the str fn in the core lib? From my point of view, the 
core fns should be performance sensitive.



On Sunday, March 2, 2014 12:03:21 AM UTC+8, Shantanu Kumar wrote:
>
>
>
> On Saturday, 1 March 2014 15:32:41 UTC+5:30, bob wrote:
>>
>> Case :
>>
>> clojure verison:
>>
>> (time (dotimes [n 1000] (str n "another word"))) ;; take about 
>> 5000msec
>>
>> java version
>>
>> long time = System.nanoTime();
>>
>> for(int i=0 ; i<1000 ;i++){
>> String a=i+"another word";
>> }
>>   System.out.println(System.nanoTime()-time); 
>>  
>>
>> The java version take about 500 msecs, I thought it might be caused by 
>> the str implementation which is using string builder, and it might not be 
>> the best choice in the case of no much string to concat, and then I replace 
>> "another word" with 5 long strings as the parameter, however no surprise.
>>
>> I just wonder what make the difference, or how to find the difference.
>>
>
> Others have added useful points to this thread. Java string concatenation 
> internally uses StringBuilder, so if you replace (str n "another word") 
> with the following:
>
> (let [sb (StringBuilder.)]
>  (.append sb n)
>  (.append sb "another word")
>  (.toString sb))
>
> ..then the perf improves 1/4 to 1/3. Further, with the following tweak:
>
> (let [sb (StringBuilder. 20)]  ; because StringBuilder allocates only 16 
> chars by default on Oracle JRE
>  (.append sb n)
>  (.append sb "another word")
>  (.toString sb))
>
> ..the perf improves from 1/3 to less than 1/2. Here we simply avoid double 
> allocation in StringBuilder.
>
> Other things I made sure were:
>
> 1. I used Criterium to measure
> 2. I used `-server` option
> 3. Made sure reflection warning was on
>
> Shantanu
>

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Clojure performance question

2014-03-01 Thread Gary Trakhman
Core fns should be simple, unsurprising, and general.

'Improving' str may hurt simplicity, make behavior more surprising and
unexpected, and less general unless proven otherwise.

On Sat, Mar 1, 2014 at 7:02 PM, bob  wrote:

>
> Good point, Thanks a lot.
>
> Shall we improve the str fn in the core lib? From my point of view, the
> core fns should be performance sensitive.
>
>
>
> On Sunday, March 2, 2014 12:03:21 AM UTC+8, Shantanu Kumar wrote:
>>
>>
>>
>> On Saturday, 1 March 2014 15:32:41 UTC+5:30, bob wrote:
>>>
>>> Case :
>>>
>>> clojure verison:
>>>
>>> (time (dotimes [n 1000] (str n "another word"))) ;; take about
>>> 5000msec
>>>
>>> java version
>>>
>>> long time = System.nanoTime();
>>>
>>> for(int i=0 ; i<1000 ;i++){
>>> String a=i+"another word";
>>> }
>>>   System.out.println(System.nanoTime()-time);
>>>
>>>
>>> The java version take about 500 msecs, I thought it might be caused by
>>> the str implementation which is using string builder, and it might not be
>>> the best choice in the case of no much string to concat, and then I replace
>>> "another word" with 5 long strings as the parameter, however no surprise.
>>>
>>> I just wonder what make the difference, or how to find the difference.
>>>
>>
>> Others have added useful points to this thread. Java string concatenation
>> internally uses StringBuilder, so if you replace (str n "another word")
>> with the following:
>>
>> (let [sb (StringBuilder.)]
>>  (.append sb n)
>>  (.append sb "another word")
>>  (.toString sb))
>>
>> ..then the perf improves 1/4 to 1/3. Further, with the following tweak:
>>
>> (let [sb (StringBuilder. 20)]  ; because StringBuilder allocates only 16
>> chars by default on Oracle JRE
>>  (.append sb n)
>>  (.append sb "another word")
>>  (.toString sb))
>>
>> ..the perf improves from 1/3 to less than 1/2. Here we simply avoid
>> double allocation in StringBuilder.
>>
>> Other things I made sure were:
>>
>> 1. I used Criterium to measure
>> 2. I used `-server` option
>> 3. Made sure reflection warning was on
>>
>> Shantanu
>>
>  --
> 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 unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


isa? problem with collection type for multiple argument dispatch

2014-03-01 Thread Dave Tenny
(isa? [String String] [Object Object]) returns true. This is nice and 
useful.

However

(isa? '(String String) '(Object Object) returns false, this is not so nice.

(isa? '(String String) [Object Object]) also return false.


So the moral of the story is that for multiple argument dispatch to work, I 
need to use 'mapv' instead of 'map' in my dispatch function, which I have 
done.
But it was sort of a pain to find out the hard way (i.e. time spent 
debugging) that 'map' won't work in this regard.

I.e. this fails:

(defmulti foo (fn [ & args ] (map class args)))
(defmethod foo [Object Object] [a b] (println a b))
(foo "a" "b")
IllegalArgumentException No method in multimethod 'foo' for dispatch value: 
clojure.lang.LazySeq@86465241  clojure.lang.MultiFn.getFn (MultiFn.java:160)

but this works:

(defmulti bar (fn [ & args ] (mapv class args)))
(defmethod bar [Object Object] [a b] (println a b))
(bar "a" "b")
a b

Bug or feature?

Clojure 1.5.1


-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: What is the right way to create dynamic var in another namespace?

2014-03-01 Thread Armando Blancas
This came up a while back and it appeared that the metadata just reflected 
whether the var was created with the ^:dynamic annotation. But the meta 
attribute is an output, so to speak; the info flows from the var 
declaration to the meta but not the reverse. Maybe it'll remain like that 
as there's already a solution.

On Saturday, March 1, 2014 7:02:14 AM UTC-8, Эльдар Габдуллин wrote:

> I expected the following to work, but it doesn't:
>
> (defn declare-foo []
>   (intern *ns*
>   (with-meta '*foo* {:dynamic true :private true})
>   "foo"))
>
> Although it creates a var, it is not dynamic. We can mark it 
> dynamic ourselves,
> but it seems that such ability is an implementation detail.
>
> (defn declare-foo []
>   (.setDynamic (intern *ns*
>(with-meta '*foo* {:private true})
>"foo")))
>
> May be it's a Clojure bug and the first variant is supposed to 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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: isa? problem with collection type for multiple argument dispatch

2014-03-01 Thread Sean Corfield
Looking at the source of isa? it very specifically calls out vector arguments 
so I'd say it's by design.

Be careful that (isa? '(String foo) '(String foo)) returns true - child equal 
to parent regardless of type.

(defn isa?
  "Returns true if (= child parent), or child is directly or indirectly derived 
from
  parent, either via a Java type inheritance relationship or a
  relationship established via derive. h must be a hierarchy obtained
  from make-hierarchy, if not supplied defaults to the global
  hierarchy"
  {:added "1.0"}
  ([child parent] (isa? global-hierarchy child parent))
  ([h child parent]
   (or (= child parent)
   (and (class? parent) (class? child)
(. ^Class parent isAssignableFrom child))
   (contains? ((:ancestors h) child) parent)
   (and (class? child) (some #(contains? ((:ancestors h) %) parent) (supers 
child)))
   (and (vector? parent) (vector? child)
(= (count parent) (count child))
(loop [ret true i 0]
  (if (or (not ret) (= i (count parent)))
ret
(recur (isa? h (child i) (parent i)) (inc i

On Mar 1, 2014, at 4:08 PM, Dave Tenny  wrote:

> (isa? [String String] [Object Object]) returns true. This is nice and useful.
> 
> However
> 
> (isa? '(String String) '(Object Object) returns false, this is not so nice.
> 
> (isa? '(String String) [Object Object]) also return false.
> 
> 
> So the moral of the story is that for multiple argument dispatch to work, I 
> need to use 'mapv' instead of 'map' in my dispatch function, which I have 
> done.
> But it was sort of a pain to find out the hard way (i.e. time spent 
> debugging) that 'map' won't work in this regard.
> 
> I.e. this fails:
> 
> (defmulti foo (fn [ & args ] (map class args)))
> (defmethod foo [Object Object] [a b] (println a b))
> (foo "a" "b")
> IllegalArgumentException No method in multimethod 'foo' for dispatch value: 
> clojure.lang.LazySeq@86465241  clojure.lang.MultiFn.getFn (MultiFn.java:160)
> 
> but this works:
> 
> (defmulti bar (fn [ & args ] (mapv class args)))
> (defmethod bar [Object Object] [a b] (println a b))
> (bar "a" "b")
> a b
> 
> Bug or feature?
> 
> Clojure 1.5.1
> 



signature.asc
Description: Message signed with OpenPGP using GPGMail


[ANN] avi: A lively vi. 0.1.0

2014-03-01 Thread Jason Felice
>From https://github.com/maitria/avi

Avi is a vi written in Clojure.  It's currently very basic and read-only,
but has solved the hardest problems first (JNI terminal writing,
installation, booting the JVM).

It currently supports h,j,k,l,^E,^Y,$,^,0,G,:q and command repeat counts.

*Vision*

A lively vi with support for incremental compilation, deep language
integration and source navigation, realtime shells and REPLs, and plugins,
written so *it* can be a plugin in other IDEs.

*Guiding Principles*


   - Test driven.  All functionality covered by tests.
   - Don't defeat vim muscle memory.
   - Code is for people.  Be expressive as hell.
   - Be friendly.  Especially to noobs.


Thanks!  We'd love to hear any and all feedback.

-Jason & Angela

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [ANN] avi: A lively vi. 0.1.0

2014-03-01 Thread Ambrose Bonnaire-Sergeant
Hi Jason, Angela,

Wow, looks like fun!

It would be nice just have to specify the install prefix path once, instead
of in the bash
and install.clj file. Also the bin directory needs to be manually created
(same with the prefix directory).

I tried running the executable, I got this:

ambrose@ambrose-VirtualBox:~/avi/bin$ ./avi
Exception in thread "main" java.lang.UnsatisfiedLinkError: no
avi_terminal_Screen in java.library.path
 at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1709)
at java.lang.Runtime.loadLibrary0(Runtime.java:844)
 at java.lang.System.loadLibrary(System.java:1051)
at avi.terminal.Screen.start(Screen.java:6)
at avi.core$_main.doInvoke(core.clj:43)
 at clojure.lang.RestFn.invoke(RestFn.java:397)
at clojure.lang.AFn.applyToHelper(AFn.java:159)
at clojure.lang.RestFn.applyTo(RestFn.java:132)
 at avi.core.main(Unknown Source)

Thanks,
Ambrose


On Sun, Mar 2, 2014 at 12:25 PM, Jason Felice wrote:

> From https://github.com/maitria/avi
>
> Avi is a vi written in Clojure.  It's currently very basic and read-only,
> but has solved the hardest problems first (JNI terminal writing,
> installation, booting the JVM).
>
> It currently supports h,j,k,l,^E,^Y,$,^,0,G,:q and command repeat counts.
>
> *Vision*
>
> A lively vi with support for incremental compilation, deep language
> integration and source navigation, realtime shells and REPLs, and plugins,
> written so *it* can be a plugin in other IDEs.
>
> *Guiding Principles*
>
>
>- Test driven.  All functionality covered by tests.
>- Don't defeat vim muscle memory.
>- Code is for people.  Be expressive as hell.
>- Be friendly.  Especially to noobs.
>
>
> Thanks!  We'd love to hear any and all feedback.
>
> -Jason & Angela
>
> --
> 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 unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [ANN] avi: A lively vi. 0.1.0

2014-03-01 Thread Gaofeng Zeng
Hi Jason, Angela
It is cool, but it not support linux. I modify the avi.install to make it 
support linux.

On Sunday, March 2, 2014 12:25:50 PM UTC+8, Jason Felice wrote:
>
> From https://github.com/maitria/avi
>
> Avi is a vi written in Clojure.  It's currently very basic and read-only, 
> but has solved the hardest problems first (JNI terminal writing, 
> installation, booting the JVM).
>
> It currently supports h,j,k,l,^E,^Y,$,^,0,G,:q and command repeat counts.
>
> *Vision*
>
> A lively vi with support for incremental compilation, deep language 
> integration and source navigation, realtime shells and REPLs, and plugins, 
> written so *it* can be a plugin in other IDEs.
>
> *Guiding Principles*
>
>
>- Test driven.  All functionality covered by tests.
>- Don't defeat vim muscle memory.
>- Code is for people.  Be expressive as hell. 
>- Be friendly.  Especially to noobs.
>
>
> Thanks!  We'd love to hear any and all feedback.
>
> -Jason & Angela
>

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Clojure performance question

2014-03-01 Thread Shantanu Kumar


On Sunday, 2 March 2014 05:32:00 UTC+5:30, bob wrote:
>
>
> Good point, Thanks a lot. 
>
> Shall we improve the str fn in the core lib? From my point of view, the 
> core fns should be performance sensitive.
>

If string formation is the bottleneck in your app and if you can come up 
with a version of `str` function that works in all use-cases, then you can 
probably `alter-var-root` the str fn with yours as long as you own the 
responsibility.

I noticed the following macro (ignore the reflection warnings) can help 
shave some nanoseconds in a large tight loop, but I leave to you to decide 
how much worth it really is:

(defmacro sb-str
  [& args]
  (cond (empty? args)  ""
(= 1 (count args)) (let [x (first args)]
 `(let [y# ~x]
(cond (nil? y#)""
  (instance? Boolean   y#) (.toString 
(Boolean.   y#))
  (instance? Byte  y#) (.toString 
(Byte.  y#))
  (instance? Character y#) (.toString 
(Character. y#))
  (instance? Doubley#) (.toString 
(Double.y#))
  (instance? Float y#) (.toString 
(Float. y#))
  (instance? Integer   y#) (.toString 
(Integer.   y#))
  (instance? Long  y#) (.toString 
(Long.  y#))
  (instance? Short y#) (.toString 
(Short. y#))
  :otherwise   (.toString 
y#
:otherwise (let [sb (gensym)
each-append #(list '.append sb %)
all-appends (map each-append args)]
`(let [~sb (StringBuilder.)]
   ~@all-appends
   (.toString ~sb)

Note that it is not a function, so you cannot use it with high order 
functions. You can possibly use `definline` instead of a macro but you lose 
varargs then.

Shantanu

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.