#clojure logs

2009-03-24

00:01arohnerclojurebot: paste
00:01clojurebotlisppaste8, url
00:01lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
00:02lisppaste8arohner pasted "subset" at http://paste.lisp.org/display/77511
00:02arohneris there a better way to accomplish this?
00:02dnolen_why not use filter?
00:04dnolen_sorry I see what yr doing.
00:07dnolen_looks good to me.
00:09cemerickarohner: try select-keys
00:09cemerick,(select-keys {:a 5 :b 6 :c 7} [:a :c])
00:09clojurebot{:c 7, :a 5}
00:09arohnerthat's *exactly* why I ask these questions :-)
00:09arohnerthanks
00:10cemericknp
00:10dnolen_nice
00:13cemerickarohner: FWIW, select-keys is basically what you pasted, except where it's defined in core.clj, 'into' isn't defined yet, so loop/recur is used to accumulate the map
00:13cemerickheh, and for isn't available there yet, either
00:14arohneryeah, I ran (source select-keys)
00:16cemerickarohner: source?
00:16arohner,(source select-keys)
00:16clojurebotjava.lang.Exception: Unable to resolve symbol: source in this context
00:17arohner,(clojure.contrib/source select-keys)
00:17clojurebotjava.lang.ClassNotFoundException: clojure.contrib
00:17arohnergrr, one last try
00:17arohner,(clojure.contrib.repl-utils/source select-keys)
00:17clojurebotjava.lang.ClassNotFoundException: clojure.contrib.repl-utils
00:17arohner,(require 'clojure.contrib.repl-utils)
00:17clojurebotjava.io.FileNotFoundException: Could not locate clojure/contrib/repl_utils__init.class or clojure/contrib/repl_utils.clj on classpath:
00:18arohneranyways, a very cool function
00:18durka42~source select-keys
00:19cemerickarohner: yes, definitely. Didn't know about that one!
00:21blbrownshould we use clojure-contrib for most clojure applications.
00:21cemerickwhew, looks like the source is ready by the source fn when it's called -- had a moment of concern there that it was hanging off of every fn as metadata
00:21cemerickblbrown: if you need it, then that's all that matters, I suppose.
00:21blbrownhmm, no download
00:22durka42i think you have to use the sv
00:22durka42svn
00:22durka42should we try to tag contrib revs corresponding to each release?
00:23arohnerdurka42: that would probably be a good idea
00:23durka42i mean, basically just the rev that was latest when the release happened
00:23durka42i don't know if the idea has already come up
00:27arohnermight as well post it
00:29jochuI have a quick question, in gen-class/gen-interface :methods return-types - is it possible to set an array return type?
00:33cemerickjochu: if you're using gen-class, I believe so; if you're using the :gen-class form in ns, no
00:33blbrownthe clojure mascot. suck on that #haskell http://www.flickr.com/photos/berlinbrown/3380716557/
00:34cemerick(class (make-array String 0)), etc.
00:34blbrownhttp://www.flickr.com/photos/berlinbrown/3381537052/in/photostream/
00:36cemerickcute
00:36cemerickhaskellers are good folk, tho. There's more that unites us than divides us, IMO.
00:36blbrownhehe
00:37jochucemerick: Hmm, I thought I tried that - :methods [[ReturnsStringArray [] "L]java.lang.String"]] doesn't work (NoClassDefFoundError), am I doing that wrong?
00:38cemerickjochu: pretty sure "L]java.lang.String" won't work -- you need to get a reference to (class (make-array String 0)), and refer to it there.
00:39cemerickit's possible I'm being daft right now, tho
00:42hjleemy clojure group post doesn't appear. any idea?
00:42cemerickhjlee: if you sent it by email, it can take some time to propagate
00:43hjleeah... then ... peoples receive 3 same messages...
00:44hjleebut 1st message sent hours ago.
00:44hjleetakes that long?
00:50cemerickI've had emails to google groups take a day to show on the group's web UI.
00:51blbrownto rhickey I just got a look at the clojure java code, you might run it through a checkstyle coding standards checker like program. Just a suggestion
00:51cemerickit seemed like that had been resolved, though.
00:54hjleenah.. a day..
00:56jochucemerick: Hmm, I don't think you can pass variable values like that into gen-interface/class
00:57cemerickjochu: we do it right now :-)
00:57cemerickthat *doesn't* work in the :gen-class form in ns, but if you're using the gen-class "manual" fn, then it's all good
00:58durka42blbrown: i think rhickey intentionally doesn't pay much attention to coding standards :)
00:59blbrowndurka42 I am writing something on the forum about it
00:59hjleeah... found reason - "Messages from new members are moderated"
00:59cemerickblbrown: don't bother -- he rebuffs any and all code style suggestions for the java stuff
01:00blbrownwell, I should rebuff all clojure conventions
01:01cemerickI guess that's your choice, but I think Rich has some special privileges. :-)
01:01blbrownno one is special
01:01cemerickapparently, it ends up looking good in IntelliJ, which is what he uses for the Java stuff.
01:02blbrownthere are no comments on any of the classes
01:02cemerickblbrown: not sure you'll find many who'd agree with that
01:03blbrownideally it should be 100%
01:05cemerickheh, no thanks. People aren't interchangeable.
01:06jochucemerick: :( Not trying it in the ns form, (gen-interface []
01:07jochucemerick: bah, premature sending - but yeah, doing it in an gen-interface and not having any luck.
01:09cemerickjochu: FWIW, gen-interface and gen-class are two completely separate mechanisms -- they share nothing, as far as I can tell at a glance
01:11cemerickwe absolutely pass concrete classes in for signatures (constructor signatures, in our case) to gen-class -- we calculate them from return types on methods on the interfaces provided to our macro
01:11durka42that seems strange, unless classes and interfaces are more different animals than i had imagined
01:13cemerickdurka42: interfaces are absurdly simple compared to classes -- the mechanisms probably could be unified, but they were developed independently. gen-class by rhickey, gen-interface by Chouser
01:13durka42ah
01:14RaynesIf you inherit a person class, is that like sex with a person object?
01:14jochucemerick: Ah, thanks. Then I guess I'm asking the wrong question, with gen-interface only - is possible to set an array return type? :P
01:15cemerickjochu: I guess you know better than I at this point, as I've never used gen-interface ;-)
01:17cemerickpatching gen-interface so that it evaluates the symbols provided certainly wouldn't be difficult -- not sure whether such a patch would cause issues for people who are using it already, though
01:18blbrownRaynes, where did you learn sex ed?
01:18cemerickI know that defining array types as well as parameterized types is on the todo list, though (probably implemented by specifying the string representation of the desired classes, so "[Ljava.lang.String" or "List<String>" would work as you'd expect).
01:19Raynesblbrown: Never took sex ed. ;)
01:22Gilbert987hi everyone
01:22Gilbert987i'm going through "programming clojure" (the book)
01:22Gilbert987and it's telling me to put "clojure-contrib.jar" in my classpath
01:23Gilbert987however, i don't see this file in the zip file that i downloaded
01:23Gilbert987am i missing sth?
01:23RaynesGilbert987: It's in the 'lib' directory. It doesn't matter however if you use the REPL script included with the sample-code.
01:23RaynesIf you use the REPL script included it will put everything on the class-path for you.
01:23cemerickg'night all
01:24RaynesNight cemerick
01:25Gilbert987Raynes: by script, do you mean "java -cp clojure.jar clojure.lang.Repl" ?
01:26RaynesGilbert987: In the sample-code, in the bin directory I believe, there are scripts, these scripts when executed will load the REPL with the classpath of everything that is used within the book.
01:39hiredmanhjlee: you still here?
01:40hiredmanah
01:40hiredmannevermind
02:32Gilbert987if i don't know a what a function does
02:32Gilbert987for e.g : "some"
02:32Gilbert987what can i do to see its docstring or other types of documentation?
02:32Cark,(doc some)
02:32clojurebot"([pred coll]); Returns the first logical true value of (pred x) for any x in coll, else nil. One common idiom is to use a set as pred, for example this will return true if :fred is in the sequence, otherwise nil: (some #{:fred} coll)"
02:33Carkdo the same at the repl, without the comma
02:41hiredmanwell
02:41hiredmanwith or without the comma, your choice
02:42Carkhum true
02:43Carkthat does not make sense
02:46hiredman?
02:48Carkahyes whitespace ... i was thinking common lisp there
03:21l_a_mgood morning
03:26Gilbert987does anyone know if there's a couchdb library for clojure?
06:42AWizzArdthewizzard_: The word "wizard" is correctly written with only one "z" :)
06:43thewizzard_AWizzArd: :p
06:44thewizzard_wanted to change the nick anyway... thanks for the reminder :)
07:17AWizzArdWell, my nick is now about 14 years old or so, and back then I didn't know about the one z, so I myself have to live with the wrong spelling.
08:08hjleeanyone with successful jswat or other debugger?
08:27AWizzArdhjlee_: only sometimes successful. jswat sometimes enters a breakpoint, although it is not fully clear to me yet when this happens and when not.
08:37hjlee_AWizzArd: thank you. I'm wondering.
08:41ericthorsenhjlee_: We are using Netbeans
08:41ericthorsenhjlee_: ...debugger
08:42hjlee_erichthorsen: ah, does Netbeans debugger work well with clojure?
08:43hjlee_I'm downloading eclipse clojure-dev now.
09:25AWizzArdclojurebot: max people
09:25clojurebotmax people is 164
09:35leafwdoes anybody know well the ExecutorServices
09:36digash`leafw: i have a pretty good idea about it.
09:36leafwhow in the world can a submit(Callable) throw a RejectedExcecutionException? The java code for that class shows that only when the service is saturated it should be rejected. But then, how can one queue, not submit, a future task?
09:36leafwi.e. I thought that submit would queue, and get executed when it can.
09:37leafwI never expected the service to reject anything on the basis of being "saturated". I thought it would queue.
09:37digash`leafw: queues have limits, depending on the implementation
09:38leafwdigash`: I see. So I have to find out how to enlarge the queue then
09:38digash`leafw: i've seen it blow up on out of memory
09:38leafwI'd like a fixed thread pool but more or less unlimited Callable queue of jobs.
09:39leafwso far it blows up with 4 or 5 elements queued
09:39leafwmakes no sense to me.
09:40digash`it should not blow up with such a small number can you lisppaste an example
09:40leafwExecutors.newFixedThreadPool(4); should give me such service ... unbounded, as the docs say.
09:42leafwdigash`: it's part of a large app: http://repo.or.cz/w/trakem2.git?a=blob;f=ini/trakem2/persistence/FSLoader.java;h=1a46048a7f811f4d9408e9a04e123b8d4cfe1a33;hb=29dd2cceee8404af24427cb2c0a1ecb65f2836bd#l2422
09:43leafwwould help a lot more if I could understand the error. As far as I can see, the quue is not full at all, yet the task is rejected.
09:47leafwdigash`: it's ok, ... likely the error is somewhere else.
09:47leafwI am translating this entire app to clojure, as a drastic measure to get all threading right.
09:59lisppaste8digash` pasted "executor service" at http://paste.lisp.org/display/77526
10:02leafwI know ... and that doesn't crash
10:02leafwthanks in any case
10:11digash`you can increase it to a million in that example and there is no problems.
10:16leafwdigash`: my best guess is that there is a problem in completing the task and it gets resubmitted infinitely, but for some reason it doesn't report so
10:19digash`leafw: interesting never run into that problem
10:26leafwdigash`: I meant the problem is on my side. The whole thing is linked to a canvas repaint.
10:27bstephensondigash`: nice example. Helps me with something I am working on. How would I use this approach if instead of wanting to do something 10 times, I wanted to use this to map a function across a collection, in a thread-ly way?
10:30leafwbstephenson: (doc pmap)
10:30leafw,(doc pmap)
10:30clojurebot"([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."
10:31bstephensonyes! thx, leafw
10:38banisterfiendanyone know where i can find a beta copy of the book 'programming clojure' ?
10:39leafwbanisterfiend: you can purchase it already
10:39leafwthen you'll receive betas until it's done; then the book.
10:39eevar2banisterfiend: http://www.pragprog.com/titles/shcloj/programming-clojure
10:39banisterfiendbeta in e-copy?
10:40rsynnottyep
10:40rsynnotta pdf, specifically
10:40rsynnottwith your name at the bottom
10:40banisterfiendnice
10:40banisterfiendyou can get it ALOT cheaper on the amazon site though
10:41banisterfiendor so it seems, it's about $25 on the amazon site, but the link you gave me is charging $40, maybe it's the beta copies that push up the price
10:42eevar240 is dead tree version + pdf
10:42eevar221 for just the pdf
10:43banisterfiendoh ok
10:43banisterfiendhttp://www.amazon.com/Programming-Clojure-Stuart-Halloway/dp/1934356336
10:43banisterfiendit doesn't say anything about it just being a pdf though, afaict
10:44dliebkeI don't think you can get the beta version of the book through amazon.com. Only through pragprog.com
10:46dliebkeyou can only pre-order through amazon, and wait until the final version of the book is published
10:46banisterfiendah ok
10:46banisterfienddliebke, but do you think the amazon version which is about $21 is the actual book or just the pdf?
10:46banisterfiendit doesn't say anything on the site about it just being a pdf
10:46dliebkethe amazon version will be the actual book, not the pdf
10:47banisterfiendwell that's amazing it's just $21 then!
10:47banisterfiend:))
11:37Chousercemerick: why does SciCL suggest reader macros?
11:39cemerickChouser: because scientists and mathematicians (and all sorts of disciplines) don't want to screw with "normal" sexprs
11:40Chouseryou're thinking of a syntax more tailored for them than what's shown at http://www.siginf.com/13023.html ?
11:40gnuvinceWhat a bunch of preciouses
11:41cemerickChouser: yeah -- his slides specified that various datastructures with special semantics were defined using {...}, [....], etc (apparently to be aligned with matlab)
11:41Chouserah
11:43cemerickI can definitely see the utility there...not for me, but I don't think we want to make clojure comparatively inhospitable for scientific computing (and other domains that are used to particular notation, maybe).
11:44ChouserI'd have to see what the desired syntax is, but there's quite a bit you can do without full-on reader macros
11:45cemerickDefinitely. And the notion of simply building a proper compiler as part of a sci-comp library is certainly out there (well-voiced in the 'are macros a menace' debate :-) )
11:46ChouserWas that last night? did you notice if anyone was taping it?
12:04sohailanyone tried clojure with gcj?
12:14durka42there isn't a seprate google group for contrib, is there?
12:14Chousernope
12:15durka42oh, well i was just going to post an idea i had, but i could ask you first
12:15durka42the idea was to tag contrib revs when releases happen
12:15durka42and maybe tar them up somewhere
12:15durka42so people who download releases and are looking for contrib don't run into compatibility issues with the latest svn
12:15Chouseryeah, that sounds like a good idea.
12:17Chouserwould it be just a jar, or a zip that contains the jar as well as other stuff?
12:18durka42i think it'd be useful to, upon a release, check out the latest contrib, ant jar WRT the released clojure.jar, and tar.gz that whole directory for http://code.google.com/p/clojure-contrib/downloads/list
12:18durka42so the source and the built jar
12:19Chouserwould you recommend they add the .jar or the src dir to their classpath?
12:20durka42well if you decided to work from a specific release you would just need the jars
12:20durka42if you were going to hacking contrib you'd want to have the src of course
12:20digash`we should ask tapestry guys to include clj-contrib in their nightly builds
12:20durka42e.g. (source partition-by) is really useful though -- does src need to be on the CP for that?
12:20Chouserthere's another nighly build server that already has both
12:20Chouserdurka42: yes it does
12:21digash`which one?
12:21durka42hmm, probably want to do that then
12:21digash`is it maven repository?
12:21durka42does it still work if you build the jar such that the clj files are in it
12:21Chouserdurka42: I think so
12:22durka42i think it does, because i don't have the src dir on my classpath
12:23durka42jar built with ant -Dclojure.jar=/path/to/clojure.jar has .class and .clj files in it
12:23Chouserso would there still be value in a zip, or would the jar be sufficient?
12:23durka42then probably just the jar would be good
12:24digash`we should have Maven repo, maven allows src jars, doc jars etc.
12:25durka42the user i have in mind goes to http://code.google.com/p/clojure/downloads/list and downloads clojure_20091230.zip, then goes to http://code.google.com/p/clojure-contrib/downloads/list and wonders where contrib_20091230.zip is
12:25durka42the situation right now if you want contrib you have to go svn latest with both or risk incompatibilities, right?
12:26digash`it will be all available for download through http and also integrates with all the IDEs
12:26durka42is if*
12:26Chouserdurka42: yes, or use svn to fetch an old version of contrib to go with your clojure release
12:26Chouserwhat about a zip and/or jar that includes both contrib and a clojure release?
12:26durka42right, but it's nontrivial to search through svn history for a date, isn't it
12:28digash`why reinvent dependency management, when maven infrastructure already provides it and IDEs/command line tools support it.
12:28durka42true
12:29ChouserI can't find the link for the non-tapestry nightly builds
12:29digash`i use the tapestry repo through maven and it is great and easy to use.
12:30digash`i would love to have clojure-contrib in their
12:30ChouserI actually thought contrib *was* in there, but I don't see it now.
12:30jsankeyhttp://pulse.zutubi.com/
12:30Chouserjsankey: thanks! that's it.
12:31jsankeyhas both core and contrib, and i'm working on integrated test reporting in the clojure-contrib-reports project
12:31durka42rev 1337?
12:31durka42that's a good number
12:31jsankeycurrently it builds continuously, i can also set up a nightly build if people want
12:31Chouserit already says 810 passed -- is that working?
12:31jsankeydurka42: haha, didn't notice that
12:32jsankeyChouser: yeah, it mostly works
12:32jsankeyi just have details to sort out, plus cleanups to the code
12:32Chouseris -reports from test-clojure or test-contrib or both?
12:32jsankeythe 810 is actually the number of (is ...) expressions
12:33jsankeywhich is more than the number of deftests
12:33Chousersure
12:33jsankey-reports does test-clojure, test-contrib and test-datalog
12:33Chouserah, great.
12:33jsankeyyou can drill into the build results to see them as suites
12:34durka42this is a nice interface
12:34durka42http://pulse.zutubi.com/browse/projects/clojure-contrib-reports/builds/15/tests/default/test-clojure/clojure.contrib.test-clojure.agents
12:34jsankeypulse actually has an ivy repository built in, in this bleeding edge version i have installed
12:35jsankeydurka42: thanks :)
12:35jsankeyyou can browse it at: http://pulse.zutubi.com/repository/
12:35durka42401
12:35Carkdurka : the link for "test suite test-clojure" and the next one are not working
12:36jsankeyoh, you can sign up for an account on the login page
12:36durka42ah, ok
12:36durka42Cark: did you mean that for jsankey
12:37jsankeyCark: ah, thanks, I hacked something by hand and looks like I messed that up :|
12:38jsankeyyou can also get the latest working and compatible (so far as the testing can attest anyhow) clojure and contrib from:
12:38jsankeyhttp://pulse.zutubi.com/browse/projects/clojure-contrib/builds/success/artifacts/
12:42jsankeyif you're extra keen you can sign up, add a contact point (e.g. email address) and subscribe to notification emails
12:42jsankeythere are also rss feeds for build results
12:42digash`jsankey: does it have maven repo?
12:43jsankeyno maven, i'm afraid
12:43digash`ivy is cool, but most of the IDEs right now support maven
12:43digash`I am stuck with it since my project is a mix of Java and Clojure and uses Maven
12:44jsankeyalthough we are considering what it would take fo the built in repo to be maven-compatible
12:44digash`as i understand it, it should not be difficult.
12:45jsankeyit's probably just about mimicking the layout and delivering a pom
12:45jsankeyas i say, these are bleeding edge pulse features, so still a work in progress :)
12:46digash`yep, take a look at the http://repo1.maven.org/maven2/
12:48jsankeyof course even if we don't build in a maven repo, we could publish to another one
13:00Cark~def send
13:01Cark~def clojure.lang.Agent/dispatch
13:01Cark~def clojure.lang.Agent
13:09Carka question about agents : outside a transaction, is it safe to assume that an action trigered with send or send-off is directly enqueued ?
13:11hiredmanyou mean they are not held till another time then enqueued?
13:11Carkyes
13:11hiredmansends with-in an agent action are held until the action completes
13:12Carkok let me explain, i'm playing with nio, i have an agent per connection and an agent for the server
13:12Carkthe server is blocking on a select
13:13hiredmanI gotta run
13:13Carkdamn =/
14:28hiredmanback
14:31Rayneshiredman: You're my hero.
14:32hiredman...
14:32durka42Raynes: i saw your sneaky almost-palindromic clojure program
14:33Raynesdurka42: Damn that Brian Carper!
14:33RaynesFound me out. :|
15:21tsdhHi. Is there a way to import a whole java package without naming all the classes?
15:25Carknope
15:25Carki remember seeing some code to do it anyways
15:26tsdhOk, thanks.
15:26Carkbut there's nothing in vanilla clojure
15:27ChouserThere will probably be some automatic performance enhancement based on the idea that you've imported the classes your code is actually likely to use.
15:28Chouserimporting a bunch of classes you don't need may complicate that, not to mention making the code harder to read since many people may not know which package a class belongs to, and thus won't know where to find docs for it.
15:37tsdhWell, in my case I need to import a package which contains 50 classes, and I'm going to need them all. ;-)
15:38hiredmanouch
15:39tsdhYes, but I admit that this is rather uncommon.
15:52Chouserfortunately
16:30jwinter_1Has Rich posted his ILC09 slides?
16:32hiredmanI think I saw posts of slides from presentation 1 and 3
16:32hiredmanclojurebot: delicious?
16:32clojurebotdelicious is http://delicious.com/clojurebot
16:32Chouserjwinter_1: they're on the google group files list
16:32jwinter_1thanks
16:37durka42why did delicious move away from del.isio.us?
16:37durka42del.icio.us
16:38SethTisuei could never remember where the first dot went
16:43ChouserI wonder why 'throw' is a special form instead of just a Java method, like in RT
16:43Chouserperhaps it's just for the sake of the generated stack trace?
16:50digash`it does not abide by the normal Java method invocation semantic
16:52digash`there is an instruction in the jvm for athrow
16:53digash`http://java.sun.com/docs/books/jvms/second_edition/html/Compiling.doc.html#9934
16:56Chouserbut there could be a fn or macro named 'throw' in clojure that turns around and calls RT.throwVal( e ), which could in turn just do a Java throw
16:56Chouserhm, I guess it participates in type hinting oddly
16:59digash`it would pollute the stack with the call
17:03Chouseryes, that's the only reason I could think of -- I suppose it's sufficient.
17:06berth_Hi, I am trying to read the java version like that: (.getProperty (java.lang.System) "java.version")
17:06berth_But I get java.lang.ClassCastException: java.lang.Class .
17:07hiredman(System/getProperty "java.version")
17:07berth_Thanks, is that a general rule for static methods?
17:08hiredmanyes
17:08hiredman,(macroexpand '(System/getProperty "java.version"))
17:08clojurebot(. System getProperty "java.version")
17:08hiredman,(macroexpand '(.getProperty (java.lang.System) "java.version")
17:08clojurebotEOF while reading
17:08hiredman,(macroexpand '(.getProperty (java.lang.System) "java.version"))
17:08berth_Interesting, thanks a lot.
17:08clojurebot(. (java.lang.System) getProperty "java.version")
17:09berth_, (+ 2 2)
17:09clojurebot4
17:09berth_... now that's funny. :-)
17:09berth_,(System/getProperty "java.version")
17:09clojurebotjava.security.AccessControlException: access denied (java.util.PropertyPermission java.version read)
17:09berth_wow.
17:20kib2Pathetic: http://www.wisdomandwonder.com/link/2110/why-mit-switched-from-scheme-to-python
17:22cmvkkthat made a lot of sense to me; then again, i have no problem accepting python as a good learning language
17:23cmvkki wonder how clojure fares in terms of 'first languageness'? Even though it's hands down my favorite language now, and I find programming in it pretty easy,
17:23cmvkkI get the feeling if someone asked me for tips on learning to program, I'd still reccomend starting wtih Ruby.
17:24p_l|backupjava & bluej is certainly a bad way to teach
17:24gnuvince_I recommend Python
17:24kib2cmvkk: Python is a good langage to learn, I've no problem with it too. What's pathetic for me is "In 1980, good programmers spent a lot of time thinking" : what now ?!
17:25gnuvince_It allows a new programmer to quickly use it to make script that can benefit him
17:25cmvkkkib2 I see what you mean; i didn't get that comment either. but the rest makes sense to me.
17:25p_l|backupkib2: now they spend time cursing
17:25gnuvince_It's easy to stay motivated that way.
17:25cmvkkabout things being understandable all the way down before, and now they aren't.
17:25gnuvince_SICP is nice and powerful, but I don't think it would grasp most programmers when they begin
17:26kib2gnuvince: not so sure...
17:26cmvkki think the thing about functional program a la clojure is, while it makes doing real programming much simpler, it still isn't as intuitive for simple tasks as a regular imperative language would be
17:26gnuvince_kib2: somebody who starts to play the guitar doesn't want to know about scales and arpegioes, he wants to learn 10 chords to play songs and sing along.
17:27gnuvince_I believe that for a lot of people who take up programming, they just want to solve one or a few little problems.
17:27gnuvince_So give them something good for that
17:27gnuvince_And if they get hooked, then they can make their own journey into SICP and Haskell and CLRS
17:27p_l|backupgnuvince_: that was purpose of things like shell scripting, perl etc.
17:28ChouserI'd be very curious to see if it really would be hard for someone to learn clojure as a first language.
17:28hiredmanthat hardly compares to a being programing course
17:28cmvkkp_l|backup, I think perl falls into the same category here as python and ruby
17:28gnuvince_p_l|backup: I would recommend them if I didn't think Python was a better choice for someone new.
17:28cmvkkyou can use those languages like that.
17:28p_l|backupI was referring to elder times :)
17:29cmvkkthe question is whether clojure can be a language that's easy for beginners to learn,
17:29cmvkkwhether clojure can be a language that's easy to write simple tasks in.
17:29gnuvince_I don't think it's easy. Simple, yes; easy, maybe not so much.
17:29kib2gnuvince: sure, SICP is rather hard (and if you really try to find all the exercices solutions, it's even harder but worth it).
17:29cmvkkand if not, why not? it's not like you can't write compicated programs in python and ruby; you can do both things in those languages.
17:29gnuvince_It makes "sense" to modify something
17:30gnuvince_You have a "sum" box, you just add something more to it by modifying it
17:30cmvkkgnuvince_ yes i think that's the crux of the problem. imperative programming is just plain intuitive.
17:30gnuvince_It may not be the best of habit, but I think it certainly makes sense to somebody who's starting out.
17:31hiredmanhonestly, I cannot imagine my classmates in the last CS course I took having any more trouble with clojure then they did with java
17:31hiredmanbut they had a lot of trouble with java so...
17:31cmvkkhiredman, on the flip side though, I always got the feeling Java was a terrible language to learn on
17:31cmvkkway worse than python would be
17:31kib2What really amazed me the first time I've read some parts of it was the little computer algebra system they introduce. Doing such things in Python is much more difficult than Scheme/Lisp.
17:31Chousukecmvkk: python teaches you that code that compiles doesn't always work
17:32ChouserI really don't know. once you've spent a day learning basic or python or any other procedural/imperative language, that's a day's worth you'll have to re-learn to use clojure or something functional.
17:32Chousuke"it compiles, ship it!"
17:32Chousuke"but it's full of stubs!"
17:32Chouserbut if you start with the idea that things don't change, I'm not sure that's actually any more difficult to grasp.
17:32cmvkkChouser, so in other words, you think it doesn't matter if languages like clojure are easier to learn than other languages, because they're necessary.
17:32Chouseryou don't even have to think about "locations"
17:33cmvkkin the end, you have to have a language like clojure, so you might as well just go with it from the start?
17:33Chouserno, I'm not asserting anything. I'd like to know if someone could learn clojure first just as easily as learning python first.
17:33cmvkkah, okay. that's basically what I want to know.
17:34Chouseror if immutable collections and immutable locals are inherently harder to grasp. I really don't think the answer is obvious.
17:34hiredmanthe idea that imperitive is easier is silly, when you see how much trouble people have with it
17:34cmvkkto me, python feels more intuitive from a beginner's perspective. but then again, I personally started programming with gw-basic, so maybe that shapes my opinions.
17:34hiredmanwithout even going into thread safety, etc
17:34Chousukepeople might have expectations that don't apply to clojure.
17:35Chousercmvkk: right, I started with basic and then got several years of various imperative languages under my belt before even hearing of immutable locals or collections.
17:35Chouserand of course my first thought was: how the heck can you *do* anything??
17:35gnuvince_Chouser: the only way you could know is to have a large sample. You would need many programmers who begin programming in functional languages.
17:35cmvkkyeah, me too. and when i started learn-- yeah, when i started learning common lisp, that's exactly what I thought.
17:35gnuvince_And unless you force them, that's probably never gonna happen.
17:35ChousukeChouser: I guess you could counter that question with something cryptic like "how do you think functions in mathematics work?"
17:36hiredmanI finished the third and final CS course the local community college offers about a year ago. this was the *third* course and people still had trouble with basic things like looping around arrays, etc, or building stuff outside of an environment like bluej
17:36gnuvince_I hang in a french programming irc channel, and no matter how much I encourage newbies to begin with Python for a variety of reasons documented on my blog, they all end up going to C or C++
17:36gnuvince_All of them
17:36Chouserwell one of these days one of my kids will show a spark of interest in programming and I'll ram something into their heads. ;-)
17:36p_l|backupC is not that bad of a choice... C++ on the other hand...
17:36gnuvince_Because "I hear they're the most popular/powerful languages" or "they're *real* programming languages" or "they're fast" or whatever.
17:36cmvkkheh
17:37gnuvince_p_l|backup: I wouldn't start somebody on C. Probably go with Python to learn about variables, loops, conditions, functions, etc. and then take a step back and look at C.
17:37ChousukeChouser: just make sure it's got lots of parentheses.
17:37p_l|backupgnuvince_: they have one thing better than those who end learning Java all the way as it's shown in introductory courses in unis...
17:37cmvkkit seems odd because nowadays, i think of Ruby as being 'the popular language'. if you want to do web programming, that is, and apparently that's all anyone ever wants to do anymore
17:37kib2gnuvince-: so they only think "speed" is better ?
17:37p_l|backupgnuvince_: namely, they get hurt by the machine :)
17:37gnuvince_kib2: who doesn't think that?
17:38kib2gnuvince_: your readers think that speed matters
17:39gnuvince_p_l|backup: could the fact that they, themselves, decide to learn programming instead of just doing what the course requires of them, count for something?
17:39gnuvince_I know that I won't ever be good at math, because I only care about learning what I need to pass the classes I take.
17:39p_l|backupgnuvince_: that too
17:49cconstantineChouser: The types of things that could be thrown from a function is a part of the method signature in java.
17:52meredyddHey - anyone here tangled with the Java SecurityManager stuff?
17:52danlarkinmeredydd: hiredman has
17:52meredyddSpecifically, I'd like to identify stuff from the Clojure classpath
17:53meredydduhh, "classpath" is the wrong word
17:54meredyddRestate: I'd like to be able to identify, in my security policy, the actual generated code rather than the Clojure compiler
17:54meredydd(so, for example, it's entirely reasonable for the former to run without (RuntimePermission createClassLoader), there's no way the latter could)
17:55meredyddIs there a way to do this for dynamically (eval)ed code, or am I just going to have to AOT everything?
17:55hiredmandanlarkin: not really
17:56hiredmanit sounds like meredydd acutally knows how policy files work
17:57meredydd*still didn't
17:57hiredmanword
17:57meredyddSausages, law, and JVM sandboxes.
17:58Chousercconstantine: oh, of course.
17:59hiredmanmeredydd: any particular jvm sandboxing resources you'd care to share?
18:00meredyddUhh...unfortunately, there appears to be no such "good resource".
18:00meredyddIf you have a question, I'll see if I can answer it, and figure out where I found that answer, though.
18:00hiredmanmakes me feel better about not finding one
18:01hiredmanI would like to disallow catches in clojurebot's sandbox
18:02meredyddI'm trying to sandbox Rhino scripts right now, and mostly used Google, the Rhino javadocs (ignore the "developer docs" wiki, the security stuff is hopelessly out of date and refers to classes that don't exist any more), and when all else failed, reference to the source of an existing implementation (the Apache batik SVG viewer, which has safely embedded javascript).
18:03meredyddSorry, not that relevant to you...
18:03meredyddwb
18:03hiredmanman
18:03hiredmanirssi sure picked a great time for that
18:03meredyddSummary: I don't think my experience from today is all that useful to you
18:04hiredmanok
18:04meredyddbasic JVM stuff like try/catch falls outside the SecurityManager's remit
18:04meredyddAll those permissions are manually checked, with calls to SecurityManager.checkPermission() and friends
18:05hiredmanwait, what?
18:05meredyddYou're trying to disallow use of (try ... (catch ...)) in the clojurebot sandbox, yes?
18:05hiredmanoutside the sm's remit, but is checkusing sm.checkPermission
18:06hiredmanmeredydd: yes
18:06hiredmancurrently I just check the macroexpanded form for 'catch
18:06hiredmanbut I would be more comfortable if the jvm took care of this for me
18:07meredyddOh, sorry. What I meant was, "the checks that are within the SM's remit, like 'can I write to this file?', are checked manually, by code in (eg) java.io.File, which calls SecurityManager.checkPermission() and friends)
18:08hiredmanhmmm
18:08hiredmanI see
18:08ChouserALU?
18:08meredyddSo I'm guessing you'd have to modify the compiler to reject (catch)s.
18:09selloutdigash: Can you vote for him for me, too?
18:09meredyddWhat's the reason? What nefarious thing can a clojurebot user do with a catch block?
18:09selloutAlthough, Peter Seibel got on the board in 2005 and later resigned out of frustration ...
18:10digash`sellout: are you a member?
18:10selloutdigash`: I'm at the conf (so, yes), but not at the meeting.
18:10hiredmanmeredydd: you can use a try/catch block to send it into a loop of trying and catching which thread.stop cannot break out of
18:11meredyddOh, that.
18:11digash`sellout: they give me only one peace of paper to write names on.
18:11selloutdigash`: just write it twice ;)
18:11meredyddhiredman: Rhino apparently disallows catching of Errors, just to let you do things like that
18:11selloutI kid ... I do think he'll get on, though.
18:11meredyddwhich is a strong indication that there's no JVM-level way of saying "no, really, kill this thread *now*"
18:12hiredman:(
18:12selloutWait ... Rich isn't at the meeting, is he? He was just talking to me a few minutes ago.
18:12meredydd(I'm surprised by Thread.stop(), though - I thought it was deprecated because it was too brutal...)
18:13digash`sellout: Yes, he is here.
18:13meredydd(Oh, right. You can still catch the ThreadDeath. How silly.)
18:13hiredmantell me about it
18:13digash`sellout: Come over and vote!
18:14meredyddhiredman: My only thought is that you could patch the compiler to refuse to compile (catch)es
18:14hiredmanugh
18:14meredydd(or, even better, refuse to compile (catch)es of anything not a subclass of Exception)
18:15meredyddShould be a one-liner. But yes, I agree, Ugly City.
18:16meredyddhiredman: Sorry I can't be more help.
18:16hiredmannot your fault
18:17digash`Rich is on the board of ALU now!
18:17hiredmanhaha
18:17hiredmansuckers
18:21cconstantineWhat is ALU?
18:23hiredmanassoc. of lisp users?
18:23SethTisueyes
18:24SethTisuelisp.org
18:24cconstantineah
18:24cconstantineI'm a lisp user... I'm guessing that means an important lisp user ;)
18:29meredyddRats. Looks like the Clojure compiler doesn't mention that a class comes from disc...
18:38cconstantineI'm writing a palendrome detector, and I've found something weird: given a list, and the reverse of the list, it's faster to just do a (= in-order-list rev-order-list) than it is to do (= (take half-size in-order-list) (take half-size rev-order-list)). Can anyone explain that?
18:38duck1123are you going for that write hello world as a palindrome challenge?
18:39cmvkkit might be that 'take' just maps over a list with a counter, so traversing (take 5 foo) would be slower than traversing foo itself.
18:39cmvkkbut would it be twice as slow?
18:40durka42cconstantine: take brings in lazy-seq machinery. i don't know if that's slow
18:40cconstantinedurka42: no, project euler
18:40cmvkkoh, is 'take' eager?
18:40durka42no
18:40durka42,(take 5 (iterate inc 0))
18:40cconstantineit claims to be lazy
18:40clojurebot(0 1 2 3 4)
18:41cmvkk(do (take 5 (map (fn [x] (print "h")) (repeat 0))) nil)
18:41cmvkk,(do (take 5 (map (fn [x] (print "h")) (repeat 0))) nil)
18:41clojurebotnil
18:41hiredman~def take
18:41cmvkkguess it's lazy
18:42cconstantinethe longest of these lists is 6 items long
18:42cmvkk'cows'
18:42cconstantineooo, I wonder if wrapping it in a take each time kills some kind of caching going on with the lazy-seq it's working with
18:44durka42,(let [ls '(1 2 3 4 5 6 7 8 9 10) rev (reverse ls)] (time (= ls rev)) (time (= (take 5 ls) (take 5 rev))))
18:44clojurebot"Elapsed time: 0.098 msecs" "Elapsed time: 0.059 msecs"
18:45cconstantinehmm
18:45durka42microbenchmarks like this may or may not be useless
18:45durka42,(let [ls (range 10000) rev (reverse ls)] (time (= ls rev)) (time (= (take 5 ls) (take 5 rev))))
18:45cconstantinethis is true... my time is something like 2-3 seconds
18:45clojurebot"Elapsed time: 0.112 msecs" "Elapsed time: 0.067 msecs"
18:45durka42whoops
18:46cconstantinehehe
18:46durka42,(let [ls (range 10000) rev (reverse ls)] (time (= ls rev)) (time (= (take 500 ls) (take 500 rev))))
18:46clojurebot"Elapsed time: 0.105 msecs" "Elapsed time: 0.06 msecs"
18:46durka42oh, i have to go
18:46cconstantinethanks :)
18:46durka42happy palindroming
18:48hjleesorry, why 500? must be 5000?
18:49cconstantine,(let [ls (range 10000) rev (reverse ls)] (time (= ls rev)) (time (= (take 5000 ls) (take 5000 rev))))
18:49clojurebot"Elapsed time: 0.111 msecs" "Elapsed time: 0.061 msecs"
18:49cconstantinegood point
18:52hjleeah... but i think "=" only take 1st element the above case. why first "=" so slow?
18:53hiredmanerm
18:53hiredmanwhy would "=" take only the first element?
18:53hiredmanah
18:54hiredmanreverse
18:55RaynesIs there a function to zip up a sequence? Like say you had [['a] ['b']] and wanted to turn it into ['a 'b].
18:56Raynes[['a] ['b]]*
18:56hiredmanthat is not zip
18:56hiredmanthat is flatten
18:57hiredmanthere is always apply concat
18:57Rayneshiredman: I was thinking of Haskells zip function.
18:57RaynesAnd thanks.
19:11blbrownis there a Java approach for loading scripts through Java. E.g. can I call main.legacy_script(String[] args); with multiple scripts...more than one time and keep the state of the interpreter
19:11blbrownhmm, or I could create my own 'main' class
19:35jhawk28has anyone seen: http://www.newartisans.com/2009/03/the-jvm-and-costs-vs-benefits.html
19:42johnwjhawk28: I have ;)
19:42albinojohnw: yeah, johnw is the author of that
19:43albinoerr that was for jhawk28
21:26texodushello
21:26durka42hi texodus
21:26cmvkkhello
21:26texodusgot a few minutes to help me with some concurrency questions?
21:27durka42have to run in a sec
21:27texodustragic
21:27cmvkkwell i'm here but i don't know how helpful i can be
21:27texodusWell, I'll ask and see what comes from it
21:29texodusI'm trying to parse a large dataset
21:29texodusand each entry has some crypto and date parsing and whatnot to be done
21:30durka42clojurebot: can clojure do crypto and date parsing and whatnot?
21:30clojurebotYes, Clojure can do that!
21:30p_l... not this shit again
21:30texodussure :)
21:30cmvkkheh
21:30texodusbut I want to do it in parallel
21:30cconstantineI've got one too.... :) I have a list of number sets ([1 2 3] [2 3 4] [3 4 5] ...) and only one of them will return true for my predicate. How can I multi-thread the search for the set that is true for my predicate? The math in the predicate should be hard enough to warrant the threading overhead.
21:30texodusand creating those objects for each task is a taxing
21:30durka42agents :)
21:30cconstantinetexodus: agents or future
21:31hiredman,(doc pvalues)
21:31clojurebot"([& exprs]); Returns a lazy sequence of the values of the exprs, which are evaluated in parallel"
21:31hiredman,(doc pmap)
21:31clojurebot"([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."
21:31texodusyes, but I don't want to create a new crypto parsing objects for every datapoint - is there a way to use send-off with a thread-local copy of the java bits, to be reused?
21:31cconstantinehiredman: is there something like pfilter?
21:32cmvkkhmmm
21:32dreishcconstantine: You could write one using pmap.
21:32hiredmancconstantine: I would make sure the predicate returns the data or nil
21:32hiredmanthen filter identity
21:32hiredmaner
21:32hiredmanthen pmap, then filter identity
21:32cconstantineThat would work..
21:33cconstantinethanks :)
21:34cmvkktexodus, you have stuff you want to do in parallel, but you want to reuse an object
21:34texodusso, is there a way I can use binding to create thread-local copy of an instance, eg DateFormat, that would be used only for that agent for every fn that is sent to it?
21:34texodusexactly
21:34texodusI dont want to recreate the java objects for every function
21:34cconstantine,(doc future)
21:34clojurebot"([& body]); Takes a body of expressions and yields a future object that will invoke the body in another thread, and will cache the result and return it on all subsequent calls to deref/@. If the computation has not yet finished, calls to deref/@ will block."
21:35hiredmantexodus: if the java object is stateful that you really have littel choice
21:35cmvkkso maybe you create 4 of these objects, then spin off 4 agents that just loop grabbing a chunk, parsing it, then doing it again
21:35hiredmanstateful and not thread-safe
21:36dreishNot necessarily. I don't see why the binding approach wouldn't work, if you can figure out how to string it together.
21:36cmvkki did this with byte-buffers once. split up the file to be rendered into chunks, then spun off N agents or so. every agent grabbed the next available chunk, parsed it, then put the result in a ref, grabbing the next one.
21:36hiredmandreish: it would only work if he bound a sepperate object each time
21:36cmvkkconcurrent, and only N byte-buffers, just reused over and over again.
21:36dreishhiredman: For each thread, which I think is the whole point.
21:37hiredman*shrug*
21:37cmvkkit's certainly possible, but there's no built-in way to do it.
21:37texodusI coudl write a macro to create n agents and n instances, then just manage handing them off
21:37texodusbut I was hoping someone else had already climbed this mountain
21:37dreishOr a function!
21:38dreishEven more powerful than a macro!
21:38texodusright, functions are worth fewer life achievement points :)
21:38hjleetexodus: why reuse something like DateFormat?
21:38cmvkktexodus that's basically what you want to do i think. it's really something you have to hand-roll based on what sort of data you're working on and what you're doing to it.
21:39texodusdateformat is a trivial example
21:39hjleethe objects are stateful?
21:40texodusif they were, is the only answer to wrap them in java concurrent to make them thread safe?
21:41texodusI dont really have a concrete example, clearly instantiating a new dateformat is no huge efficiency drain
21:41texodusthe crypto stuff is worse
21:42cmvkki don't think mutable java objects play well with clojure's concurrency semantics
21:42dreishThey're not so bad with thread-local bindings.
21:42texodusI'd like to be able to say something like (def some-agent (agent-with start-state & thread-local-bindings)
21:42cmvkkyeah, that's basically the only option
21:42dreishThey don't play well with programs that are easy to reason about, in general, but that's not a Clojure-specific feature.
21:43dreishSo you're no worse off than in most languages, in the worst case.
21:43cmvkktexodus, what you want is a function that creates a copy of whatever java object you want, then uses it to process N entries, then returns all those entries at once.
21:44cmvkkthen you pass THAT to an agent.
21:44texodushrmm
21:44texodusthat may work
21:45dreishFeh. Too simple. There must be a more complicated way to spend weeks banging your head against a wall.
21:45cconstantinewow, so my Core 2 Duo is NOT happy with all this multi-threading :) Its fans are going like crazy and I get answers really fast.
21:47texodusso, on a completely unrelated question, is there a way to create a blocking function in clojure other than through overlapping transactions?
21:48Chouseroverlapping transactions may not block. :-)
21:48Chouser(doc locking)
21:48clojurebotExecutes exprs in an implicit do, while holding the monitor of x. Will release the monitor of x in all circumstances.; arglists ([x & body])
21:48texodusright, so also consistent blocking
21:48Chouser(doc future)
21:48dreish(locking ob (...))
21:48texodusah so
21:48clojurebotTakes a body of expressions and yields a future object that will invoke the body in another thread, and will cache the result and return it on all subsequent calls to deref/@. If the computation has not yet finished, calls to deref/@ will block.; arglists ([& body])
21:48dreish(doc locking)
21:48clojurebotExecutes exprs in an implicit do, while holding the monitor of x. Will release the monitor of x in all circumstances.; arglists ([x & body])
21:48texodusthat was easy
21:49texodusthanks
21:49texodusvery helpful channel
21:49dreishTwice as helpful as channels were just one guy gives you the same answer!
21:49cconstantinehehe
21:50Chouserha
22:15arohnerI have an ns declaration, where I use a (:require [foo :as bar]). Now I want to change the ns foo to something else, but reloading the file complains that bar already points to foo. is there a way to unalias foo?
22:17arohnerah, ns-unalias
22:17arohner(doc ns-unalias)
22:18clojurebotRemoves the alias for the symbol from the namespace.; arglists ([ns sym])
23:17matthew`Hi, I am interested in using Clojure and the Netbeans platform. How do people link up the actions with Clojure code?
23:17matthew`Also what is done about build and delivery.
23:18Chousermatthew`: you've looked at "enclojure"?
23:19matthew`Chouser: I have looked at enclojure.
23:19Chouserwell then you've exhausted my knowledge. :-)
23:19matthew`Even in enclojure the two seem like separate entities.
23:20matthew`I am talking in terms of the Netbeans platform.
23:20Chouseroh, you want to customize netbeans itself using clojure?
23:21matthew`Yes, I want to build a netbeans platform application using clojure.
23:21matthew`So I want to join a Java action up to a Clojure function.
23:22Chouserwell, you could look at the enclojure sources themselves.
23:22matthew`What's more is that I want to be able to deliver such and application. The dynamic nature of Clojure has me a bit stumped there.
23:22Chouseryou have two routes for calling clojure from java
23:22matthew`Yes that sounds like a good idea.
23:23arohnerI'm not familiar with netbeans, but I assume that means you need to inherit from a java class?
23:23Chousereither use gen-class and AOT compilation to create .class files that look like what netbeans is expecting
23:23Chouseror write java code that calls clojure fns using the .invoke() method
23:26matthew`Thanks for information. I will investigate the two options and the enclojure code itself. Thanks again.
23:26Chouserenclojure uses the latter, last I knew
23:35Chouserhttp://en.wikibooks.org/wiki/Clojure_Programming/Tutorials_and_Tips#Invoking_Clojure_from_Java
23:50matthew`Chouser: Thanks.