#clojure log - May 02 2009

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

3:30 yason: Hmmm, did Clojure have a function/idiom to join a list of strings together with a glue string? Java doesn't seem to have one!

4:02 unlink1: str-join?

4:03 yason: unlink1: sounds like it but it isn't in the API index

4:04 unlink1: http://code.google.com/p/clojure-contrib/wiki/StrUtilsApiDoc#str-join

4:05 yason: oh, the contrib repository

4:06 thank you, i should remember that more often :)

4:12 cgrand: yason: or (apply str (interpose \- ["hello" "world"]))

4:12 ,(apply str (interpose \- ["hello" "world"]))

4:12 clojurebot: "hello-world"

11:49 * Raynes has switched to Linux and will no longer be complaining about how bad Git sucks on windows.

11:49 Chousuke: :)

11:59 unlink1: Might I also recommend switching to mercurial? ;-)

12:21 jboner: hg over git, no

12:24 Raynes: jboner: Woar.

12:31 AWizzArd: Ah, again hg vs git? ;)

12:31 This whole discussion could be ended by a sweet version control system written in Clojure :)

12:31 Raynes: I haven't even installed a VCS yet.

12:31 Chousuke: hg is fine, but I like having control over what branches I publish from a repo. :/

12:32 AWizzArd: I like to have different branches in different repos, and decide which of those repos I publish

12:32 Chousuke: with hg it seems I'd have to clone the repository every time I want a private branch... acceptable I guess, but not the way I want to work.

12:32 well, git obviously supports that as well :)

12:34 there's just rarely any need to clone a local repository because you can just branch.

12:45 AWizzArd: Chousuke: it is very simple with hg and the typical workflow

12:45 hg supports hard links, so those repositories won't eat much HD space

12:45 Chousuke: git does too

12:45 AWizzArd: in googles analysis they only noticed that git repos are bigger than hgs

12:46 So, that speaks more for hg in my opinion.

12:46 It is trivial to start a new repo, and the hosting services provide tools for that.

12:46 Chousuke: bigger?

12:46 AWizzArd: as in "more hd space is used"

12:46 Chousuke: I thought they were about the same size.

12:47 AWizzArd: probably not huge differences

12:47 what surprised me was that cloning via http is much faster with hg

12:47 Google measured about 8 seconds for their test repo with hg

12:47 and 178 seconds with git

12:47 Chousuke: yeah, that's one thing hg has for it.

12:48 git has no good protocol for http cloning.

12:48 AWizzArd: Anyway, from the technical point of view both are too similar to see an obvious better candidate

12:48 Chousuke: they'll probably fix it in some future version though.

12:48 actually the first benchmark I find with google regarding repo size shows that git repos are smaller :/

12:49 but it's almost a year old. maybe hg has improved.

12:50 http://vcscompare.blogspot.com/2008/06/git-mercurial-bazaar-repository-size.html anyway

12:50 AWizzArd: I think yes

12:51 Raynes: I can't believe I managed to spark a conversation about VCS's simply by saying I had switched to Linux. :o

12:51 AWizzArd: Raynes: yeah, good job

12:51 Chousuke: :P

12:51 Raynes: you mentioned git.

12:51 that's enough.

12:51 AWizzArd: if it is silent here mention git

12:52 Raynes: "What are the benefits of using Git?" I bet that phrase would make people talk in here who have never talked before.

12:53 AWizzArd: I think git has won the popularity thing

12:53 For example in #git there sit around 500+ people, while in #mercurial we have 120 or so

12:53 But this does not seem to reflect the technical capability

12:54 Chousuke: git and hg are both good. I just think git is a bit better

12:54 AWizzArd: For example git hosts as its maybe biggest project the Linux kernel with over 2,5 mio LOC

12:54 hg has Mozilla with around 2,3 mio LOC

12:54 Raynes: :o

12:55 Chousuke: X.org uses git too

12:55 clojurebot: git is http://www.github.com

12:55 AWizzArd: and not to forget OpenSolaris. Alone the OpenJDK has 6,5 mio LOC. So from that it seems that hg is capabale of holding big code bases.

12:55 Chousuke: though X is modularised into several repos nowadays

12:56 AWizzArd: Would be cool if Rich would switch to hg which is now available on Google.

12:56 Chousuke: I wouldn't mind that at all :)

12:56 AWizzArd: I also already said: if the choice is hg or git instead of svn, then both options are a win

12:56 Chousuke: yeah :P

12:57 AWizzArd: But Rich will also have tool support in mind

12:57 technicaly speaking hg and git seem to be very similar

12:58 In 2010 someone will start Clojanarian - the next VCS

12:58 Chousuke: :P

13:00 Raynes: Yes, I will, and it will be called Verjure.

13:03 Or, Jursion. JCS Jursion Control System.

13:06 CVCS Clojure Version Control System.

13:07 Drakeson: just build a java/clojure version that reads and writes to the .git directory and uses git protocols, and everyone will be happy.

13:08 Chousuke: you mean http://www.jgit.org/ ? :P

13:08 Raynes: But, I'd rather just trump Git in general.

13:10 Drakeson: does it work well, then?

13:10 is it actively maintained?

13:13 alvivi: http://hgbook.red-bean.com/read/preface.html#id412633 more git vs hg flame :P

13:14 Chousuke: and out of date :P

13:30 AWizzArd: That Google decided to go with hg tells a lot :)

13:32 Drakeson: such as it is easier to deploy hg in a python environment

13:32 not to forget that they have a great set of tools around git (gerrit, etc.)

13:38 AWizzArd: So git as a set of C programs and shell scripts can make sense for the Linux kernel

13:39 unlink1: Why do I get a reflection warning from (defn f [o] (.toString o))?

13:39 AWizzArd: but things like Mozilla and the OpenJDK or Python decided to go the hg route.

13:40 I think at compile time it is not obvious which .toString method needs to be called

13:40 Chousuke: I suppose for those projects, windows support is essential.

13:40 also in google's case, HTTP cloning.

13:40 not to mention they are very familiar with python :P

13:41 AWizzArd: unlink1: Clojure cannot insert a direct call to the right .toString. Only at runtime we know which of the many thousands .toString is the right one.

13:41 The OpenJDK guys? ;-)

13:42 hiredman: unlink1: you need to type hint o

13:42 unlink1: Doesn't everything have toString?

13:43 Chousuke: AWizzArd: google

13:47 AWizzArd: funnily googles Android project..

13:47 Chousuke: what about it?

13:47 AWizzArd: it's under git

13:47 Chousuke: heh.

13:47 maybe they decided git was better for it :P

13:48 AWizzArd: Oh well, possible. In the end I don't care too much. I used git for some months, now switched for hg (because I like that working style more and find it easier to use). I can use both systems and have both installed.

13:48 I hope they can divide the market fairly so that there is always some pressure on both teams to evolve their system.

13:49 Chousuke: I don't think that'll be a problem :)

13:51 AWizzArd: even if more people and projects decided to use git, I can still be happy that Mercurial has the cooler name

13:51 replaca: ~seen hiredman

13:51 clojurebot: hiredman was last seen in #clojure, 9 minutes ago saying: unlink1: you need to type hint o

13:52 replaca: hiredman: I got some json for ya

13:53 hiredman: http://clojure-contrib.googlecode.com/svn/wiki/ApiDocIndex.json

13:53 dreish: unlink1: It looks like Clojure just spits out reflection warnings on non-type-hinted objects without exception. If you type hint it as #^Object (which provides no actual information; everything is an Object), the warning goes away.

13:56 replaca: 1/4 MB on a single-line, since c.c.json.write doesn't seem to know any other way

13:56 danlarkin: replaca: clojure-json does :) It can do indenting!

13:56 replaca: danlarkin: cool, maybe we should pull that behavior into contrib

13:57 I was thing I'd just write a pp dispatch table rather then replicating the indenting logic everywhere

13:57 danlarkin: ,(org.danlarkin.json/encode-to-str "[1 2 3 {\"a\" \"b\"} 4 5]" :indent 4)

13:57 clojurebot: "\"[1 2 3 {\\\"a\\\" \\\"b\\\"} 4 5]\""

13:57 danlarkin: well.. ok it doesn't indent on irc but you get the idea

13:57 hiredman: gnarly

13:58 danlarkin: ,(org.danlarkin.json/encode-to-str [1 2 3 {"a" "b"} 4 5] :indent 4)

13:58 clojurebot: "[\n 1,\n 2,\n 3,\n {\n \"a\":\"b\"\n },\n 4,\n 5\n]"

13:58 danlarkin: there we go

13:58 hiredman: replaca: I'll get on that tomorrow or next week sometime

13:58 replaca: but since it's for clojurebot anyway, I'm not sure it matters right this sec - I'll fix it up later

13:59 yup, no worries, I just wanted you to know it was ready when you are

13:59 I'm thinking I'll probably write some repl and slime tools to go with it too

14:00 so you can find doc without loading all the namespaces

14:00 Lau_of_DK: Good evening all

14:00 replaca: Hi Lau

14:01 I'm off to spend a rainy day at the museum looking at Andy Warhol paintings...

14:01 by all

14:01 bye all

14:01 having fun arguing git vs. hg!

14:05 Lau_of_DK: Guys - I remember technomancy talking about using thread-local vars when handling sessions for webusers on a jetty servlet - Anybody know how thats done ?

14:06 Chousuke: with-local-vars?

14:09 Lau_of_DK: Thanks big guy, I'll look into it

14:14 Quiark: Anyone has vimclojure working? I'm getting all sorts of seemingly random errors...

14:17 hiredman: vimclojure is sensitive about having a correct namespace declaration

14:17 and the namespace has to be on the classpath of the nailgun server

14:18 Quiark: yep, I think I have that correct

14:18 hiredman: are you sure?

14:18 Quiark: I restarted vim once more and now it works without changing anything...

14:19 hiredman: *shrug*

14:19 Quiark: I'm using the svn head version of clojure, so if its unstable, it could be the cause

14:22 hiredman: nope

14:22 unless you wait months between checkouts

14:23 Quiark: I just started using clojure, so I have yesterday's checkout :)

14:24 hiredman: ~latest

14:24 clojurebot: latest is 1360

14:24 hiredman: r1360

14:26 Quiark: yes, 1360 is what I have

14:34 unlink1: I'm not sure exactly what *warn-on-reflection* accomplishes. It seems like it just complains if you use field/method accesses on an object which doesn't have a type annotation, and then is silenced when that object is given a type annotation, regardless of the type; but then fails at runtime if the field/method doesn't resolve.

14:36 dnolen: unlink1: it's telling you that the code will have to use reflection. This is a _massive_ performance hit.

14:36 hiredman: type hinting is just a sort of unsafe cast :P

14:37 unlink1: OK, so it says "cast to this type"?

14:37 hiredman: more or less

14:37 so if the type doesn't have the corrent field or method at runtime *boom*

14:37 correct

14:40 unlink1: so (fun x [#^String s] (.trim s)) corresponds to something like public static Object x(Object s) { String s = (String)s; return s.trim(); } ?

14:41 Well I mean you can't shadow a parameter in java.

14:42 hiredman: I forget if casts have higher or lower presidence then method calls

14:42 ((String)s).trim

14:42 ();

14:42 unlink1: uh, . has the highest precedence I think.

14:44 I actually never used reflection in Java.

14:45 Interesting, you can access private fields with it?

14:46 I guess that would be an important feature.

15:00 technomancy: is there a function like remove that takes an element to remove instead of a predicate?

15:03 cgrand: technomancy: (remove #{foo} coll)?

15:04 (doesn't work with false and nil as usual)

15:05 technomancy: right; that's fine; thanks

15:23 lisppaste8: technomancy pasted "dir-seq" at http://paste.lisp.org/display/79555

15:23 technomancy: how would you write that without using "flatten"?

15:30 Drakeson: who mentioned jGit? it is a funny joke at the moment. It only has branch, clone, daemon, fetch, init, log, push, rm, tag, version.

15:32 I cannot imagine what can be done using those, other than just reading a git repo, and/or serving it.

15:33 technomancy: Drakeson: well it would be pretty silly to use a JVM-hosted tool for actually committing given the JVM's boot time

15:33 but letting JVM-hosted apps read repositories could be pretty useful

15:34 Drakeson: technomancy: no it is not. you don't need to launch a new JVM for every operation. People are already looking for libgit to use git as a storge backend for whatever makes sense.

15:35 technomancy: Drakeson: still, there's very little advantage to JVM-hosting for day-to-day usage.

15:35 Drakeson: also, it is a matter of things not written yet. the have added the "push" command recently.

15:36 technomancy: unless you use a git repos as a persistence backend.

15:36 (again, for limited but important use cases)

15:37 technomancy: well it sounds like if you want to do that you'll have to write the commit functionality yourself. =)

15:37 eee: does anyone here use clojure-dev

15:39 Drakeson: The usage I have in mind is sharing libraries with source code. A central repository of git repositories for clojure libraries.

15:40 (with read-only operations a good portion of that can be done, though)

15:41 eee: i'm interested in mercurial before git

15:41 personally

15:42 kadaver_: I'm gonna post my mp3player to the mailinglist

15:42 what is thge best format to post it?

15:43 Ie should I paste the code somewhere or upload .clj files?

15:43 Drakeson: eee: It is not a matter of which is functionally superior, anymore. Right now it only matters which one is being used by more projects.

15:44 eee: i use the same reasoning, and the eclipse plugin sucks

15:44 and eclipse is awesome

15:45 therefore ...

15:45 but I haven't used mercurial yet

15:45 just curious about it

15:45 is all I was saying :)

15:47 kadaver_: git git git git

15:48 eee: lol

15:48 kadaver_: noone is curious about my mp3player

15:48 it has a weirdo bug

15:48 probably with threading :P

15:48 eee: kadaver_ i don't know how to answer other than to say to check into the github

15:48 and then post to the group that you have a third-party

15:49 and then rich can add it to the third party page

15:49 or that would be my guess

15:56 technomancy: interesting comparison: http://bitbucket.org/repo/all/?name=clojure vs http://github.com/languages/Clojure

15:57 2 pages vs 12 pages

15:58 eee: i never heard of bitbucket

15:58 to support your argument

15:58 which one is older?

15:58 hiredman: can't say I am surprised that most clojure projects are following clojurebot's lead...

16:01 Drakeson: does github has a way to initiate a project right from the commandline, without going through the web interface?

16:06 What is the vision for lancet? Is it going to be a versatile dependency resolution and be able to obtain and track/update dependencies from external and local repositories?

16:11 technomancy: hiredman: heh

16:11 Drakeson: yeah, you can initiate projects through the command line through github. the Jeweler project does that, and the "gh" gem might as well.

16:11 Drakeson: Stu doesn't seem to be that interested in adding dependency resolution to lancet.

16:12 I've been playing around with a prototype here: http://github.com/technomnacy/corkscrew ... doesn't support transitive deps yet, but it can pull jars from HTTP and projects from git/svn repos

16:18 Drakeson: Where do you put the jar files?

16:19 is it in ~/.m2 ?

16:45 technomancy: Drakeson: right now it uses ~/.corkscrew, but eventually it should integrate with mvn and use ~/.m2

17:55 Raynes: Business is picking up with severe weather here. :\ Tornado warnings.

17:55 I don't like tornado warnings.

18:01 rsynnott: presumably better than un-warned-of tornados

18:10 kadaver_: there is no function like reduce-and-add-to-end?

18:12 unlink1: What's the idiomatic way of taking a list and an object and returning the list with the object appended (i.e. to the end of the list)?

18:12 Like conj but at the end of the list.

18:14 Chousuke: ,(concat '(1 2 3) (list 4)) ; this is probably as idiomatic as you can get.

18:14 clojurebot: (1 2 3 4)

18:14 AWizzArd: You should just be aware that this is O(n)

18:14 Chousuke: it's lazy, actually :)

18:14 AWizzArd: If you need that then maybe lists are not the right datatype for the task at hand.

18:14 Chousuke: so it's only O(n) if you traverse the list.

18:15 in which case it would be O(n) anyway :)

18:15 unlink1: I'm not too worried, I don't expect n > 4 or 5.

18:15 Chousuke: anyway, vectors would be more idiomatic

18:16 or well, I guess it depends on what you do with it.

18:16 unlink1: I'm trying to write a macro that does the same thing as -> except threads the return value as the last argument to the next function.

18:17 Chousuke: hmm, tricky.

18:17 kadaver_: the idiomatic way in clojrue is suing evctors...

18:18 Chousuke: but yeah, if it's a macro, performance doesn't matter much.

18:19 kadaver_: @paste

18:19 clojurebot: paste?

18:19 clojurebot: lisppaste8, url

18:19 lisppaste8: To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.

18:20 kadaver pasted "mp3-main" at http://paste.lisp.org/display/79566

18:20 AWizzArd: Chousuke: when does the concat gets fired off?

18:20 Chousuke: AWizzArd: immediately. it just returns a lazy seq

18:20 AWizzArd: Only when one touches the (to be concated) last element of the list?

18:21 Raynes: This is rare.

18:21 116 people in here. 128 in #Scala.

18:21 We normally trump that channel.

18:21 lisppaste8: kadaver pasted "guilogic" at http://paste.lisp.org/display/79567

18:22 kadaver pasted "utils" at http://paste.lisp.org/display/79568

18:22 Chousuke: kadaver_: load-latest looks like it does IO. does it?

18:23 guessing from hte name :P

18:23 lisppaste8: kadaver pasted "database" at http://paste.lisp.org/display/79569

18:24 Chousuke: right, it does.

18:24 you can't do that in a transaction

18:24 arohner: spit and slurp both do I/O

18:24 Chousuke: it'll break.

18:25 I wonder if slurp and spit contain an (io!) block? :/

18:26 ~source slurp

18:27 apparently not.

18:27 wonder if they should :P

18:28 cp2: i'll slurp you

18:31 aperotte: hi everyone

18:32 I've been working on a new datatype for clojure and I posted my work so far up on github

18:33 http://github.com/aperotte/persistentmatrix

18:33 It's a matrix/n-dimensional array datatype, and would welcome any and all feedback

18:35 kadaver_: http://groups.google.com/group/clojure/browse_thread/thread/c0819f314391a311

18:35 ^^ mp3player written in Clojure, thread in the google group, some info and comments on programming in clojrue + ofc the code.

18:36 it is ~400 LOC

18:38 I'd love comments on the code

18:39 Chousuke: aren't you using a version control system? :/

18:40 kadaver_: nah

18:40 Chousuke: you should

18:40 there's no reason not to use one :/

18:40 kadaver_: REAL programmers dont use version control systems

18:40 Chousuke: you're not a REAL programmer :)

18:40 kadaver_: they write one perfect program in ASM.

18:41 Chousuke: kadaver_: anyway, as I said, doing IO inside a dosync is generally not good

18:41 it might get retried.

18:43 have you even tested if that code works at all. because it looks like it won't :P

18:44 or hm.

18:45 never mind, I just forgot Ref does pass-through when in operator position

18:47 but you should do something like (let [latest (utils/load-latest (str (player-state :dir) "latest"))] (dosync (commute player-state assoc :playlist latest)))

18:49 alter works too, but looks like commute should do in that case.

18:49 kadaver_: it does

18:49 Chousuke: anyway, it's time for me to sleep. so good night. :)

18:50 kadaver_: alter vs commute?

18:54 Drakeson: How would you talk to a webserver (It needs POST, https).

18:55 I couldn't find anything for that in contrib

19:10 cgrand: technomancy: you can use tree-seq to avoid flatten (flatten being usually implemented with tree-seq), but file-seq looks very much like your dir-seq

19:12 Raynes: "What is linux?" :o

19:14 bradford: ,(for [x (range 5)] x)

19:14 clojurebot: (0 1 2 3 4)

19:15 gnuvince_: bradford: alternatively, (range 5) ;)

19:15 bradford: gnuvince - just showing my friend the repl :-)

19:18 gnuvince_: ok

19:19 kadaver_: rhickey: are you opposed to static typing?

19:43 rlb: Does clojure already have something like a map for n-ary trees? i.e. map (fn [x] (* x 2)) over (1 (2 3)) to produce (2 (4 6))

19:53 Raynes: I hate the sound of tornado sirens.

19:53 * Raynes plugs his ears.

20:33 AWizzArd: Drakeson: it depends on the complexity of your requirements

20:33 You may want to consider htmlunit, if that fits your needs.

20:33 http://htmlunit.sourceforge.net/

20:34 rlb: Can you index a map by a string, i.e. ("x" {"x" 42}) -> 42?

20:34 AWizzArd: ,({"x" 1, "y" 2} "x")

20:34 clojurebot: 1

20:34 rlb: I know maps are functions of their values for symbols at least.

20:34 oh, right

20:35 (thinking backward)

20:35 AWizzArd: rlb: only when you use keywords, such as :x or :my-keyword you can put them into the position of the function.

20:35 rlb: AWizzArd: I think that's what confused me.

20:35 Thanks

20:35 AWizzArd: ,(:a {:a 1})

20:35 clojurebot: 1

20:35 AWizzArd: there it works

20:40 rlb: I imagine there's probably a clever way to take f and '(x y z) and call (((f x) y) z).

20:54 ee: this should be easy, but how do you print "done" if a java object is null?

20:55 I have (when (= nil heap) (println "done"))

20:55 so what's the predicate for "isNull"

20:55 AWizzArd: ,(doc nil?)

20:55 clojurebot: "([x]); Returns true if x is nil, false otherwise."

20:56 ee: i tried that

20:56 i guess it's not null

20:56 duh

20:57 it ws null

20:59 hmmm

20:59 AWizzArd: ,(when (nil? nil) (print "done"))

20:59 clojurebot: done

21:00 AWizzArd: probably your heap was not nil at that time

21:00 ee: yeah

21:01 it wasn't, but i was getting null pointer exception. but it was from inside the heap I guess

21:01 thanks

21:01 i think I figured it out

21:56 eee: i finally solved the problem with my heap. I'm glad I'm forcing myself to get through some gotchas

21:57 my mistake was probably something pretty simple for a veteran java person.

21:57 :)

22:00 i was trying to break ties between user data associated with keys

22:00 i mean associated with priorities

22:00 so I call hashCode

22:00 seems obvious now

22:13 technomancy: Drakeson: danlarkin and I are working on an HTTP client that may make it into contrib

22:13 Drakeson: http://github.com/technomancy/clojure-http-client

22:14 Drakeson: it does POST, but I don't know about https

22:15 eee: what's a longer description

22:15 technomancy: Drakeson: also check out the "resourcefully" branch for a higher-level wrapper.

22:16 eee: i see

22:17 it's for programmatically accessing web pages?

22:17 technomancy: Drakeson: let me know if you end up using it; would like to hear what you think. obviously there's still a lot missing right now

22:17 eee: more for REST-based APIs. if you just need to read a web page you can use slurp

22:17 eee: cool

22:18 technomancy: rather, use duck-streams; slurp might not do it

22:18 eee: oh i see in the test

22:18 technomancy: bbiab &

22:40 eee: glad to have learned about miglayout

22:40 from that mp3 app

22:41 posted to the user group

Logging service provided by n01se.net