#clojure logs

2009-05-02

03:30yasonHmmm, did Clojure have a function/idiom to join a list of strings together with a glue string? Java doesn't seem to have one!
04:02unlink1str-join?
04:03yasonunlink1: sounds like it but it isn't in the API index
04:04unlink1http://code.google.com/p/clojure-contrib/wiki/StrUtilsApiDoc#str-join
04:05yasonoh, the contrib repository
04:06yasonthank you, i should remember that more often :)
04:12cgrandyason: or (apply str (interpose \- ["hello" "world"]))
04:12cgrand,(apply str (interpose \- ["hello" "world"]))
04:12clojurebot"hello-world"
11:49Chousuke:)
11:59unlink1Might I also recommend switching to mercurial? ;-)
12:21jbonerhg over git, no
12:24Raynesjboner: Woar.
12:31AWizzArdAh, again hg vs git? ;)
12:31AWizzArdThis whole discussion could be ended by a sweet version control system written in Clojure :)
12:31RaynesI haven't even installed a VCS yet.
12:31Chousukehg is fine, but I like having control over what branches I publish from a repo. :/
12:32AWizzArdI like to have different branches in different repos, and decide which of those repos I publish
12:32Chousukewith 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:32Chousukewell, git obviously supports that as well :)
12:34Chousukethere's just rarely any need to clone a local repository because you can just branch.
12:45AWizzArdChousuke: it is very simple with hg and the typical workflow
12:45AWizzArdhg supports hard links, so those repositories won't eat much HD space
12:45Chousukegit does too
12:45AWizzArdin googles analysis they only noticed that git repos are bigger than hgs
12:46AWizzArdSo, that speaks more for hg in my opinion.
12:46AWizzArdIt is trivial to start a new repo, and the hosting services provide tools for that.
12:46Chousukebigger?
12:46AWizzArdas in "more hd space is used"
12:46ChousukeI thought they were about the same size.
12:47AWizzArdprobably not huge differences
12:47AWizzArdwhat surprised me was that cloning via http is much faster with hg
12:47AWizzArdGoogle measured about 8 seconds for their test repo with hg
12:47AWizzArdand 178 seconds with git
12:47Chousukeyeah, that's one thing hg has for it.
12:48Chousukegit has no good protocol for http cloning.
12:48AWizzArdAnyway, from the technical point of view both are too similar to see an obvious better candidate
12:48Chousukethey'll probably fix it in some future version though.
12:48Chousukeactually the first benchmark I find with google regarding repo size shows that git repos are smaller :/
12:49Chousukebut it's almost a year old. maybe hg has improved.
12:50Chousukehttp://vcscompare.blogspot.com/2008/06/git-mercurial-bazaar-repository-size.html anyway
12:50AWizzArdI think yes
12:51RaynesI can't believe I managed to spark a conversation about VCS's simply by saying I had switched to Linux. :o
12:51AWizzArdRaynes: yeah, good job
12:51Chousuke:P
12:51ChousukeRaynes: you mentioned git.
12:51Chousukethat's enough.
12:51AWizzArdif it is silent here mention git
12:52Raynes"What are the benefits of using Git?" I bet that phrase would make people talk in here who have never talked before.
12:53AWizzArdI think git has won the popularity thing
12:53AWizzArdFor example in #git there sit around 500+ people, while in #mercurial we have 120 or so
12:53AWizzArdBut this does not seem to reflect the technical capability
12:54Chousukegit and hg are both good. I just think git is a bit better
12:54AWizzArdFor example git hosts as its maybe biggest project the Linux kernel with over 2,5 mio LOC
12:54AWizzArdhg has Mozilla with around 2,3 mio LOC
12:54Raynes:o
12:55ChousukeX.org uses git too
12:55clojurebotgit is http://www.github.com
12:55AWizzArdand 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:55Chousukethough X is modularised into several repos nowadays
12:56AWizzArdWould be cool if Rich would switch to hg which is now available on Google.
12:56ChousukeI wouldn't mind that at all :)
12:56AWizzArdI also already said: if the choice is hg or git instead of svn, then both options are a win
12:56Chousukeyeah :P
12:57AWizzArdBut Rich will also have tool support in mind
12:57AWizzArdtechnicaly speaking hg and git seem to be very similar
12:58AWizzArdIn 2010 someone will start Clojanarian - the next VCS
12:58Chousuke:P
13:00RaynesYes, I will, and it will be called Verjure.
13:03RaynesOr, Jursion. JCS Jursion Control System.
13:06RaynesCVCS Clojure Version Control System.
13:07Drakesonjust build a java/clojure version that reads and writes to the .git directory and uses git protocols, and everyone will be happy.
13:08Chousukeyou mean http://www.jgit.org/ ? :P
13:08RaynesBut, I'd rather just trump Git in general.
13:10Drakesondoes it work well, then?
13:10Drakesonis it actively maintained?
13:13alvivihttp://hgbook.red-bean.com/read/preface.html#id412633 more git vs hg flame :P
13:14Chousukeand out of date :P
13:30AWizzArdThat Google decided to go with hg tells a lot :)
13:32Drakesonsuch as it is easier to deploy hg in a python environment
13:32Drakesonnot to forget that they have a great set of tools around git (gerrit, etc.)
13:38AWizzArdSo git as a set of C programs and shell scripts can make sense for the Linux kernel
13:39unlink1Why do I get a reflection warning from (defn f [o] (.toString o))?
13:39AWizzArdbut things like Mozilla and the OpenJDK or Python decided to go the hg route.
13:40AWizzArdI think at compile time it is not obvious which .toString method needs to be called
13:40ChousukeI suppose for those projects, windows support is essential.
13:40Chousukealso in google's case, HTTP cloning.
13:40Chousukenot to mention they are very familiar with python :P
13:41AWizzArdunlink1: 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:41AWizzArdThe OpenJDK guys? ;-)
13:42hiredmanunlink1: you need to type hint o
13:42unlink1Doesn't everything have toString?
13:43ChousukeAWizzArd: google
13:47AWizzArdfunnily googles Android project..
13:47Chousukewhat about it?
13:47AWizzArdit's under git
13:47Chousukeheh.
13:47Chousukemaybe they decided git was better for it :P
13:48AWizzArdOh 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:48AWizzArdI hope they can divide the market fairly so that there is always some pressure on both teams to evolve their system.
13:49ChousukeI don't think that'll be a problem :)
13:51AWizzArdeven if more people and projects decided to use git, I can still be happy that Mercurial has the cooler name
13:51replaca~seen hiredman
13:51clojurebothiredman was last seen in #clojure, 9 minutes ago saying: unlink1: you need to type hint o
13:52replacahiredman: I got some json for ya
13:53replacahiredman: http://clojure-contrib.googlecode.com/svn/wiki/ApiDocIndex.json
13:53dreishunlink1: 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:56replaca1/4 MB on a single-line, since c.c.json.write doesn't seem to know any other way
13:56danlarkinreplaca: clojure-json does :) It can do indenting!
13:56replacadanlarkin: cool, maybe we should pull that behavior into contrib
13:57replacaI was thing I'd just write a pp dispatch table rather then replicating the indenting logic everywhere
13:57danlarkin,(org.danlarkin.json/encode-to-str "[1 2 3 {\"a\" \"b\"} 4 5]" :indent 4)
13:57clojurebot"\"[1 2 3 {\\\"a\\\" \\\"b\\\"} 4 5]\""
13:57danlarkinwell.. ok it doesn't indent on irc but you get the idea
13:57hiredmangnarly
13:58danlarkin,(org.danlarkin.json/encode-to-str [1 2 3 {"a" "b"} 4 5] :indent 4)
13:58clojurebot"[\n 1,\n 2,\n 3,\n {\n \"a\":\"b\"\n },\n 4,\n 5\n]"
13:58danlarkinthere we go
13:58hiredmanreplaca: I'll get on that tomorrow or next week sometime
13:58replacabut since it's for clojurebot anyway, I'm not sure it matters right this sec - I'll fix it up later
13:59replacayup, no worries, I just wanted you to know it was ready when you are
13:59replacaI'm thinking I'll probably write some repl and slime tools to go with it too
14:00replacaso you can find doc without loading all the namespaces
14:00Lau_of_DKGood evening all
14:00replacaHi Lau
14:01replacaI'm off to spend a rainy day at the museum looking at Andy Warhol paintings...
14:01replacaby all
14:01replacabye all
14:01replacahaving fun arguing git vs. hg!
14:05Lau_of_DKGuys - I remember technomancy talking about using thread-local vars when handling sessions for webusers on a jetty servlet - Anybody know how thats done ?
14:06Chousukewith-local-vars?
14:09Lau_of_DKThanks big guy, I'll look into it
14:14QuiarkAnyone has vimclojure working? I'm getting all sorts of seemingly random errors...
14:17hiredmanvimclojure is sensitive about having a correct namespace declaration
14:17hiredmanand the namespace has to be on the classpath of the nailgun server
14:18Quiarkyep, I think I have that correct
14:18hiredmanare you sure?
14:18QuiarkI restarted vim once more and now it works without changing anything...
14:19hiredman*shrug*
14:19QuiarkI'm using the svn head version of clojure, so if its unstable, it could be the cause
14:22hiredmannope
14:22hiredmanunless you wait months between checkouts
14:23QuiarkI just started using clojure, so I have yesterday's checkout :)
14:24hiredman~latest
14:24clojurebotlatest is 1360
14:24hiredmanr1360
14:26Quiarkyes, 1360 is what I have
14:34unlink1I'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:36dnolenunlink1: it's telling you that the code will have to use reflection. This is a _massive_ performance hit.
14:36hiredmantype hinting is just a sort of unsafe cast :P
14:37unlink1OK, so it says "cast to this type"?
14:37hiredmanmore or less
14:37hiredmanso if the type doesn't have the corrent field or method at runtime *boom*
14:37hiredmancorrect
14:40unlink1so (fun x [#^String s] (.trim s)) corresponds to something like public static Object x(Object s) { String s = (String)s; return s.trim(); } ?
14:41unlink1Well I mean you can't shadow a parameter in java.
14:42hiredmanI forget if casts have higher or lower presidence then method calls
14:42hiredman((String)s).trim
14:42hiredman();
14:42unlink1uh, . has the highest precedence I think.
14:44unlink1I actually never used reflection in Java.
14:45unlink1Interesting, you can access private fields with it?
14:46unlink1I guess that would be an important feature.
15:00technomancyis there a function like remove that takes an element to remove instead of a predicate?
15:03cgrandtechnomancy: (remove #{foo} coll)?
15:04cgrand(doesn't work with false and nil as usual)
15:05technomancyright; that's fine; thanks
15:23lisppaste8technomancy pasted "dir-seq" at http://paste.lisp.org/display/79555
15:23technomancyhow would you write that without using "flatten"?
15:30Drakesonwho mentioned jGit? it is a funny joke at the moment. It only has branch, clone, daemon, fetch, init, log, push, rm, tag, version.
15:32DrakesonI cannot imagine what can be done using those, other than just reading a git repo, and/or serving it.
15:33technomancyDrakeson: well it would be pretty silly to use a JVM-hosted tool for actually committing given the JVM's boot time
15:33technomancybut letting JVM-hosted apps read repositories could be pretty useful
15:34Drakesontechnomancy: 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:35technomancyDrakeson: still, there's very little advantage to JVM-hosting for day-to-day usage.
15:35Drakesonalso, it is a matter of things not written yet. the have added the "push" command recently.
15:36Drakesontechnomancy: unless you use a git repos as a persistence backend.
15:36Drakeson(again, for limited but important use cases)
15:37technomancywell it sounds like if you want to do that you'll have to write the commit functionality yourself. =)
15:37eeedoes anyone here use clojure-dev
15:39DrakesonThe usage I have in mind is sharing libraries with source code. A central repository of git repositories for clojure libraries.
15:40Drakeson(with read-only operations a good portion of that can be done, though)
15:41eeei'm interested in mercurial before git
15:41eeepersonally
15:42kadaver_I'm gonna post my mp3player to the mailinglist
15:42kadaver_what is thge best format to post it?
15:43kadaver_Ie should I paste the code somewhere or upload .clj files?
15:43Drakesoneee: 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:44eeei use the same reasoning, and the eclipse plugin sucks
15:44eeeand eclipse is awesome
15:45eeetherefore ...
15:45eeebut I haven't used mercurial yet
15:45eeejust curious about it
15:45eeeis all I was saying :)
15:47kadaver_git git git git
15:48eeelol
15:48kadaver_noone is curious about my mp3player
15:48kadaver_it has a weirdo bug
15:48kadaver_probably with threading :P
15:48eeekadaver_ i don't know how to answer other than to say to check into the github
15:48eeeand then post to the group that you have a third-party
15:49eeeand then rich can add it to the third party page
15:49eeeor that would be my guess
15:56technomancyinteresting comparison: http://bitbucket.org/repo/all/?name=clojure vs http://github.com/languages/Clojure
15:57technomancy2 pages vs 12 pages
15:58eeei never heard of bitbucket
15:58eeeto support your argument
15:58eeewhich one is older?
15:58hiredmancan't say I am surprised that most clojure projects are following clojurebot's lead...
16:01Drakesondoes github has a way to initiate a project right from the commandline, without going through the web interface?
16:06DrakesonWhat 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:11technomancyhiredman: heh
16:11technomancyDrakeson: yeah, you can initiate projects through the command line through github. the Jeweler project does that, and the "gh" gem might as well.
16:11technomancyDrakeson: Stu doesn't seem to be that interested in adding dependency resolution to lancet.
16:12technomancyI'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:18DrakesonWhere do you put the jar files?
16:19Drakesonis it in ~/.m2 ?
16:45technomancyDrakeson: right now it uses ~/.corkscrew, but eventually it should integrate with mvn and use ~/.m2
17:55RaynesBusiness is picking up with severe weather here. :\ Tornado warnings.
17:55RaynesI don't like tornado warnings.
18:01rsynnottpresumably better than un-warned-of tornados
18:10kadaver_there is no function like reduce-and-add-to-end?
18:12unlink1What'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:12unlink1Like conj but at the end of the list.
18:14Chousuke,(concat '(1 2 3) (list 4)) ; this is probably as idiomatic as you can get.
18:14clojurebot(1 2 3 4)
18:14AWizzArdYou should just be aware that this is O(n)
18:14Chousukeit's lazy, actually :)
18:14AWizzArdIf you need that then maybe lists are not the right datatype for the task at hand.
18:14Chousukeso it's only O(n) if you traverse the list.
18:15Chousukein which case it would be O(n) anyway :)
18:15unlink1I'm not too worried, I don't expect n > 4 or 5.
18:15Chousukeanyway, vectors would be more idiomatic
18:16Chousukeor well, I guess it depends on what you do with it.
18:16unlink1I'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:17Chousukehmm, tricky.
18:17kadaver_the idiomatic way in clojrue is suing evctors...
18:18Chousukebut yeah, if it's a macro, performance doesn't matter much.
18:19kadaver_@paste
18:19kadaver_clojurebot: paste?
18:19clojurebotlisppaste8, url
18:19lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
18:20lisppaste8kadaver pasted "mp3-main" at http://paste.lisp.org/display/79566
18:20AWizzArdChousuke: when does the concat gets fired off?
18:20ChousukeAWizzArd: immediately. it just returns a lazy seq
18:20AWizzArdOnly when one touches the (to be concated) last element of the list?
18:21RaynesThis is rare.
18:21Raynes116 people in here. 128 in #Scala.
18:21RaynesWe normally trump that channel.
18:21lisppaste8kadaver pasted "guilogic" at http://paste.lisp.org/display/79567
18:22lisppaste8kadaver pasted "utils" at http://paste.lisp.org/display/79568
18:22Chousukekadaver_: load-latest looks like it does IO. does it?
18:23Chousukeguessing from hte name :P
18:23lisppaste8kadaver pasted "database" at http://paste.lisp.org/display/79569
18:24Chousukeright, it does.
18:24Chousukeyou can't do that in a transaction
18:24arohnerspit and slurp both do I/O
18:24Chousukeit'll break.
18:25ChousukeI wonder if slurp and spit contain an (io!) block? :/
18:26Chousuke~source slurp
18:27Chousukeapparently not.
18:27Chousukewonder if they should :P
18:28cp2i'll slurp you
18:31aperottehi everyone
18:32aperotteI've been working on a new datatype for clojure and I posted my work so far up on github
18:33aperottehttp://github.com/aperotte/persistentmatrix
18:33aperotteIt's a matrix/n-dimensional array datatype, and would welcome any and all feedback
18:35kadaver_http://groups.google.com/group/clojure/browse_thread/thread/c0819f314391a311
18:35kadaver_^^ mp3player written in Clojure, thread in the google group, some info and comments on programming in clojrue + ofc the code.
18:36kadaver_it is ~400 LOC
18:38kadaver_I'd love comments on the code
18:39Chousukearen't you using a version control system? :/
18:40kadaver_nah
18:40Chousukeyou should
18:40Chousukethere's no reason not to use one :/
18:40kadaver_REAL programmers dont use version control systems
18:40Chousukeyou're not a REAL programmer :)
18:40kadaver_they write one perfect program in ASM.
18:41Chousukekadaver_: anyway, as I said, doing IO inside a dosync is generally not good
18:41Chousukeit might get retried.
18:43Chousukehave you even tested if that code works at all. because it looks like it won't :P
18:44Chousukeor hm.
18:45Chousukenever mind, I just forgot Ref does pass-through when in operator position
18:47Chousukebut you should do something like (let [latest (utils/load-latest (str (player-state :dir) "latest"))] (dosync (commute player-state assoc :playlist latest)))
18:49Chousukealter works too, but looks like commute should do in that case.
18:49kadaver_it does
18:49Chousukeanyway, it's time for me to sleep. so good night. :)
18:50kadaver_alter vs commute?
18:54DrakesonHow would you talk to a webserver (It needs POST, https).
18:55DrakesonI couldn't find anything for that in contrib
19:10cgrandtechnomancy: 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:12Raynes"What is linux?" :o
19:14bradford,(for [x (range 5)] x)
19:14clojurebot(0 1 2 3 4)
19:15gnuvince_bradford: alternatively, (range 5) ;)
19:15bradfordgnuvince - just showing my friend the repl :-)
19:18gnuvince_ok
19:19kadaver_rhickey: are you opposed to static typing?
19:43rlbDoes 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:53RaynesI hate the sound of tornado sirens.
20:33AWizzArdDrakeson: it depends on the complexity of your requirements
20:33AWizzArdYou may want to consider htmlunit, if that fits your needs.
20:33AWizzArdhttp://htmlunit.sourceforge.net/
20:34rlbCan you index a map by a string, i.e. ("x" {"x" 42}) -> 42?
20:34AWizzArd,({"x" 1, "y" 2} "x")
20:34clojurebot1
20:34rlbI know maps are functions of their values for symbols at least.
20:34rlboh, right
20:35rlb(thinking backward)
20:35AWizzArdrlb: only when you use keywords, such as :x or :my-keyword you can put them into the position of the function.
20:35rlbAWizzArd: I think that's what confused me.
20:35rlbThanks
20:35AWizzArd,(:a {:a 1})
20:35clojurebot1
20:35AWizzArdthere it works
20:40rlbI imagine there's probably a clever way to take f and '(x y z) and call (((f x) y) z).
20:54eethis should be easy, but how do you print "done" if a java object is null?
20:55eeI have (when (= nil heap) (println "done"))
20:55eeso what's the predicate for "isNull"
20:55AWizzArd,(doc nil?)
20:55clojurebot"([x]); Returns true if x is nil, false otherwise."
20:56eei tried that
20:56eei guess it's not null
20:56eeduh
20:57eeit ws null
20:59eehmmm
20:59AWizzArd,(when (nil? nil) (print "done"))
20:59clojurebotdone
21:00AWizzArdprobably your heap was not nil at that time
21:00eeyeah
21:01eeit wasn't, but i was getting null pointer exception. but it was from inside the heap I guess
21:01eethanks
21:01eei think I figured it out
21:56eeei finally solved the problem with my heap. I'm glad I'm forcing myself to get through some gotchas
21:57eeemy mistake was probably something pretty simple for a veteran java person.
21:57eee:)
22:00eeei was trying to break ties between user data associated with keys
22:00eeei mean associated with priorities
22:00eeeso I call hashCode
22:00eeeseems obvious now
22:13technomancyDrakeson: danlarkin and I are working on an HTTP client that may make it into contrib
22:13technomancyDrakeson: http://github.com/technomancy/clojure-http-client
22:14technomancyDrakeson: it does POST, but I don't know about https
22:15eeewhat's a longer description
22:15technomancyDrakeson: also check out the "resourcefully" branch for a higher-level wrapper.
22:16eeei see
22:17eeeit's for programmatically accessing web pages?
22:17technomancyDrakeson: 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:17technomancyeee: more for REST-based APIs. if you just need to read a web page you can use slurp
22:17eeecool
22:18technomancyrather, use duck-streams; slurp might not do it
22:18eeeoh i see in the test
22:18technomancybbiab &
22:40eeeglad to have learned about miglayout
22:40eeefrom that mp3 app
22:41eeeposted to the user group