#clojure logs

2008-05-26

01:15abrooksHrm. xml/emit-element does not properly escape XML entities.
01:53abrooksHas anyone use xml-stream-reader.clj?
01:53abrooksI'm properly steeped in Java to grok the context, I think.
01:53abrooksI'm looking for examples if anyone has them.
11:25rapidohow hard would it be to allow meta-data for *all* types, not only for collections or symbols?
11:31rhickeyimpossible, as many types, like String are final
11:31rhickeyand I don't want to require wrappers
11:32rapidocan't you just keep a separate global map that maps any object to its meta data?
11:32rapido(i know global is evil)
11:32rhickeythere is that
11:33rhickeyplus, the original concept of metadata coincides with data as values - with-meta produces a new object
11:33rhickeyany global cache would be identity-basec
11:33rhickeybased
11:33rhickeymetadata on Vars is an anomaly
11:34rapidostill, i feel the concept can be pushed a lot further
11:35rhickeywell, java.util.concurrent is there
11:36rapidodoes java.util.concurrent have something similar to meta-data?
11:37rhickeyno, just the tools to build the global map you want
11:39rhickeyactually, maybe not, as no concurrent identity map
11:41rapidoi have been looking at PersistentHashMap which is nice, performance wise
11:41rhickeythanks
11:41rapidobut i feel PersistentVector could be implemented similarly fast.
11:41rapidodo you know about ropes?
11:42rhickeyhow is persistent vector not similarly fast?
11:42rhickeysame data structure
11:42rapidois it possible to concatenate two vectors?
11:43rapidoin O(log(n))?
11:44rhickeyno, nothing that virtualizes concat for vector
11:45rapidoi think you should do an implementation that's optimized for vectors
11:45rhickeyof concat?
11:46rapidoconcat, head, tail, subvector etc. all the important operations
11:47rhickeyI don't think vector concat is important
11:48rhickeyhead/tail/conj/subvector are all smoking, as is initialization with an existing array
11:48rapidolet's say you have a sequence of chars
11:48Chouserrapido: wouldn't it be pretty easy to write an object that holds two (or more) vectors, and translates the operations you need to the underlying vectors?
11:49rapidofast concatenation of string would be nice not?
11:49rapidostring<-strings
11:49rhickeyThere is fast concat, it just doesn't yield a vector
11:49rapidois it lazy?
11:49rhickeylazy-cat is
11:50rapidowhere can i find fast concat and what algorithm is used?
11:50rhickeyum, the source for concat?
11:51rhickeyboot.clj
11:51rhickeygotta run
11:53rapidobut if you repeatedly concat *n* times you end up with a linear structure that resembles a linked list
11:54rapidobut if the (lazy) structure would be balanced with using a tree balance algorithm you would still have good performance for all operations
11:54rapidochouser: does that answer your question?
11:55rapidochouser: that's how the ropes data structure works, see http://ahmadsoft.org/ropes/
11:56rapidoreplace strings(=sequence of chars) with any sequence of objects
11:58ChouserYeah, I see your point.
11:58ChouserThe Clojure data structures (vector, etc.) are written in Java. There's no reason you can't write your own if you have an application that needs a certain performance profile.
12:01rapidosure. it's the old 'library' versus 'build-in' debate :)
12:02rapidonevertheless, there are many more interesting immutable data structures
12:02Chouseryup.
12:03ChouserIt'll be interesting to see how that debate plays out over time.
12:03rapidoavl trees, alpha-beta trees, etc. etc.
12:03ChouserI think Rich wants to keep the core language pretty small, which seems like a good idea.
12:03ChouserWe've got clojure-contrib as a semi-official place to offer general-purpose code.
12:04rapidoi saw (one of) his presentations which are very good.
12:04ChouserI always liked how Python gives you such a large library be default. It'll be interesting to see where Clojure ends up.
12:05rapidoi also very strongly believe that mutability is evil, but for more reasons than concurrency
12:06rapidostill, keeping mutability *out* of all the frameworks will be difficult
12:07ChouserI'm not deeply familiar with this stuff, but in order to have complete immutability, don't you need monads? I think Clojure has chosen a more practical approach of carefully controlled mutability.
12:08rapidoi've implementation my own (research) language that pushed immutability to the extreme
12:08Chouserah
12:08rapidodata, code, computations, environments are all immutable (without using monads)
12:09rapidoi've done several implementations in java, factor, haskell and (finally) scala
12:10rapidohaskell was nice but when i wanted to add io, the code turned into an ugly mess
12:10rapidochouser: do you know factor?
12:11Chousernope
12:15rapidowhat i don't understand why slava, the factor developer, has moved away from the jvm
12:15rapidoi think that was his biggest mistake
12:16rapidoyou can't beat the libraries and the cummulated thousands of man years of (compiler) research that went into the jvm
12:17Chouseryeah
12:17rapidoi think rich made very a good choice there
12:21rapidochouser: so what's your take/interest on clojure
12:21rapido?
12:26rapidogot to go... later..
13:59leafwI have just sent a feature proposal to the mailing list: embedding java code -like python weaver package. Would be great.
14:00leafwto have the best of both worlds ... convenience+power, and speed where it matters.
15:55Chouserrhickey: I'm poking at the code in the "embedded java" post to the group.
15:56ChouserImageJ beat me up, so I'm using: (def pix (into-array (for [x (range 512) y (range 512)] (+ x y))))
15:57Chouseron my computer: (time (dotimes i 10 (/ (apply + pix) (count pix)))) ; 863.762673 msecs
15:58Chouseroh, nm -- I don't have anything interesting to say yet. Sorry.
16:05Chouserwell, one thing is sort interesting: (reduce + pix) is pretty much the same speed as (reduce long/+ pix)