On Aug 10, 11:50 pm, Christophe Grand wrote:
> 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 th
Java object serialization handles cycles based on object identity.
On Tue, Aug 11, 2009 at 6:17 AM, fft1976 wrote:
>
> 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
>
On Tue, Aug 11, 2009 at 12:39 AM, Andy
Fingerhut wrote:
> Wow, you ain't kiddin. I changed about 10 lines from my last version,
> to avoid using aset-double, using aset and type hints until the
> reflection warnings went away, and it sped up by a factor of 10. I'm
> leaving the previous version'
On Aug 10, 11:42 pm, Jonathan Smith
wrote:
> The way your code is setup, you will spend a lot of time in funcall
> overhead just because you used a lot of functions instead of doing the
> calculation in bigger chunks.
I thought, as I understood from Rich's lectures, JVM inlines whatever
it want
On Aug 11, 12:39 am, Andy Fingerhut
wrote:
>
> http://github.com/jafingerhut/clojure-benchmarks/blob/9dc56d8ff53f0b8...
>
Why isn't the array-using version as fast as Java? Shouldn't using
Java's data structures, mutation and no reflection supposed to be
equivalent to using Java?
--~--~
On Aug 11, 12:39 am, Andy Fingerhut
wrote:
> On Aug 10, 11:50 pm, Christophe Grand wrote:
>
> > 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
On Aug 11, 2:25 am, fft1976 wrote:
> Hmmm
>
> I just ran your version #8, and it's almost as slow as mine
> (nbody_v2.clj): 53 times slower than Java, but I'm running Clojure 1.0
> and
Strike that. I f'ed up the namespaces and was actually measuring my
own version. Yours is 8x slower than Ja
On Aug 10, 11:15 am, Christophe Grand wrote:
> 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
> >
I was browsing through core when I noticed something I didn't
understand in 'into' (from core.clj):
;redef into with batch support
(defn into
"Returns a new coll consisting of to-coll with all of the items of
from-coll conjoined."
[to from]
(if (instance? clojure.lang.IEditableCollection
> As for the coding style, we are not maniacs, later we intend to run the
> code in a formater to standardize.
> We use LISP style naming conventions (hyphens in names, +constant+.
> *global-var*,...)
While we are at it, I would like to know if there are any Clojure/Lisp
formatter which re-indent
On Aug 11, 4:42 am, fft1976 wrote:
> On Aug 10, 11:42 pm, Jonathan Smith
> wrote:
>
> > The way your code is setup, you will spend a lot of time in funcall
> > overhead just because you used a lot of functions instead of doing the
> > calculation in bigger chunks.
>
> I thought, as I understoo
How can I split a string, but not to drop witespaces.
Like this:
" a word and another word1 " --> (" ", "a", " ", "word", " ",
"and", " ", "another", " ", "word1", " ").
Thanks in advance.
--~--~-~--~~~---~--~~
You received this message because you are subs
On Tue, Aug 11, 2009 at 12:28 PM, Andy Fingerhut <
andy_finger...@alum.wustl.edu> wrote:
>
> On Aug 10, 11:15 am, Christophe Grand wrote:
> > Hi Andy,
> >
> > On Thu, Aug 6, 2009 at 7:40 PM, Andy Fingerhut <
> >
> >
> >
> > andy_finger...@alum.wustl.edu> wrote:
> > > Thank you, Christophe! I've
The intent of the mapping can be made clearer with destructuring I
> think. Also, flatten is not needed: a core function called "into" will
> transform a sequence of key/value pairs into a map.
>
> (def age-index
> (into (sorted-map)
>(map (fn [[k [name age]]] [age k]) data)))
>
Jarkko,
Than
clojure.contrib.str-utils/re-partition is what you are looking for;
(re-partition #"\w+" " a word and another word1 ")
-> (" " "a" " " "word" " " "and" " " "another" " " "word1" " ")
On Aug 11, 12:57 pm, ogcraft wrote:
> How can I split a string, but not to drop witespaces.
> Like th
Thanks
On Aug 11, 4:27 pm, sross wrote:
> clojure.contrib.str-utils/re-partition is what you are looking for;
>
> (re-partition #"\w+" " a word and another word1 ")
>
> -> (" " "a" " " "word" " " "and" " " "another" " " "word1" " ")
>
> On Aug 11, 12:57 pm, ogcraft wrote:
>
> > How can
For the sake of contradicting myself, in this paper Alan Bawden
explains quasi-quote much better than I can.
https://eprints.kfupm.edu.sa/60346/1/60346.pdf
Note the explanation towards the end of defmacro and constructs such
as ',' (in clojure I believe it would be '~' )
Also note that Clojure
For nested backquotes, Paul Graham in ANSI Common Lisp gives the
clearest explanation. He makes it look almost trivial. As a matter of
fact, once you get the hang of it, it's not at all that complicated.
I've pretty much verified that what he says concerning CL backquotes
applies perfectly to Clo
On Tue, Aug 11, 2009 at 6:39 AM, Krukow wrote:
>
> I was browsing through core when I noticed something I didn't
> understand in 'into' (from core.clj):
>
> ;redef into with batch support
> (defn into
> "Returns a new coll consisting of to-coll with all of the items of
> from-coll conjoined."
>
On Mon, Aug 10, 2009 at 10:57 PM, Kyle R. Burton wrote:
> On Mon, Aug 10, 2009 at 10:42 PM, Kyle R. Burton
> wrote:Sorry, forgot to offer up the inverse of freeze, thaw:
>
> (defn thaw [bytes]
> (with-open [bais (java.io.ByteArrayInputStream. bytes)
> ois (java.io.ObjectInputStream.
On Tue, Aug 11, 2009 at 12:17 AM, fft1976 wrote:
> I don't know JVM too well, but I think no efficient user-level
> solution is possible. Why? To take care of substructure sharing, you
> need to remember a set of shareable values that have already been
> serialized, and do "reference equality" co
On Aug 11, 8:36 am, John Harrop wrote:
> System.identityHashCode() and IdentityHashMap. These use a hash that
> respects reference equality. So one in fact can implement one's own
> serialization that is O(n) using O(1) hashmap lookups (and using reflection,
> and not working if SecurityManage
On Aug 11, 8:15 am, John Harrop wrote:
> Which in turn gives us this, otherwise sorely lacking from the Java standard
> library, but much less useful to us Clojurians who tend to mainly use
> immutable objects:
>
> (defn deep-copy [obj]
> (thaw (freeze obj)))
Somebody should benchmark that vs
Hey all,
I recently went through this process as a total clojure/emacs noob.
Trying to use the command line (especially in Windows) to enter
samples that were more than one line was just brutal. Also, I really
wanted the emacs experience while toying around with Clojure samples
and reading this g
On Aug 11, 4:50 am, Jonathan Smith wrote:
> I don't think you have to put *everything* in the let, just your
> constants. (so days per year and solar mass, the bodies themselves).
How will they "escape" from the LET though? I see that in your code
everything is inside a LET. That's what I tried
On Tue, Aug 11, 2009 at 11:40 AM, John Harrop wrote:
> On Tue, Aug 11, 2009 at 6:39 AM, Krukow wrote:
>>
>> I was browsing through core when I noticed something I didn't
>> understand in 'into' (from core.clj):
>>
>> ;redef into with batch support
>> (defn into
>> "Returns a new coll consisting
I feel that this question is important enough to warrant its own
thread.
If you use Java's arrays and declare all types, should Clojure be as
fast as the equivalent Java? I had taken this for granted, but
empirical evidence indicates otherwise:
Andy's version of the Nbody benchmark still appears
On Aug 11, 11:55 am, fft1976 wrote:
> I feel that this question is important enough to warrant its own
> thread.
http://groups.google.com/group/clojure/search?group=clojure&q=%22as+fast+as+java%22&qt_g=Search+this+group
>
> If you use Java's arrays and declare all types, should Clojure be as
On Aug 11, 2:43 pm, fft1976 wrote:
> On Aug 11, 4:50 am, Jonathan Smith wrote:
>
> > I don't think you have to put *everything* in the let, just your
> > constants. (so days per year and solar mass, the bodies themselves).
>
> How will they "escape" from the LET though? I see that in your code
Hi,
i've been wanting to play with clojureql for a while and now it seems i'm
pretty much stuck at the entry point...
a simple example:
; set up includes, db connection info etc
(require '[dk.bestinclass.clojureql :as cql])
(cql/load-driver "com.mysql.jdbc.Driver")
(def *connection* (cql/make-co
It looks like (speaking without having looked at the ClojureQL source)
the results are being returned as a lazy sequence. In the first case
the sequence isn't being realized but it is in the second.
On Tue, Aug 11, 2009 at 2:15 PM, Maximilian
Karasz wrote:
> Hi,
>
> i've been wanting to play wit
ah, thank you so much for the hint, forcing the sequence did the trick.
out of curiousity: while the following works
(cql/run [*connection* result] (cql/query * people) (doall (take 5 result)))
this does not
(doall (cql/run [*connection* result] (cql/query * people) (take 5 result)))
suggestin
On Aug 11, 12:02 pm, ataggart wrote:
> On Aug 11, 11:55 am, fft1976 wrote:
>
> > I feel that this question is important enough to warrant its own
> > thread.
>
> http://groups.google.com/group/clojure/search?group=clojure&q=%22as+f...
>
Sounds like you are saying that the consensus is "no", but
Yes, Clojure can be just as fast as Java. There's an example on the
Clojure website that illustrates this.
http://clojure.org/java_interop
Rather than write this Java:
static public float asum(float[] xs){
float ret = 0;
for(int i = 0; i < xs.length; i++)
ret += xs[i];
return ret;
}
Hi,
Am 11.08.2009 um 21:59 schrieb Maximilian Karasz:
ah, thank you so much for the hint, forcing the sequence did the
trick.
out of curiousity: while the following works
(cql/run [*connection* result] (cql/query * people) (doall (take 5
result)))
this does not
(doall (cql/run [*connec
On Aug 11, 1:09 pm, tmountain wrote:
> Yes, Clojure can be just as fast as Java.
Then why is Andy's code 10x slower?
> There's an example on the
> Clojure website that illustrates this.
> http://clojure.org/java_interop
I've seen that. There is a difference between "I can come up with two
snip
On Aug 11, 2009, at 4:26 PM, fft1976 wrote:
> I've seen that. There is a difference between "I can come up with two
> snippets in Java and Clojure doing the same thing at the same speed"
> and "For any Java code, I can write Clojure code that does exactly the
> same thing just as fast". The diff
On Aug 11, 4:35 pm, Chas Emerick wrote:
> Maybe others will disagree, but I don't think that standard can ever
> be met. There will always be tasks for which clojure is slower than
> java, just as there are tasks where java is slower than assembly.
>
> I suspect that those cases will become
Let Over Lambda by Hoyte contains a very lucidly well-written
discussion of quotation levels in macros. It also includes a pretty
useful technique for being explicit about variable capture. The code
is in Common Lisp, but will mostly only differ syntactically from the
Clojure code (for the basic
On Aug 11, 1:50 pm, Stuart Sierra wrote:
>
> I agree wholeheartedly. Let's optimize wherever possible, but drop on
> the side-by-side comparisons.
>
I think it's very immature to dictate to others what should be
important to them. Speed may be of minor concern to some Ruby-on-Rails
types, but
Well, the question posed in the subject is whether Clojure can be as
fast as Java. The answer to that question is yes. As with any
generated code, there are many layers of optimization that could be
performed. With Clojure being as young as it is, I doubt that
generating isomorphic bytecode to tha
In case it matters to anyone, my intent in creating these Clojure
programs to compare their speed to others isn't to try to rip into
Clojure, or start arguments. It is for me to get my feet wet with
Clojure, and perhaps produce some examples that others can learn from
on what performs well in Clo
On Tue, Aug 11, 2009 at 5:26 PM, Andy
Fingerhut wrote:
>
> In case it matters to anyone, my intent in creating these Clojure
> programs to compare their speed to others isn't to try to rip into
> Clojure, or start arguments. It is for me to get my feet wet with
> Clojure, and perhaps produce some
On Aug 11, 2:24 pm, tmountain wrote:
> Well, the question posed in the subject is whether Clojure can be as
> fast as Java.
The question was: "If you use Java's arrays and declare all types,
should Clojure be as fast as the equivalent Java?" I'm sorry if the
current subject line appears ambiguou
On Aug 11, 2:26 pm, Andy Fingerhut
wrote:
> As always, suggestions or improved versions are welcome.
I noticed that when I wrap ~new-mass in (double ...) in this
(defmacro set-mass! [p new-mass] `(aset ~p 0 ~new-mass))
and other setters, I get warnings.
--~--~-~--~~~--
Ahem, does it have to be as fast as Java ?
The way I see it, it's the same issue we dealt with languages like
Fortran, Cobol, ...
At some point, the only way to speed programs was to find hot spots and
replaces
these with faster code, mainly written in assembler or another language
suited to
the p
If I am reading the README correctly, clj-8 is 10.8 times slower than
Java, but clj-9 does better: 3.2 times slower.
Stu
>
> I feel that this question is important enough to warrant its own
> thread.
>
> If you use Java's arrays and declare all types, should Clojure be as
> fast as the equival
On Aug 11, 4:27 pm, Stuart Halloway wrote:
> If I am reading the README correctly, clj-8 is 10.8 times slower than
> Java, but clj-9 does better: 3.2 times slower.
>
> Stu
You are reading that correctly. My clj-9 wasn't created until after
fft1976's message starting this thread.
Andy
--~--~
On Aug 11, 2:36 pm, Aaron Cohen wrote:
> At that point is it possible you're just paying the price of
> PersistentVector for the "bodies" vector? Does it improve much if you
> change bodies to an array?
About 7% faster changing bodies to a Java array of java.lang.Object's,
each of which happens
On Wed, Aug 12, 2009 at 6:02 AM, Luc
Prefontaine wrote:
>
> If your algorithm is single threaded and performance is a must then even
> Java should be tossed away.
> Any native machine code equivalent would be faster than Java...
Pay attention when making assumptions:
http://stackoverflow.com/ques
> Perf bottlenecks are being addresses in Clojure already but not a
> the expense of expressiveness.
> And that is perfectly fine...
I agree completely with everything you're saying, and I too find
fft1976's obsession hard to relate to. But I think that one problem
with many modern language
C++ has nothing to do with my previous statement. C++ is object
oriented. It's plagued with similar
problems than Java in terms of performance.
I was talking about writing the machine code by hand, not relying on a
compiler's optimizer to do so.
C is a bit better than C++ but if you use a cross p
On Aug 11, 5:19 pm, Daniel Lyons wrote:
> I agree with him that unadorned
> functional code should perform well
Huh?! Andy, can you explain to him what needs to be explained? I'm all
out of politeness for today.
--~--~-~--~~~---~--~~
You received this message
On Aug 11, 2009, at 5:14 PM, fft1976 wrote:
> On Aug 11, 1:50 pm, Stuart Sierra wrote:
>
>> I agree wholeheartedly. Let's optimize wherever possible, but drop
>> on
>> the side-by-side comparisons.
>
> I think it's very immature to dictate to others what should be
> important to them. Speed m
On Aug 11, 2009, at 8:19 PM, Daniel Lyons wrote:
>> Perf bottlenecks are being addresses in Clojure already but not a
>> the expense of expressiveness.
>> And that is perfectly fine...
>
>
> I agree completely with everything you're saying, and I too find
> fft1976's obsession hard to relate
On Tue, Aug 11, 2009 at 2:31 PM, fft1976 wrote:
> On Aug 11, 8:36 am, John Harrop wrote:
>
> > System.identityHashCode() and IdentityHashMap. These use a hash that
> > respects reference equality. So one in fact can implement one's own
> > serialization that is O(n) using O(1) hashmap lookups (a
On Wed, Aug 12, 2009 at 8:02 AM, Luc
Prefontaine wrote:
> C++ has nothing to do with my previous statement. C++ is object oriented.
> It's plagued with similar
> problems than Java in terms of performance.
>
> I was talking about writing the machine code by hand, not relying on a
> compiler's opti
On Aug 11, 7:39 pm, Chas Emerick wrote:
> can to help -- but please don't assume that everyone else in the
> community shares your specific priorities.
Why are you implying that that I assume that? You are replying to a
message where I wrote that one should not assume others' priorities.
--~
I wonder if continued discussion on this thread will be
helpful to anyone. It seems to me we are not likely to soon
get any closer to an answer for the original question than
has already been offered. It's been lively and informative
but I hope it's run its course.
--Chouser
--~--~-~--
I'll admit that I haven't done much GUI programming at all, but I'm
finding that I want to throw together small simple Gui apps with
Clojure. My problem is that every way I try to build my app, it feels
wrong (ugly, over complex, etc). My current least-ugly solution is to
share a ref between the
On Tue, Aug 11, 2009 at 8:13 PM, Andy
Fingerhut wrote:
>
> On Aug 11, 2:36 pm, Aaron Cohen wrote:
>> At that point is it possible you're just paying the price of
>> PersistentVector for the "bodies" vector? Does it improve much if you
>> change bodies to an array?
>
> About 7% faster changing bo
On Tue, Aug 11, 2009 at 8:52 PM, Chouser wrote:
>
> I wonder if continued discussion on this thread will be
> helpful to anyone. It seems to me we are not likely to soon
> get any closer to an answer for the original question than
> has already been offered. It's been lively and informative
> b
Hi fft1976,
> If you use Java's arrays and declare all types, should Clojure be as
> fast as the equivalent Java?
So is the question you are trying to ask that since we have unwrapped
access to Java is Java code written in Clojure as fast as if it were
written as actual Java code?
I guess tha
On Fri, Aug 7, 2009 at 8:14 PM, John Harrop wrote:
> Your core loop seems to be:
> (loop [zr (double 0.0)
> zi (double 0.0)
> zr2 (double 0.0)
> zi2 (double 0.0)
> iterations-remaining iterations-remaining]
> (if (and (not (neg? iterations-remaining))
>
Hi Brad,
I saw your question on IRC the other day and came up with this:
http://gist.github.com/164652
That demo creates a frame with sliders that control the horizontal and
vertical position of a spot in a panel.
It's certanly not the best possible implementation, but you might find its
style i
On Aug 11, 10:15 pm, Abhishek Reddy wrote:
> Hi Brad,
>
> I saw your question on IRC the other day and came up with
> this:http://gist.github.com/164652
>
> That demo creates a frame with sliders that control the horizontal and
> vertical position of a spot in a panel.
>
> It's certanly not the
On Jul 28, 7:47 pm, Andy Fingerhut
wrote:
> I have added a script that uses the Java version of the benchmark
> programs to generate the large files that were in the distribution
> file I gave a link to earlier, so it is much smaller. I've also
> published it on github and added a COPYING file t
67 matches
Mail list logo