#clojure log - Sep 09 2009

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

0:00 technomancy: tomoj: I don't actually understand it myself; don't feel bad.

0:19 Bercilak: how can I make seqs not explode with out of memory errors?

0:20 I've seen streams mentioned, and I'm staring at the contrib doc page, but I can't figure out for the life of me how to use them

0:22 I'm trying to traverse a directory for a bunch of mp3s with file-seq and filter... and kaboom.

0:23 tomoj: Bercilak: holding the head?

0:26 Bercilak: I suppose I have to be if the GC's not reclaiming space, it ain't obvious where though. I'll try and figure out a minimal test case.

0:46 jbell: technomancy: have you worked out your problem yet?

1:14 albino: well it could be my job to deal with french, though I only took spanish in school

3:13 tomoj: french?

4:32 ol3: hi, is there a something like #+nil in clojure?

4:34 found it by myself #_

4:55 tomoj: what does that mean?

4:55 oh, reader comment?

5:01 ol3: (doc #_)

5:01 clojurebot: Unmatched delimiter: )

5:01 ol3: ignore next form

5:01 ,(+ 123 123 123)

5:01 clojurebot: 369

5:01 ol3: ,(+ 123 123 #_ 123)

5:01 clojurebot: 246

5:03 tomoj: I wonder what the difference is between

5:03 (doc comment)

5:03 clojurebot: "([& body]); Ignores body, yields nil"

5:03 tomoj: oh, well, different usage clearly

5:03 and #_ doesn't even make it past the reader

5:06 Chousuke: ,#_)

5:06 clojurebot: Unmatched delimiter: )

5:07 Chousuke: so even if it gets ignored it has to have proper syntax :)

5:17 Fossi: that's weird.

5:23 tomoj: well..

5:25 oh guess you're right

5:25 I had done stuff like:

5:25 ,(println "foo" #_(, .,cuh.c,u .,cu.r,))

5:25 clojurebot: foo

5:26 tomoj: but that is proper syntax I guess :)

5:27 I guess it has to have proper syntax for the reader to know what the "next form" is

5:55 ol3: tomoj: you can use it to comment out forms

5:57 Chousuke: to comment out text you still need to use ; :)

6:22 LauJensen: Alright Clojurians, as always comments are encouraged and appreciated: http://www.dzone.com/links/php_vs_clojure_whats_the_cost_of_being_oldschool.html

6:51 I would hope it was (true true true...) :)

6:51 But you're right ofc, bad naming policy on my part

6:51 fixed

8:07 AWizzArd: ,(System/getProperty "java.version")

8:07 clojurebot: java.security.AccessControlException: access denied (java.util.PropertyPermission java.version read)

8:58 johnmn3: good day

8:59 Chouser: hi

9:00 johnmn3: So I've been playing around with the gnome-java bindings...

9:00 I've got a working version of the celcius converter.. pretty straight-forward

9:01 I'm wondering how I might stress test it with some multi-threading, since, supposedly, the gnome-java bindings are thread-safe

9:03 what could I implement that would otherwise cause problems, were it not for the thread-safety

9:03 Chouser: draw to the UI in another thread while doing the regualr callback handling as normal.

9:05 or for stress, I guess draw to the UI from two threads at the same time -- if they're both doing animation as fast as they can, you'd be likely to hit an error pretty quick I think.

9:07 johnmn3: hmm, can you think of a scenario involving just widgets, or would I have to draw on a canvas

9:07 I suppose drawing on a canvas would be the best example

9:08 rsynnott: johnmn3: as a matter of interest, why are you using gnome-java?

9:08 just for integration with gnome?

9:09 johnmn3: rsynnott: just to experiment with the supposed "thread-safetey" of the library

9:09 Though I do use linux

9:10 Chouser: can you change widget status? like size, position, etc.?

9:10 how about two buttons bouncing around a container, each driven by a separate thread?

9:10 johnmn3: unfortunately, I don't think the gtk part of the gnome-java bindings work on windows yet

9:12 hmm.. or maybe click a button, spawning a new window in a new thread, then affecting window 1 from a button in window 2?

9:12 brb

9:13 I swear my bladder is the size of an apricot these days

9:14 * Chouser pretends he doesn't know that.

9:14 Fossi: yeah, tmi

9:15 johnmn3: yea, my manners, sorry

9:15 ambient: i don't really mind

9:15 it's interestig

9:16 johnmn3: I think it's the elevation, 7000+ feet up

9:16 ambient: or too much coffee?

9:16 rsynnott: 7000 feet up? Where's that?!

9:17 johnmn3: mountains in afghanistan

9:17 I'm a soldier

9:20 mmm.. I'm going to give the canvas drawing a shot.. just found a java example. What threading mechanism should I use? agents?

9:21 ambient: i'm also wondering what kind of a drawing method to use

9:21 im thinking of abstracting opengl window with some additional functions behind an event queue

9:22 Chouser: johnmn3: agents would be fine, or just (.start (Thread. #(do-stuff ...)))

9:24 tmountain: is it correct to say that calling def creates a root binding in the current namespace, and how do *global* type variables differ from def'd bindings?

9:24 johnmn3: Chouser: ok.

9:25 Chouser: tmountain: calling def with a value creates a root binding in the current namespace

9:25 tmountain: if it's called without a value, the variable is interned?

9:26 Chouser: the var, yeah.

9:26 *global* vars are created with def -- do difference

9:27 tmountain: ok, I know this would be a terrible way of doing things, but what's to stop someone from using def as a glorified assignment operator and just hammering on a bunch of root bindings?

9:28 Chouser: nothing. you can do that.

9:29 tmountain: what's the distinction between def and set! then?

9:29 Chouser: but if you see code like (loop [] (if foo (def bar 5) (def bar 10)) ...) all sorts of alarms should be going off in your head.

9:29 tmountain: you can only use set! on a var when it has a thread-local binding.

9:29 tmountain: yeah, absolutely, I know that's an awful way of doing it ;-), I'm just exploring hypothetical situations

9:30 Chouser: ,(set! map 5)

9:30 clojurebot: java.lang.IllegalStateException: Can't change/establish root binding of: map with set

9:30 tmountain: ahh, ok

9:30 Chouser: ,(binding [map 5] (set! map 10))

9:30 clojurebot: 10

9:30 tmountain: established via binding

9:30 thanks for the clarification

9:31 Chouser: the more I think about it, the more I'm surprised we have a thing like 'binding'. It's a powerful and subtly dangerous tool.

9:32 tmountain: I'm thinking about writing a small MUD in Clojure, and I was wondering if it'd be a bad idea to store the world state as a ref to a map

9:32 Chouser: tmountain: that's probably exactly the right way

9:33 tmountain: if the order of events happening is important like player #1 does something then player #2 does something, I'd need to use alter as opposed to commute, and I'm wondering if that would have a big impact on performance

9:36 Chouser: with a single ref, your writes are going to be serialized anyway, so my guess (and it's not a terribly educated one) is that it won't matter much.

9:36 if you find the performance is insufficient, you can add more refs at another level (one ref per room? per object?)

9:36 rhickey: commute is an optimization and premature optimization...

9:40 tmountain: ok, thanks guys

9:41 is there a convenient way to serialize a map for the purpose of shutting things down and saving state?

9:42 Chouser: ,(pr-str {:a 1 :b [2 3 4]})

9:42 clojurebot: "{:a 1, :b [2 3 4]}"

9:42 duck1123: spit/slurp

9:42 Chouser: ,(read-string "{:a 1, :b [2 3 4]}")

9:42 clojurebot: {:a 1, :b [2 3 4]}

9:43 tmountain: beautiful, you're a gentleman and a scholar ;-)

9:51 johnmn3: ok, one line has been drawn.. now to do that a hundred times with 3 threads

9:53 Chouser: heh

10:01 somnium: having trouble getting a gui launched from slime to log events back to the slime buffer, passed in a println callback, but no error and output. Assuming an issue with threads?

10:03 Chouser: somnium: I think slime may use thread-local bindings to capture output from the java thread and send it to the buffer

10:03 so printing from some other thread might lose that binding

10:03 that's pure speculation though

10:03 somnium: hmm, any idea what incantation might send them back to slime?

10:05 Chouser: oh -- are you starting your own new thread? I may have misread your post.

10:07 somnium: actuall I'm not sure, clojure hides all the runnable stuff

10:07 (been a long time since I've used swing so I'm fuzzy on the details in any case...)

10:08 I have a function that takes a map of callbacks and returns a map with show and update functions, but the callbacks I pass in don't report back to slime

10:08 update and show works fine

10:17 I think all swing instances go into new threads don't they? Unless I completely misunderstood the first time around

10:20 dms: doesn't swing callbacks get called in the same thread i.e the swing event thread?

10:24 somnium: hmm, yeah I don't know why I thought it would work now that I reflect on it. Ill just log events in the gui in meantime.

11:35 johnmn3: so what do you get when you cross ubuntu, gnome-java bindings, clojure, multi-threading, and a newbie?

11:36 ambient: not much, I'd recon

11:36 johnmn3: system lockup, rather

11:36 ambient: :D

11:36 johnmn3: not sure if the experiment worked.

11:37 the lines kept drawing, but they wouldn't stop

11:48 tmountain: johnmn3: what are you working on?

12:04 AWizzArd: Is there a better way to sort a map?

12:04 ,(apply sorted-map (interleave (keys {:a 1, :b 2, :c 3}) (vals {:a 1, :b 2, :c 3})))

12:04 clojurebot: {:a 1, :b 2, :c 3}

12:06 cgrand: , (into (sorted-map) {:a 1, :b 2, :c 3})

12:06 clojurebot: {:a 1, :b 2, :c 3}

12:07 technomancy: tmountain: have you seen mire?

12:23 tmountain: technomancy: yes, I've looked at it in the past. very cool project. I'm mostly just interested in doing the MUD as a learning experience and to play around with Clojure.

12:26 AWizzArd: cgrand: good, thanks

12:29 technomancy: tmountain: cool; have fun.

12:31 tmountain: technomancy: just glanced over it again via Git. very concise and nicely done BTW. I'd use it as a reference for what I'm doing, but that would be "cheating". I'll compare notes after the fact to see what I could've done better.

12:41 fradiavalo: technomancy: Are you the author of emacs-starter-kit?

12:42 technomancy: fradiavalo: yep

12:43 fradiavalo: technomancy: Excellent work! I stumbled upon it yesterday. It is very useful, except you choose to ignore python ;)

12:43 technomancy: fradiavalo: I've had a couple people offer to contribute python support, and then they go disappear and I never hear back from them. =)

12:44 fradiavalo: ha, well. python mode seems to be in a bit of a mess with the official python.el and more popular python.el

12:45 technomancy: fradiavalo: are you volunteering? =)

12:45 fradiavalo: opps I meant more popular python-mode.el

12:45 I have to sort it out for myself, so if I come up with something useful, I will definitely contribute

12:45 technomancy: great

12:46 fradiavalo: Right now, I don't know whether to start hacking the emacs python.el or the other one.

12:49 LauJensen: Its on the frontpage now : http://www.dzone.com/links/php_vs_clojure_whats_the_cost_of_being_oldschool.html

12:50 ambient: hmm, sql transactions/hour. what happens when clojure runs out of memory to hold the data structures?

12:51 im quessing that it's the reason for so few actual transactions

12:51 just did a quick overview, will parse it later

12:52 Licenser: LauJensen: interesting link but I must say I never ever have anyone heared saying “I love PHP because its so productiv..."

12:53 ambient: i've never heard anyone say "i love php" ...

12:54 Licenser: ambient: you've a point

13:05 replaca_: LauJensen: nice post - a good way of expressing what clojure does

13:06 LauJensen: Thanks replaca_ :)

13:06 Licenser: I have :)

13:06 ambient: Thats another story

13:07 Licenser: LauJensen: I think I should be sorry for you :Ü

13:08 ambient: LauJensen microbenchmarks always leave me hungry

13:13 Licenser: another question I had looking at the article, since when is PHP old scool o.O

13:20 LauJensen: Since now

13:20 I think Wordpress.com just got nuked

13:20 hmm, maybe PHP swallowed all its ressources

13:20 ambient: some script kiddies finally caught sniff of all the numerous vulnerabilities?

13:21 Licenser: must have been theese old school PHP hackers :P (sorry teasing)

13:21 Chousuke: they just proved your point ;P

13:23 albino: Isn't 10+ years as a programming language make you old school?

13:23 LauJensen: wordpress.com just got back up, but my blog is still down.. hmm ;)

13:23 albino: You're old school as soon as you stop keeping up

13:23 (per my definition)

13:24 albino: looks like 1994 for PHP according to wikipedia

13:25 LauJensen: does "keeping up" mean keeping the website responding to requests?

13:25 LauJensen: I think my next post will be about C - Its quite intriquing that language.. Imagine 1 language which consistently produces 2 bugs per line of code...

13:25 ambient: lisp is still pretty hot and it was 1969 something

13:25 albino: ambient: but you would agree lisp is old-school under your own opinion, wouldn't you?

13:25 LauJensen: albino: Keeping up means, if cutting edge development can lean on parallel code execution, multicore/multithread concurrency etc, that you're doing the stuff

13:26 * mDuff reads "keeping up" as following new trends or developments.

13:26 ambient: idk, old school would suggest that it was somehow redundant and irrelevant, which it is not

13:26 albino: LauJensen: oh, gotcha

13:26 dammit, old school doesn't seem to mean the same thing to anyone

13:26 ambient: MS-DOS programming with int 13h is old school

13:27 mDuff: K&R C is old school

13:27 albino: I thought it was cool to be old school, cause I never hear anyone say "Yeah, I'm new chool, you should get into it man"

13:27 mDuff: POSIX sh is old school -- not all things old school are bad.

13:27 LauJensen: int 19h is fresh though

13:28 manic12: Hi, yesterday I was told to check out clojure.contrib.test-is, but I'm not sure if it's what I am looking for, or I am using it wrong

13:28 LauJensen: albino: It's a cool thing to a lot of people, but in industriel development, old school often frustrates me

13:28 manic12: is test-is a test framework or a test suite or both?

13:29 LauJensen: Its a little funny - On the Java post I did, I got a lot of Java Golfers sending me examples. Nobody seems to stand up for PHP

13:30 technomancy: manic12: it's a framework

13:30 but it's moved out of contrib to clojure.test in recent versions

13:30 manic12: is there a test suite?

13:30 technomancy: yes, also used to live in contrib but is now in clojure itself

13:30 manic12: ok, got any pointers to that?

13:31 technomancy: it's in the test/ directory?

13:33 albino: LauJensen: Well yeah, it's good we moved on from Cobol

13:34 manic12: technomancy: any docs on the website for that?

13:36 technomancy: manic12: what are you looking for? how to run the tests? how to contribute new tests? what to do if they fail?

13:36 LauJensen: albino: I guess - Just wish I hadn't made so many stops along the way to Clojure

13:36 manic12: I'm looking for tests that have already been defined

13:36 albino: LauJensen: did you do the perl thing? If so I do feel bad for you

13:37 LauJensen: albino: I wasn't able to do Perl

13:37 technomancy: manic12: http://github.com/richhickey/clojure/tree/270185aba54cef1d8ce59ec347b5623f2e502afe/test/clojure/test_clojure

13:55 manic12_: .

14:02 anybody there?

14:02 LauJensen: yea?

14:03 manic12_: ...just wondering if this channel was working

14:03 ambient: we're all really just figments of your imagination

14:06 manic12_: I like fig newtons

14:26 I am assuming that clojure-1.0.0 is not compatible with the libraries from git://github.com/richhickey/clojure.git

14:26 if so,

14:26 where are the directions to build that version of clojure

14:27 * manic12_ is not a java programmer

14:28 Chousuke: just cd to the dir and run "ant"

14:29 manic12_: where do I get ant?

14:29 sorry for the dumb questions

14:30 albino: Grab it from the apache ant website

14:30 run the ant executable in the same directory where the build.xml file resides

14:30 manic12_: ok

14:32 stuartsierra: http://ant.apache.org/

14:34 Chouser: I guess I didn't think about that carefully enough. I need to implement ISeq, so I have to provide a 'cons' method anyway -- seems silly to then also have both consLeft and consRight

14:37 but RT.cons doesn't call ISeq.cons -- does ISeq really need to require a cons method?

14:39 rhickey: IPersistentCollection.cons is really conj - need to refactor that at some point

14:40 so, should replace consRight

14:40 Chouser: ok. either way I need to implement the the method called by RT.conj

14:41 ok. So I should implement cons and consLeft?

14:41 except current conj sometimes goes on the left. so cons and reverseCons?

14:42 rhickey: sometimes?

14:42 Chouser: for persistent list

14:42 rhickey: oh, but for fts I thought cons left conj right

14:42 Chouser: I mean the conj contract doesn't specify which end, so it seems wrong for consLeft to name an end.

14:43 rhickey: well, ft will have to declare what conj means for it (right)

14:43 Chouser: sure, I'll have a patch for RT so that RT.cons is left and RT.conj is right. I'm wondering about the interface names since RT.conj is currently coll.cons

14:44 this is why I used "left" and "right" explicitly in my code up til now. Would have been hopelessly confused otherwise.

14:44 rhickey: yeah, it would be better if it were already refactored, then cons/conj as methods would work.

14:44 Chouser: I guess it wouldn't be too hard to fix, just a big ugly patch.

14:45 rhickey: consRgith should be called cons in order to get into the refactor, consLeft can stay that until after the refactor

14:45 Chouser: it makes my head hurt. PersistentList would provide only conj?

14:46 rhickey: Chouser: yes

14:46 Chouser: only double-headed things would provide cons after refactor, consLeft for now.

14:46 rhickey: we could do rconj for double ended things

14:47 but yes, consLeft is fine, I don't anticipate any callers other than the impl

14:48 Chouser: ok, thanks.

14:48 I think I have the delays working correctly now -- they're only used for deque, to defer recursion until you've paid for it with enough shallow rest/pop calls.

14:50 I'll have to spend some time on the performance. I'm pretty sure the complexity is correct, but the speed is unimpressive.

14:50 clojurebot: http://clojure.org/java_interop#toc46

14:52 LauJensen: Double headed, double ended?

14:52 Chouser: LauJensen: you can conj onto either end of a finger tree in amortized O(1) time

14:53 LauJensen: amortized O(1) ?

14:53 Chouser: LauJensen: "fast"

14:54 liwp`: :)

14:54 LauJensen: I just dont see how O(1) could 'amortize', that means slowly decrease in speed right?

14:54 liwp`: LauJensen: it means that it something not 1, but in time you get really close to one

14:54 LauJensen: ah ok

14:55 liwp`: i.e. fast

14:55 Chousuke: usually it means doing an expensive operation every once in a while so that most of the operations can be fast

14:56 liwp`: yeah, like purely functional queues where once in a while you need to reverse a list

14:56 Chouser: because calling it O(log n) makes it sound worse than it generally is

14:56 liwp`: but most of the time you can just call first and rest

14:56 Chouser: so how finished are you with finger trees?

14:57 Chouser: and are they difficult to implement

14:57 Chouser: I bet they're pretty easy to implement compared to, say, PeristentVectors or red-black trees.

14:58 it didn't seem very easy to me, but I think that says more about me than about finger trees. :-)

14:58 liwp`: Chouser: the impl is in java rather than pure clojure?

14:58 Chouser: nope, pure clojure. I have no interest in spending my spare time writing java code. :-)

14:59 liwp`: ooh, excellent

14:59 good man

14:59 Chousuke: you can spy: http://github.com/Chouser/finger-tree/blob/8b06d89b63c63a446f16314b1859c53f17437b5f/finger_tree.clj

15:00 liwp`: cool, I'll have to have a look

15:06 urgh, I just switched from Aquaemacs to plain Emacs on OS X and now I can't figure out how to produce a hash mark / pound sign

15:15 Chousuke: liwp`: you need to change the option button to not be meta I think

15:15 I have that in my config somewhere

15:16 liwp`: (setq mac-option-modifier 'none)

15:17 you may also want to configure mac-command-modifier and mac-control-modifier

15:17 LauJensen: What does the concept of a double headed structure cover?

15:19 Chouser: like a doubly-linked list -- you can add to either end or iterate from either end.

15:19 except this is clojure, so I also mean persistent, which a doubly-linked list is not.

15:19 LauJensen: Ok, so its something in Clojures low-level handling of sequences?

15:20 Chouser: clojure seqs are not double-headed in this way.

15:20 manic12_: is this an ok place to ask java questions, if the ultimate reason for is to use clojure?

15:21 Chouser: manic12_: probably

15:21 Chousuke: manic12_: well, you can ask about libraries and such of course, but not everyone here is all that familiar with java the language

15:21 manic12_: ok

15:22 has anyone here ever set up a callback from c into java?

15:23 Chouser: I've done C++ into java.

15:23 using SWIG, which I would recommend

15:24 Though for plain C, I'd check JNA first and see if it has anything to offer.

15:24 manic12_: actually maybe a better question to ask is, do you think that java wrappers of c++ objects are lightweight enough to throw away every time I get a reference to the c++ object, or should I use callbacks to synchronize the identities

15:24 LauJensen: What could be the reasons for wanted to do C into Java ?

15:25 s/wanted/wanting

15:25 manic12_: I have been working with a large c++ library with swig and CL

15:26 now I am thinking to adapt the interface files to work for java, for the purpose of using clojure on the C++ lib

15:26 * mDuff was disgusted by just about everything that wasn't CNI last time he looked, and CNI doesn't work anywhere but GCJ and friends.

15:27 manic12_: the CL version I created uses callbacks from c++ so that you extend c++ objects with clos slots

15:27 mDuff: http://en.wikipedia.org/wiki/GNU_Compiler_for_Java#CNI_.28Compiled_Native_Interface.29

15:29 Chouser: rhickey: I think I may be stumbling on a bridge method issue with reify

15:29 (conj (new [clojure.lang.ISeq] (cons [x] (println "got" x))) 5) ==> java.lang.AbstractMethodError

15:30 manic12_: cni is an alternative to swig?

15:30 Chouser: rhickey: that works if I implement IPersistentCollection instead

15:31 mDuff: manic12_, ...only if you're using GNU's Java infrastructure, though, so though it's easy to write and easy to read and beauty and truth, it doesn't work for most people.

15:32 Chouser: rhickey: ok, I can work around it by implementing IPersistentCollection explicitly as well.

15:33 manic12_: does clojure run on GNU Java?

15:34 hiredman: what do you mean by gnu java?

15:35 manic12_: (on a tangent: I just ran clojure-test on jamvm on ARM and it did 178 tests, 0 failures, 5 errors)

15:35 hiredman: if you mean gcj, I dunno, but most java people have such a bad opinion of gcj that I wouldn't bother

15:37 manic12_: swig it is then...with sun jvm

15:38 i have had decent luck with swig

15:39 except for the fact that with allegro, wrapping the whole c++ library produced 130,000 lines of lisp code and 130,000 lines of c/c++ code

15:40 hiredman: have you seen clojure-jna?

15:40 http://github.com/Chouser/clojure-jna/tree/master

15:40 LauJensen: Using my recently developed algorithm for predicting bugs in C code, that'll give you roughly 260.000 bugs

15:42 Chousuke: LauJensen: do you consider side-effects bugs or something? :/

15:43 LauJensen: no, a bug is when your program does something unexpected and that results in incorrect program evaluation

15:44 manic12_: hiredman: looks interesting

15:47 if I do the linking such that the c++ classes look and smell like java classes, people using java will benefit, and that might interest the maker of the c++ library

15:47 and then they would just look like java to clojure

15:50 what does it look like for a java programmer to call into clojure?

15:51 is it unweildy?

15:51 Chouser: manic12_: if you want it to look good, you provide java classes and interfaces via gen-class and gen-interface respectively.

15:52 otherwise java can poke around in Namespace objects and call .invoke() on functions.

15:52 hiredman: manic12_: crossing the native <-> jvm divide means taking a serious performance hit

15:53 manic12_: ok, so if I ever decide to replace chunks of the c++ code with clojure, I could gen-class and callback from c++ to the java class

15:54 strlen: don't quote me on it, but you might get less of a performance hit exposing it as a web service using thrift/protobuffs/avro

15:54 err not really a web service

15:54 manic12_: hiredman: the C++ library took over ten years to write and is highly mathematical

15:54 strlen: but as RPC

15:54 now going Clojure->C will be easier as you're going through JNI

15:54 hiredman: manic12_: ah

15:55 manic12_: strlen: can C call clojure directly?

15:55 strlen: manic12_: (def can-c-call-clojure-directly? can-c-call-java-directly?)

15:55 manic12_: the allegrocl swig version works pretty good albeit slow compared to native

15:56 but I can live with that

15:56 if I can get comparable performance with jvm<->c++

15:57 strlen: that went back to my question about what it looks like calling clojure from java

15:57 so you gen-class/gen-interface and call the java

15:57 from c

15:58 hiredman: seems like a lot of indirection

15:58 clojurebot: literal [?] problem

15:58 clojurebot: 2

15:58 hiredman: clojurebot: literal [1] problem

15:58 clojurebot: <reply>People have a problem and think "Hey! I'll use a regular expression!". Now they have two problems....

15:59 manic12_: that's why I asked if c can call clojure directly (or what the c code would look like if it's not calling back java classes)

16:00 I bet calling clojure directly from c would look fairly ugly

16:00 and would break when clojure changes

16:03 hiredman: clojurebot: literal [0] problem

16:03 clojurebot: <reply>"There is no problem in computer programming which cannot be solved by an added level of indirection." -- Dr Maurice Wilkes

16:03 hiredman: that's the one

16:03 Chouser: except performance

16:04 * manic12_ snickers

16:04 hiredman: pffft

16:05 premature optimization is the root of all evil

16:05 :P

16:05 manic12_: that being said hiredman, there is something also to be said about code too slow to be useful

16:06 hiredman: I kid

16:06 manic12_: you're mostly right though

16:07 Chouser: I do my optimizations up front and cache them so they'll be faster to use later.

16:08 * manic12_ wonders why it is easier to find a java irc client than get his current client to connect to a java irc channel

16:12 manic12_: somebody tell me what the main java channel on irc.freenode.net is called if any

16:13 i did try the obvious

16:14 Chouser: I think it's ##java

16:15 hiredman: you have to have your nick registered to join

16:15 manic12_: ah

16:15 thx

17:06 rhickey: Chouser: yes, bridge methods are currently a problem for reify. That and non-reflective self-calls are still todo

17:08 Chouser: ok

17:09 the workaround in this case is trivial

17:10 auto-hinted 'this' will allow removal of almost every type hint

17:10 the other hint cluster is around deref

17:11 Two other things I'm thinking about: 1. some kind of compile-time warning for unimplemented methods in reify

17:12 2. how best to use macros to mix in implementations

17:13 rhickey: 1, yeah

17:14 2, I'm still on the fence about this

17:14 Chouser: sheesh. vectors are so fast.

17:14 rhickey: the no-arg-ctor-super will still let you do the equiv of abstract classes, iff you can name them

17:15 Chouser: tough to beat them eh?

17:15 Chouser: yeah. I've avoided that so far, but ASeq would be very handy.

17:15 rhickey: yes!

17:16 rhickey: Chouser: I definitely intend to make the abstract all have no arg sigs so we can largely preserve my original design for the colls. It's mostly meta ctors that spoil things

17:16 Chouser: oh

17:16 * Chouser totally forgot about IMeta

17:16 Chouser: I guess I should support that.

17:18 rhickey: the naming thing will be tricky to combine with dynamic, as we've discussed. But it will also be needed for interface injection, which long-term could be great in combination with this design strategy

17:19 hiredman: rhickey: is it true you will be on the ms campus next week, and if so, are you giving some kind of talk/presentation?

17:19 Chouser: jvm7 interface injection?

17:23 rhickey: hiredman: yes, I am giving a talk at MS next week, also an interview I think

17:23 Chouser: yes

17:23 hiredman: hmmmm

17:23 rhickey: Chouser: although I don't think that's making it into 7 is it?

17:24 Chouser: oh, I dunno. thought it was, but I'm a bad source.

17:24 hiredman: rhickey: do you know what day you are giving the talk?

17:25 rhickey: hiredman: Monday or Tuesday, I don't have the schedule yet

17:26 hiredman: ok

17:26 * hiredman is going to try and be there

17:27 rhickey: hiredman: you work for MS?

17:27 hiredman: no

17:27 if I did, I would definitely be there :P

17:28 strlen: MS Mountain View?

17:28 or MS in Sea?

17:28 rhickey: Redmond

17:29 strlen: ah. any talks planned around bay area?

17:29 i've read the transcript of the clojure for lispers talk though, that was *very* helpful.

17:29 manic12: it made my brain hurt

17:29 rhickey: from there I go to the JVM language summit, doing keynote and a workshop

17:29 hiredman: strlen: there are videos of the talk online

17:30 strlen: ooh september 16-18

17:30 ambient: manic12 my brain still hurts and i've been coding with clojure for a while

17:30 i've not even gone into the whole STM/atom/agent thing yet

17:31 strlen: i am context switching between perl with C++ (and passing void ptrs through XS), java and scala. now i am thinking of adding clojure into the mix-- way to go, brain :-)

17:31 but then again i've coded quite a bit in common lisp and scheme so it might not be too much of a jump to get into clojure.

17:31 ambient: yeah, without scheme background it would've definitely been harder

17:32 manic12: i'm a cl programmer and the talk made my brain hurt

17:32 strlen: (of course i also do tons of emacs hacking/customizing, but i cheat with (require :cl)

17:32 ambient: there's 4 things instead of 1 to learn at the same time (5 if you count emacs) 1) immutability 2) functionality 3) java interop 4) parallelism

17:33 with C i just had to learn the syntax and i was golden

17:34 manic12: rhickey: is clojure supposed to work on jamvm on arm?

17:34 strlen: i'd like to say i know parallelism, but honestly i only know pthreads well and recently began dabling with JVM parallelism (java memory models, java.util.concurrent.*)

17:34 rhickey: manic12: don't know much about jamvm

17:34 manic12: it passed most of the tests

17:37 hiredman: most?

17:46 technomancy: I'm trying to call this collect method with a DocumentID and a DocumentAndOp but it's throwing no matching method: http://p.hagelb.org/tmpCollector.html

17:46 I'm wondering if it's due to the use of generics.

17:47 hiredman: I doubt it

17:47 Generics are implemented via type erasure

17:48 so they effectively only exist at compile time

17:48 (for java)

17:48 technomancy: I only ask because I don't understand generics and can't think of any reasonable explanation for why the method that clearly exists would pretend not to.

17:48 hiredman: technomancy: does it show up in the output of .getMethods

17:49 technomancy: hiredman: repl-utils/show does display it; is that the same thing underneath?

17:49 hiredman: ~def show

17:49 yep

17:50 technomancy: it even shows a version that accepts Object, Object

17:50 hiredman: are you sure the DocumentID and the DocumentAndOp are actually those things

17:51 technomancy: yeah, they're definitely coming from the same package as is expected

17:51 hiredman: can you paste the exception?

17:52 technomancy: http://p.hagelb.org/collect-not-found.html

17:52 Chouser: bah, I thought I'd worked around the bridge method issue, but apparently not. landmines lurking in corner cases...

17:54 technomancy: what's odd is if I pass an object that is actually the wrong type, I get a different error

17:54 Chouser: technomancy: try type hinting the object you're calling .collect on. Might give a better error message

17:54 technomancy: Cannot cast clojure.lang.PersistentVector to org.apache.hadoop.contrib.index.mapred.DocumentAndOp

17:54 it's only with the correct types that I get no matching method

17:55 hiredman: ohhhh

17:55 yeah

17:55 type hint the object you are calling methods on

17:55 technomancy: hmm... it's an anonymous class.

17:55 is that even possible?

17:55 hiredman: org.apache.hadoop.contrib.index.mapred.IndexUpdateMapper$1 is the class of the object you are calling methods on

17:56 technomancy: ok, will try that

17:56 hiredman: thats not what I meant

17:56 but yeah, try that I guess

17:57 technomancy: you mean hint the args?

17:57 hiredman: no hint it with OutputCollector

17:57 technomancy: gotcha

17:58 hiredman: or whichever superclass/interface has the collect method

17:58 technomancy: well I'll be damned.

17:58 hiredman: major kudos.

17:59 is that a java interop bug then?

17:59 hiredman: nah, it was Chouser

17:59 technomancy: oh, right

17:59 thanks Chouser

17:59 hiredman: I think it might be the same thing as something chouser ran into and was talking to rhickey about

18:00 technomancy: that wasn't a reify thing?

18:02 hiredman: no, this was a while back

18:02 somnium: what's the best way to convert between strings and keywords?

18:03 ,(keyword (str :foo))

18:03 clojurebot: ::foo

18:03 Chousuke: hmm

18:03 somnium: (rest (str :foo))

18:03 hiredman: something about the actual class being private so method lookups would fail, or something like that

18:03 Chousuke: ,(name :foo)

18:03 clojurebot: "foo"

18:03 somnium: ah

18:03 thanks

18:03 Chousuke: ,(name :foo/bar) ; note this though :P

18:03 clojurebot: "bar"

18:04 Chousuke: but for simple keywords that'll do

18:06 somnium: is there anything like gsub? didn't see one in the re- functions

18:06 ah, str utils

18:06 nm

18:11 how to reconstitute a str after a seq operation?

18:11 ,(str (rest foo))

18:11 clojurebot: java.lang.Exception: Unable to resolve symbol: foo in this context

18:11 somnium: ,(str (rest "foo))

18:11 clojurebot: EOF while reading string

18:11 somnium: 3rd time the charm

18:12 ,(str (rest "foo"))

18:12 clojurebot: "(\\o \\o)"

18:12 hiredman:

18:12 Chousuke: :p

18:12 hiredman: ,(apply str (seq "foo"))

18:12 clojurebot: "foo"

18:59 hiredman: http://blog.headius.com/2009/08/introducing-surinx.html dynamic language that uses invokedynamic

18:59 headius: :)

19:00 hiredman: :)

19:16 ambient: seems like the rate of new languages popping up is increasing exponentially

19:19 hiredman: well it has become somewhat easier because you can rely on the vm/runtime/platform to provide more and more

19:33 kanzenryu: morning all

19:33 anybody interested in http://rogeralsing.com/2008/12/07/genetic-programming-evolution-of-mona-lisa/

19:34 I'm trying to write a reasonably fast piece of code to compare the images

19:34 So far it takes around ~250 milliseconds for a 400x400 image

19:37 ambient: hmm, i'd think it's just something like (reduce + (map #(- % pic_a) pic_b)) to calculate fitness

19:37 kanzenryu: My attempt so far is at http://paste.lisp.org/display/86835

19:37 ambient: ive heard that (+ a (+ b c)) is faster than (+ a b c)

19:38 kanzenryu: I was trying to do the comparison separately for each of R G B

19:39 ambient: i would really try to do it in a functional style instead of iterating with dotimes and mutating

19:39 then pic_a becomes the R component of pic_a etc..

19:39 kanzenryu: I would like to, I'm still learning to twist my brain that way

19:42 I couldn't work out how to extract the RGB stuff in a functional way

19:44 ambient: just copy the data into a sequence and iterate over that sequence

19:44 although i've yet to do it myself either :)

19:44 Chousuke: hmm

19:45 kanzenryu: I'm just wondering if getting the pixels out of the BufferedImage is the slow part... maybe I should time that

19:52 Chousuke: most likely setting the var is slow

19:52 kanzenryu: really?

19:52 not compared to all the looping and so forth, surely?

19:53 Chousuke: well you're setting the var once in each iteration of the loop

19:54 kanzenryu: okay, right... but I do need to keep that running total

19:55 Chousuke: http://paste.lisp.org/display/86835#1

19:55 though hm

19:55 I'm not sure if the ranges are actually correct :P

19:56 did dotimes start from 0 or 1?

19:56 ,(dotimes [i 3] (println i))

19:56 clojurebot: 0 1 2

19:56 Chousuke: right. should be fine :)

19:56 kanzenryu: okay, looks good...

19:57 Chousuke: though using for you can't get down to primitive math :/

19:58 you need an explicit loop (though using set! is still not what you should do)

19:58 * rhickey_ hates RDF bnodes

19:58 Chousuke: anyway, the bitops don't support operating on primitives anyway so that optimisation has to wait until they do ;P

19:59 kanzenryu: okay

19:59 thanks for the help

19:59 ambient: RGB value is basically a vector, and substracting one from another could return the right value

20:00 Chousuke: oh, so just c1-c2? :P

20:00 of course.

20:00 ambient: yes

20:01 kanzenryu: Okay, I was thinking in terms of squares of differences... maybe that's overkill

20:02 ambient: the vector length is the fitness value, or if you want length to the power of two

20:15 kanzenryu: Now it

20:15 it

20:15 Now it's taking 1.9 seconds

20:15 ;-)

20:15 ambient: :P

20:15 well you could always use a java library like parallel colt

20:17 kanzenryu: The other issue is that when comparing the value directly (instead of separately for RBG it will have a massive bias towards the most significant bits

20:18 I'll keep fiddling with it...

20:18 ambient: i really really love python/numpy style for this kind of stuff

20:18 just wish it were a bit faster

20:20 it would be basically sum(abs(pic1-pic2)) iirc

20:20 kanzenryu: It's the meaning of the minus sign that's critical

20:21 ambient: if the dimensions match, it just goes through them both and substracts the second from the first step by step

20:21 with highly numerically optimised BLAS lib

20:22 kanzenryu: nifty

20:25 ambient: radix sort is just: while mask <= npy_max: cond = npy_nums & mask; npy_nums = numpy.r_[npy_nums[cond==0], npy_nums[cond>0]]; mask <<= 1; :)

20:26 array processing is fun

20:28 found my compare_blocks method that compares to images and finds fitness/price: compare_blocks(ba1, ba2): bares=(ba1-ba2)**2; return numpy.add.reduce(bares.flat)/ba1.shape[0]

20:28 thats it :D

20:28 *two images

20:29 i dont know how one would go about setting up an array processing language on top of lisp

20:38 hiredman: ambient: there is the forkjoin stuff

20:39 ambient: im just reading a paper of combining J and Lisp :) http://www.cs.trinity.edu/~jhowland/aprol.paper.pdf called APROL

20:39 hiredman: I saw a wrapper around some kind of GPU processing stuff which is usually vector based

20:39 ambient: yes, the opencl one

20:40 but afaik opencl uses c-like syntax which doesnt directly deal in arrays

20:53 Chouser: ah! finally got a use case where finger-trees win. :-)

20:53 ambient: huffman?

20:54 Chouser: queue!

20:54 of course we also already have a persistent queue...

20:54 * Chouser tries that

20:55 Chouser: shoot

20:58 lisppaste8: Chouser pasted "finger tree as a queue" at http://paste.lisp.org/display/86837

20:59 ambient: is that a priority queue (PersistentQueue)?

21:00 agh, i need sleep

21:00 Chouser: nope, just a straight queue

21:00 ambient: well, try doing priorityq with clojure vs. finger trees

21:00 im quite sure finger trees win there

21:01 Chouser: ambient: how do you determine the priority of your values

21:01 ambient: you have a use case, right?

21:01 ambient: huffman encoding with just values between 0-255

21:01 or 0-127

21:01 with uneven distribution

21:02 hiredman: http://github.com/hiredman/clojurebot/blob/c9ae225fd06ce101ecc1470fa62ad845c1525764/hiredman/pqueue.clj

21:02 Chouser: I'm afraid a clojure sorted map will beat my finger trees for a priority queue.

21:02 ambient: hiredman cool :)

21:02 hiredman: err

21:03 * hiredman sees some issues

21:03 somnium: is there a zip-with fn in core or contrib? ... like (zw [1 2 3] [4 5 6]) => [1 4 2 5 3 6] ?

21:03 hiredman: ,(doc zipmap)

21:03 clojurebot: "([keys vals]); Returns a map with the keys mapped to the corresponding vals."

21:03 hiredman: actually

21:03 somnium: not the same, no?

21:03 hiredman: ,(doc interleave)

21:03 Chouser: ,(interleave [1 2 3] [4 5 6])

21:03 clojurebot: "([& colls]); Returns a lazy seq of the first item in each coll, then the second etc."

21:03 (1 4 2 5 3 6)

21:03 somnium: thats it

21:05 ambient: using cc/stuff is really confusing, because scheme has cc/call

21:06 hiredman: *shrug*

21:25 Chouser: hm, a whole lot of var deref'ing and apply'ing...

21:27 rhickey: when you get a chance, could you look at how I have organized my code here? http://tinyurl.com/mdm3rw/finger_tree.clj

21:29 rhickey: it looks like I'm spending a lot of time do var deref's. I guess I can do it all in a big letfn?

21:31 hiredman: :(

21:31 albino: Brent agreed to use the pop up window and require them to login to echoloops in that window. Then they will get a page like the one attached where they can download and enter the hardware codes for all of the games at one time. Then they can log back in to that pop up again to see their game license codes. Call me with questions.

21:31 rhickey_: Chouser: I'd like to see the stats on that. I've been thinking about var perf recently. Have you compared to letfns?

21:40 Chouser: I haven't compared to one big letfn. that just sounds so ugly

21:41 rhickey_: Chouser: but you have profiler data indicating var deref?

21:41 as a bottleneck

21:42 Chouser: yes, I'm getting a screenshot

21:44 rhickey_: one of the problems I've had profiling is that I think it disables some optimizations that usually kick in on var deref

21:44 Chouser: http://n01se.net/paste/dwqq -- profiling finger tree

21:44 oh. well, that would be unfortunate.

21:44 rhickey_: so it looks hot in profiling but if you remove it it make little difference

21:45 Chouser: I've got an 'apply' or two to get rid of as well I think.

21:46 rhickey_: apply should be much faster in master now, with specific arity overloads

22:04 Chouser: best time with defn: 1330.715023 msecs Best time with letfn: 1028.015362 msecs

22:05 and maybe not as ugly as I thought...

22:21 letfn only seems to be 8 or 9% speedup consistently.

22:29 the apply arity patch doesn't seem to help

22:52 manic12: I have a bunch of "class" files and I want to make a new instance of one of the objects, and I have no idea how to do it

22:53 dms: http://clojure.org/java_interop#new

22:53 manic12: been there

22:55 dms: it is not what you want? you are getting an error doing it?

22:56 manic12: i am sure it is what I want, but I have no idea at all how to specify the class name, or even if the class files are loaded

22:57 hiredman: uh

22:57 how do you not know the class name?

22:58 manic12: I'm in netbeans, I add a directory of .class files to Libraries

22:58 is that wrong so far?

22:59 in cl it's as difficult as (load "filename")

23:00 apparently you have to have a phd in netbeans to know how to have access to a class

23:00 clojurebot: with style and grace

23:00 hiredman: where did you get the class files?

23:00 manic12: I made them

23:01 hiredman:

23:01 how did you make them?

23:01 manic12: javac *.java

23:02 hiredman: so, how can you possibly not know the names of the classes?

23:02 you have the source right there

23:02 manic12: I know the name of every one of the damn classes

23:03 how do i make an instance of one?? (and don't say "new" because I tried that 175 different ways)

23:04 hiredman: manic12: if new doesn't work then you are doing something wrong

23:04 manic12: i think we have determined that.

23:04 hiredman: if want more detail, than please provide more detail

23:04 manic12: how do I un-wrong it

23:05 somebody please just tell me in netbeans how to load a class file

23:05 hiredman: I don't use netbeans, and I think the majority of people here don't either

23:06 enclojure apears to have its own irc channel

23:06 and its own google group

23:07 http://enclojure.net/Community.html

Logging service provided by n01se.net