Re: Pure-functional N-body benchmark implementation

2009-08-10 Thread Christophe Grand
Hi Andy, On Tue, Aug 11, 2009 at 8:15 AM, Andy Fingerhut < andy_finger...@alum.wustl.edu> wrote: > I've tried an approach like you suggest, using mutable Java arrays of > doubles, macros using aget / aset-double for reading and writing these > arrays, and loop/recur everywhere iteration is needed

Re: Pure-functional N-body benchmark implementation

2009-08-10 Thread Andy Fingerhut
On Aug 10, 11:33 pm, Mark Engelberg wrote: > On Mon, Aug 10, 2009 at 11:15 PM, Andy > > Fingerhut wrote: > > I suspect I'm doing something wrong in my mutable Java array > > implementation, but I don't see what it could be. > > There still seems to be a lot of boxing and unboxing going on.  For e

Re: Pure-functional N-body benchmark implementation

2009-08-10 Thread Jonathan Smith
On Aug 10, 11:08 pm, fft1976 wrote: > On Aug 10, 2:19 pm, Jonathan Smith wrote: > > > 1.) use something mutable > > 2.) unroll all the loops (mapping is a loop) > > 3.) try not to coerce between seq/vec/hash-map too much. > > Are you saying this w.r.t. my code or in general? If the former, be

Re: Pure-functional N-body benchmark implementation

2009-08-10 Thread Mark Engelberg
On Mon, Aug 10, 2009 at 11:15 PM, Andy Fingerhut wrote: > I suspect I'm doing something wrong in my mutable Java array > implementation, but I don't see what it could be. There still seems to be a lot of boxing and unboxing going on. For example, in: (let [[momx momy momz] (offset-momentum bodie

Re: Pure-functional N-body benchmark implementation

2009-08-10 Thread Andy Fingerhut
On Aug 10, 5:57 pm, Mark Engelberg wrote: > Andy, > > My understanding is that any double that gets stored in a vector or > map is boxed, and therefore, the vast majority of your double > conversions aren't really doing anything, because when you pull them > out of the vector or map, they'll just

Re: binding and bundles of variables

2009-08-10 Thread Meikel Brandmeyer
Hi, On Aug 10, 9:10 pm, jvt wrote: > Be this as it may, you can still get weird run-time behavior from this > kind of macro in the following situation: > > (def *v1* 10) > (def var-map {:*v1* 100}) > (def wrong-map {:*v2* 10}) > > (with-bindings-from-map var-map (+ v1 100)) ; -> 200,  does what

Re: How to write a macro that writes another macro?

2009-08-10 Thread Jonathan Smith
On Aug 10, 3:20 pm, Dragan Djuric wrote: > For example: > > (defmacro creator [param] >  `(defmacro created [p] `(the code...)) ;; note the nested quote... > how to resolve that? any examples? Although I wouldn't cite my own code as a necessarily *good* or easy to understand example, I'll pimp i

Re: binary serialization

2009-08-10 Thread fft1976
On Aug 10, 8:19 pm, "Kyle R. Burton" wrote: > > Does all this work with cycles, Java arrays, etc.? > > It will work with anything that implements the Serializable interface > in Java.  Arrays do implement that interface, as do all the > primitives.  With respect to cycles, I'd suspect it does, bu

How to write a macro that writes another macro?

2009-08-10 Thread Dragan Djuric
For example: (defmacro creator [param] `(defmacro created [p] `(the code...)) ;; note the nested quote... how to resolve that? any examples? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post t

Re: How to create structure with a seq of keys

2009-08-10 Thread Dragan Djuric
Thanks. (I discovered the solution shortly after posting here, but there is that annoying delay until the message is approved by mods, so I couldn't answer my question...) On Aug 10, 2:55 am, David Nolen wrote: > Sounds like you want apply: > (apply fn args) > > On Sun, Aug 9, 2009 at 4:28 PM,

Re: binding and bundles of variables

2009-08-10 Thread samppi
I'm also concerned about the implementation, which seems to rely on what appears to me to be a little magical. An alternative that I was considering was to just break backwards compatibility and combine all of the variables into one variable containing a map in a new major version of my library. B

Re: binary serialization

2009-08-10 Thread Kyle R. Burton
> Does all this work with cycles, Java arrays, etc.? It will work with anything that implements the Serializable interface in Java. Arrays do implement that interface, as do all the primitives. With respect to cycles, I'd suspect it does, but would test it. If you have a repl handy it should

Re: binary serialization

2009-08-10 Thread fft1976
On Aug 10, 7:57 pm, "Kyle R. Burton" wrote: > On Mon, Aug 10, 2009 at 10:42 PM, Kyle R. Burton wrote: > >> Is there a way to do binary serialization of Clojure/Java values? > >> ASCII (read) and (write) are nice, but they are wasting space, > >> truncating floats and are probably slow compared to

Re: Transient Data Structures

2009-08-10 Thread samppi
Excellent, excellent. But I'm wondering, is it planned (or feasible) for structmap transients to be supported too? I often use and "modify" protean structmaps in loops, and I'd love to know if the concept of transients can be applied to them. On Aug 6, 4:53 am, Rich Hickey wrote: > On Aug 5, 10:

Re: Pure-functional N-body benchmark implementation

2009-08-10 Thread fft1976
On Aug 10, 2:19 pm, Jonathan Smith wrote: > 1.) use something mutable > 2.) unroll all the loops (mapping is a loop) > 3.) try not to coerce between seq/vec/hash-map too much. Are you saying this w.r.t. my code or in general? If the former, be specific, better yet, show us your code. I avoided (

Re: binary serialization

2009-08-10 Thread Kyle R. Burton
On Mon, Aug 10, 2009 at 10:42 PM, Kyle R. Burton wrote: >> Is there a way to do binary serialization of Clojure/Java values? >> ASCII (read) and (write) are nice, but they are wasting space, >> truncating floats and are probably slow compared to binary >> serialization. > > The following utility f

Re: creating classes in Clojure

2009-08-10 Thread Kyle R. Burton
On Mon, Aug 10, 2009 at 10:31 PM, fft1976 wrote: > > Is there a way to create a Java class (not instance) in Clojure > without writing actual Java? e.g. > > public class person { >  public string name; >  public int num_children; >  public double weight; > } Yes, tho perhaps not according to the

Re: binary serialization

2009-08-10 Thread Kyle R. Burton
> Is there a way to do binary serialization of Clojure/Java values? > ASCII (read) and (write) are nice, but they are wasting space, > truncating floats and are probably slow compared to binary > serialization. The following utility functions have worked in many cases for me: (defn object->file

creating classes in Clojure

2009-08-10 Thread fft1976
Is there a way to create a Java class (not instance) in Clojure without writing actual Java? e.g. public class person { public string name; public int num_children; public double weight; } --~--~-~--~~~---~--~~ You received this message because you are subscr

binary serialization

2009-08-10 Thread fft1976
Is there a way to do binary serialization of Clojure/Java values? ASCII (read) and (write) are nice, but they are wasting space, truncating floats and are probably slow compared to binary serialization. --~--~-~--~~~---~--~~ You received this message because you are

Re: Pure-functional N-body benchmark implementation

2009-08-10 Thread fft1976
On Aug 10, 5:15 pm, Andy Fingerhut wrote: > OK, I've got a new Clojure program for the n-body benchmark, and it is > significantly faster than my previous one -- down from 138 x Java run > time, to 37 x Java run time.  Still room for improvement somewhere > there, I'm sure, including perhaps us

Re: current rule of thumb for optimization?

2009-08-10 Thread Stuart Sierra
First thing to check is always (set! *warn-on-reflection* true) Then add type hints until the reflection warnings go away. This can make 10-20 times difference in code that calls a lot of Java methods. -SS On Aug 10, 6:06 pm, Raoul Duke wrote: > hi, > > while i realize the real answer is "it

Re: Pure-functional N-body benchmark implementation

2009-08-10 Thread Mark Engelberg
Andy, My understanding is that any double that gets stored in a vector or map is boxed, and therefore, the vast majority of your double conversions aren't really doing anything, because when you pull them out of the vector or map, they'll just be Double objects again. I believe that the biggest

Re: Pure-functional N-body benchmark implementation

2009-08-10 Thread Isaac Gouy
On Aug 10, 3:00 pm, Andy Fingerhut wrote: > On Aug 10, 2:19 pm, Jonathan Smith wrote: > > > 1.) use something mutable > > 2.) unroll all the loops (mapping is a loop) > > 3.) try not to coerce between seq/vec/hash-map too much. > > > in real world, stuff like theshootoutis pretty useless, as g

Re: Pure-functional N-body benchmark implementation

2009-08-10 Thread Andy Fingerhut
OK, I've got a new Clojure program for the n-body benchmark, and it is significantly faster than my previous one -- down from 138 x Java run time, to 37 x Java run time. Still room for improvement somewhere there, I'm sure, including perhaps using Java arrays instead of Clojure vectors. http://g

Re: current rule of thumb for optimization?

2009-08-10 Thread David Nolen
The only thing I've ever seen in Clojure that is "slow" is tight loops on primitives. Most of the time that people bring up Clojure performance, it's usually about tight loops on primitives. For starters, this isn't even something you could really optimize in popular dynamic languages like Python o

Re: Processing elements in a lazy seq in parallel

2009-08-10 Thread _hrrld
On Aug 10, 12:18 pm, Tom Emerson wrote: > Hello Clojurians, > > file-seq gives me a convenient way to get a seq of all these files. > What I would like to do is process elements in this sequence in > parallel. My first thought was to process the seq with pmap, but this > is suboptimal because I'm

Re: Processing elements in a lazy seq in parallel

2009-08-10 Thread Laurent PETIT
Hi, 2009/8/10 Tom Emerson > > Hello Clojurians, > > I want to process approximately 74K XML files that are stored on disk > in a series of nested directories, each of which contains upto 1000 > files. For example, > > rootdir >0 >file1.xml >file2.xml >1 >file3.xml

current rule of thumb for optimization?

2009-08-10 Thread Raoul Duke
hi, while i realize the real answer is "it depends!", are there any current rules of thumb based on experience about how to tackle performance tweaking in Clojure? (e.g. as a small random example, i think i've heard at times that type notes should speed things up, but then other times have heard

Re: Pure-functional N-body benchmark implementation

2009-08-10 Thread Andy Fingerhut
On Aug 10, 2:19 pm, Jonathan Smith wrote: > 1.) use something mutable > 2.) unroll all the loops (mapping is a loop) > 3.) try not to coerce between seq/vec/hash-map too much. > > in real world, stuff like the shootout is pretty useless, as generally > you'd reach for a better algorithm rather th

Re: Processing elements in a lazy seq in parallel

2009-08-10 Thread tmountain
You can use agents in combination with the send function which will operate on a fixed size thread pool. I'm sure there are other ways as well, but I've found agents very easy to work with. Travis On Aug 10, 2:18 pm, Tom Emerson wrote: > Hello Clojurians, > > I want to process approximately 74K

Re: Pure-functional N-body benchmark implementation

2009-08-10 Thread Jonathan Smith
1.) use something mutable 2.) unroll all the loops (mapping is a loop) 3.) try not to coerce between seq/vec/hash-map too much. in real world, stuff like the shootout is pretty useless, as generally you'd reach for a better algorithm rather than implementing the shackled, crippled, naive algorith

Re: Pure-functional N-body benchmark implementation

2009-08-10 Thread Andy Fingerhut
On Aug 10, 11:35 am, fft1976 wrote: > On Aug 10, 4:46 am, Jarkko Oranen wrote: > > > I'm not going to start optimising, > > Somebody'd better! > > You always hear this dogma that one should write "elegant" code first > and optimize later, and when you do that, a few little changes can > make Clo

Re: binding and bundles of variables

2009-08-10 Thread jvt
Really, this should be (with-bindings-from-map var-map (+ *v1* 100)) ; -> 200, does what we expect (with-bindings-from-map wrong-map (+ *v1* 100)) ; -> 110, does the wrong thing entirely, silently Anyway, you may want to think about why common-lisp does not have a with-all-slots macro for use

Re: binding and bundles of variables

2009-08-10 Thread jvt
Meikel, What concerns me is that this macro lets you write code which depends on names which are not present at compile time (someplace). Coming from scheme, not only would you _not_ do this, but you _can't_ do it without using eval in your macro body, which is considered bad form. That we can d

Re: Pure-functional N-body benchmark implementation

2009-08-10 Thread fft1976
On Aug 10, 4:46 am, Jarkko Oranen wrote: > I'm not going to start optimising, Somebody'd better! You always hear this dogma that one should write "elegant" code first and optimize later, and when you do that, a few little changes can make Clojure as fast as Java. Here's your chance to show it

Processing elements in a lazy seq in parallel

2009-08-10 Thread Tom Emerson
Hello Clojurians, I want to process approximately 74K XML files that are stored on disk in a series of nested directories, each of which contains upto 1000 files. For example, rootdir 0 file1.xml file2.xml 1 file3.xml file4.xml and so on. file-seq gives

Add 'source' to build.xml

2009-08-10 Thread Yaroslav Kavenchuk
For built clojure with jdk7 need small change: --- build.xml 2009-08-05 21:29:32 +0300 +++ build.xml 2009-08-10 21:11:25 +0300 @@ -79,7 +79,7 @@ + debug="true" target="1.5" source="1.5"/> http://groups.google.com/group/clojure?hl=en -~--~~~~

Re: Transient Data Structures

2009-08-10 Thread Christophe Grand
Hi Andy, On Thu, Aug 6, 2009 at 7:40 PM, Andy Fingerhut < andy_finger...@alum.wustl.edu> wrote: > Thank you, Christophe! I've been wanting to try those out. > > I made changes to 3 lines of my Clojure program for the k-nucleotide > benchmark, which spends most of its time in a function tally-dna

Re: Question about pmap

2009-08-10 Thread cliffc
I'll volunteer to run your code on an Azul box. - Azul gear has a great profiling tool. I should be able to rapidly tell hot-locks/lock-contention from other resource bottlenecks. - Azul gear has far more bandwidth than X86 gear, so if your X86 is bandwidth bound - this won't show up on us. - Az

Re: Commenting Code (Was: Re: Clojure as a First Language)

2009-08-10 Thread Luc Prefontaine
It's along the lines that we follow. Declaring the public functions first however forces you to use a declare statement for all the private functions used by your public API. We use section comments to split the module (constants, global defs, private functions, public ones, ...) and keep the publ

Re: ANN: Clojure Ant Tasks

2009-08-10 Thread Chas Emerick
On Aug 10, 2009, at 11:45 AM, J. McConnell wrote: > On Mon, Aug 10, 2009 at 9:07 AM, Chas Emerick > wrote: > Looks like a good start. I initially didn't grok what was going on, > until I realized that you were aiming for an "actual" ant library. > > Yes, I wasn't very familiar with Ant Task

Re: ANN: Clojure Ant Tasks

2009-08-10 Thread J. McConnell
On Mon, Aug 10, 2009 at 9:07 AM, Chas Emerick wrote: > Looks like a good start. I initially didn't grok what was going on, until > I realized that you were aiming for an "actual" ant library. > Yes, I wasn't very familiar with Ant Tasks (as in org.apache.tools.ant.Task) or macros until I looked

Re: ANN: Clojure Ant Tasks

2009-08-10 Thread J. McConnell
I hadn't looked at the patch before, but I was delighted to see the posting about it a few days ago. I think it will benefit everyone. However, I was well underway with these tasks at the time (I haven't had a lot of time to work on them, so it took a couple of weeks). Regardless, I really wanted t

Re: ANN: Clojure Ant Tasks

2009-08-10 Thread Chas Emerick
Looks like a good start. I initially didn't grok what was going on, until I realized that you were aiming for an "actual" ant library. We have a couple of ant macros that do all of our clojure building for us (including auto-detecting namespaces within source directories, compiling only tho

Re: Pure-functional N-body benchmark implementation

2009-08-10 Thread Jarkko Oranen
On Aug 10, 12:41 pm, fft1976 wrote: > I just uploaded to the group an implementation of the n-body benchmark > in Clojure (see nbody_init.clj) > > http://shootout.alioth.debian.org/u32/benchmark.php?test=nbody〈=j... > > My goal was to write a pure-functional version and to avoid any micro- > opti

Re: ANN: Clojure Ant Tasks

2009-08-10 Thread Laurent PETIT
Hi, have you seen the recent patch submitted by Mike Hinchey ? http://www.assembla.com/spaces/clojure/tickets/168 Regards, -- Laurent 2009/8/10 J. McConnell > Most of the Ant setups I've seen for building and testing Clojure code, > including some of my own, have suffered from the fact that

Pure-functional N-body benchmark implementation

2009-08-10 Thread fft1976
I just uploaded to the group an implementation of the n-body benchmark in Clojure (see nbody_init.clj) http://shootout.alioth.debian.org/u32/benchmark.php?test=nbody&lang=java&box=1 My goal was to write a pure-functional version and to avoid any micro- optimizations. There are no type declaratio

SOAP Server

2009-08-10 Thread Steve Nunez
Does anyone have an example of using Clojure as a SOAP server? There was one tread that Google found, but a quick search of the wiki and this list didn¹t turn up anything. A bit surprising really, as I thought that would be one of the first things written. If a SOAP library doesn¹t exist, how woul

Re: ANN: Clojure Ant Tasks

2009-08-10 Thread Garth Sheldon-Coulson
I haven't had a chance to try it out yet, but this is very promising. Thanks for doing it. On Sun, Aug 9, 2009 at 11:58 PM, Richard Newman wrote: > On 9 Aug 2009, at 8:14 PM, J. McConnell wrote: > > http://github.com/jmcconnell/clojure-ant-tasks/tree/master > > I hope someone finds some benefit

Re: Commenting Code (Was: Re: Clojure as a First Language)

2009-08-10 Thread John Harrop
On Sun, Aug 9, 2009 at 12:47 PM, Lauri Pesonen wrote: > > 2009/8/8 Luc Prefontaine : > > > I totally agree no comments is not good at all but JavaDoc style comments > in > > Clojure ? I pray you all, please stay away of it : > > I was quite taken by this scheme style guide recently: > > http:

Re: binding and bundles of variables

2009-08-10 Thread Niels Mayer
On Thu, Aug 6, 2009 at 10:12 PM, samppi wrote: > > I have about six variables that are often rebound together using > binding; these variables are used to access and set data in a state > object (whose type is of the user's choice). These variables' values > (the accessors and setters) are often

Re: How to create structure with a seq of keys

2009-08-10 Thread John Harrop
On Sun, Aug 9, 2009 at 8:55 PM, David Nolen wrote: > Sounds like you want apply: > (apply fn args) > Indeed. Since create-struct (not create-structure!) is a function, this should work. It wouldn't work with a macro, though. --~--~-~--~~~---~--~~ You received th

Re: Reflection warning: reference to field getClass can't be resolved.

2009-08-10 Thread Mike Hinchey
This is nothing to worry about, but it does seem to be something that can be improved in clojure. I submitted a patch with a simple fix: http://www.assembla.com/spaces/clojure/tickets/171-reflection-warning-from-ns There is a more complex fix that could be made to the clojure compiler so it woul