#clojure log - Dec 31 2010

The Joy of Clojure
Main Clojure site
Google Group
IRC
List of all logged dates

0:20 amalloy: Berengal: hey, are you on the xkcd forums? i don't read them often, but i happened across a Berengal just now recommending shell scripting

0:21 Berengal: amalloy: Yeah, that's me

0:21 tanuki: Should I get "Clojure in Action" or "The Joy of Clojure"?

0:27 amalloy: tanuki: depends what you want, i'm sure. i don't know who wrote CiA, but if you get JoC you can hassle the author in #clojure

0:28 tanuki: They cancelled "F# in Action", so I'm considering getting a Clojure book instead

0:28 (I like Lisp syntax more than ML syntax anyway)

0:33 technomancy: get the Joy of Clojure

0:34 * tanuki is a .NET developer by trade

0:35 tanuki: which is why I leaned toward F# at first

0:37 qbg: Getting closer towards a release of my syntax-rules lib

0:42 Parsing the macro usage is easy; putting together the expansion is hard

0:43 Clinteger: f#'s syntax confuses me so much

0:44 tanuki: It's not nearly as elegant as Lisp, but it's not horrible

0:44 it's just kinda goofy at first

2:12 LauJensen: Morning :)

2:25 scottj: In case anyone's interested, Arc has this interesting (and poorly documented) feature called ssyntax, which I think stands for symbol syntax.

2:28 it allows things like (inc:dec 1) => ((comp inc dec) 1), (str a!name b!name) => (str (:name a) (:name b)), ~a => (complement a), (a.b c) => ((partial a b) c), (a&b c) => (and (a c) (b c))

2:33 LauJensen: That looks really nice

2:43 scottj: it could probably be used for evil ($pr:+.10:filter.<20?&~even?.l1!l2) :)

3:41 Derander: scottj: call it a new language: "nospace"

4:20 LauJensen: Derander: only "J" gets that title

5:10 ejackson: Good Morning #clojure, and goodbye 2010 !

5:38 LauJensen: ejackson: Goodbye!! :)

5:39 ejackson: LauJensen: you're changing you're name to 2010 ? Its a bit radical :)

6:38 fliebel: morning

6:45 ejackson: morning fliebel

7:08 maacl: LauJensen: In moustache is there a way of getting at the querystring ?

7:11 raek: maacl: accessing the query params is usually done by http://clojuredocs.org/ring/ring.middleware.params/wrap-params

7:12 moustache only does four things: wrap handlers, dispatch on HTTP request URI, dispatch on HTTP method and render plain text

7:14 maacl: raek: OK, but how would I combine the two? moustache dispatch + get at the querystring when I handle the request?

7:15 raek: (app wrap-params ["foo"] {:get get-foo-handler} ["bar"] {:post post-bar-handler})

7:16 (defn get-foo-handler [{:keys [params], :as request}] ...)

7:16 maacl: did you want to select the handler by looking at a query parameter?

7:18 maacl: raek: yeah that was the idea

7:18 raek: moustache cannot do that, but you can very easily implement that yourself

7:20 maacl: raek: yes, thanks

7:20 raek: (defn dispatch-on-param [param handlers] (fn [{:keys [params], :as request}] (let [value (get params param), handler (get handlers value)] (handler request))))

7:21 maacl: this is my idea of what it could look like

7:21 calling (dispatch-on-param "foo" {"a" handler-a, "b" handler-b}) will return a handler that delegates everything to one of the given handlers

7:22 (app wrap-params ["foo"] {:get (dispatch-on-param "foo" {"a" handler-a, "b" handler-b})})

7:23 maacl: raek: yeah, looks elegant - would work after having dispatched on request and method, right?

7:25 raek: yes, you can plug it in at any place the moustache syntax labels as "(some clojure code)": http://moustache.cgrand.net/syntax.html

7:28 fliebel: If I wanted to do some sort of message queue, what would I use? Lamina looks real nice, but I need something that works transparently over a network. Could I do this with Aleph, or would it be better to use a project with a name that ends in 'mq'? Lamina over *mq would be nice...

7:28 kumarshantanu: fliebel: consider using HornetQ -- it's based on Netty and exposes HTTP interface

7:29 fliebel: kumarshantanu: Thanks, will check it out.

7:31 ejackson: fliebel: I'd suggest RabbitMQ if you're being serious, and Redis (no really) if its just a toy.

7:31 fliebel: with redis you can have something up in 10 minutes :)

7:33 fliebel: ejackson: Are you saying RabbitMQ is hard?

7:33 ejackson: fliebel: not at all, its harder than redis is all :)

7:34 rabbitmq has exchanges and queues and stuff to wrap your head around. They have a product that can survive powerdowns and other bad stuff, so neccessarily is more complex.

7:35 redis will give you a pubsub channel in no time but isn't going to be as robust, and I'm not sure how it handles multiple readers of a channel etc.

7:35 check out : http://simonwillison.net/static/2010/redis-tutorial/

7:36 fliebel: ejackson: I don't know if I need al that. What I want to do is write a little game using a message system, and use the same system later for multiplayer, either local or over a network.

7:38 ejackson: redis might work for that. at any rate, its so easy to get going that you'll lose very little finding out.

7:38 if you discover you need some clever handling of the queues, then upgrade to a proper messaging system

7:40 fliebel: ejackson: Thanks, I'll take a look at that as well.

7:40 ejackson: lemme know how you get on :)

7:40 fliebel: ejackson: I'm just in the gathering-ideas mode, so it'll brobably be a while.

7:57 bmh: What is the third argument to state-m-until?

8:01 fliebel: bmh: You could have told me it's in clojure.contrib.monads ;)

8:01 bmh: fliebel: sorry

8:02 fliebel: bmh: I don't know, but see for yourself: https://github.com/richhickey/clojure-contrib/blob/master/src/main/clojure/clojure/contrib/monads.clj#L401

8:03 bmh: ah-ha. I missed the state argument at the bottom (fn [s] ... )

9:51 duck1123: so does anyone know what I should be using for contexts in lazytest 2 now? I'd really like to find something similar to rspec's before(:each) but can't see how to do that.

9:52 If I had a var to hook onto, something like add-hook would do well for me. (that way I could wrap my bindings)

10:23 _na_ka_na_: hellos, is there a way to change 'binding in all threads in this context' kinda thing? w/o doing alter-var-root

10:24 rhickey: http://news.ycombinator.net/item?id=2054230

10:27 fliebel: rhickey: I looked as hard as I can at clojure.lang.Atom, but I still don't see why swap uses state.compareAndSet. I also came up with another alternative for the interface: Add a constructor that takes a AtomicReference. People can subclass that to customize atom in that case.

10:27 rhickey: fliebel: I thought the question was why can't it be isA AtomicReference?

10:28 fliebel: rhickey: I asked to many in one go, I guess. I figured that one out I think.

10:29 rhickey: fliebel: I think not as it applies to your suggestion right now - subclassing AtomicReference is futile as everything is final

10:29 Raynes: Intense. I've never heard such emotion rhickey before. I like it.

10:33 fliebel: rhickey: Atom is final, but AtomicReference doesn't seem to be. Or is that my mistake?

10:34 rhickey: http://download.oracle.com/javase/1.5.0/docs/api/java/util/concurrent/atomic/AtomicReference.html

10:34 fliebel: look - all the interesting methods are final

10:35 fliebel: rhickey: I… need to refresh my Java. I didn't know *methods* could be final. Thanks for clearing that up. Back to the drawing board.

10:37 rhickey: That leaves me with the swap question, why does it use state.compareAndSet? https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Atom.java#L81

10:39 It seems Atom.compareAndSet would work, and handles validating and notifying just the same.

10:40 rhickey: fliebel: it could, probably due to order of implementaiton

10:42 fliebel: rhickey: Splendid! Now, that means I can supposedly implement swap in Clojure and drop it of the interface. Objections?

10:43 rhickey: fliebel: yes

10:45 fliebel: oh

10:46 rhickey: why?

10:46 clojurebot: http://clojure.org/rationale

10:46 rhickey: aargh

10:47 nickik: rhickey: I looked at dylen a bit and i think the multimethodes are pretty cool there too. Have you thougt about implementing something like dispatch on values? http://99-bottles-of-beer.net/language-dylan-225.html

10:48 rhickey: nickik: yes, CL has dispatch on values

10:48 nickik: something like a standard dispatch function that works like dylans

10:48 rhickey: fliebel: I don't want to preclude implementations of Atom that use locks

10:48 nickik: not interested

10:49 nickik: been there, done that

10:50 if you always want values, you can use identity as a dispatch function

10:50 mixing values and dispatch fn means double lookup

10:51 fliebel: rhickey: That… Is… a good point. So much to learn still… Thanks. :)

10:52 nickik: rhickey: ah ok so its for speed reasons or are there other objectives?

10:52 rhickey: fliebel: you can interface-ize the stuff the Clojure code uses, but new interfaces that change the shape of things require design time - not a priority now

10:53 nickik: speed and simplicity

10:53 fliebel: rhickey: I understand.

10:53 nickik: rhickey: ok thanks I wounderd about that for a while.

11:00 _na_ka_na_: rhickey: In my tests I keep wanting a cousin of binding which binds across threads... is there a way out w/o using alter-var-root ?

11:01 rhickey: _na_ka_na_: what does it mean to bind across threads?

11:09 _na_ka_na_: rhickey: I mean a construct like (binding-across-threads [a 10] @(future (prn a)) works ..

11:10 but binding-across-threads can be spawned many times concurrently w/o affecting each other

11:10 I don't know how to achieve that though

11:11 rhickey: ,(clojure-version)

11:11 clojurebot: "1.2.0"

11:11 _na_ka_na_: (map deref (map #(future (binding [a %] @(future (prn a)))) (range 2)))

11:12 rhickey: _na_ka_na_: regular binding does that now in master

11:12 _na_ka_na_: oh, that's awesome! I'll take a look

11:13 how about creating a bot which runs 1.3-master on IRC ?!

11:15 ,(try (finally (doseq [_ [1 2]])))

11:15 clojurebot: _na_ka_na_: I don't understand.

11:15 Bronsa_: lol

11:16 _na_ka_na_: @(try (finally (doseq [_ [1 2]])))

11:16 I forgot how to run the Rayne's bot

11:17 rhickey: I don't have a CA can I still submit a bug on jira?

11:17 edoloughlin: Does if-let treat nil as true? My code at https://gist.github.com/761119 isn't behaving as expected.

11:17 tonyl: &(try (finally (doseq [_ [1 2]])))

11:17 sexpbot: java.lang.UnsupportedOperationException: Cannot recur from catch/finally

11:18 _na_ka_na_: ah yes thx tonyl

11:18 tonyl: doseq uses loop/recur

11:18 _na_ka_na_: , (if-let [a nil] 1 2)

11:18 clojurebot: 2

11:18 rhickey: _na_ka_na_: yes, but not a patch without a CA

11:19 _na_ka_na_: edoloughlin, are you sure your expression in if-let returns nil?

11:19 try inserting a trace

11:20 edoloughlin: _na_ka_na_ - yes. I'm using the (dbg) macro and also eval'ing it in the REPL

11:21 My actual code returns the binding-form, which is set to nil

11:24 pdk: (doc dbg)

11:24 clojurebot: Huh?

11:24 cemerick: _na_ka_na_: no, you don't need a CA to submit a bug report.

11:27 edoloughlin: _na_ka_na_ - seems I'm suffering from blame-the-compiler syndrome. As soon as I share the problem I spot the cause. Thanks.

11:35 r2q2: hi

12:10 mduerksen: do i understand this correctly: protocols always establish a type-based dispatch, so i can't implement different methods for different keywords (inside the same method, i could of course still distinguish with a cond). right?

12:11 qbg: Right

12:12 nickik: they methodes dispatch on the first argument

12:12 mduerksen: ok, thanks

12:15 r2q2: Is there any code checked in for the clojure to clojure compiler?

12:16 nickik: there is alread a clojure in clojure compiler but not an offical one

12:16 r2q2: Where is that

12:16 nickik: i cant find it anymore

12:16 somewhere on github

12:17 r2q2: ok

12:19 nickik: its kind of hard to find we talked about it in here maybe you find something there

12:21 qbg: It was also announced on the group

12:22 r2q2: Oh i found it

12:23 https://github.com/jarpiain/cljc for further refrence

12:51 TheLolrus: Hi. I'm a python programmer interested in clojure. Should I learn Java before learning Clojure?

12:51 dakrone: TheLolrus: it's not required at all

12:53 TheLolrus: OK. Would I be recommended to learn emacs? :P

12:54 headlessClown: A familiarity with the java virtual machine and classpaths isn't a bad idea but not necessarily java the language.

12:54 dnolen: TheLolrus: or NetBeans, or Textmate, or Vim, or Eclipse, or IntelliJ

12:54 headlessClown: lots and lots of clojure devs use emacs but there are other ways

12:54 clojurebot: clojure is making your sexp smile

12:55 Bronsa: Alol

12:55 TheLolrus: hmm if only there was a scribes plugin.

12:55 dnolen: TheLolrus: if you're not afraid of ruby, the cake project management tool you can pretty much use a regular text editor if you want.

12:55 headlessClown: Me personally, i tried vimclojure and the netbeans plugin before trying to learn emacs/slime/leiningen

12:56 And I'm sticking with emacs

12:56 TheLolrus: mkay. Would you guys recommend any tutorials besides the reference guide? A book perhaps?

12:57 By the way the reason I don't want to learn emacs is I'm an impatient 13 year old. :P

12:57 qbg: TheLolrus: That is a good reason to learn emacs :)

12:57 TheLolrus: heh

12:57 headlessClown: Just start using emacs for any ole text editing

12:58 TheLolrus: I mean impatient to learn all the keyboard commands and get used to it

12:58 tonyl: TheLolrus, you can use any text editor

12:58 qbg: There aren't that many for basic use

12:59 headlessClown: I'm double your age, kid, and I picked up emacs (basic command set) this last summer :p

13:00 TheLolrus: Maybe next summer when I have freedom :D

13:01 So are there any good clojure books or introductions? That explain it in detail. Then I can dive into the reference guide.

13:01 dnolen: TheLolrus: have you done much functional programming before?

13:02 headlessClown: There are couple on the book shelf and a couple that are releasing soon.

13:02 TheLolrus: well. Python has functions. I have tried C a few times but never got far in it. xP

13:02 so not much.

13:02 qbg: Functional programming is more than just functions

13:03 TheLolrus: I thought so

13:03 so no, then.

13:03 qbg: ,(map inc [1 2 3])

13:03 clojurebot: (2 3 4)

13:03 TheLolrus: nope. :P

13:04 dnolen: TheLolrus: well Joy of Clojure is really good, but it assumes some experience w/ functional programming (FP)

13:04 qbg: Programming Clojure is nice also

13:04 dnolen: Stuart Halloway's book Programming Clojure is not a bad place to start, though perhaps getting long in the tooth now.

13:04 trptcolin_: TheLolrus: you might also take a look at http://learn-clojure.com/

13:04 qbg: A lot of it still applies

13:04 headlessClown: Has Joy of Clojure shipped yet?

13:05 ie the MEAP edition

13:05 r2q2: Maybe? http://www.amazon.com/Joy-Clojure-Thinking-Way/dp/1935182641/ref=sr_1_1?ie=UTF8&s=books&qid=1293818813&sr=8-1

13:06 qbg: It says Jan 28, 2011

13:07 headlessClown: ahhh

13:07 qbg: That bestsellers rank is far too low...

13:08 TheLolrus: how about http://www.youtube.com/user/briantwill#g/c/AC43CFB134E85266

13:08 currentB: simple question: what is the best way to generate a list filled with a given number of other lists, should i use for?

13:08 qbg: currentB: example?

13:09 ,(repeat 5 [1 2 3])

13:09 clojurebot: ([1 2 3] [1 2 3] [1 2 3] [1 2 3] [1 2 3])

13:09 qbg: ?

13:09 r2q2: Aren't richhickeys webcasts still relevant

13:09 qbg: r2q2: They should largely still be

13:09 r2q2: TheLolrus: You should probably watch those

13:09 qbg: The syntax has changed since the older ones, but not much

13:10 currentB: yup repeat is perfect (sometimes i get hung up on which simple fn i'm looking for) thanks!

13:11 TheLolrus: I'm thinking those videos, then http://en.wikibooks.org/wiki/Clojure_Programming/Concepts , then http://java.ociweb.com/mark/clojure/article.html

13:12 mids: TheLolrus: sounds like a good start

13:19 I just bought The Joy of Clojure e-book... the PragProg order process is so much nices than Manning :(

13:30 qbg: I reimplemented condp using my syntax-rules lib: https://github.com/qbg/syntax-rules/raw/master/src/qbg/syntax_rules/examples.clj (see ex-condp at the bottom)

13:30 I need a more powerful templating language eventually...

13:31 The syntax is simple, the template is hard...

13:32 Raynes: qbg: Why did you give the raw link? :o

13:32 https://github.com/qbg/syntax-rules/blob/master/src/qbg/syntax_rules/examples.clj is prettier

13:32 In any case, that is pretty awesome.

13:34 qbg: I'd try to reimplement for if I only understood how it works...

13:35 Raynes: for is insanity.

13:35 qbg: 95+% of the work would be in the template anyways...

13:35 Probably not worth it.

13:35 Raynes: It's probably the one thing I'm having the most trouble explaining in my book. I've mostly left it as a placeholder until it comes to me in a dream or something.

13:36 cemerick: Have you explained it in yours yet? /me will leech inspiration.

13:36 qbg: For is easy to implement in Scheme

13:36 (relatively easy that is)

13:37 continuations help a bit

13:40 I should make a release in the next few days

14:09 fliebel: I just noticed someone mentioned https://github.com/jarpiain/cljc in here. *amazed* What is the status of that?

14:26 pdk: considering it mentions the 1.3 alphas in the readme it's probably pretty recent

14:26 1.3 hasn't gone gold yet

14:49 cemerick: Raynes: explained what?

14:56 bhenry: what is non-lazy map?

14:59 qbg: cemerick: Raynes was talking about for

15:00 bhenry: i want to do a function with side effects to every item in a seq

15:00 cemerick: bhenry: (doseq [x some-sequence] (println x))

15:00 for example

15:01 bhenry: thanks

15:06 pdk: do/doseq/dotimes basically exist for side effects

15:08 cemerick: qbg: yeah, we'll be covering for

15:10 TheLolrus: what's so good about maven?

15:10 pdk: the name sounds like mavis beacon

15:10 that's what we like with t

15:10 it

15:12 qbg: Maven treats XML like violence

15:13 TheLolrus: the enclojure site looks epic

15:13 I wonder if it's made in clojure :P

15:17 cemerick: TheLolrus: this is now a bit old and out of date, but should give you some context about why one might use maven: http://cemerick.com/2010/03/25/why-using-maven-for-clojure-builds-is-a-no-brainer/

15:18 TheLolrus: mkay

16:03 amalloy: qbg: syntax rules is intimidating, even with the examples. the simple macros look promisingly simple, but even slightly non-trivial ones like -> are hard to follow. do you have a link to a good intro/tutorial?

19:05 devn: well, I won't be doing much for the next year

19:05 * devn reads Clojure in Small Pieces

19:08 qbg: The title of Clojure in Small Pieces makes it sound like it would be like Lisp in Small Pieces, but it is not

19:08 (LiSP is a good book by the way)

19:59 pdk: where do you find clojure in small pieces

19:59 also is LiSP worth it if you've read graham's acl

20:04 * joshua__ is very frustrated as he has just spent hours trying to purchase an ebook with paypal unsuccessfully. Or put another way is frustrated at having experienced the most compelling argument for piracy, the sellers make things difficult on the consumer.

20:13 Adamant: pdk: yes, it's a implementation of a language system book

20:13 joshua__: agreed

20:14 pdk: so there's still stuff to learn from it

20:14 Adamant: joshua__: I've been known to pay for things then immediately use the pirated version due to that being the easiest

20:14 pdk: probably, unless you're already a compiler geek

20:14 pdk: da f is with the pricing

20:14 is this like on lisp

20:14 Adamant: it's expensive

20:14 they aren't printing more copies, IIRC

20:14 pdk: where there's a freebie version but a physical copy will cost you your first born

20:14 Adamant: check to see if they released a e-copy

20:15 pdk: not on kindle at least

20:15 Adamant: also look at several bookstores

20:16 joshua__: Adamant, I think I'm going to do that actually.

20:17 The other funny thing is how much is charged for lets say, "Structure And Interpretation of Computer Programs."

20:18 Charging well over $50 for a book that is free is a bit wacky to me.

20:18 Adamant: that's a hardback with pretty awesome binding

20:18 pdk: if you think it's bad take a look at on lisp

20:18 graham gives you a free pdf

20:18 or you could go $140 for hardcover

20:18 qbg: You could get LiSP from a good library

20:19 Adamant: $140 is most of a Kindle or half a NOOKColor

20:19 more than half, actually

20:19 joshua__: I suppose that its a good thing that it is all overpriced for the dead tree edition. Less dead trees and all.

20:19 Adamant: mostly it's due to it not being reprinted

20:19 I expect

21:11 Derander: Adamant: it's all of a kindle if you go for the wi-fi only version.

21:11 Adamant: Derander: not surprised

21:11 I wasn't up on current prices :P

21:12 Derander: :-P

21:53 auser: is there a non-lazy form of filter?

21:56 cemerick: auser: doall will force evaluation of any lazy seq

21:56 auser: that's what I thought...

21:56 thx

23:24 duck1123: What is a good clojure 1.3 replacement for re-partition?

23:33 joshua__: duck1123, what do you mean?

23:34 duck1123: re-partition was in str-utils, which is no longer in contrib 1.3

23:34 so I'm trying to find a good replacement

23:37 joshua__: duck1123, I don't know, but the source is at https://github.com/richhickey/clojure-contrib/blob/a1c66df5287776b4397cf3929a5f498fbb34ea32/src/main/clojure/clojure/contrib/str_utils.clj#L28 if you can't find an option.

23:38 duck1123: I've been going through the dependencies of my application and seeing what it takes to get them all to play nice with 1.3. I'm working on autodoc right now

23:39 the changes with the string-related libs has been a pain

23:54 replaca: duck1123: how's it going with autodoc? I haven't turned on 1.3 yet, but I have a new version in the works that should be more multiversion friendly

23:59 programble: happy new year!

Logging service provided by n01se.net