#clojure logs

2009-06-03

01:16sunwukongis there a function in core/contrib for #(filter identity %) ?
01:17sunwukong(that is, removing every nil/false element from a coll)
01:59replacasunwukong: not that I can think of off hand
01:59sunwukongok, thanks
07:41cemerickwhew, the rhickey interview from qcon is done in a very unpleasant format, IMO
07:42arbschtgot a link?
08:00cemerickarbscht: http://www.infoq.com/interviews/hickey-clojure
08:00arbschtthanks
08:00cemerickit's sort of an interview, but the interviewer is sitting in the audience, which strikes me as odd
08:18gnuvincecemerick: that interview is not really good IMO because the interviewer sticks mostly to his notes and is generally boring
08:18cemerickyeah, that too :-)
08:20gnuvinceInterviewers should be more like Simon Peyton-Jones
08:24cemerickI don't think I've seen him interview anyone.
08:26gnuvinceMe neither, I mean that the interviewer should be enthused and engaging instead of sitting his butt on a chair and just going through a list of questions.
08:44cemerickthe treatment of the last map in an apply form as a seq of args can lead to some very hard-to-diagnose bugs
08:45cemerickI guess I'm supposed to know what I'm doing with all this rope ;-)
08:46Chouserheh
08:50eliantorhi
08:51Chousereliantor: hello
08:51cemerickChouser: what's your take on the UI stuff from javaone? I was pretty bummed about the consistent soft-pedaling of swing.
08:52Chousercemerick: didn't pick up on that. you're referring to the big javafx push in the keynote?
08:53eliantori'm trying to do something like this: (map + [[1 2 3] [1 2 3]]) --> [2 4 6]
08:53cemerickI saw a bunch of tweets about sun people saying they're "still planning on *supporting* swing", jwebpane maybe being released alongside jdk7, but not included in the jre, etc.
08:54cemericktwitter rumors are probably not the best thing to go by, but it's what I've got right now :-)
08:54eliantori mean how can i inline a list to provide it to map?
08:54Chouser,(apply map + [[1 2 3] [1 2 3]])
08:54clojurebot(2 4 6)
08:54eliantorthanks
08:54eliantor:)
08:55cemerickalso:
08:55cemerick,(map + [1 2 3] [1 2 3])
08:55clojurebot(2 4 6)
08:55cemerickif you have distinct collections
08:55Chousercemerick: hmph. and is javafx their replacement for it, or am I confused.
08:55cemerickech, join the club.
08:56cemerickthey don't have much of any story around javafx widgets that would be the analog of those available in swing, so I don't see how they can expect people to make the jump.
08:57cemerickMaybe all UIs are supposed to be done in photoshop or their "JavaFX Designer" vaporware :-P
08:57Chouseryou know, the canvas 2d api isn't that complicated -- if you've got a canvas-based ui toolkit you like, what about something that proovides not a full browser stack, but just a canvas compatible api?
08:57Chouserdo you have a canvas-based ui toolkit you like? :-)
08:58cemerickcanvas-based UI toolkit? Like dojo, or whatever?
08:58Chousercemerick: I dunno, I thought that's why you wanted jwebpane
09:00cemerickI want jwebpane for a variety of reasons. Most of all, I don't want to be dragging a "legacy" toolkit around everywhere, and there's going to be light and heat around canvas for the next decade at least.
09:08cemerick is there a "deep" map merge somewhere? (deep-merge {:a #{1 2}} {:a #{3 4}}) => {:a #{1 2 3 4}}
09:08cemerickah, deep-merge-with, perhaps :-)
09:59drewrReminder: Clojure Search http://www.google.com/coop/cse?cx=004621955734675372103:0oxuogeollc
10:07lisppaste8cgray pasted "gen-class problem" at http://paste.lisp.org/display/81280
10:08chillitomi think I've just realised a massive problem with my UniqueBlockingQueue.. because all methods are synchronized a call to take() can never return if the queue is empty
10:08cgrayso I'm having trouble figuring out why the class that I'm generating isn't getting loaded properly...
10:09chillitomdamn conncurency is difficult!
10:09Chouserchillitom: yeah, that's actually a feature. :-)
10:09Chouser.take not returning is a feature, I mean, not that concurrency is complex. :-/
10:10cgrayjava.lang.IllegalStateException: Cannot create AdaptiveSignalSystemControler for class name:
10:10cgrayplayground.cgray.adaptivecontroler
10:10cgrayany ideas?
10:11Chousercgray: That's not all in one file, is it?
10:11cgrayChouser: no, after add-classpath is in a different file
10:12Chouserhey, you know what though -- if all you're doing is implementing an interface, I *highly* recommend proxy over gen-class, even if you intend to compile to .class files.
10:12cgrayI don't think that works in my case. I have to give the name of the class to an xml file
10:13Chouserbah. ok.
10:13Chouserwell, the first thing I'd try is getting rid of the add-classpath
10:14Chouserset your classpath on the command line with -cp and then try compiling
10:14cgraywhat do you mean?
10:15Chouserjava -cp clojure.jar:src clojure.main
10:15Chouserthen you can bind *compile-path* to "src" and try compiling.
10:15Chouseradd-classpath is unreliable.
10:16cgrayok, good to know
10:19cgrayhmm, from the command line I get a ClassNotFoundException on the interface that I am trying to implement
10:19cgrayand it's in a jar that's on the classpath
10:20cgrayno, never mind
10:20cgraythe jar wasn't on the classpath :)
10:21Chouser:-)
10:24cgrayok, so it compiles. how would I test if it can actually be loaded?
10:26Chouser(new playground.cgray.adaptivecontroler)
10:26ryshttp://www.infoq.com/news/2009/06/g1-free-or looks like Sun changed the wording on G1 in the latest update to 6
10:26Chouser(.givenSignalGroupIsGreen (new playground.cgray.adaptivecontroler))
10:28dnolenrys: good
10:28cgraythe first one worked, the second one didn't
10:28Chousercgray: odd. What kind of error did you get?
10:28cgrayNo matching field found
10:30Chouseroh, it wants an arg. my bad.
10:30Chouser(.givenSignalGroupIsGreen (new playground.cgray.adaptivecontroler) nil)
10:30cgraythanks, I should have caught that :)
10:33Chousercgray: so add-classpath was the only thing you had to change?
10:33cgrayso it works at the repl, but when the larger application tries to call it, it still barfs... at least I know that problem isn't with clojure though...
10:41cgrayChouser: I missed your question. I think it was working, I just wasn't testing it properly.
10:41Chouseroh, even with add-classpath it was working?
10:42cgrayI think
10:42Chouserok
10:56cemerickis there a deep macroexpand anywhere yet?
10:56gnuvinceNot built-in
10:56gnuvinceI don't know about clojure-contrib
10:57cemerickwell, clojure.contrib.macros doesn't have one, which I presume would be where it'd be.
10:57cgrand1konrad has put a macroexpand-all in contrib
10:58cemerickah, it's in walk
10:59cgrand1or mexpand-all in macro-utils
11:02cgrand1walk/macroexpand-all seems to not care about locals nor special symbols
11:03stuartsierracgrand1: yes, that's true, but it should still work
11:09ChouserWhy doesn't this work: (defn #^bytes foo [])
11:09dnolenisn't that a primitive type?
11:16cemerickhrm, type-hinting issues is this week's theme
11:17Chouserdnolen: it means an array of primitive bytes when used in other type-hinting contexts.
11:17dnolenprimitive arrays aren't Objects
11:17dnolenfunctions can only return Objects
11:18dnolenthis is what the whole boxing issue on primitive types is all about
11:18Chouser,(make-array Byte/TYPE 10)
11:18clojurebot#<byte[] [B@8bb8b2>
11:18Chouserwhat's that?
11:18dnolenthe repl printing out a primitve, this probably uses reflection I'm assuming.
11:19dnolencould be wrong of course, but this was the take away when rhickey explained it.
11:19Chouserno, I think you're incorrect. make-array is a function, and it's returning a thing
11:19Chouser,(instance? Object (make-array Byte/TYPE 10))
11:19clojurebottrue
11:19dnolenbut that might be boxed right?
11:20Chousuke,(class (make-array Byte/TYPE 10))
11:20clojurebot[B
11:20cemerickChouser: maybe defn doesn't play well with the primitive hints? {:tag (Class/forName "[b")} ?
11:20Chousuke:P
11:20ChouserI think a primitive can't be returned by a clojure function, but an *array* of primitives is fine.
11:20Chousukehmm
11:21Chousukethe bash prompt git branch addition is nice
11:21Chousukenow I no longer need to type "git branch" to know where I am.
11:22cemerickspeaking of git, my quick experiment to keep patches on top of a git-svn clone of clojure's svn didn't go well. Apparently, one cannot push git-svn state to a git remote...?
11:22ChousukeI think it's possible somehow manually though.
11:22danlarkinI think that (instance? Object (make-array Byte/TYPE 10)) comes back as true because passing the array to instance? boxes it? since it's a function boundary?
11:22dnolenChouser gotcha, dunno then.
11:23dnolen,(instance? Object (ints (make-array Integer/TYPE 10)))
11:23clojurebottrue
11:23Chouserdanlarkin: make-array is clojure function -- the thing that it returns has to obey the same rules as any args would.
11:23stuartsierraYou can do (defn #^"[B" my-function ...)
11:24dnolen,(instance? Object (int 1))
11:24clojurebottrue
11:25dnolenno way that is true
11:25Chousuke,(class (int 1))
11:25clojurebotjava.lang.Integer
11:25danlarkinit's the function boundary
11:25dnolenyes
11:25Chouserstuartsierra: ouch. But yes, that works fine. Thanks.
11:26Chouserint is not a plain function
11:26dnolen,(instance? Object 1)
11:26clojurebottrue
11:26Chouser1 is a boxed object
11:26dnolenthan how can you know that something is primitive?
11:26Chouserdo it in a big loop and see if it's slow?
11:27dnolenhaha
11:27Chouser:-)
11:27stuartsierradnolen: arguments to Clojure fns are always boxed.
11:27Chousuke~def instance?)
11:27clojurebotExcuse me?
11:27Chousukeoops
11:27Chousuke~def instance?
11:27dnolenstuartsierra: yeah.
11:28Chousuke,(.isInstance (int 1) Object)
11:28clojurebotjava.lang.IllegalArgumentException: No matching method found: isInstance for class java.lang.Integer
11:28Chouserit's hard because primitives are boxed almost without you even touching them.
11:28Chousuke,(.isInstance Object (int 1))
11:28clojurebottrue
11:29Chouserboxed!
11:29Chousukeevil
11:29danlarkinwe're experiencing the quantum phenomenon, where observing a thing inherently changes it!
11:29stuartsierraYou can only get primitives in a loop.
11:30aravindhi
11:30Chouserthe real problem is that you want to be able to see what the compiler concludes about stuff. This is after read, after macro-expand, but before bytecode-generation.
11:30ChouserThe compiler's got an AST that describes all it's conclusions, but it's hard to get to and opaque.
11:30Chouserclojure-in-clojure will fix that, and allow questions like this to be answered well.
11:32Chouser,(clojure.lang.Compiler/analyze clojure.lang.Compiler$C/EXPRESSION '(int 5))
11:32clojurebot#<StaticMethodExpr clojure.lang.Compiler$StaticMethodExpr@138009b>
11:32dnolenso has anyone tested, are chunked-seqs as fast as loop/recur?
11:32Chousukearen't they potentially faster :/
11:33dnolenthat would be great
11:33aravindI have a for loop that that acts on a list of two items generates a sequence of two lists, something like ((1 2 3) (4 5 6)). however, I want it to generate a map with two entries, one for each of the entries in the for seq.
11:33Chousukeunless you loop over chunks I guess.
11:33ChouserI thought rhickey claimed he had tests showing they were faster in some cases.
11:33aravindI have been trying all kinds of combinations but I finally gave up..
11:33Chouseraravind: I don't understand -- what should the map look like?
11:33Chouser{1 4, 2 5, 3 6} ?
11:34aravindokay, the for acts on (:a :b) and generate ((1 2 3) (4 5 6)), I want the final map to be {:a (1 2 3) :b (4 5 6)}
11:34Chousuke,(map list [[1 2] [3 4] [5 6]]); you mean you have something like this?
11:34clojurebot(([1 2]) ([3 4]) ([5 6]))
11:34Chousukeer, whoops
11:34Chousuke,(map list [1 2] [3 4] [5 6]); you mean you have something like this?
11:34clojurebot((1 3 5) (2 4 6))
11:35Chouser,(zipmap [:a :b] '((1 2 3) (4 5 6)))
11:35clojurebot{:b (4 5 6), :a (1 2 3)}
11:36aravindhmm..
11:36aravind,(zipmap (:a :b) '(((1 2 3) (4 5 6))))
11:36clojurebot{}
11:37dnolenaravind: (:a :b) is not a quoted list
11:37dnolenaravind: also why are you using lists instead of vectors, lists are rarely the right choice.
11:37dnolen,(zipmap [:a :b] [[1 2 3] [4 5 6]])
11:37clojurebot{:b [4 5 6], :a [1 2 3]}
11:37aravinddnolen: all that stuff is autogenerate from java iterators (or some sort of java arrays).
11:38aravinddnolen: I have to somehow conver them to be sequences to use them in clojure, and (seq java-form), only generates lists?
11:38dnolen(vec (make-array Integer/TYPE 10))
11:38dnolen,(vec (make-array Integer/TYPE 10))
11:38clojurebot[0 0 0 0 0 0 0 0 0 0]
11:38dnolenyou can convert java arrays into vectors
11:39Chousukearavind: seq doesn't generate lists; it generates seqs :)
11:39dnolen,(vec (seq '(1 2 3 4)))
11:39clojurebot[1 2 3 4]
11:40aravindokay, but doesn't it feel like an aweful lot of convertions.. just to be able to use the results?
11:40Chousukeif you have seqs there's no need to put them in a vector usually, but sometimes it helps
11:40Chousukebut if you're typing out literal sequences, '(1 2 4 5 232 43232) is rather unclojurey
11:40Chousukevectors are more idiomatic in that case.
11:41aravinddammit, I swear I looked through zipmap, but it didn't strike me as something I could use for this.
11:41dnolenaravind: heh Clojure is like that. most of the things you could think of for operating on sequences is already there.
11:42aravindso something like (zipmap (vector generating-array) final-generated-array) should work for my case.
11:43aravinddnolen: yeah, for a while there, I was actually calling the java iterator and stepping through next.. before I read about seq :(
11:43Chouser,(let [compiler-type #(let [e (clojure.lang.Compiler/analyze clojure.lang.Compiler$C/EXPRESSION %)] (.getJavaClass e))] (compiler-type '(int 5)))
11:43clojurebotint
11:43Chouser,(let [compiler-type #(let [e (clojure.lang.Compiler/analyze clojure.lang.Compiler$C/EXPRESSION %)] (.getJavaClass e))] (compiler-type '(+ 5 10.5))))
11:43clojurebotjava.lang.Number
11:43dnolenheh cool
11:43Chouser,(let [compiler-type #(let [e (clojure.lang.Compiler/analyze clojure.lang.Compiler$C/EXPRESSION %)] (.getJavaClass e))] (compiler-type '(+ (int 5) (float 10.5)))))
11:43clojurebotfloat
11:43dnolenc.c.compiler-helper?
11:46aravindthanks guys, that works beautifully. Sometimes I should just give up sooner and beg for help
11:46dnolenperfect macro for checking what the compiler sees for a given expression.
11:48ChouserI'm afraid it might add to confusion...
11:59ChousukeChouser: I just wonder when clojure-in-clojure is actually going to materialise.
12:00ChouserChousuke: it's not next on Rich's list, I think, but not last either.
12:00ChousukeI guess rhickey is going to have to implement the instance thing first
12:00Chouserhe said that, but I don't understand why yet.
12:01Chousercompiler-type's a bad name for that thing. What should I call it?
12:01Chouser,(let [compiler-type #(let [e (clojure.lang.Compiler/analyze clojure.lang.Compiler$C/EXPRESSION %)] (when (.hasJavaClass e) {:class (.getJavaClass e) :primitive? (.isPrimitive (.getJavaClass e))}))] (compiler-type '(+ (int 4) 5)))
12:01clojurebot{:class java.lang.Number, :primitive? false}
12:02Chousukecompiler-info
12:02Chousukehmm
12:02stuartsierracompiler-tag
12:02Chousukeyou could expand the function to return as much compiler knowledge as you can and return a map.
12:03Chouserwell.. that's what clojure-in-clojure does. ;-)
12:03Chousukeheh
12:03ChouserI guess not really.
12:03Chousukeyour code as it is looks a bit scary :P
12:04Chouserin general, or in this case?
12:04Chouser:-D
12:04ChousukeI mean in the clj-clojure code you have on github
12:04Chouseroh. yeah. ugly.
12:04Chousuke50 lines is a lot for a lisp function.
12:05Chouserwhat's there is largely the result of a (incomplete) learning process on my part. It probably ought to be scrapped and written from scratch.
12:06Chouserbut then Compiler.java is over 5000 which is (I hope) a lot for a .java file.
12:07Chousukefairly large, yes :P
12:09cemerickan optional string arg should be added to time that is appended to the elapsed time printlns.
12:11Chouser"expr-info"?
12:11cemerickyeah, something along those lines
12:14Chousukepeople are too fond of abbreviating things IMO ;P
12:14ChouserChousuke: "expression-information"?
12:15ChousukeI think just expression-info would be fine :)
12:15cemerickcurrent-expression-timing-description gets my vote
12:17ChousukeI just think the programmer's fingers don't matter as much as the burden on the reader :P
12:18stuartsierraspeak for yourself -- I have carpal tunnel and tendinitis. :)
12:18cemerickThere's certainly a balance to be had. Some of the names in CL are abominations, for instance.
12:18Chousuke... and most IDEs and editors have keyword completion anyway
12:19cemerickoh-no -- not the "IDEs will save us from ourselves" bit
12:19cemerickThat's the #1 counterargument to "java/C# is too verbose"
12:19cp2personally i like the cl names
12:19Chousukecemerick: in this case, I think "expr-info" would be too abbreviated simply because it's difficult to pronounce if you read it aloud.
12:19arohnerreplaca?
12:20ChousukeI still have no idea what that does.
12:20Chouser"ehk-SPRINFO"
12:20dnolensexpr-info
12:20Chousukelooks like a misspelling of replica :/
12:20Chousersex-pr-info
12:21cemerickcp2: least-negative-normalized-double-float?
12:22arohnerChousuke: it's surprisingly hard to google for the definition of replaca
12:22duck1123does anyone know why the tests for clojure.contrib.sql are showing up in the documentation on the wiki?
12:22Chousukearohner: heh
12:22arohnerbut there are two functions, replace car, and replace cdr
12:22arohnerreplacA, replacD
12:22Chousukeso why couldn't they just keep the r
12:22cp2cemerick: lol
12:22Chousukethat would have made it a LOT better.
12:23arohneror even replace-car
12:23Chousuke; I totaled my Toyota ;(
12:23arohnerthough early lisps may have had a limit on the fn name length
12:24cemerickyeah, it was 7 chars in the really early days
12:24arohnerthough I'm amazed car and cdr stuck around as long as they did
12:32arohnerdoes anyone else find themselves writing (interleave (keys map) (vals map)) a lot?
12:33stuartsierraonly in macros
12:33arohnerseveral core fns want a flat seq of key value pairs, but (seq map) returns ([k v] [k v]). I find myself needing to fix that often
12:34Chousuke,(apply concat {1 2 3 4})
12:34clojurebot(1 2 3 4)
12:34stuartsierraI wrote a flatten-map function, I think it's in contrib somewhere.
12:35stuartsierraChousuke: that's better.
12:35arohnerthat is a better solution. Though I'm kind of wondering why there are fns that take lists of key value pairs rather than a map
12:36Chousukethey're usually map-constructing functions I suppose
12:36stuartsierraBefore array-map, maps were unordered, too.
12:38cemerickstuartsierra: perhaps test-is/testing should emit a separator between different context names? I see it puts a space there now, but something more to indicate the separation between levels would be good. first context / second context / third ... etc.
12:39stuartsierracemerick: I was copying RSpec, where concatenating the contexts is supposed to yield a complete sentence.
12:40cemerickoh, I see
12:40cemerickheh, that seems really unlikely to work out, except in contrived examples
12:40stuartsierraThat's why I don't like it.
12:41cemerick"when only the demo slides matter..."
12:41arohnerthat's never stopped ruby before
12:43cemerickChousuke: I just noticed your msg from earlier -- are you OK?
12:44Chousukecemerick: you mean the toyota one? fortunately that was a joke on replace-car. :)
12:44cemerickHA!
12:55replacaarohner: despite my nick, the CL funcs are rplaca, rplacd, iirc
12:56replacahttp://www.lispworks.com/documentation/HyperSpec/Body/f_rplaca.htm#rplaca
14:19hiredmanWhen he was pointed out that Clojure is already doing what he wants, he said "Well, I don't like the square brackets" :-(
14:20danlarkinwho said that?
14:21hiredmanhttp://www.artima.com/weblogs/viewpost.jsp?thread=259505 The EuroLisp Symposium and the Future of Common Lisp
14:21hiredmanScott McKay
14:22danlarkinThis seems accurate, "The impression I got is that he would only accept as new Common Lisp a language designed by himself..."
14:24hiredman"one sends his proposal to the CDR site and nothing happens"
14:27replacaIf Clojure's as successful as that language about which people say, "I don't like the fact that whitespace is syntactically significant," I'll be happy. :-)
14:27replacathe rest of the world can dislike our parens and square brackets
14:27hiredmanhttp://infoworld.com/d/developer-world/java-get-more-modular-jdk-7-upgrade-919 "Class path is dead,"
14:29Chouserhuh
14:34Chousukenice and vague: "The modularity aspect gives us a taste of how perhaps we're getting to a point where we can start to think about how we might end up with one Java" :P
14:36wwmorganis there a function in core or contrib that takes a directory and returns all files under it, traversing the directory structure?
14:37slashus2wwmorgan: Tried file-seq?
14:37wwmorganslashus2: that's it. Thanks
14:38mrsolois there better way to do this? (defn unique [a] (sort (into () (set a))))
14:38mrsolominus the sort part
14:38Chouser'a' is any collection?
14:38mrsoloya
14:39mrsoloor just list if that matters
14:39Chousukesorted-set?
14:39Chousukeor did that exist
14:39danlarkinYess, down the classpath!
14:39mrsolobasically i wants to remote duplciates '(1 2 2) -> '(1 2) etc
14:39Chouserset is probably faster than sorted-set
14:39Chousukeright
14:39ChousukeChouser: but he's going to sort anyway
14:40Chouser(seq (set a)) should do it
14:40mrsolosort isn't necessary..but i found that the elements order aren't guanarntee after transformation...
14:41Chousukeright.
14:41Chousukeis the original seq containing the duplicates sorted?
14:41mrsoloit contains duplicated, not sorted
14:42mrsolobut i couldn't figure out a way to collaps item in place
14:42mrsoloso.. will just enforce sort order
14:42Chousukeare the duplicates always adjacent?
14:42mrsolono
14:42Chousercan you just use a set in your algorithms instead of a list?
14:42Chousukeokay, so putting stuff in a set is probably better.
14:42mrsolohmm
14:43mrsolomay be let me check
14:44hiredman~def clojure.set/union
14:45hiredmana lot of the operations in clojure.set call seq or use functions that call seq :(
14:47mrsolohmm probably not.. i uses lots of concat mapcat filter etc.. the change isn't worth it..
14:47Chouser(expression-info '(+ (int 5) (float 10))) ==> {:class float, :primitive? true}
14:48hiredmanooo
14:49cemerickChouser, Dark Lord of the Cons
14:50danlarkinneat
14:51Chouser(expression-info '(/ 5 2)) ==> {:class java.lang.Number, :primitive? false}
14:51Chouser(expression-info '(/ (int 5) (int 2))) ==> nil
14:52Chouser(expression-info '(/ (float 5) (int 2))) ==> {:class float, :primitive? true}
15:30cemerickhrm, trying to print refs that have metadata fails reliably
15:30cemerickoh, only those that have :type metadata
15:31Chouserthat's because the printer dispatches on :type
15:31Chouserit's a feature!
15:32hiredmanI feel a disturbance
15:32cemerickChouser: right, but there's a :default dispatch for print-method. The problem is that the fn for :default tries to dissoc the :type metadata out of the object being printed (which might also be a feature? ;-) )
15:33hiredmanas if millions of abstractions had just become concrete
15:38danlarkinthe fu is strong with you
15:40stuartsierraAnyone know a decent Java SSH library?
15:41hiredmanapache may have one
15:42hiredmanlooks like not
15:42stuartsierranope
15:42StartsWithKjsch
15:42StartsWithKhttp://www.jcraft.com/jsch/
15:42stuartsierraI've tried JSch and j2ssh, both are clumsy and poorly documented.
15:42StartsWithKhttp://www.ganymed.ethz.ch/ssh2/
15:43StartsWithKif all fails try this one
15:43StartsWithKi haven't used it
15:43stuartsierraNo longer maintained, by the original author or Trilead.
15:43StartsWithKbut looks complete
15:44StartsWithKtrilead died like 2 weeks ago
15:44hiredmanhttp://mina.apache.org/sshd/
15:44hiredman:/
15:44StartsWithKthey deleted public repo and everything :/
15:44hiredmanhttp://mina.apache.org/sshd/embedding-sshd-in-5-minutes.html <-- thats kinda cool
15:44StartsWithKjna+native ssh libs?
15:44StartsWithKthat will be my last option too
15:45stuartsierraNo JNA, I'd rather call the command-line client.
15:45stuartsierraMINA looks interesting.
15:45hiredmanmina is the framework the twitter guys used for their scala thing
15:46hiredman#java doesn't seem to be fond of it, but #java is also home to an author of a competing framework
15:46StartsWithKgrizzly? :)
15:47hiredmansomething affiliated with jboss
15:48stuartsierraWhat's the jboss one?
15:48hiredmanxnio maybe?
15:49hiredmanthe issue with the framework whosename I can't remember is it is annotation driven, which is bad for clojure integration
15:49stuartsierraxnio looks like a sockets library
15:50StartsWithKmina has ssh client? or server only?
15:50stuartsierrathat's what I'm trying to figure out
15:50StartsWithKssh/sftp?
15:51hiredmanApache SSHD is a 100% pure java library to support the SSH protocols on both the client and server side.
15:51hiredmanThis library is based on Apache MINA, a scalable and high performance asynchronous IO library.
15:51hiredmanSSHD does not really aim at being a replacement for the SSH client or SSH server from Unix operating systems, but rather provides support for Java based applications requiring SSH support.
15:53stuartsierraIt does include a SshClient class, though.
15:54StartsWithKand in the frist example it looks dead simple to use it (at the top of .java file)
16:07stuartsierra"NoClassDefFoundError: org/apache/mina/core/future/IoFutureListener"
16:13StartsWithKit looks like it requires main mina distribution to work, http://svn.apache.org/repos/asf/mina/trunk/core/src/main/java/org/apache/mina/core/future/IoFuture.java
16:29arohneris there a way to use -> if the result should go into an arg other than the first?
16:29hiredmanarohner: yes, but it isn't pretty
16:30hiredman,(-> 1 (#(/ 3 %)))
16:30clojurebot3
16:30arohnerhmm
16:30arohnerthanks
16:30cemericktemplate should be able to make that better eventually...
16:30cemerick(if not already)
16:30arohnertemplate?
16:31cemerickclojure.contrib.template
16:31cemerickI've only used it in the context of test-is, but controlling placement of values in -> seems like a natural next step
16:32cemerickwhat hiredman showed is clearly easier than what you'd have to do right now using template, but a -> variant that explicitly used it shouldn't be too difficult.
16:34arohnerthanks
17:06bhurtIs there a retry for Clojure transactions, like Haskell's retry? Basically, it just aborts the current transaction and waits until one of the STM ref cells you accessed has been written, and then retries the transaction.
17:08hiredmansounds icky
17:08bhurtUgly to implement, granted, but really useful.
17:09hiredmanfor what purpose?
17:10bhurtSo I have a ref cell holding a map. If the element I'm looking for isn't in the map (and some other conditions hold), another thread is going to add the element RSN. A retry in this case would be exactly what I want to do.
17:11ChouserI just wrote await-iref, which you could do before entering your transaction.
17:11stuartsierraReading a ref doesn't require a transaction.
17:11hiredmanbhurt: you could just, you know, loop
17:11bhurtI don't want to busy wait.
17:12ChouserI haven't gotten rhickey's attention yet to see if the goals of await-iref are inherently flawed. :-)
17:12hiredmanI think I'd use a blockingqueu
17:13Chouserhttp://paste.lisp.org/display/81237#2 -- await-iref (tested)
17:13Chouserbhurt: so that's not a busy loop, but I'm not sure it's a good idea either.
17:13hiredmanthread B does a blocking .take from the queue and thread A, when it updates the map, pushes some token into the queue
17:14ChouserThere are plenty of existing concurrency mechanisms that might suffice: Semaphore, BlockingQueue, etc.
17:14bhurtA blocking queue might work...
17:14bhurtA Semaphore would work as well.
17:15Chouserin my case, most of the time nobody cares when I'm updating the ref -- seems a shame to create/update a Semaphore every time.
17:16ChouserSo if I want to block on it, I use await-iref (which uses add-watch and a Semaphore) to block until some condition is met.
17:17bhurtI only create the semaphore when I'm inserting the element.
17:17hiredman:/
17:18bhurtThis isn't that performance sensitive.
17:20replacaChouser: I *like* that! A good use case for watchers.
17:21Chouserreplaca: thanks, but like I said I'm a little worried I'm just unaware of some more correct alternative.
17:22ChouserOr I guess more that this would be seen as an abuse of iref's or wathes or seomthing.
17:22replacaChouser: you never know until you ask. Watchers are still marked *experimental*
17:22replacabut I'm using them in the object explorer thing I'm presenting tonight
17:23Chouserha!
17:23Chouseroh, watchers
17:23Chouseryes, good.
17:23Chousersomething like watchers will be around. I think what's "experimental" is the specific API which has already been adjusted a couple times.
17:24replacaI drive the UI off a set of refs so you can update it interactively or programattically
17:24replacaand the various parts of the UI just watch the parts they're interested in
17:24replaca(basically like cells)
17:24Chouseryes, very good.
17:25AWizzArd~ seen kotarak
17:25clojurebotkotarak was last seen quiting IRC, 8606 minutes ago
17:25AWizzArd,(/ 8606.0 60)
17:25clojurebot143.43333333333334
17:25AWizzArd,(/ *1 24)
17:25clojurebotjava.lang.IllegalStateException: Var clojure.core/*1 is unbound.
17:26Chousukeclojurebot has awful attention span :)
17:35mrsolo what is ~ in front of variable in defmacro for?
17:36Chousukeunquote
17:36Chousuke,(let [foo 5] `(foo ~foo))
17:36clojurebot(sandbox/foo 5)
17:36hiredman,(let [a 1] `(n ~a d))
17:36clojurebot(sandbox/n 1 sandbox/d)
17:36mrsolothanks
18:40gnuvince_Is anybody getting these reflection warnings in the svn version?
18:40gnuvince_Reflection warning, /home/vince/prog/clojure/clj-starcraft/dump.clj:3 - reference to field getClass can't be resolved.
18:40gnuvince_Reflection warning, /home/vince/prog/clojure/clj-starcraft/dump.clj:3 - reference to field getClassLoader can't be resolved.
18:42slashus2gnuvince: yes
18:45durka42what else should I compile to get c.c.fnmap working? ant -Dclojure.jar=../clojure.jar didn't do it (java.lang.ClassNotFoundException: clojure.contrib.fnmap.PersistentFnMap)
18:46gnuvince_Wel..
18:47gnuvince_Arch updated the JDK to 6u14
18:47slashus2gnuvince: I don't know.
18:47gnuvince_No change in my Starcraft program
18:47gnuvince_:(
18:47slashus2gnuvince_: Did you activate the G1GC?
18:47gnuvince_It's not on by default?
18:47slashus2no
18:47durka42no you need some scary arguments
18:47slashus2-XX:+UnlockExperimentalVMOptions -XX:+UseG1GC
18:48gnuvince_(and regardless, I don't think this would make the difference I'm looking for)
18:48slashus2Try and see if that makes any difference at all.
18:48durka42PS, they rewrote ("clarified") the thing about G1GC requiring a support contract
18:48durka42now it just says it may eat your pets when turned on
18:49Chousukegnuvince_: you said you had some performance problems with that starcraft thingy?
18:50gnuvince_Chousuke: not so much "problems" as "I'm annoyed that it's not more within Java's range"
18:50gnuvince_slashus2: slower with G1GC
18:50slashus2nooooo
18:51Chousukegnuvince_: where does most of the time go, though? :/
18:51slashus2Run it over and over again to make sure there were no anomalies.
18:51gnuvince_Chousuke: hang on, I'll run a few profile runs
18:52slashus2gnuvince_: Have you played around with visualvm?
18:52gnuvince_slashus2: not yet
18:53gnuvince_Though I imagine the numbers won't be much different from -Xrunhprof
18:53slashus2no
18:53slashus2It will just be prettier.
18:53Chousukegnuvince_: I have the feeling that boxing things might be hurting performance
18:54Chousukeit's something that's fairly difficult to detect and avoid :/
18:54gnuvince_Chousuke: the most costly calls change from profile run to profile run
18:55gnuvince_But it's between java.nio.Buffer.position and clojure.lang.Cons.first
18:55gnuvince_java.lang.reflect.Array.setInt also takes a sizeable percentage
18:56Chousukehmm
19:00Chousukeso what clojure function is calling these?
19:00gnuvince_Split between parsing the actual binary data and converting it to something "sensible" to the domain
19:02gnuvince_Chousuke: if you want to play around with it, the code is on BitBucket and I can pack you up a bunch of data files to test
19:03ChousukeI might.
19:03gnuvince_Although my guess is that to attain Java-like performance, I'm going to need to radically change my approach
19:05Chousukeif you have a link to the data files, give me that and I'll download them for later use. I'm going to go to sleep soon but I can poke around tomorrow.
19:08gnuvince_Chousuke: uploading now
19:09Chousukeoh damn, I need to install hg
19:15gnuvince_argh
19:18Chousukehmm
19:19Chousukein make-reader using aset-int looks suspicious
19:22gnuvince_using aset or aset-int changes nothing
19:23gnuvince_Oh come on!
19:23gnuvince_I'm uploading the file
19:23gnuvince_Site has a problem with it
19:24dreishDrawing a blank. Isn't there something equivalent to (dorun (for ...))?
19:24ChousukeI would assume that it wants a primitive int as the value you're putting in it, but that looks like a boxed value in all cases :/
19:25Chousukedreish: doseq?
19:25dreishThanks. For some reason I was thinking that was the same as doall.
19:25dreishI blame the heat.
19:26Chousukegnuvince_: plus that it has to do reflection I think because the return type of (mask-fn (getter buf)) is not known at compile time.
19:26gnuvince_Chousuke: looking at Clojure's code, all aset-* functions use the reflection framework
19:26gnuvince_So I think I'm pretty screwed there.
19:26gnuvince_I tried to cast pretty much everything in that code block without success
19:26Chousuke~def aset-int
19:29Chousukegnuvince_: have you tried using a plain old vector?
19:31Chousukehm
19:31gnuvince_I used one in the very early stages, but switched to an array for some reason
19:32gnuvince_god damn
19:33gnuvince_I can't upload this stupid file to senduit or at work
19:33gnuvince_*sigh*
19:33Chousukegnuvince_: :/
19:33gnuvince_I'll try a friend's server
19:34Chousukewell, if you get some data available somewhere, ping me. I really have to go get some sleep now. I'll investigate more later.
19:35gnuvince_damn
19:35gnuvince_it always stalls
19:36gnuvince_I'm beginning to think I'M the problem
19:36rhickeyreplaca: ping
19:36gnuvince_ok
19:40ataggartis there a way to clear out whatever junk I've added to the namespace when working in a repl? (other than ^D)
19:41replacarhickey: yeah
19:41rhickeyreplaca: all set? seems like a big crowd
19:41replacayeah!
19:41rhickeyI have a 10 minute talk prepped on chunked seqs
19:42replacait's going to be cozy. Who knew you were so popular?!
19:42replacarhickey: sorry all presentation slots filled.
19:42replaca(joking!)
19:42rhickeyAlso, I saw the latest IntelliJ plugin - awesome. Can we squeeze in a few minutes for Ilya to demo?
19:42replacasure.
19:42replacaI'd love to see it
19:42rhickeyshould be great - I'm heading out soon
19:43rhickeythanks for putting this together
19:43replacacool, phil, amit and a couple of others are already here working on swamiji stuff
19:43replaca*swarmiji
19:43rhickeysee you soon
19:43replacanp, it's fun
19:44dreishI made a repl that runs things in the background if they take longer than *repl-timeout* seconds.
19:44replacai'll put you on last (to lead in to town hall) and ilya right before you
19:48gnuvince_are you guys both at JavaOne or something?
19:49replacaa bunch of us just live here
19:49replacaa few are here for javaOne and a couple of others (like technomancy) are in just for the meetup
19:49gnuvince_ok
19:53tbatchelliI work a block away from the meetup venue :)
19:53replacatbatchelli: hope you don't get stuck in traffic! :-)
19:53replacaluckily, the Giants are out of town
19:54tbatchellireplaca: if you guys need any help I can come over right now (I am bored)
19:56replacaFeel free to come when you want, but we're pretty well set up.
20:07ataggartI guess quite a few of us work in soma
20:12replacanow live from the SF clojure meetup!
20:23dysinger<crickets>
20:26tashafahow would ai go about creating a byte array in clojure?
20:30hiredman,(make-array Byte/TYPE 10)
20:30clojurebot#<byte[] [B@1926603>
20:31hiredman,(into-array Byte/TYPE [1 2 3 4])
20:31clojurebotjava.lang.IllegalArgumentException: argument type mismatch
20:31hiredmanbah
20:31hiredman,(into-array Byte/TYPE (map byte [1 2 3 4]))
20:31clojurebot#<byte[] [B@1c65470>
20:35tashafathanks hiredman!
20:36tashafa(doc byte)
20:36clojurebot"([x]); Coerce to byte"
20:52dreishhttp://gist.github.com/123364
21:29technomancyis there a significant overhead to running with the JVM args that jdb needs?
21:30technomancy-agentlib:jdwp=transport=dt_socket,address=8021,server=y,suspend=n
21:34dysingerthere is overhead
21:34dysingerI don't have any stats
21:34stuhoodi assume it would have to instrument every class and method
21:42technomancyobviously you wouldn't do it in production, but I wonder if it's worth leaving on in development
21:42technomancyjust so you don't have to restart when you realize you need it.
21:44replacai love it that you two are chatting while sitting right next to each other
21:45dysingerdoes jdp actually instrument byte code? I thought it just inspected things as it was running.
21:45dysingerI don't know though
21:47dysingerYeah I don't think it would hurt anything to run it locally like that most of the time.
21:47dysingerif no debugger is connected - it just wont debug
21:48technomancycool; adding it to my .emacs then
21:49dysingerone thing is this though - you can't run two on the same port
21:49dysingerso you could only have one slime sess
21:51durka42you could come up with some clever way to auto-generate the port
21:52dysingerbut you need the port number to connect the debugger
21:52dysingerso you'd have to go look if you weren't using the default port
21:52dysinger=====
21:52dysingersomebody ask him if they use emacs underneath !
22:10technomancyoh bummer; if you try to start a Clojure instance with a jdb port that's in use it just fails to launch Clojure itself rather than just leaving jdb out.
22:20chessguyis it correct to say "a symbol can refer to a var that is bound to a value"?
22:20chessguyi would have expected to see "a symbol can refer to a var to which is bound a value"
22:21chessguysounds strange to me to talk about something getting bound to a value instead of the other way around
22:25lisppaste8ozzilee pasted "Nested Macro Definitions" at http://paste.lisp.org/display/81329
22:25technomancybtw, you can vote for Clojure to get uploaded to the official mvn repos here: http://jira.codehaus.org/browse/MAVENUPLOAD-2464
22:26ozzileeI'd like write a macro that only exists inside another macro, as above. defaction outside of defservice should be an error. Is there something better than codewalking?
22:27chessguytechnomancy: what's mvn?
22:27ezyangchessguy: Maven
22:27chessguywhich is...
22:27technomancychessguy: lets you handle dependencies in an automated fashion
22:27technomancyso you don't have to manually manage jar files etc.
22:27dysingerbabble babble
22:27stuhooddysinger: hehe
22:28ezyangchessguy: If you use Debian, it's sort of like apt
22:28chessguyah, ok. i don't, but i do get the analogy :)
22:28technomancychessguy: it does a lot of other things, but that's the part that's relevant to clojure
22:29hiredmantechnomancy: is there a video camera in the room?
22:29chessguyso...do values get bound to vars, or vars to values?
22:29dysingervoted ?
22:30technomancyhiredman: yes, and there have even been loose plans announced to upload them.
22:32ezyangHow important is it for me to learn clojure macros?
22:32ezyangI've touched TeX and C macros, and I'm really not relishing the prospect
22:32technomancyezyang: learn macros last.
22:32ezyangOk.
22:33dreishSeconded. They're nice, but everyone who dives into Lisp because of macros tries to use them for everything that they shouldn't be used for.
22:33technomancyezyang: they're useful, but it's easy to get carried away if you're relatively inexperienced
22:34dysingerY it's like saying "there is no line between your language and your application" - can make debugging hard
22:35technomancyI love how rich always deflects questions about internals that you shouldn't have to care about. =)
22:36hiredman:D
22:37dysingerbut his whole presentation is about internals that we shouldn't have to care about !
22:37dysinger(chunked seqs)
22:37dysingershould be transparent
22:37hiredmandysinger: well that depends
22:37technomancyyeah, he mostly does that when people ask about locking/concurrency details
22:37technomancybecause they're way more complicated than chunking
22:38hiredmanI can imagine chunked seqs will be useful for library writting
22:38hiredman(well the details of)
22:38chessguy,String
22:38clojurebotjava.lang.String
22:38dysingerrichhickey just said his testing methodology is the "scream test" #heh
22:58hermanChesshello
22:58stuhoodheya
23:44arohnerclojurebot: paste
23:44clojurebotlisppaste8, url
23:44arohnerclojurebot: *ahem*
23:44lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
23:44clojurebotexcusez-moi
23:45arohnerI have a goofy performance problem
23:45lisppaste8arohner pasted "perf problem" at http://paste.lisp.org/display/81335
23:45arohnerI can run that test as many times as I like, and I get similar results each time
23:46arohnerthe first run is slow, and the final run is 2x faster than the first run
23:46arohnerbut between runs, I'm doing *nothing*
23:46arohnerno reloading code, etc
23:47hiredmanarohner: hotspot
23:48arohnerI understand that if I had new code, it would take awhile to optimize
23:48arohnerbut why would it get slower between runs?
23:48hiredmanoh
23:48durka42at the repl, the code is going to be compiled each time
23:49hiredmandurka42: not in the example usage he has
23:49arohnerbut only my expression of (dotimes [i 10] (perf-test)) should be recompiled
23:49durka42yeah
23:49durka42and that shouldn't affect the optimization of performance-test...
23:50durka42what's in perf-test, out of curiosity
23:50durka42and by curiosity i mean i want to try this at my repl
23:50hiredmanhard to say, there is always some jitter up and down in time's numbers
23:51durka42but you have to run with -server to enable hotspot at all, yes?
23:51arohner_sorry, computer trouble
23:51arohner_I missed everything after "not in the example he has"
23:51hiredmanhard to say, there is always some jitter up and down in time's numbers
23:51arohner_that's a 2x difference though
23:51durka42what's in perf-test? i kind of want to try this at my repl
23:51arohner_just a bunch of math
23:51hiredmandurka42: actually the also appears to be a client version of hotspot
23:52arohner_multiplies divides
23:52durka42oh ok
23:53stuhoodthe example you show looks reasonable... it can take a few thousand iterations for hotspot to optimize something
23:53arohner_and I'm fine with that the first time
23:54arohner_the problem is, if I keep running (dotimes [i 10] (perf-test)), I get the same distribution
23:54durka42i am not seeing that effect
23:54hiredmanstuhood: he is asking about the large up and down in the numbers
23:54arohner_i.e. run 0 is always slow, no matter how many times I run the same expression
23:54durka42(defn perf-test [] (time (dotimes [i 20000] (+ 3 Math/PI (/ 10 7)))))
23:54durka42gives me pretty stable values for (dotimes [i 10] (perf-test))
23:55arohner_durka, I'm doing about a million multiplies and divides in each (perf-test)
23:55durka42paste it?
23:56arohner_that's kind of hard
23:57arohner_let me see if I can find a more representative paste
23:58arohner_clojurebot: paste
23:58clojurebotlisppaste8, url
23:58lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
23:58lisppaste8arohner pasted "perf problem #2" at http://paste.lisp.org/display/81338
23:59arohner_so there, I run the exact same line, twice in a row
23:59arohner_run 1 of each dotimes is slow, but run 10 of each dotimes is fast
23:59stuhoodgotcha
23:59arohner_I'm ok with the first run 1 being slow. I'm not ok with the second run 1 being slow