On Jan 27, 2011, at 10:41 PM, Ben Mabey wrote:
> On 1/27/11 7:24 PM, Ken Wesson wrote:
>> On Thu, Jan 27, 2011 at 6:24 PM, Mark Engelberg
>> wrote:
>>> Records don't have serialization yet, do they?
>> user=> (defrecord Foo [n])
>> user.Foo
>> user=> ((supers Foo) java.io.Serializable)
>> jav
Hi,
On 28 Jan., 13:46, Chas Emerick wrote:
> I don't think it's obvious whether any particular serialization
> mechanism is generally better or worse than another without knowing
> details about a particular context. *print-dup*'s (and others')
> generally human-readable representations and dyn
Hey if you like to do something with the (relatively new) Facebook
Graph API (http://developers.facebook.com/docs/api/) give clj-facebook-
graph a try. It's a simple Clojure client for the Facebook Graph API
based on clj-http (https://github.com/getwoven/clj-http) and Ring
(https://github.com/mmcgr
I tried to convert this java code line for line to clojure to compare
the speed differences, and boy was I surprised!
public static void ConvertToAWT(byte[] cpuArray){
// Given an array of bytes representing a c-style bgra image,
// converts to a java style
On Fri, Jan 28, 2011 at 10:48 AM, Robert McIntyre wrote:
> I tried to convert this java code line for line to clojure to compare
> the speed differences, and boy was I surprised!
>
> public static void ConvertToAWT(byte[] cpuArray){
> // Given an array of bytes representing a
On Fri, Jan 28, 2011 at 10:48 AM, Robert McIntyre wrote:
> I tried to convert this java code line for line to clojure to compare
> the speed differences, and boy was I surprised!
>
>public static void ConvertToAWT(byte[] cpuArray){
>// Given an array of bytes representing
Hi,
I'm trying to get the midi sound class in Java to work in Clojure.
Everything seems to work fine except for the conversion of the
following Java code:
MidiChannel[] channels = synthesizer.getChannels;
I've tried just dumping the channels into a Clojure object -
(let [channels
Arg, wrong link. Should be:
http://thestrangeloop.com/blog/11/01/27/strange-loop-2011
On Jan 27, 11:25 pm, Alex Miller wrote:
> Strange Loop 2011 will be Sept. 18-20th in St. Louis.
>
> More info:http://thestrangeloop.com/blog/10/11/05/strange-loop-video-schedule
>
> (send-off conj-agent (not (s
On Fri, Jan 28, 2011 at 11:30 AM, WoodHacker wrote:
> Hi,
>
> I'm trying to get the midi sound class in Java to work in Clojure.
> Everything seems to work fine except for the conversion of the
> following Java code:
>
> MidiChannel[] channels = synthesizer.getChannels;
>
> I've tried just dum
> While this serialization has been fine for most of my needs I have quite
> often wanted to be able to use *print-dup* since binary serialization
> seemed overkill in those cases. Hopefully something like defrecord2
> gets added to clojure at some point to make dealing with records more
> pleasan
Combining Ken and David's tips, this version processes a byte-array of
sizd 192 in about 13 milliseconds on my machine:
(def buffer-size 192)
(def array (byte-array buffer-size))
(defn java-like [^bytes cpuArray]
(loop [i (int 0)]
(if (< i buffer-size)
(let [b (aget cpuArray i
On Fri, Jan 28, 2011 at 12:55 PM, Benny Tsai wrote:
> It seems that 'unchecked-add' returns a primitive (note that in the
> first version, 'recur' happily accepts the return from 'unchecked-add'
> without coercion), but when 'unchecked-add' is bound to a new name,
> the return gets boxed.
>
> Is t
And the plot thickens:
This:
(defn convert-image [#^bytes cpuArray]
(let [unchecked-add clojure.core/unchecked-add
len (int (count cpuArray))]
(loop [i (int 0)] (if (< i len)
(let [
b (byte (aget cpuArray i))
On Sat, Oct 30, 2010 at 10:38 PM, Alex Miller wrote:
> Hi all,
>
> I'm doing a bit of doc cleanup on http://clojure.org and I'd welcome
> your feedback on things that are broken or could be improved. I'm not
> looking (or likely authorized :) to make any drastic changes but if
> there are things
(ns atest)
(set! *warn-on-reflection* true)
(def buffer-size 192)
(def array (byte-array buffer-size))
(defn java-like [^bytes cpuArray]
(loop [i (int 0)]
(if (< i (int buffer-size))
(let [b (byte (aget cpuArray i))
g (byte (aget cpuArray (unchecked-add i (int 1
Try replacing 'aset-byte' with 'aset' and hinting all literals (change
1 to (int 1), etc.) as per David's suggestions. That should reduce
the gap even further.
On Jan 28, 11:31 am, Robert McIntyre wrote:
> And the plot thickens:
>
> This:
>
> (defn convert-image [#^bytes cpuArray]
> (let [unch
On Fri, Jan 28, 2011 at 1:55 PM, David Nolen wrote:
> As a comparison, the following accomplishes the same thing in 1.3.0.
> (ns test)
> (set! *unchecked-math* true)
> (set! *warn-on-reflection* true)
> (def buffer-size 192)
> (def array (byte-array buffer-size))
> (defn java-like [^bytes cpuA
Ah I see. Thank you Ken.
On Jan 28, 11:07 am, Ken Wesson wrote:
> On Fri, Jan 28, 2011 at 12:55 PM, Benny Tsai wrote:
> > It seems that 'unchecked-add' returns a primitive (note that in the
> > first version, 'recur' happily accepts the return from 'unchecked-add'
> > without coercion), but whe
On Fri, Jan 28, 2011 at 2:01 PM, Aaron Cohen wrote:
> On Fri, Jan 28, 2011 at 1:55 PM, David Nolen
> wrote:
> > As a comparison, the following accomplishes the same thing in 1.3.0.
> > (ns test)
> > (set! *unchecked-math* true)
> > (set! *warn-on-reflection* true)
> > (def buffer-size 192)
>
David, thanks for your suggestions.
I copied your code and tested it out, but on my machine it takes 230
milliseconds while the java version takes about 3.
If it's not too much trouble, how long does the java implementation
take on your machine?
sincerely,
--Robert McIntyre
On Fri, Jan 28, 2011
On my computer this seemed to work.
(import 'javax.sound.midi.Synthesizer)
(seq (.getChannels (MidiSystem/getSynthesizer)))
(#
#
# # # # # # # # # \
#
#
# # #)
Maybe that's helpful :P
I hope.
good luck,
--Robert McIntyre
On Fri, Jan 28, 2011 at 11:59 AM, Ken Wesson wrote:
> On Fri, Jan 28,
Hi guys.
I was working on a macro for easily defining mutable classes without
having to previously define a protocol for the methods in them (the
macro takes care of that for you) and providing basic get-set
operations.
However, I have trouble when defining classes, cause I get the
following erro
oh and of course
(import 'javax.sound.midi.MidiSystem)
before everything.
sorry about that.
sincerely,
--Robert McIntyre
On Fri, Jan 28, 2011 at 2:47 PM, Robert McIntyre wrote:
> On my computer this seemed to work.
>
> (import 'javax.sound.midi.Synthesizer)
>
> (seq (.getChannels (MidiSystem/
On Fri, Jan 28, 2011 at 2:36 PM, Robert McIntyre wrote:
> David, thanks for your suggestions.
>
> I copied your code and tested it out, but on my machine it takes 230
> milliseconds while the java version takes about 3.
>
> If it's not too much trouble, how long does the java implementation
> tak
I think I have the same error as in this post:
http://groups.google.com/group/clojure/browse_thread/thread/8257e4ec8a652b23/e94df8077ecb1ac4
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Hi Robert,
Just out of curiosity, are you running Clojure with the -server
option? When I run David's code, -server mode cuts the time for the
first run by half, and the time for subsequent runs by a factor of 5.
On Jan 28, 12:36 pm, Robert McIntyre wrote:
> David, thanks for your suggestions.
There are a handful of Clojure HTTP libraries on Github, but I do not have
one in particular to recommend.
It's not hard to use Java's HttpUrlConnection directly.
-S
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email
David Liebke gave a talk at Clojure-Conj 2010 titled "From Concurrency to
Parallelism" with detailed performance comparisons of map, pmap, and
Fork/Join-style iteration. Look for it on clojure.blip.tv in the near
future!
-Stuart Sierra
clojure.com
--
You received this message because you are
defrecord is preferred over structmap in all cases going forward.
Neither defrecords nor structmaps can be printed and read back by the
Clojure reader. You can work around this by converting them to plain maps
or using a custom printer that prints the constructor forms.
Many people have reques
Hi Eduardo,
Are you aware of the :volatile-mutable and :unsynchronized-mutable options
in deftype?
http://clojure.github.com/clojure/clojure.core-api.html#clojure.core/deftype
-Stuart Sierra
clojure.com
--
You received this message because you are subscribed to the Google
Groups "Clojure" grou
Sigh. Sorry, I'm not an experienced Java developer, and I'm sure
there are basic things relating Java packages, directories in
classpaths, and Clojure hierarchical namespaces that I just don't have
in my head yet. Right now I feel like I'm banging my head against a
wall and not getting an
On Fri, Jan 28, 2011 at 5:20 PM, Andy Fingerhut
wrote:
> --
> (ns try
> (:gen-class))
Try using a two-component (or more) namespace name. I think gen-class
in a one-component namespace will try to create the class in the
default
Thanks for the suggestion. I'm not sure I implemented it correctly.
Still no joy. Here is exactly what I tried:
% ls -R
andy
./andy:
try.clj
% cat andy/try.clj
(ns andy.try
(:gen-class))
(gen-class
:name andy.try.ReversibleByteArray
:prefix rba-)
(defn rba-reverse [this]
(println
Woops.
I meant to have both occurrences of (rba-reverse) in defn -main
replaced with just (reverse). I made that replacement, and still get
nearly the same error message:
Exception in thread "main" java.lang.IllegalArgumentException: No
matching method found: reverse for class andy.try.R
On Fri, Jan 28, 2011 at 2:09 PM, Stuart Sierra
wrote:
> Neither defrecords nor structmaps can be printed and read back by the
> Clojure reader. You can work around this by converting them to plain maps
> or using a custom printer that prints the constructor forms.
>
So if I don't care about huma
Haven't tried this, but some ideas/questions in my mind:
Is it not better to use the (:gen-class :name ... :prefix ...) inside (ns)
instead of having a separate (gen-class ...) outside (ns ...)? Maybe it
makes no difference? (dunno, but the documentation for ns suggests
otherwise)
Where y
On Fri, Jan 28, 2011 at 6:13 PM, Andy Fingerhut
wrote:
>> (ns andy.try
>> (:gen-class))
>>
>> (gen-class
>> :name andy.try.ReversibleByteArray
>> :prefix rba-)
I find it confusing that you have both of ":gen-class in the ns macro"
(I guess you're using this to get -main) and "(gen-class) at th
That was what I was missing. Thanks, Aaron.
Regarding using :gen-class in the ns macro, and also (gen-class) at
the top level, I am using the first because I know it works for AOT
compilation (important for the shootout web site to avoid measuring
compilation as part of the run time). If
On Fri, Jan 28, 2011 at 6:50 PM, Mark Engelberg
wrote:
>
>
> On Fri, Jan 28, 2011 at 2:09 PM, Stuart Sierra
> wrote:
>>
>> Neither defrecords nor structmaps can be printed and read back by the
>> Clojure reader. You can work around this by converting them to plain maps
>> or using a custom print
I'm running my JVM with:
-verbose:gc -Xmn500M -Xms2000M -Xmx2000M -server
sincerely,
--Robert McIntyre
On Fri, Jan 28, 2011 at 4:24 PM, Benny Tsai wrote:
> Hi Robert,
>
> Just out of curiosity, are you running Clojure with the -server
> option? When I run David's code, -server mode cuts the t
And if anyone is curious, I've now got a Clojure program that works
pretty much exactly like this Java program, including using gen-class
to extend java.io.ByteArrayOutputStream with a new method, and access
two protected (non-static) fields of the superclass:
http://shootout.alioth.debian.
I think what you're talking about is continuation passing style -
http://en.wikipedia.org/wiki/Continuation-passing_style
I think there was a thread on it a few months back, but from what I
remember its not supported (its dependent on TCO to prevent the stack
from exploding as explained above).
O
On my home computer, using the same options, the java version runs in
1.5 milliseconds, and David's 1.2 Clojure version in 16 milliseconds.
I'm at a loss as to why you're still seeing such a large gap between
the two versions.
On Jan 28, 6:16 pm, Robert McIntyre wrote:
> I'm running my JVM with:
43 matches
Mail list logo