#clojure logs

2009-05-29

00:29djpowellhoeck: yeah that is easier
00:30djpowellI'm trying to wrap log4j calls in clojure, so I need to pass the name of the wrapper class to log4j so that it can figure out the line number of the caller from the stack trace
00:31djpowellI'm seeing that my function proxies the call to the clojure logging function via RestFn.invoke. What is RestFn?
00:37opqdonuthow do I read a string into an int?
00:40djpowell,(Integer/parseInt "123")
00:40clojurebot123
00:41djpowellis there a better way that isn't restricted to Java ints?
00:42djpowellhmm, this is better:
00:42djpowell,(read-string "123")
00:42clojurebot123
00:42talios,(Integer/valueOf "5")
00:42clojurebot5
00:47djpowell,(num (read-string "1234")) ; if you want to fail if it isn't a num, but still support the whole numeric tower
00:47clojurebot1234
03:20alinphi
03:20Chouserhi
03:20alinpcan anyone please tell me what is wrong with this code: http://pastie.org/493850
03:20alinp?
03:20alinpI get NPE ... and I don't really get it
03:23alinpI don't really get it ... means that I don't got an idea where it comes from
03:23Chousukealinp: the nil is the initial value of the agent, and you're trying to add 1 to it.
03:24Chousukeor maybe not... hm
03:24alinpyey
03:24alinpthanks Chousuke
03:24alinpthis was it ...
03:24alinpat least for me
03:24alinpbut .. shouldn't be the case
03:25Chousuke(doc send)
03:25clojurebot"([a f & args]); Dispatch an action to an agent. Returns the agent immediately. Subsequently, in a thread from a thread pool, the state of the agent will be set to the value of: (apply action-fn state-of-agent args)"
03:25alinpbecause I'm not adding to agent value
03:26jdzyou are
03:26Chousukethe agent's state goes in as the first parameter to f
03:26alinp(defn second-test [coll]
03:26alinp(map (fn [x] (send (agent nil) (fn [_] (+ x 1)))) coll))
03:26alinp(def x (second-test (list 1 2 3)))
03:26alinpand it works
03:27alinpalso the agent is having nil value
03:27Chousukeyeah, because now you're ignoring the agent's value :)
03:27Chousukeinstead, you're using x
03:27alinpoh, crap
03:27jdzwhy are you creating agents with nil state?
03:27alinpthe agent's value is going instead of _
03:27Chousukealinp: ?
03:27alinpdon't know, because I don't have an initial state of it ?!
03:28Chousukealinp: _ is just an "I don't care" marker
03:28alinpyes, this is what I said .. .
03:28Chousukeit still gets assigned the value though. which is the agent's state in this case.
03:28alinpI didn't saw where the agent's value was placed
03:28Chousukeit's not easy to see from that, I agree :/
03:29Chousukein your test-map call it kinda looks like y would be the list values, but they're not.
03:29Chousukeinstead, you're completely ignoring the list :)
03:30alinpI see
03:30alinpthanks
03:30alinpso .. there is a solution for that ?
03:30alinpor the solution will be not to use nil ?
03:30Chousukeis there a problem to solve? what do you actually want to do?
03:31Chousukehave an agent and add a listful of value to it?
03:31Chousukevalues*
03:31alinpno, have a list and apply a function to all elements that is spawning a thread for each element
03:31Chousukeah
03:32alinpand I don't want to do it (thread spawning) outside of this function
03:32alinpI just want the function to get the same params as map function, but, backstage to apply function to each element in a separate thread
03:32Chousukemaybe you should use futures.
03:33alinpwell, but can't be done this way ? :)
03:33Chousukehmm
03:33alinpto be honest, I'm just playing
03:33Chousukesure it can, but... gmm
03:33alinpit's not something for production or so ..
03:33Chousukebut if you want to use agents: (map (fn [item] (send-off (agent initvalue) f item)) coll)
03:34rhickey,(doc pmap)
03:34clojurebot"([f coll] [f coll & colls]); Like map, except f is applied in parallel. Semi-lazy in that the parallel computation stays ahead of the consumption, but doesn't realize the entire result unless required. Only useful for computationally intensive functions where the time of f dominates the coordination overhead."
03:34Chousukeor that :D
03:35alinpha
03:35alinpyes, is what I want to do :)
03:35alinpok, thank you
03:35alinpI'll see about that
03:36Chouseralinp: and then you can look at the definition of pmap and learn how its done. :-)
03:36alinpyes, sure, this is what I have in mind :D
03:36alinp*I had
03:43alinpChousuke:
03:43alinp,(map (fn [x] (send (agent nil) (fn [_] (+ x 1)))) coll))
03:43clojurebotjava.lang.Exception: Unable to resolve symbol: coll in this context
03:44alinp,(map (fn [x] (send (agent nil) (fn [_] (+ x 1)))) (list 1 2 3)))
03:44clojurebot(#<Agent@15ec870: nil> #<Agent@1b95de0: nil> #<Agent@c22530: nil>)
03:44alinphmmmm
03:44alinpwtf ?
03:45alinp,(map (fn [item] (send-off (agent 0) f item)) (list 1 2 3))
03:45clojurebotjava.lang.Exception: Unable to resolve symbol: f in this context
03:45alinp(def f (fn [p] (+ p 1)))
03:45alinp(map (fn [item] (send-off (agent 0) f item)) (list 1 2 3))
03:45alinpjava.lang.IllegalArgumentException: Wrong number of args passed to: user$f
03:46alinp(map (fn [item] (send-off (agent 0) (f item))) (list 1 2 3))
03:46alinpjava.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn
03:47alinp(map (fn [item] (send-off (agent 0) (fn [_] (f item)))) (list 1 2 3))
03:47alinpit seems that I need to do something like this
03:49hoeckalinp: your function f has to take the agent state as the first arg
03:50hoeckalinp: it should be (defn f [p item] (+ p item))
03:50Chousukeyes
03:50Chousukefunctions sent to agents must always take the agent as the first parameter
03:50Chousukethe state of the agent that is
03:50alinpoh, I see
03:50Chousukejust send + to it :)
03:51Chousuke,(map #(send-off (agent 5) + %) [1 2 3])
03:51clojurebot(#<Agent@7704dd: 6> #<Agent@1e05ef2: 5> #<Agent@1799932: 5>)
03:52Chousukehmm
03:52Chousukethat's not what I expected :D
03:52alinpha
03:52alinp:)
03:52Chousukemight be the asynchrony
03:52Chousukethe rest of the agents didn't complete the action before the map thing printed them
03:53Chousuke,(map #(send (agent 5) + %) [1 2 3])
03:53clojurebot(#<Agent@8eb8bf: 5> #<Agent@31f94: 5> #<Agent@10e58a3: 5>)
03:53Chousukehmm.
03:53alinp(defn my-map [f coll]
03:53alinp (map
03:53alinp (fn [item] (send-off (agent nil) (fn [_] (f item))))
03:53alinp coll)
03:53alinp )
03:53alinpthis is what I made ...
03:53alinpand it seems it working ;)
03:54Chousukeyeah, that would work.
03:54Chousukeand send and send-off are both asynchronous
03:54Chousuke:p
03:54alinpyep
03:54Chousukealso, putting the closing paren on its own line is not very lispy :)
03:54alinpthe thing is that I was taking always the value of agent
03:55Chousukeyou should learn the Real Way!
03:55alinpand not the value of each item
03:55Chousukeyou'll ~never see code like that anyway.
03:55alinpyou're talking about what piece of code ? (mine, of course, but which)
03:55Chousukeso you need to get used to the closing parens not being on separated
03:55Chousukethe ) at the end
03:55Chousukeit should be after coll)
03:56Chousukeand also the end paren for defn should be after those
03:56Chousukelisppaste8: url
03:56lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
03:56alinpI see, well .. I saw plenty of clojure code this way ...
03:56Chousukewhere? :/
03:57alinpI don't remember right now ... but I'll be sure to show you some when I see it ;)
03:58alinp"and also the end paren for defn should be after those"
03:58alinpwhat do you mean ?
03:58alinp(defn my-map [f coll]
03:58alinp (map
03:58alinp (fn [item] (send-off (agent nil) (fn [_] (f item))))
03:58alinp coll))
03:58alinpthis is what you mean ?
03:59lisppaste8chousuke pasted "coding style" at http://paste.lisp.org/display/81021
04:00alinpyep, cool, thanks
04:00Chousukewhen writing lisp, don't match parentheses manually; let the editor do it for you
04:00alinpwell, yes... but
04:00alinpanyway, is better than haskell
04:01alinpI hate the indentation stuff
04:01alinptabs over spaces ... etc
04:01Chousukelisp has no forced indentation but there are of course conventions you should follow.
04:02Chousukefor example, one indent is generally two spaces
04:02alinpyes, this is how my vim is configured for clj
04:05Chousukegrouping the end parens has the effect that lisp code usually has quite a distinct "shape"
04:05Chousukeand if that shape looks weird, you may need a rewrite ;)
04:53durka42github's clojure highlighter has a few bugs >:o
04:55hiredmanso does the php highlighter
04:58gnuvinceI blame Ruby
05:15alinpit is possible in clojure to create an initial list with n agents ?
05:15alinpor .. n elements
05:15alinpit doesn't matter if are agents or other type
05:16cmvkklike this?
05:16cmvkk,(repeat 5 0)
05:16clojurebot(0 0 0 0 0)
05:16alinpmake-array is used for classes
05:16alinpyes, like this :)
05:16alinpthanks cmvkk
05:17{newbie}Hi I have a list of stuff I want to pass to a var arg function?
05:17{newbie}how do i destruct the list into multiple values?
05:17Chouser{newbie}: apply
05:18alinp{newbie}: map
05:18{newbie}thanks ^^
05:18alinphmmm, apply will be better, Chouser is right
06:00hiredman,(map agent (repeate 5 nil))
06:00clojurebotjava.lang.Exception: Unable to resolve symbol: repeate in this context
06:00hiredman,(map agent (repeat 5 nil))
06:00clojurebot(#<Agent@866463: nil> #<Agent@128b564: nil> #<Agent@19ce804: nil> #<Agent@446cc5: nil> #<Agent@4127cf: nil>)
06:25hiredmanException java.lang.OutOfMemoryError occurred dispatching signal SIGINT to handler- the VM may need to be forcibly terminated
06:25hiredmanNice
06:47rhickeyooh: http://java.sun.com/javase/6/webnotes/6u14.html
06:47rhickeyThe -XX:+DoEscapeAnalysis option directs HotSpot to look for objects that are created and referenced by a single thread within the scope of a method compilation. Allocation is omitted for such non-escaping objects, and their fields are treated as local variables, often residing in machine registers. Synchronization on non-escaping objects is also elided.
06:48Chousukecool
06:49stuartsierraSo that eliminates the object-allocation penalty?
06:50ChousukeI wish I weren't on OS X so I could try and see what kind of effect that has :)
06:50rhickeyChousuke: me too :(
06:50rhickeystuartsierra: in some cases - it will be interesting to see which ones
06:58durka42i like -XX:+UnlockExperimentalVMOptions
06:58durka42clojure has *leveled up*! clojure has unlocked new VM features!
06:59Chousukeheh
06:59Chousukehmm, there's a recent java developer preview update on ADC
06:59Chousukelet's see which version it is ;P
07:00Chousukedamn, 1.6.0_13
07:00Chousukeno fair
07:01Chousukestill, probably worth upgrading
07:02rhickeyhow's everyone doing with chunked seqs?
07:03Chouserhaven't noticed any problems
07:04Chousercould lazilypersistentvectors and arraymaps each provide one big chunk?
07:06rhickeyChouser: that would actually be bad. The beauty of chunks is that they are just a slightly expanded version of seqs - not realizing full intermediate results is a big win
07:07Chouserdoes a chunk stay the same size through the whole chain?
07:07ChouserI hadn't thought about that, but I guess it must.
07:07rhickeynot necesarily
07:08rhickeyyou can have heterogeneous seqs, with some chunks some not
07:08Chouserbut most intermediate funcs (map, filter, etc.) won't do extra work to break up or coalesce chunks?
07:09rhickeyChouser: no, ideally they should copy the incoming chunk size, filter and its ilk being the exception
07:10rhickeychunked-seq, or whatever we call it, will actually drop the chunk if it is empty - (chunked-seq [] foo) => foo
07:11rhickeysorry, meant chunked-cons above
07:11rhickey (chunked-cons [] foo) => foo
07:12rhickeyChouser: ah, now I see, by through the chain you mean chain of calls, not chain of seqs
07:12clojurebotWho??
07:13Chouseryes, sorry, the call chain
07:13rhickeythen yes, will be same size, thus whole-coll-as-chunk = bad
07:13Chousergot it
07:14rhickeythat's why LazilyPersistentVector.ChunkedSeq is the way it is
07:14Chouserso... lpv and arraymap could provide artificially small chunks of themselves at whatever the "ideal" size is.
07:14Chouseroh.
07:14Chouser32. ok.
07:15Chouserthat was my next question
07:15rhickeythere is still an issue for multi-seq map regarding chunk alignment
07:16rhickeyditto any other multi-seq consumer, like zipmap or interleave
07:16Chousermmm, sure.
07:16rhickeythe simplest default is to do chunks only when aligned
07:16rhickeythus 32
07:17rhickeybut not guaranteed, since e.g. hashmap chunks are sparse
07:17Chouserany sense of how small chunks can be and still be worth the overhead (if any)? 2 items? 4?
07:18rhickeyChouser: since the chunked seqs are as fast as the original seqs when used as ordinary seqs, I think it is all win, but haven't tried very small chunks
07:18ChouserI'm just thinking that the second-simplest behavior for multi-seq would be to produce one (small) chunk for each range of fully-overlapping chunks.
07:19rhickeyChouser: the trick is remembering the half-chunk you didn't yet consume
07:19Chouseryeah. all them. :-)
07:19rhickeyI thought about it and got a headache
07:22rhickeybut, one of the reasons this is in trunk is I welcome contributions towards getting it fully done. I foresee the need for:
07:22rhickeychunked arrayseqs
07:22rhickeychunked hashmap seqs, plus chunked keys and vals seqs
07:22rhickeymulti-arg map
07:22rhickeyvectors of primitives
07:23rhickeychunked versions of arithmetic ops, both chunk/chunk and chunk/scalar
07:23rhickeychunked-map which takes a fn expecting chunks
07:23rhickeychunked-pmap
07:24rhickeyintegration of chunking logic in the core seq fns where it makes sense - I'll do map/filter/reduce as examples
07:24ChouserI don't understand chunked arithmetic
07:24rhickey(+ chunk-of-ints chunk-of-ints) => chunk-of-ints
07:26Chousercan't do that with seqs now, can you?
07:26rhickey(chunked-map + int-vector1 int-vector2)
07:26rhickeythe perf of this would be as good as loops with primitives
07:28Chousermap* as pasted yesterday doesn't tell f it's got a chunk. is there some other api detail I'm missing?
07:28rhickeyso, people could use vectors of primitives transparently and at a high leve like they do vectors of objects, and get fast math when needed, without going to Java arrays
07:29Chousersounds absolutely gorgeous, but I'm not seeing how all the pieces fit together yet.
07:29rhickeyChouser: sorry if this is confusing, the logic in map* of yesterday is going to end up in regular map. After that, there will be a map-chunked which takes a fn that *expects* a chunk, and requires a chunked seq as input
07:30rhickey+ would become such a fn
07:30rhickey(map-chunked + int-vec1 int-vec2), would pass the first chunk from each to +
07:31rhickey+ would be overloaded for chunks
07:31rhickeyso instead of boxing each int, we 'box' entire chunks in int-vectors
07:31stuartsierraJust got my "Programming Clojure" -- pretty nifty.
07:31Chouseroh, so map-chunked is different from map* and map
07:31Chouser(yes, I understand map* is going away)
07:31rhickeyChouser: yes, map-chunked passes chunks o f
07:31rhickeyto f
07:32Chousergot it.
07:32Chouserand what are these vectors of primitives you slipped in there?
07:33rhickeybasically exactly like vectors, except specialized for int/long/float/double. They will present the exact interface as vectors, but will ensure that things put in will 'fit' in the primitive types
07:33rhickey(int-vec 1 2 3 4)
07:34rhickeyhm, int-vector I guess
07:34Chousersounds like a lot more boilerplate Java code.
07:34Chouserbut great to use! :-)
07:34rhickeywhen seq'ed, a primitive vector's chunks will be chunks of primitives
07:35rsynnottstuartsierra: oh, they released it?
07:35rhickeymath ops will detect such chunks and do primitive/primitive op, boxing occurring once per chunk
07:36Chouserah, sure. whatever seq produces would still need to be boxed, so without chunks you'd get some memory savings, but no performance boost. boxing whole chunks gives perf as well.
07:36stuhoodso the main benefit is speed then?
07:37stuhoodimo, the speed isn't worth it unless the chunking can be done transparently
07:37stuartsierrarsynnott: yes
07:37Chouserstuhood: it will be
07:38stuhoodah, i misunderstood map-chunked
07:38asbjxrnEven non-transparent speed is worth it if you need it.
07:38Chouserstuhood: a regular vector of regular objects passed through regular map/filter/reduce should run quite a bit faster with chunks under the hood.
07:39rhickeystuhood: it might seem to be only about perf, but there comes a point where perf determines the viability of using the higher-level ops for everything. The model right now when switching to arrays + primitives + loops is very different
07:39rhickeythis is best-of-both-worlds, IMO
07:39Chouserright, map-chunked is not transparent, but is more pleasant than loop/recur when your only reason for doing so was perf (via primitives)
07:40rhickeyalso the increased granularity means pmap might makes sense in more cases, since the per-step work unit is bigger
07:40Chouserah, nice
12:49rhickeybut the transparency is key - right now all the vector seqs are chunked, and no one seems to care
12:49stuhoodcould map defer to map-chunked transparently?
12:49stuhoodoh, gotcha
12:49rhickeystuhood: unlikely
12:50stuhoodcould the sequence just implement another interface that map/reduce/filter would check for?
12:50ChouserI do wonder if we have as much usage of svn head as we did.
12:51ChouserI know I'm running 1.0.0 more often then I ever ran old revs before.
12:51rhickeystuhood: it does and they will, but that doesn't mean the fn is ready to accept chunks
12:51stuhoodahhh, doh.
12:52stuhoodcould it not fall back to map if the function didn't have a high enough arity?
12:52Chouserbetter than arity would be metadata explicitly saying it can do chunks
12:52rhickeystuhood: it's not a question of arity, both could have arity 1
12:52Chouserbut you'd want to determine that at compile time, wouldn't you?
12:53stuhoodrhickey: it is if you (apply) the chunk to the function
12:53Chousukea new kind of type hint? :)
12:53Chouserso it'd be more like ... metadata on that specific AFn subclass rather than the closure instance. heh.
12:53stuhoodoh, nvm.
12:54stuhoodscuse me... too much typing, not enough thinking
12:55rhickeyChouser: one of the earlier models was chunked seqs were seqs of chunks - it didn't work out, and I'm not sure with metadata it could do the right thing, but maybe
12:55rhickeyMathematica has a similar notion
12:56rhickeylistable
12:56{newbie}I define a strut but i can acess the struct members inside a function. An exception is thrown "Unable to resolve classname")
12:56rhickeyhttp://reference.wolfram.com/mathematica/ref/Listable.html
12:56{newbie}can't*
13:02{newbie}it works outside a functioin
13:02{newbie}function*
13:03Chousukeyou need to show the code that fails.
13:03{newbie}(defstruct news :title :date :author :body :link :feed)
13:03{newbie} [nil (new :author) (new :title) (new :body) (new :link) (new :date) (new :feed)])
13:03Chousukethat's completely wrong :)
13:03{newbie}I'm a {newbie} :p
13:04Chousukenew is for java classes
13:04{newbie}X| so simple
13:04{newbie}it is not highlighted in my editor
13:04{newbie}thanks!
13:04Chousuke(def newnews (struct news title date author body link feed))
13:05gnuvince~s def defstruct
13:05clojurebotExcuse me?
13:05gnuvincemange un char
13:05Chousukestructmaps are popular for some reason.
13:05ChousukeI guess they serve as documentation for the map keys.
13:05Chouserthey are! But I hardly ever use them. I wonder what I'm missing.
13:06stuartsierraI never use them either.
13:06Chousukeand sometimes I guess someone might even use the accessors!
13:06Chouseroh, I never ever make those
13:06{newbie}I used then because this data is going to be saved to the database
13:06rhickeythat's because you guys are old-school Clojurian's, pre structmap
13:07{newbie}and if the order is wrong the world get's blown up
13:07ChouserI don't think I'm *that* old-school.
13:07Chousukeorder? do struct maps have order? :/
13:07{newbie}no
13:07stuartsierraI always kind of felt that structmap was a premature optimization. :)
13:07ChouserChousuke: yes!
13:07rhickeywhen I was learning Clojure we didn't have no stinkin' structmaps sonny... :)
13:08ChouserDec 16 2007 -- first cut PersistentStructMap
13:08{newbie}but with struct they must be created with a specific order
13:08Chousukerhickey: until you made them :(
13:08ChouserI wouldn't pick up clojure for another 2 or 3 months.
13:08rhickeyah, so just stuartsierra
13:09Chousuke{newbie}: but how does the creation order matter? :/
13:09rhickeyI didn't realize they were that old
13:09{newbie}btw I have a question about style, I have a method that converts the news to a tuple and a method that converts a single new to a tuple, the method that works on lists uses map.
13:09ChouserChousuke: seqs on structmaps return things in the order that the keys were declared
13:09{newbie}Should I use a multimethod instead?
13:10ChousukeChouser: ah, neat.
13:10ChouserDunno if that's promised, but they do currently.
13:11Chousuke{newbie}: multimethod? nah.
13:11{newbie}So my approach is fine?
13:12Chousuke{newbie}: if you have a news->tuple function that converts a news map into a tuple, then (map news->tuple seq-of-news) is better than overloading news->tuple for sequences.
13:12cemerickheh, we use structmaps *everywhere*
13:12slashus2rhickey: I know this is far less important than your current work, but what is your opinion on this issue? http://groups.google.com/group/clojure/browse_thread/thread/a767baaa0b3b17eb
13:12Chousukeassuming I understand what you mean.
13:12{newbie}you did :D
13:13rhickeyslashus2: already removed count inlining here - I'll put it up
13:13slashus2Not keen on creating function signatures for (int int) (float float) etc.?
13:13clojurebotfor is not a loop
13:13Chousuke{newbie}: you should use multimethods if you need to handle many kinds of input data each with a similar result
13:14rhickeyslashus2: maybe, but that is not on deck right now
13:14slashus2agreed
13:14slashus2Would you like me to create an issue?
13:14Chousuke{newbie}: so an anything->tuple might be a good candidate for a multimethod; then you could even transform a seq of anythings with just (map anything->tuple seq-of-things)
13:14rhickeyif you have a CA you can submit a patch
13:15Chouserwhat's a tuple?
13:15ChouserI mean, in clojure.
13:16slashus2I will mail in my CA.
13:17{newbie}Chouser: in my case it's a list
13:17clojurebotWho??
13:17gnuvinceChouser: a term used to designate a sequence of things that is supposed to have a fixed length.
13:17ChousukeChouser: maybe he has a java Tuple class or something.
13:17Chouser{newbie}: ah, thanks.
13:18{newbie}the sql lib has a method to insert multiple rows it accepts lists
13:18{newbie}i mean't vectors
13:18Chousuke{newbie}: in that case you can make a tuple out of your news with just (vals news) :p
13:18Chousukeor (into [] (vals news)) for a vector
13:18{newbie}:|
13:18Chouser(vec (vals news))
13:19{newbie}dam I'm felling stupid now
13:19ChousukeI prefer (into [] ...)
13:19Chouser{newbie}: nah, it's extremely common to re-write several builtin functions when starting.
13:19Chousuke{newbie}: though it assumes that the structmap really does return key-val pairs in the order you specified
13:19ChouserChousuke: why?
13:19{newbie}are the vals garantee to be ordered by teh key order where I define the strct?
13:20ChousukeChouser: if it's going into the database lib, it probably wants the order the columens are defined in the db.
13:20Chousukecolumns, too
13:20ChouserChousuke: but vec uses the order of the seq given to it, so ... ?
13:21ChousukeChouser: ah, I didn't mean only your solution; I meant mine too (after all, they're equivalent)
13:21Chousuke(into [] ..) is just more explicit so I like it.
13:21Chouserah, I see, sorry. I meant "why do you prefer (into [] ...)"
13:22Chouseroh, ok.
13:22rhickeyA struct map will retain its base keys in order.
13:22rhickeyhttp://clojure.org/data_structures
13:23{newbie}nice thanks!
13:23Chouserwow, that's coming up fast.
13:23Chousuke:/
13:24ChousukeI assume "vec" predates into?
13:24stuartsierraother way around, I think
13:26jkantzis there a release of clojure-contrib that goes with the release clojure-1.0.0?
13:26technomancyjkantz: nope
13:27Chouserman, we're all just lazy bums. no clojure demo, no clojure-contrib release, nobody volunteering to write chunked hashmap seqs
13:28stuartsierraSpeaking for myself, I'm a busy bum. :)
13:28technomancyChouser: I think you'd make a good contrib manager. =)
13:28Chousertechnomancy: well if it needs is a very hand-off manager, then maybe...
13:29ChousukeI really have no idea what would make a good clojure demo.
13:29technomancyI saw a lib was removed from contrib a few days ago since it just plain didn't work any more. I'm glad that's happening.
13:30stuartsierraYeah, I've been trying to clean up stuff I wrote a long time ago.
13:30stuartsierraNext I need to reorganize my individual library tests to be part of test_contrib
13:31technomancystuartsierra: was looking at your hadoop integration in altlaw yesterday
13:31stuartsierracool
13:32technomancylooks like you've got a nice way to abstract all the insane hadoop bits away and deal with it pretty functionally
13:32stuartsierraThat was the idea. Not perfect yet, but easier than writing Hadoop jobs in Java.
13:32cemerickstuartsierra: speaking of contrib and tests, a suggestion: after reading the docs for the testing macro, I thought each child form in the testing body would be wrapped with is, but that's not what happens...
13:33cemerick(testing "foo" (= blah (foo))) evals the equality, but doesn't assert it.
13:33stuartsierraThat's correct.
13:33stuartsierra'testing' is just for documentation
13:33cemerickthat's fine, but the docs say "...which takes a string followed by any number of 'is' assertions".
13:34stuartsierraOops, need to change the example. I'll fix that.
13:34cemerickyeah, that was my only point :-)
13:34rhickeyChouser: I didn't mean to imply that
13:34Chouserrhickey: oh, I wasn't taking it personally. It's just the nature of these things.
13:35Chousereverybody's working on what they want to do, not what anybody else wants them to do. And maybe it's better that way in the long run, dunno.
13:35rhickeyI had thought we'd all be assigned the same task, like last year, which would have been more of a can you help me do X rather than an open-ended - got anything neat?
13:36rhickeybut it ended up being open
13:36cemerickstuartsierra: are is awesome, too. Though, it would be handy to have something that does wrap every child form with is. Right now, (are (= _1 _2) ...) does that just fine, but that particular template seems so typical that a top-level macro would be handy.
13:36rhickeyso I don't know how it will serve as a competition, no apples to apples
13:37Chouserfwiw, I can recommend *not* taking a group of java and c++ devs through 600 lines of clojure wrappers around protobuf and Socket as their first exposure.
13:37cemerickrhickey: I would have tried to put something together using processing (which I've been experimenting with for work), but I've had my back against the wall since ILC :-(
13:37Chouserdid that wednesday, and although it went fine I don't think they were exactly wowed.
13:38cemericktechnomancy: indeed -- I happened to listen to a "is java unproductive today" roundtable on the java posse podcast on the drive in today. It was a sad display, IMO.
13:39technomancyin the Programming Clojure book there's an example of a "code snippet" mini-web app in just a few pages
13:39cemericklots of "it'd be so great to get an elvis operator in the next version of java", etc
13:40technomancybut I guess we didn't want the demo to be a web app
13:41alinphi
13:41alinphttp://pastie.org/494198
13:41alinphaving this code
13:41marklarDoes the development process count as 'something cool about the language'? I know coming from Java/C# the best part for me has been the Repl and the ease of development
13:42alinpwhy is getting this error: Exception in thread "main" java.lang.IllegalArgumentException: Argument is not an array (ringclbg.clj:0)
13:42alinp?
13:42technomancymarklar: yeah, but if you're being pitted against other dynamic JVM languages they will all take that for granted
13:42alinpI can't see what is wrong there
13:42marklartechnomancy: ah, I guess I should look what other languages are included :)
13:42Chousercemerick: well, that's a thought. show some code that wants an elvis operator ... then writing fricking elvis macro.
13:42technomancynot that slime isn't more advanced than IRB, but it's not a core strength
13:43dnolentechnomancy: it's subtle to explain the power of the REPL over something like IRB or python interactive mode.
13:43cmvkkalinp, aset takes an array as a first argument, but "ring" isn't an array
13:43cmvkkit's just a list.
13:43dnolenpython interactive mode sucks, it can't even handle updating imported libs.
13:43dnolenirb sounds better, but it doesn't seem good to leave open the way you do with lisp projects.
13:44Chousukewhy are you using an array in the first place? doesn't look like you need one :/
13:44clojurebotLisp isn't a language, it's a building material.
13:44technomancycemerick: the whole, "let's patiently hope that Sun does this neat thing in the next release" rather than "let's hack out an experiment and see if it ends up being a net win" mindset... I just don't know what to make of it.
13:44alinpI see
13:44technomancyutterly foreign
13:44alinpwell ... someone used it
13:44alinpand I modified the code a little bit
13:44alinpand it seems that I did wrong
13:44alinpso, it's about that
13:44alinpthanks
13:44alinpI'll see what I can do
13:44Chousukeyou want the agent with 0 at the end of the array? :/
13:45alinpmno
13:45alinpin fact is my fault that I did copied the code without knowing exactly what it does
13:46alinpyes, I don't need that
13:46alinpfor sure
13:46alinpI'll delete it and write it my own implementation
13:46Chousukebecause you can create a vector of agents like so: (into [] (for [i (range 10)] (agent i)))
13:47alinpthanks Chousuke & cmvkk
13:47alinpwell ... I can create a list of agents .... (def ring (repeat ring-size (agent nil)))
13:47alinpit's easier, right ?
13:47Chousukeyeah, except it's lazy
13:47alinpI don't need a vector, at all
13:47cemerickChouser: yeah, maybe. I honestly don't know what to say to a crowd that is currently at or below that level, though.
13:47cmvkkby the way, that only creates a list of the same agent over and over again.
13:47alinpthe list, or the vector ?
13:47alinpthe vector, right ?
13:47Chousukethe list
13:48cmvkkif you want n different agents, you want something like (take ring-size (repeatedly #(agent nil)))
13:48alinp.......
13:48Chousukeit's not a list at all, actually
13:48alinphmmm
13:48Chousukeit's a seq
13:48cemericke.g. you'll say macro, and they'll roll their eyes thinking about C macros or something.
13:48alinpit's a seq ?
13:48alinpwell , I didn't said that it's a lazy seq
13:48Chousukeyeah.
13:48Chousuke(doc repeat)
13:48clojurebot"([x] [n x]); Returns a lazy (infinite!, or length n if supplied) sequence of xs."
13:48alinpshouldn't I specify it's lazy ?
13:48alinpoh
13:48alinpcrap
13:48alinpright
13:48cemericktechnomancy: there is a very large population that wants java to stay exactly the same....and continue to use it as is. *shrug*
13:49alinpso, what's wrong with that ? :)
13:49alinpI want it to be lazy
13:49ataggartcemerick: that depends on precisely what you mean by "stay the same"
13:49technomancycemerick: luckily for them, Java 1.6.0_10 _will_ stay the same.
13:50Chousukealinp: well, if you make a lazy seq of agents, you won't actually have them until you read them from the list somewhere :p
13:50alinpI'll do read them
13:50ataggartchanges to the underlying capabilities of the VM is one thing, slapping on more "stuff" into the Java language itself is another
13:50cmvkkChousuke, that would be okay i think, becuase you can't send to them unless they exist already
13:50alinpthat's why I said that I'll write the code myself
13:50alinpinstead of the old one
13:50cemerickataggart: I can't pretend to know the full argument from that side. One of the big sticking points in the discussion I listened to was "learning new language features is simply too hard and time-consuming".
13:50{newbie}how was the world before structmap btw?
13:51Chousuke{newbie}: you just used regular maps, I guess :p
13:51cemericktechnomancy: heh, we still get people emailing asking if we support java 1.2, sometimes 1.1.7
13:51ataggartmy view at this point is Java is... sufficient. If you want a different set of features, pick a new JVM language.
13:51ataggarta la clojure
13:53Chousukecemerick: and about the macro thing... I guess you could just say you can make functions that run at compile time
13:53Chousukeand generate more code
13:53cemerickChousuke: maybe.
13:53{newbie}well I'm learning clojure for a project with just a few weeks for the deadline
13:53ataggarta lot of java devs won't know what a macro is anyway
13:53Chousukeso that if you end up with a boilerplate pattern, you can write a compile-time function that generates that boilerplate pattern for you
13:54cemerick{newbie}: welcome to the 5%-club :-)
13:54Chousukeand since clojure code is data, there will be no string handling involved!
13:54{newbie}:P I won't touch on macros
13:54{newbie}yet
13:54technomancywise
13:54Chousukemost of the time you don't need them, anyway
13:55Chousukeother than what the core libraries already provide, of course.
13:55ataggartor if you do, it's already been written by someone else
13:55cemerickI'd agree with whoever suggested it that the best demo is the workflow. Use a mainstream environment (one of the plugins for NB, Eclipse, IntelliJ), and code stuff up at runtime, without an edit, compile, run cycle.
13:56cemerickFWIW, of course. I'd have a lot more weight if I had put together a shiny demo. :-/
13:56technomancyeveryone understands telnet, and there's less overhead to explain than HTML-generation
14:02technomancywith mire I had a multiplayer text adventure working in < 60 LOC. that could make a good demo.
14:03Chousukeheh
14:04Chousukewonder if the audience has laptops. would probably impress them if they could join the game themselves.
14:04technomancydepends more on if the wifi holds I suspect
14:05technomancydon't know about JavaOne, but conference wifi is usually sketchy
14:05technomancybut yes, that would be pretty cool.
14:07Chousukeit was also fun sending local mail on the school unix server when the mail system was demoed.
14:07hiredmantechnomancy: I assume JavaOne is Enterprise Ready(TM(TM)
14:07Chousukeno need for pesky @ signs :)
14:11slashus2,(* (int 2) (int 356666666666666666666))
14:11clojurebot-1029352108
14:11slashus2,(* (int 2) (int 3566666666666666666))
14:11clojurebotjava.lang.ArithmeticException: integer overflow
14:12Chousuke,(class 356666666666666666666)
14:12clojurebotjava.math.BigInteger
14:12Chousuke,(int 356666666666666666666)
14:12clojurebot-514676054
14:13slashus2Seems like the first one should give an integer overflow too.
14:13Chousukeprobably.
14:14durka42_,(int 3566666666666666666)
14:14clojurebot-1293636950
14:15ataggart,(class (int 356666666666666666666))
14:15clojurebotjava.lang.Integer
14:15durka42i wish colloquy would do that automatically
14:16durka42so int doesn't check for integer overflows, but * does
14:16emacsenI asked this a few days ago and I think I was misunderstood...
14:16durka42i guess in the first case, the conversion from int overflows but * doesn't, and in the second case the conversion from int overflows, but the multiplication overflows again (in the other direction)
14:16emacsenIs there a method that I can run on an object (or a class) that will give me a list of methods availalble for it?
14:17durka42c.c.repl-utils/show
14:17emacseneg if I pass it a list, it will return sort, first, rest
14:17durka42scratch that
14:17durka42show is not quite that smart
14:17emacsendurka42: Well repl-utils doesn't work for me. It doesn't build properly, and secondly, as that was the suggestion people gave me last time, that's not what I want, show. :)
14:18durka42i guess that's hard to do without types :)
14:18durka42emacsen: it doesn't build?
14:18emacsendurka42: Not AFAICT. It doesn't import at least
14:18durka42ah, well you don't import clojure libs, you use or require them
14:18emacsenthe NS is there but it doesn't work
14:18slashus2durka42: Is that the correct behavior for *?
14:18emacsensure, okay, require
14:18Chousukeemacsen: the problem is that clojure functions don't have type information by design (except maybe a type tag... sometimes)
14:18emacsenbut contrib.math works
14:19emacsenChouske: how does CL do it?
14:19durka42slashus2: define "correct"
14:19emacsenyou can ask CL for this... I forget how but I know you can
14:19ChousukeI have no idea.
14:19slashus2Was it designed to behave that way.
14:19durka42~bat signal
14:19clojurebot/summon Chouser
14:19durka42hmm, no, the other one
14:20durka42has this been discussed on the group?
14:21slashus2Are you talking to me?
14:21Chousukeemacsen: it'd be quite difficult to figure out in general what a function can consume
14:21durka42slashus2: yeah
14:21slashus2No. I was playing around with math operations, and discovered this behavior.
14:22durka42http://clojure.org/news seems to suggest ("integer arithmetic should not silently produce corrupt values due to overflow") that the behavior of int is wrong
14:22durka42on the other hand, casting to int isn't really arithmetic
14:23Chousukeyeah, but using primitive ints should still raise exceptions :/
14:23Chousukeand it does; so I think the cast should too.
14:24slashus2I will bring it up in the group.
14:24durka42(isa? 3M Number)
14:24durka42,(isa? 3M Number)
14:24clojurebotfalse
14:24durka42,(isa? 3M BigInteger)
14:24clojurebotfalse
14:24ChousukeI think it goes the other way
14:25durka42,(instance? BigInteger 3M)
14:25clojurebotfalse
14:25Chousukehmm
14:25Chousuke,(class 3M)
14:25clojurebotjava.math.BigDecimal
14:25durka42,(instance? Number 3M)
14:25clojurebottrue
14:25durka42(.intValue 3M)
14:25durka42,(.intValue 3M)
14:25clojurebot3
14:26durka42,(.intValue 3566666666666666666)
14:26clojurebot-1293636950
14:26durka42but that was a long, not a BigDecimal
14:26durka42,(.intValue 3566666666666666666M)
14:26clojurebot-1293636950
14:26emacsenChouske: http://lisp.org/mop/dictionary.html#specializer-direct-generic-functions is sorta what I'm talking about
14:27ataggartso, the reason the first one "worked" and the second threw an exception is because in both cases the args were wrapped, but the result of * in the first case didn't wrap, wheeras it would have wrapped in the second?
14:28Chousukeemacsen: hm
14:28Chousukeemacsen: I don't think that does what you think it does. or maybe I don't know what you think it does.
14:29durka42ataggart: i think so
14:30emacsena friend showed me it can /sorta kinda/ do what I want
14:30emacsenbut it's not pefect, that's true. I just see it as an impediment. You have to keep the reference docs open a lot, I'm finding
14:30Chousukeso what does it actually do?
14:31Chousukehow do you call it? :/
14:31emacsenI'm getting my more CL knolwedgeable friend to come and explain it
14:31emacsenI, in truth, have never used it :)
14:32technomancyemacsen: generics are a different thing; I don't think that would work for normal functions.
14:32Chousukearen't the specialisers limited for generics in CL?
14:32Chousukeor am I misunderstanding if I think it means the dispatch functions you can use
14:33emacsentechnomancy: In truth I did so little CL I never used CLOS
14:33emacsenso maybe my solution is wrong, but I can't think of a solution
14:34technomancythat's because CLOS is ... hard to remember
14:34Chousukethe dispatch function for clojure's multimethods is arbitrary, but I guess you technically could look up multimethods if you have the actual function object used as the dispatch :P
14:34ataggartemacsen: what problem are you trying to solve?
14:35slashus2ataggart: I figured out the problem
14:35slashus2In Numbers.java multiply with the signature int int does an overflow detection.
14:35emacsenI'm finding the reference docs a bit... scattered
14:35slashus2it tests if y != 0 and if ret/y != x
14:35emacsenand so it'd be nicer/easier if I could simply ask a function for help
14:36Chousukewell, there's find-doc
14:36ataggartand regular doc
14:36slashus2In this rare case ret/y is equal to x ret: -1029352108 x: 2 y: -514676054
14:36emacsendoc is useless as you have to know the method you want
14:36slashus2,(/ -1029352108 -514676054)
14:36clojurebot2
14:36Chousukefind-doc isn't :)
14:36Chousukeit takes a regexp
14:37slashus2Does that make sense?
14:37emacsenChouske: true. What would also be very nice would be a find-doc that could operate over every NS in your classpath
14:37ataggartsomeone needs to start a clojure.contrib.esp project
14:37Chousukethe reference on the web page is pretty well interlinked nowadays at least.
14:37emacsenChouseke: yeah... it's gotten better. It should also be doownloadable :)
14:38Chousukeemacsen: I don't think that's possible in a practical manner.
14:38emacsenChouseke: downloadable docs are impractical?
14:38Chousukeno, I mean searching the entire classpath
14:38Chousukeyou need to (require) stuff to get the metadata.
14:38emacsenI've seen many people rewrite stuff in contrib
14:38technomancyyou could write a spider that could auto-require stuff if you didn't mind bloating memory usage
14:39Chouser_I suppose you could grep the classpath. :-P
14:39technomancyin fact, it'd probably be three lines of code using file-seq
14:39Chousukeemacsen: rewrite?
14:39emacsenusually they rewrite the functions poorly too ;)
14:39technomancythen find-doc would work
14:39emacsenChouske: they need something that's already written
14:39Chousukeah, right.
14:39Chousukethey should use the doc index on the site!
14:40Chousuke:P
14:40Chousukehttp://code.google.com/p/clojure-contrib/wiki/ApiDocIndex there :)
14:40emacsenChouseke: Maybe you're right that my original idea was poor but the docs should be easier to search... and search offline :)
14:41emacseneven if that's with a separate tool ala pydoc
14:41Chousukehmm
14:41Chousukewell, that shouldn't be too difficult
14:41Chousukethey ARE already generating the wiki markup after all
14:41emacsenand the scope is certainly less
14:41ataggartmy browser lets me save webapges...
14:41emacsenattaggart: My editor lets me save browsers ;)
14:41Chousukeshouldn't be too difficult to adapt it to generate something else.
14:42emacsenChouseke: yeah I should read find-doc and see if there's a simple way to generate a meta-index of terms
14:42technomancyemacsen: (map load-file (filter #(re-find #"\.clj$" %) (map #(.getPath %) (file-seq (java.io.File. "src/clj/clojure-contrib/src")))))
14:43technomancythen find-doc will work over all contrib
14:43emacsenfair nuff :)
14:44Chousukeemacsen: there's gen-html-docs.clj in contrib too
14:44emacsenChouske, but no one knew about it :-P
14:44Chousukethough is that actually the script used to generate the wiki docs? :/
14:48emacsenwell, that solves the problem enough, having docs
14:52emacsenBTW, since I heard about them in the interview, are these "ports" official?
14:52emacsenclojurescript and the C# one?
14:52technomancywhat does "official" mean?
14:52emacsenWell, good question
14:52emacsenWhat is a Clojure? :)
14:52emacsenis there a test suite?
14:52technomancyClojure is still implementation-defined.
14:53technomancythe test suite is ... not a high priority.
14:53technomancyto put it kindly
14:53emacsenwell a test suite is important when you want to define the API
14:53Chouser_implementation-defined, for an open source project, is Good.
14:53emacsenChouser: for a while. then it's bad :)
14:53technomancyespecially at this stage
14:53emacsenyes, at this stage
14:53Chouser_what makes it become bad?
14:54emacsenChouser: multiple implementations
14:54emacsenlook at, say Python. There are seven or eight Pythons
14:54ataggartclojure.org <-- that one
14:54emacsenbut you can know how complete they are by how they perform the test suites
14:54emacsenataggart, then why would Rich mention the others?
14:54unknown_lameremacsen: so what I am supposed to explain hrm?
14:55emacsenunknown_lamer: the discussion's over. There's no good way to do it
14:55ataggartcuz he was asked a question about it. Some people have an aversion to the JVM
15:03Chousukeemacsen: the lack of a spec is both a blessing and a curse
15:04Chousukeand I don't think the ports are in any way official
15:05Chousukethough it'll be an interesting problem to solve if at some point you'd like compatibility between a .NET clojure and the JVM clojure.
15:06Chousukebut the tight integration with the host platform makes that non-trivial.
15:07ataggartif the effective evidence of compatibility is something written for one can run on the other, then I imagine you won't ever get it between JVM and .NET clojures
15:07emacsenYeah that's why I asked why bring up unofficial ports. It's like opening the perverbial pandora's box
15:07hiredmananyone know anything about the new G1 garbage collector? like what the deal is with "production use of G1 is only permitted where a Java support contract has been purchased."
15:07Chousukeataggart: well you could, if you don't use host interop
15:07technomancyhiredman: it means Oracle's Reign of Terror has begun.
15:08technomancyhide you women.
15:08emacsentechnomancy: You mean "your"?
15:08ataggartchousuke: my point is the interop is inherent to clojure
15:08hiredmanhttp://java.sun.com/javase/6/webnotes/6u14.html
15:08technomancyemacsen: yes
15:08emacsenor "You, women, hide!" ;)
15:08technomancyactually both work.
15:08Chousukeataggart: well, kind of.
15:08hiredman-XX:+DoEscapeAnalysis looks juicy
15:08Chousukeataggart: you *could* write wrappers for it all.
15:08Chousukehiredman: go ahead and do a benchmark!
15:09hiredmanChousuke: :(
15:09Chousuke(I can't, I'm on OS X with not u14 ;()
15:09Chousukethe latest java for OS X is... u13
15:10hiredmanheh
15:10hiredmanI think the only place I can run the latest ins my shiny new (delivered today) vista desktop at work
15:10ataggartI'm on a 32-bit OS X... no java 6 for me.
15:10technomancydo openjdk versions get numbered differently than sun's?
15:11Chousukeataggart: PPC or older intel? :/
15:11ataggartintel
15:12ataggartI'm just waiting for the new macbook pro to be released, then I'll be set
15:12slashus2This isn't the fault of the multiply function. The argument has already overflown by the time it reaches the multiply method. Maybe adding overflow detection to the coercion functions?
15:12ataggartslashus2: the (int... is you saying you want the overflow
15:13ataggartor rather, are willing to have it for the sake of speed
15:13slashus2When you coerce something with int maybe it could give you an overflow exception if it overflows?
15:13Chousukeataggart: are you sure? operations with the cast int DO throw exceptions.
15:13jlbHey all, I'm pretty new to Clojure, and I've run into a casting issue... I have a javax.naming.InitialContext instance which I'm using to look up a remote EJB interface... in Java, I cast the return value to the interface class of the EJB... this doesn't work in Clojure, or at least not the way I'm trying to do it.
15:13Chousukeataggart: there's unchecked-add etc. for when you don't want them
15:14slashus2Chousuke: I found a fringe case where the overflow detection fails.
15:14jlbIn particular, (cast foo.bar.InterfaceName x) throws a ClassCastException
15:14Chousukethat's a separate bug I think :)
15:15ataggartiirc, numberc values will get autopromoted, unless you say something like (int...), and matematical operations on real ints which would result in the answer being wrapped will throw an exception
15:15Chousukejlb: cast doesn't actually do anything
15:15ataggartand iirc, there's a way to turn even that excpetion stuff off
15:15Chousukejlb: it just checks if x is of the said interface.
15:16jlbChousuke: understood, but it is the simplest test indicative of the problem
15:16slashus2Chousuke: I don't think so. The multiply function does all it can to see if it's result is overflown, but if it gets an argument that has been coerced by int (and overflown) or something, an unexpected number could be sent to the multiply method.
15:17Chousukeah, of course. so there needs to be an overflow check in the int cast :/
15:17slashus2right
15:17slashus2I think it needs it to live up to the promise of correct math.
15:18technomancyclojurebot: math?
15:18clojurebotmake a note of http://scienceblogs.com/goodmath/2006/11/the_c_is_efficient_language_fa.php it is yet another article about picking c or c++ for performance being naive
15:18jlbthe lookup returns a proxy object which I don't fully understand all the inner workings of, but I can cast it in Java but not in Clojure
15:18technomancyclojurebot: math is hard.
15:18clojurebotc'est bon!
15:18ataggartbut you're asking for possibly non-correct *values* by forcing it to be an int
15:18Chousukeataggart: I think the docs say that operations on (int foo) are still checked; just not boxed.
15:19slashus2ataggart Surely I don't want it to overflow though.
15:22hiredmanjlb: clojure is a dynamic language, casting is generally not something to care about
15:22ataggartchousuke: nope, only mathematical operations are checked
15:22hiredmanjust call your methods
15:22ataggart 'int just does a java (int) cast
15:23jlbhiredman: well that's my problem, I do that and I get a ClassCastException (trying to just call them)
15:23hiredmanjlb: pastebin some code
15:25hiredmanlisppaste8: url
15:25lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
15:25hiredmanjlb: you might just need to type hint with the correct class
15:25ataggartand for Numbers (i.e., non-primitive numeric types), it calls intValue(), which is specified to behave as it does for primitives, namely overflowing.
15:25jlbhiredman: will do
15:25hiredmanI think there is (or was) an issue with private classes
15:26jlbhiredman: tried that, didn't work, though it's possible I screwed it up
15:26hiredmannot being able to reflect properly on them
15:26slashus2ataggart: I see.
15:28ataggartnot checking on 'int seems a reasonable thing to me, since the intent id speed and you generally don't cast to int after already having a large number.
15:28hiredmanjlb: have you run (class ...) on whatever to see what class it is?
15:29slashus2ataggart: Moral of the story is. Don't cast a large number to an int. Rely on the mathematics operations to check for overflow?
15:29ataggartya
15:29ataggartwhich is probably what's happening anyway
15:30ataggartlarger numbers as a result of mathematical operations. typically you'd cast to int before such ops
15:30ataggarthence you'll get an exception
15:30slashus2fair enough
15:31jlbhiredman: http://pastebin.com/m49b0f7d9
15:35hiredmanjlb: can you paste the exception output somewhere too?
15:37jlbhiredman: yep - http://pastebin.com/d855920d
15:38hiredmanthats the whole exception?
15:38jlbI'm going to guess I can make it work by writing some java on the client side and returning the cast-ed interface from it, but seems like it "should" work in Clojure directly
15:38jlbyep
15:39ataggart(PortableRemoteObject/narrow foo MyClass)
15:39hiredmanwhat is the method signature for lookup?
15:40jlbObject lookup(String)
15:40ataggartjib: have you tried using PRO.narrow ?
15:40alrex021Is there an up to date off-line version of the Clojure reference? (pdf or html format)
15:41ataggartalrex021: for html, your browser probably lets you save webapges
15:41jlbataggart: trying that now
15:43jlbataggart: same exception
15:43ataggarthm
15:43ataggartand the java verions is working?
15:43jlbyep, been using it for months :)
15:43alrex021ataggart: would be really cool if it was downloadable so the html links work nicely.
15:45ataggartjib: what's the result of (ancestors (class foo)) ?
15:45rich_holygoatafternoon folks
15:45rich_holygoatanyone going to Java One have a Refer A Friend code they'd like me to put in my registration?
15:46rodgertqholy goat, is that like a regimental goat?
15:48jlbataggart: #{java.lang.Object java.io.Serializable org.jboss.ejb3.JBossProxy java.lang.reflect.Proxy foo.bar.FooEJBRemote}
15:48rich_holygoatrodgertq: heh. it's a pun :)
15:48ataggartand foo.bar.FooEJBRemote is the class you've been trying to cast to?
15:49jlbright
15:49ataggartthat's messed up
15:49jlb(it's an interface)
15:49ataggartya
15:49ataggartmy first EJB project was in 2000
15:49ataggartols skool
15:50dnolenGoogle Wave Server is written in Java, that will be fun to code against with Clojure
15:50jlbI'm relatively new to it (1 year). Seems like things used to be a lot more painful. :)
15:50dnolenhttp://groups.google.com/group/google-wave-api/browse_frm/thread/a12aa99aa83ee7f9
15:52ataggartjib: the only other thing I can think of is either that class is not in the classpath (doubtful) or that its from a different classloader
15:52ataggartnot in the classpath would be a different excpetion, so ya not that
15:53ataggartI thought PRO.narrow handled the classloader issue
15:53jlbataggart: right, I ran into that... it seems that the Repl doesn't pay attention to CLASSPATH? (env variable)
15:54hiredmanuh
15:54hiredmanclasspath is handled by java
15:54hiredmanif you launch java with the -cp flag java ignores the CLASSPATH environment variable
15:55triddelldnolen: I'm just finishing yesterdays presentation now... very interesting.
15:57jlbhiredman: that's what I thought, but I installed jline and clojure in the java extensions folder, so they get picked up automatically... my command line to run the Repl is: java jline.ConsoleRunner clojure.lang.Repl, so I would expect CLASSPATH to be honored by Java, but I had to (add-classpath) for everything
15:57hiredman!
15:58hiredmanadd-classpath is your problem
15:58hiredmandon't ever use it and expect it to work
15:58ataggartclasspath being not mutable during runtime
15:59ataggartjib: given that one of the ancestors of foo is the class you're trying to cast to, I'd bet it's a classloader problem
16:00jlbok
16:00jlbI'll try to figure out what is going on w/ CLASSPATH then
16:00ataggart(= (getClassLoader (class #{})) (getClassLoader (class foo)))
16:00ataggarttry running that
16:00ataggartI bet it'll be false
16:00hiredmanjlb: you could always just -cp $CLASSPATH
16:03ataggartor more appropriately: (= (getClassLoader (class foo.bar.FooEJBRemote)) (getClassLoader (class foo)))
16:04jlbis there a canonical way to print the classpath from inside clojure?
16:05stuartsierra(System/getProperty "java.class.path")
16:05dnolentriddell: yes, I'm thinking about adopting it for one our projects. Google Wave + Clojure.
16:05Chouser_The problem has to do with the fact that there's not really just one classpath, I think.
16:05Chouser_Each classloader can have a classpath, can't it?
16:06ataggartthe VM has a classpath
16:06jlbSo (System/getProperty) returns the right thing
16:06j-dotis it possible to call new with the result of an expression?
16:06ataggartbut classes emitted by different classloaders are not equivalent
16:06j-dote.g. (new (type []))
16:06j-dotI mean to say, is there some way to do the equivalent?
16:09ataggartif the returned value is a Class, then (.newInstance c)
16:09Chousuke,(.newInstance (class []))
16:09clojurebotjava.lang.InstantiationException: clojure.lang.PersistentVector
16:09Chousukehmm
16:09ChousukeI guess it needs parameters
16:09ataggartno public constructor
16:10Chousukeah, heh
16:10ataggarterm, well
16:10ataggartwow it's hard to read this non-standard java
16:10Chousukenon-standard?
16:10j-dothmmm ...
16:10ataggartnot a criticism, but it's just... differently written
16:10jlbSo if I run java with -cp /path/to/foo-api.jar, it fails to find FooEJBRemote when I try to import it... I must not be understanding something.
16:10Chousukeyou nean the clojure source code?
16:11ataggartchousuke: ya
16:11Chousukeit has peculiar style
16:11Chousukebut at least it isn't like the iTerm source code :P
16:11ataggartok, no arg constructor is protected
16:11ataggartso ya
16:12Chousukethe whole project could use a =G in vim for all its files.
16:12ataggart,(.newInstance (class "test"))
16:12clojurebot""
16:12ataggartta-da!
16:12j-dotjlb: is that your full classpath, just the one jar?
16:12j-dotthanks ataggart
16:13jlbj-dot: no, but now I'm trying to eliminate possibilities... I should NOT get a ClassNotFoundException for FooEJBRemote, correct? (even if it depends on something else which isn't found?)
16:14jlb(If something isn't found, I should get an exception for the not found thing?)
16:14ataggartCNFE means something is missing from the classpath, CCE means different classloaders (or just a real error)
16:14j-dotjlb: no, I don't believe you should .... right, the exception should be for the missing thing
16:15ataggartyay! I can contribute to #clojure :)
16:15Chousuke:p
16:15Chousukegot a CA in?
16:15jlbataggart: right... I think you're right about the classloaders, and perhaps using (add-classpath) caused that problem... so I'm now trying to figure out why it doesn't see my classes based on CLASSPATH (or -cp)
16:16ataggartjust so I'm clear on the context, you have an ejb server runing somewhere, and you're using the repl to act as a client to that server, right?
16:16jlb(I'm in the same directory that my plain Java code is built in, with the same classpath, etc... so the classpath should "just work")
16:16ataggarterm, no
16:16ataggartonce you us e-cp, the current directory isn't automatically used
16:17jlbataggart: right... I have a long and annoying Java client for exercising various things, and it would be much better to use clojure :)
16:18ataggartit's been a while since I've written java that *didn't* run inside a server setup
16:19ataggartso -cp ./:clojure.jar:jline.jar:ejb.jar:other-libs.jar
16:19ataggartyour cp looks something lke that right?
16:21jlbI stuck jline and clojure in the existing java classpath (/Library/Java/Extensions on the Mac) ... so my CLASSPATH (or -cp, I've done both) includes all of the ejb stuff and my ejb-client jars
16:22ataggartugh
16:30technomancyis anyone using hbase and/or capjure?
16:30technomancyI spend a day earlier this week trying to get it going with disappointing results; would love to hear some awesome stories about it that could get me motivated as I try again.
17:11duck1123Does anyone know if it's possible to kill a slime connection without killing all of the connections?
17:12duck1123if I try to kill it from the *SLIME Connections* buffer, it kills the server
17:13duck1123and if I M-x slime-disconnect, it disconnects all of my connections
17:16technomancyduck1123: I've found it's much easier to stick to one slime connection per emacs instance
17:18duck1123technomancy: right, but sometimes I accidentally open a second one, and I want to cut back to just one
17:20duck1123I suppose I could add some logic to my connection fn that checks if I'm connected, but I was just wondering if there was a way if I already have multiples
17:21technomancyjust find the second *inferior-lisp* buffer and kill it
17:21technomancythat will disconnect you
17:22hiredmanwhats the url for that loop thing?
17:22duck1123I'm not using *inferior-lisp*, I'm running a compojure-jetty server and use slime-connect to connect to the running server
17:23technomancyduck1123: if you use slime-connect, it creates an inf-lisp buffer in the background
17:23technomancyyou just usually don't interact with it, but it's there
17:25duck1123ah ha. it's actually ' *cl-connection*' but if I kill that, it'll close just one of the connections, thanks
17:25slashus2Do commits run concurrently in clojure? Talking about transactions.
17:27technomancyslashus2: I think as long as they don't touch the same refs they should
17:27slashus2So transactions working on the same ref are locked?
17:32duck1123does it actually use locking? I thought I heard that you didn't need locking with Clojure. Or was it that the STM took care of all of that for you?
17:32slashus2I was talking about internally.
17:35technomancyslashus2: I don't know if it uses locking internally, the answer rhickey always gives is that you shouldn't care how it works, you should only care about the guarantees it provides
17:35hiredmanError: no `server' JVM at `C:\Program Files\Java\jre6\bin\server\jvm.dll'.
17:35hiredmanD:
17:35technomancyhiredman: your slashes are backwards.
17:35technomancyunless... is it backwards day? /me checks his calendar.
17:35slashus2technomancy: Someone is creating a similar STM in CL, and I was trying to figure some internals out for them.
17:35arohnercould be backwards OS day
17:36arohner:-)
17:36technomancyslashus2: probably no way around reading the source yourself if that's the goal. =)
17:37slashus2I was trying to. Just needed to confirm.
17:37dnolenslashus2: isn't there CL-STM?
17:38slashus2Could be, but I think this other person has slightly different goals.
17:41duck1123I would almost bet that there are locks somewhere in the stm impl, which is just where I want them. (as opposed to in my code)
17:47scgilardiclojure/src/jvm/clojure/lang/LockingTransaction.java implements the guts of "dosync". It uses locks.
17:48duck1123makes sense, I couldn't figure out how you would do what dosync does without using locks somewhere
17:52slashus2yes LockingTransaction.java is neat.
17:55hiredmanhow do I install hotspot on windows?
17:55hiredmanapparently the 32bit jre for windows does not come with hotspot
17:55Chousukehuh
17:56Chousukethat would be weird.
17:56hiredmannot "would", its a fact
17:56Chousukeis HotSpot the name for the server jvm then?
17:56hiredmanyes
17:57ChousukeI thought it was the name of the JIT/Interpreter combo
17:57Chousukeanyway, perhaps you need the java SDK
17:57Chousukeor some enterprisey version :P
17:58technomancyhotspot comes in client and server varieties
17:58Chousukehmm, yeah
17:58Chousuke"Java HotSpot(TM) Client VM (build 1.5.0_16-135, mixed mode, sharing)"
18:00hiredmanoi
18:00Chousuke(java -server -version gives the other one)
18:00clojurebot?
18:01Chousuke~botsnack
18:01clojurebotthanks; that was delicious. (nom nom nom)
18:05replacaI have to say I get a warm feeling inside everytime I type ^C-RET in emacs/slime and get a pretty printed macro expansion.
18:07Chousuke:)
18:07Chousukecertainly helps
18:07Chousukethe non-pretty-printed expansions were a bit of a pain sometimes :p
18:08replacaI hope Chouser, stuartsierra and others get that feeling lots, since they've added so much
18:24replacaalso, after years of lisp-2s, I *really* like being in a lisp-1
18:24technomancyreplaca: seriously
18:25replacaI never knew the pain I was feeling until it was gone :-)
18:25arohnerI started playing with CL and scheme around the same time
18:25arohnerI dropped CL *because* it was a lisp-2
18:26replaca(let [f (fn [x y] ...)] ...) is bliss
18:26replacanever got very far into scheme, so this is the first time I've had the joy
18:26ataggartI still haven't grokked the difference
18:27arohnerataggart: lisp-2s require special syntax to pass fns around
18:27technomancyataggart: it's really awkward to keep functions in variables in lisp-2s
18:27replacaataggart: whether functions live in a different namespace from other stuff
18:27replacaso you end up with different syntax and idioms around funcs than other things
18:28Chousukealso, lots of funcalls :P
18:28ataggarthmm... seems kind of antithetical to FP
18:28replacae.g., in CL you need funcall to call a func in a variable
18:28Chousukewhich aren't very fun at all!
18:28replacaataggart: yeah
18:28hiredman"Elapsed time: 52.964274 msecs"
18:28hiredmanhmm
18:28ataggartwell, clojure is my first lisp (not counting reading scheme in SICP)
18:28Chousukehiredman: for what?
18:29hiredmanChousuke: the ring thing
18:29hiredmanwith N = 1000
18:29Chousukewhere? I haven't been following the channel :/
18:29hiredmanhttp://groups.google.com/group/clojure/browse_thread/thread/5e0c078d0ad8b8bc
18:31Chousukethat with escape analysis on?
18:31technomancyanyone else find that they're avoiding adding docstrings because then the arg list isn't right next to the fn name?
18:31Chousukewhat about without.
18:31technomancyor is that just me?
18:31hiredmanChousuke: haven't tried
18:31hiredmanI just messing with Queues
18:32Chousukecan't do them myself either :(
18:32Chousukewould require installing Linux and probably the JVM manually too
18:32Chousuke:P
18:32hiredmanerg
18:33hiredmanslowed down
18:33hiredmanactually, I think it is about the same, with about 10milliseconds of jitter either way
18:35Chousukemaybe 1000 is too small... the JIT won't optimise it.
18:35eevarChousuke: if you're on debian, getting Java is just: aptitude install openjdk-6-jdk -R
18:35hiredmanwell, not a lot of allocation and gc going on in this code anyway
18:35Chousukeeevar: will it be the latest version though? :)
18:36Chousukeright.
18:36Chousukeprobably not a good benchmark of escape analysis.
18:36Chousukenot that I really know what I'm talking about ;(
18:36hiredmanmmmm
18:36eevarhmm.. I have 6b14-1.5~pre1-5 -- no idea how recent that is
18:37hiredmanso nice
18:37eevardebian testing, tho -- not stable
18:37hiredmanmy machine at work just went from and old p4 laptop to a core 2 quad desktop
18:37hiredmanb14 is the latest
18:38Chousukequad core? neat.
18:38hiredmanit sure is
18:38Chousukenow you can have up to three stuck mplayer instances without noticing anything.
18:39scgilardiI recall (perhaps incorrectly) from Cliff Click's writing or presentation that hotspot doesn't even think about JIT compiling something until it happens order of 10,000 times. He has a nice writeup on microbenchmarks in general and in relation to hotspot somewhere in the interweb.
18:39Chousukemplayer used to often go into an infinite loop when I quit it, and the only way to tell it happened was to listen to the fan.
18:40hiredmanheh
18:40Chousukescgilardi: I've heard the 10k number before too.
18:40hiredmanbah
18:40hiredmanaudio from hulu.com isn't working now
18:52technomancyif you've got an object that implements Map, how do you make a clojure map out of it?
18:58Chousukehmm.
18:59technomancyapart from reducing over the keyset
18:59ChousukeI think you need to do that.
18:59Chouseryou can use 'get' on it just like a clojure map
18:59technomancyok; I guess it's not too awkward
18:59eevarclojure map, Map instance, what's the difference?
19:00Chousukeeevar: a Map instance is not necessarily persistent :)
19:00Chouserclojure.lang.IPersistentMap vs java.util.Map
19:00hiredman,(clojure.lang.IPersistentMap. {})
19:00clojurebotjava.lang.IllegalArgumentException: No matching ctor found for interface clojure.lang.IPersistentMap
19:00Chousukehiredman: it's an interface
19:01hiredman,(clojure.lang.APersistentMap. {})
19:01clojurebotjava.lang.IllegalArgumentException: No matching ctor found for class clojure.lang.APersistentMap
19:01Chousuke,(class {})
19:01clojurebotclojure.lang.PersistentArrayMap
19:01hiredman,(clojure.lang.PersistentArrayMap. {})
19:01clojurebotjava.lang.ClassCastException: clojure.lang.PersistentArrayMap cannot be cast to [Ljava.lang.Object;
19:01Chouserif you want to do anything other than make a seq of it, or look up an item, you'll need to copy it into a clojure map
19:01Chouser,(supers {})
19:01clojurebotjava.lang.ClassCastException: clojure.lang.PersistentArrayMap cannot be cast to java.lang.Class
19:01Chousukethe seq will be a weird one too :/
19:01Chouser,(supers (class {}))
19:01clojurebot#{clojure.lang.IMeta clojure.lang.Obj clojure.lang.Counted java.lang.Runnable java.io.Serializable clojure.lang.AFn java.lang.Object java.util.concurrent.Callable clojure.lang.IPersistentMap clojure.lang.IFn clojure.lang.APersistentMap clojure.lang.IPersistentCollection clojure.lang.IObj clojure.lang.Associative java.lang.Iterable java.util.Map clojure.lang.Seqable}
19:01Chousukeit just contains a bunch of Entries :p
19:01Chouserbut the destructure, so it's ok
19:02Chousuke,(into {} (java.util.HashMap. {1 2 3 4}))
19:02clojurebot{3 4, 1 2}
19:02Chouser,(java.util.HashMap {:a 1, :b 2})
19:02clojurebotjava.lang.ClassCastException: java.lang.Class cannot be cast to clojure.lang.IFn
19:02Chousukecool.
19:02ChouserChousuke: uh, right, what you said. :-)
19:02technomancy(apply hash-map (seq my-map))
19:02technomancymuch better than reducing with assoc
19:03Chouserinto is roughly the same there.
19:03Chouser(apply array-map my-map) may have slightly different results.
19:03Chousukeapply might be a bit faster
19:03Chousukeinto uses reduce conj I think
19:03technomancyoh crap... but in this case my keys are all byte arrays, and I want strings. lousy.
19:04Chousukehmm
19:04Chouserfear not! zipmap
19:04technomancyoh! I just read about that last week.
19:05Chousuke(apply hash-map (map (fn [k v] [(convert k) v]) mymap))
19:05technomancythat's probably better actually
19:06Chousukeoops. the parameter list has to be [[k v]]
19:06Chouser(zipmap (map convert (keys mymap)) (vals mymap)) ; why not?
19:09technomancyChouser: oh! didn't realize I could call keys on mymap; thought that just worked on PersistentHashMaps
19:09technomancywas thinking I'd have to convert it to a clj map, split it apart, and then reassemble it, but that's not true
19:09technomancyyay interfaces!
19:45hiredmanclojurebot: what do you think of scala?
19:45clojurebotexcusez-moi
19:45hiredmanclojurebot: have you ever tried scala?
19:45clojurebotExcuse me?
19:49RaynesI think the syntax hurt's my eyes considerably.
19:54hiredmanclojurebot: what do you think of scala?
19:54clojurebot"you can usually accomplish a lot by laboriously enumerating type arguments everywhere." -- seen in #scala
20:12gnuvince_Has anyone tried the new 6u14 Sun JVM with escape analysis? Does it help with the performance of Clojure programs?
20:14technomancygnuvince_: was going to, but I thought I'd better wait for approval from Oracle first.
20:15slashus2hmm?
20:15gnuvince_technomancy: heh
20:15gnuvince_It's not yet in Arch's repos, so I can't test it myself
20:15gnuvince_(don't feel like installing by hand)
20:16slashus2I can go download the binaries on my Linux system.
20:22slashus2gnuvince_: What would you like me to test?
20:25gnuvince_One guy on Reddit mentions a numerical test
20:25gnuvince_Try something involving numbers
20:26gnuvince_Not sure what's a numerical test that's long though
20:26slashus2(+ 1 2) seems to be a little slower in the new JVM.
20:26clojurebot3
20:26gnuvince_Personally, I want to try it on my own Clojure project
20:27gnuvince_But making a good test would involve downloading 100+ MB of files to analyse
20:27slashus2gnuvince_: Do you think that the upcoming chunked seqs are going to have a great impact on your project?
20:28gnuvince_I kind of doubt it
20:28gnuvince_My issue doesn't seem to be the time required to process data, but the creationg of data structures in tight loops
20:28slashus2Scratch my last comment. I don't think that little addition thing is any different.
20:29gnuvince_Though I guess one of my main "loops" is a big reduce call
20:29gnuvince_So, I guess I'll have to see
20:30slashus2When I launch clojure with -XX:+UnlockExperimentalVMOptions -XX:+UseG1GC the jvm crashes
20:31slashus2so much for the G1 garbage collector
20:31gnuvince_:)
20:35slashus2I get better times with the new vm with (dotimes [_ 10] (time (reduce + (range 1000000))))
20:36slashus2250 ms compared to 284 ms
20:37slashus2comparing with and without escape analysis
20:37gnuvince_,(count (ns-publics 'clojure.core))
20:37clojurebot459
20:38slashus2These micro-benchmarks don't say much.
20:49gnuvince_About the new chunked stuff, do I need t change something in my program or does it just happen when I svn up?
20:50slashus2I think it is going to be transparent for the most part.
20:51slashus2gnuvince_: I just compiled your code clj-starcraft
20:51gnuvince_You'll need replay files now
20:51gnuvince_Hang on
20:53gnuvince_I made a tarball of 100 of them
20:54Chousergnuvince_: the chunked stuff isn't all in yet
20:54gnuvince_Chouser: ok, but like I said earlier, I think I'll get a bigger speed improvement if I try to move some processing out of those tight loops
20:56gnuvince_Hang on, I'm uploading the file...
21:08slashus2gnuvince_: large file?
21:08gnuvince_Not really, but my upload bandwidth sucks
21:08gnuvince_http://senduit.com/008764
21:08gnuvince_12 MB
21:09gnuvince_(I upload at 20KB/s)
21:09slashus2okay done downloading it.
21:10gnuvince_try this command: time java -server -cp /path/to/clojure.jar:/path/to/clj-starcraft.jar clojure.main dump.clj *.rep
21:10gnuvince_On my machine, it takes about 10 seconds for those 100 files. Java take 2 seconds for the same 100 files and 12 seconds for 1050 files.
21:11gnuvince_(Clojure takes 70+ seconds for the 1050 files)
21:13gnuvince_any difference between the two JVMs?
21:13slashus2I am setting everything up.
21:14gnuvince_ok
21:14gnuvince_Sorry, didn't mean to rush you :)
21:15slashus2I am getting a strange error... java.lang.NoSuchMethodError: clojure.lang.Util.equal(Ljava/lang/Object;Ljava/lang/Object;)Z
21:18slashus2gnuvince_: Seems to be line 18
21:18slashus2in parse.clj
21:19gnuvince_the (if (= len 1)?
21:22slashus2That is where it ends.
21:24gnuvince_oh
21:24gnuvince_I didn't see the part about the error
21:24gnuvince_sorry
21:24gnuvince_hmmm
21:24gnuvince_that's weird...
21:24slashus2Is it giving you an error?
21:25gnuvince_no
21:25slashus2Let me try this on my other computer.
21:26Chouserthat sounds most like a classpath or clojure.jar issue
21:26Chousukedid you try recompiling?
21:26slashus2Yep
21:29slashus2gnuvince_: Are you using the latest svn revision?
21:29gnuvince_yep
21:30slashus2I recompiled clojure clojure-contrib and then compiled clj-starcraft with those
21:32gnuvince_Mercurial doesn't report any changes I haven't pushed
21:34slashus2hmm
21:34slashus2Now it works.
21:34slashus2I erased it and repulled it with mercurial.
21:34slashus2Seems to work now.
21:35gnuvince_ok
21:36slashus2it took around 21.5 seconds with the built in java in ubuntu 9.04
21:37gnuvince_gcj?
21:38slashus2openjdk 6b14
21:38slashus2With the binaries from sun it was about the same with 21.3. Now I will apply the special flags to the vm
21:39slashus2With escape analysis turned on it did 18.5
21:39slashus2I will run it again to confirm the improvement
21:40slashus2Second run gave 20.1.
21:40slashus2Oh well
21:40Chousukeserver or client VM?
21:40slashus2server
21:41slashus2There seems to be a slight improvement with the escape analysis turned on.
21:42slashus2With the G1GC turned on, I get 15.2 seconds
21:42gnuvince_I really should refactor the whole thing and try and move a bunch of stuff out of those loops
21:43slashus2So the G1 helps in this case quite a bit.
21:43slashus2I wish I could test it with both, but the jvm crashes when I turn on both escape analysis and the G1GC
21:46gnuvince_ok
21:46gnuvince_Thanks for the tests
21:47slashus2With EscapeAnalysis I get: 20-23 seconds With the G1GC turned on I get: 14-15 seconds
21:48gnuvince_Cool
21:48gnuvince_Still, I better clean up my code
21:48slashus2I don't think escape analysis deviated much from the run without it.
21:48gnuvince_I wonder if visualvm could help...
21:49slashus2I have that installed, but I don't really know how to use it.
21:52hiredmanhttp://blog.juma.me.uk/2008/12/17/objects-with-no-allocation-overhead/ <-- review of the ea
22:09slashus2gnuvince_: On line 104, you might want to change = to == to get a little performance boost?
22:10slashus2I am getting 13.5 after changing that and coercing cmd-size and (.position buf) to int to make (+ (int cmd-size) (int (.position buf)))
22:15gnuvince_I seem to recall trying that and not seeing a difference (though I had expected one)
22:15gnuvince_let me try...
22:17gnuvince_10.97s for = and 11.32 for ==
22:18slashus2gnuvince_: Did you try the second change?
22:18slashus2Yeah the equals thing didn't make the difference.
22:18slashus2It was the second change that made the difference.
22:19gnuvince_12.1s
22:19gnuvince_it seems to go in the opposite direction on my machine...
22:19slashus2I am using the G1GC
22:20gnuvince_I don't have it
22:20slashus2Maybe try both the changes together?
22:20gnuvince_But you see, this function is the one I should be changing
22:20gnuvince_I should not be creating those maps in that loop
22:21slashus2How are you going to go about changing it?
22:21gnuvince_I'm not sure yet
22:22gnuvince_Rewrite it in Haskell maybe? :)
22:22slashus2I think this "improvement" that I am seeing with those changes is due to the normal errors of the times.
22:23slashus2gnuvince_: That would be a neat experiment. Do you like haskell?
22:24slashus2I have been reading real world haskell, but I hit a wall when I started reading about the type system.
22:25gnuvince_I do like Haskell
22:25gnuvince_And the more I use their type system, the more I believe that static typing is probably the way to go
22:26slashus2How long did it take you to become comfortable with their type system?
22:26gnuvince_To give you an idea, I tried Haskell 4 times before I finally "clicked" with it
22:26gnuvince_And that was AFTER I had clicked with OCaml!
22:26slashus2I haven't even looked at OCaml
22:26gnuvince_Haskell is definitely *not* a simple language
22:26gnuvince_But it's worth it in my opinion
22:27slashus2Good performance?
22:27gnuvince_As for the type system, I'd say I still sometimes struggle with it
22:27gnuvince_Haskell or OCaml?
22:27gnuvince_(mind you, both have pretty good performance, although getting good performance is easier with OCaml)