#clojure logs

2009-09-09

00:00technomancytomoj: I don't actually understand it myself; don't feel bad.
00:19Bercilakhow can I make seqs not explode with out of memory errors?
00:20BercilakI'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
00:22BercilakI'm trying to traverse a directory for a bunch of mp3s with file-seq and filter... and kaboom.
00:23tomojBercilak: holding the head?
00:26BercilakI 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.
00:46jbelltechnomancy: have you worked out your problem yet?
01:14albinowell it could be my job to deal with french, though I only took spanish in school
03:13tomojfrench?
04:32ol3hi, is there a something like #+nil in clojure?
04:34ol3found it by myself #_
04:55tomojwhat does that mean?
04:55tomojoh, reader comment?
05:01ol3(doc #_)
05:01clojurebotUnmatched delimiter: )
05:01ol3ignore next form
05:01ol3,(+ 123 123 123)
05:01clojurebot369
05:01ol3,(+ 123 123 #_ 123)
05:01clojurebot246
05:03tomojI wonder what the difference is between
05:03tomoj(doc comment)
05:03clojurebot"([& body]); Ignores body, yields nil"
05:03tomojoh, well, different usage clearly
05:03tomojand #_ doesn't even make it past the reader
05:06Chousuke,#_)
05:06clojurebotUnmatched delimiter: )
05:07Chousukeso even if it gets ignored it has to have proper syntax :)
05:17Fossithat's weird.
05:23tomojwell..
05:25tomojoh guess you're right
05:25tomojI had done stuff like:
05:25tomoj,(println "foo" #_(, .,cuh.c,u .,cu.r,))
05:25clojurebotfoo
05:26tomojbut that is proper syntax I guess :)
05:27tomojI guess it has to have proper syntax for the reader to know what the "next form" is
05:55ol3tomoj: you can use it to comment out forms
05:57Chousuketo comment out text you still need to use ; :)
06:22LauJensenAlright Clojurians, as always comments are encouraged and appreciated: http://www.dzone.com/links/php_vs_clojure_whats_the_cost_of_being_oldschool.html
06:51LauJensenI would hope it was (true true true...) :)
06:51LauJensenBut you're right ofc, bad naming policy on my part
06:51LauJensenfixed
08:07AWizzArd,(System/getProperty "java.version")
08:07clojurebotjava.security.AccessControlException: access denied (java.util.PropertyPermission java.version read)
08:58johnmn3good day
08:59Chouserhi
09:00johnmn3So I've been playing around with the gnome-java bindings...
09:00johnmn3I've got a working version of the celcius converter.. pretty straight-forward
09:01johnmn3I'm wondering how I might stress test it with some multi-threading, since, supposedly, the gnome-java bindings are thread-safe
09:03johnmn3what could I implement that would otherwise cause problems, were it not for the thread-safety
09:03Chouserdraw to the UI in another thread while doing the regualr callback handling as normal.
09:05Chouseror 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.
09:07johnmn3hmm, can you think of a scenario involving just widgets, or would I have to draw on a canvas
09:07johnmn3I suppose drawing on a canvas would be the best example
09:08rsynnottjohnmn3: as a matter of interest, why are you using gnome-java?
09:08rsynnottjust for integration with gnome?
09:09johnmn3rsynnott: just to experiment with the supposed "thread-safetey" of the library
09:09johnmn3Though I do use linux
09:10Chousercan you change widget status? like size, position, etc.?
09:10Chouserhow about two buttons bouncing around a container, each driven by a separate thread?
09:10johnmn3unfortunately, I don't think the gtk part of the gnome-java bindings work on windows yet
09:12johnmn3hmm.. or maybe click a button, spawning a new window in a new thread, then affecting window 1 from a button in window 2?
09:12johnmn3brb
09:13johnmn3I swear my bladder is the size of an apricot these days
09:14Fossiyeah, tmi
09:15johnmn3yea, my manners, sorry
09:15ambienti don't really mind
09:15ambientit's interestig
09:16johnmn3I think it's the elevation, 7000+ feet up
09:16ambientor too much coffee?
09:16rsynnott7000 feet up? Where's that?!
09:17johnmn3mountains in afghanistan
09:17johnmn3I'm a soldier
09:20johnmn3mmm.. I'm going to give the canvas drawing a shot.. just found a java example. What threading mechanism should I use? agents?
09:21ambienti'm also wondering what kind of a drawing method to use
09:21ambientim thinking of abstracting opengl window with some additional functions behind an event queue
09:22Chouserjohnmn3: agents would be fine, or just (.start (Thread. #(do-stuff ...)))
09:24tmountainis 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?
09:24johnmn3Chouser: ok.
09:25Chousertmountain: calling def with a value creates a root binding in the current namespace
09:25tmountainif it's called without a value, the variable is interned?
09:26Chouserthe var, yeah.
09:26Chouser*global* vars are created with def -- do difference
09:27tmountainok, 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?
09:28Chousernothing. you can do that.
09:29tmountainwhat's the distinction between def and set! then?
09:29Chouserbut 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.
09:29Chousertmountain: you can only use set! on a var when it has a thread-local binding.
09:29tmountainyeah, absolutely, I know that's an awful way of doing it ;-), I'm just exploring hypothetical situations
09:30Chouser,(set! map 5)
09:30clojurebotjava.lang.IllegalStateException: Can't change/establish root binding of: map with set
09:30tmountainahh, ok
09:30Chouser,(binding [map 5] (set! map 10))
09:30clojurebot10
09:30tmountainestablished via binding
09:30tmountainthanks for the clarification
09:31Chouserthe more I think about it, the more I'm surprised we have a thing like 'binding'. It's a powerful and subtly dangerous tool.
09:32tmountainI'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
09:32Chousertmountain: that's probably exactly the right way
09:33tmountainif 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
09:36Chouserwith 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.
09:36Chouserif you find the performance is insufficient, you can add more refs at another level (one ref per room? per object?)
09:36rhickeycommute is an optimization and premature optimization...
09:40tmountainok, thanks guys
09:41tmountainis there a convenient way to serialize a map for the purpose of shutting things down and saving state?
09:42Chouser,(pr-str {:a 1 :b [2 3 4]})
09:42clojurebot"{:a 1, :b [2 3 4]}"
09:42duck1123spit/slurp
09:42Chouser,(read-string "{:a 1, :b [2 3 4]}")
09:42clojurebot{:a 1, :b [2 3 4]}
09:43tmountainbeautiful, you're a gentleman and a scholar ;-)
09:51johnmn3ok, one line has been drawn.. now to do that a hundred times with 3 threads
09:53Chouserheh
10:01somniumhaving 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:03Chousersomnium: I think slime may use thread-local bindings to capture output from the java thread and send it to the buffer
10:03Chouserso printing from some other thread might lose that binding
10:03Chouserthat's pure speculation though
10:03somniumhmm, any idea what incantation might send them back to slime?
10:05Chouseroh -- are you starting your own new thread? I may have misread your post.
10:07somniumactuall I'm not sure, clojure hides all the runnable stuff
10:07somnium(been a long time since I've used swing so I'm fuzzy on the details in any case...)
10:08somniumI 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:08somniumupdate and show works fine
10:17somniumI think all swing instances go into new threads don't they? Unless I completely misunderstood the first time around
10:20dmsdoesn't swing callbacks get called in the same thread i.e the swing event thread?
10:24somniumhmm, 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:35johnmn3so what do you get when you cross ubuntu, gnome-java bindings, clojure, multi-threading, and a newbie?
11:36ambientnot much, I'd recon
11:36johnmn3system lockup, rather
11:36ambient:D
11:36johnmn3not sure if the experiment worked.
11:37johnmn3the lines kept drawing, but they wouldn't stop
11:48tmountainjohnmn3: what are you working on?
12:04AWizzArdIs there a better way to sort a map?
12:04AWizzArd,(apply sorted-map (interleave (keys {:a 1, :b 2, :c 3}) (vals {:a 1, :b 2, :c 3})))
12:04clojurebot{:a 1, :b 2, :c 3}
12:06cgrand, (into (sorted-map) {:a 1, :b 2, :c 3})
12:06clojurebot{:a 1, :b 2, :c 3}
12:07technomancytmountain: have you seen mire?
12:23tmountaintechnomancy: 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:26AWizzArdcgrand: good, thanks
12:29technomancytmountain: cool; have fun.
12:31tmountaintechnomancy: 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:41fradiavalotechnomancy: Are you the author of emacs-starter-kit?
12:42technomancyfradiavalo: yep
12:43fradiavalotechnomancy: Excellent work! I stumbled upon it yesterday. It is very useful, except you choose to ignore python ;)
12:43technomancyfradiavalo: I've had a couple people offer to contribute python support, and then they go disappear and I never hear back from them. =)
12:44fradiavaloha, well. python mode seems to be in a bit of a mess with the official python.el and more popular python.el
12:45technomancyfradiavalo: are you volunteering? =)
12:45fradiavaloopps I meant more popular python-mode.el
12:45fradiavaloI have to sort it out for myself, so if I come up with something useful, I will definitely contribute
12:45technomancygreat
12:46fradiavaloRight now, I don't know whether to start hacking the emacs python.el or the other one.
12:49LauJensenIts on the frontpage now : http://www.dzone.com/links/php_vs_clojure_whats_the_cost_of_being_oldschool.html
12:50ambienthmm, sql transactions/hour. what happens when clojure runs out of memory to hold the data structures?
12:51ambientim quessing that it's the reason for so few actual transactions
12:51ambientjust did a quick overview, will parse it later
12:52LicenserLauJensen: interesting link but I must say I never ever have anyone heared saying “I love PHP because its so productiv..."
12:53ambienti've never heard anyone say "i love php" ...
12:54Licenserambient: you've a point
13:05replaca_LauJensen: nice post - a good way of expressing what clojure does
13:06LauJensenThanks replaca_ :)
13:06LauJensenLicenser: I have :)
13:06LauJensenambient: Thats another story
13:07LicenserLauJensen: I think I should be sorry for you :Ü
13:08ambientLauJensen microbenchmarks always leave me hungry
13:13Licenseranother question I had looking at the article, since when is PHP old scool o.O
13:20LauJensenSince now
13:20LauJensenI think Wordpress.com just got nuked
13:20LauJensenhmm, maybe PHP swallowed all its ressources
13:20ambientsome script kiddies finally caught sniff of all the numerous vulnerabilities?
13:21Licensermust have been theese old school PHP hackers :P (sorry teasing)
13:21Chousukethey just proved your point ;P
13:23albinoIsn't 10+ years as a programming language make you old school?
13:23LauJensenwordpress.com just got back up, but my blog is still down.. hmm ;)
13:23LauJensenalbino: You're old school as soon as you stop keeping up
13:23LauJensen(per my definition)
13:24albinolooks like 1994 for PHP according to wikipedia
13:25albinoLauJensen: does "keeping up" mean keeping the website responding to requests?
13:25LauJensenI 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:25ambientlisp is still pretty hot and it was 1969 something
13:25albinoambient: but you would agree lisp is old-school under your own opinion, wouldn't you?
13:25LauJensenalbino: Keeping up means, if cutting edge development can lean on parallel code execution, multicore/multithread concurrency etc, that you're doing the stuff
13:26ambientidk, old school would suggest that it was somehow redundant and irrelevant, which it is not
13:26albinoLauJensen: oh, gotcha
13:26albinodammit, old school doesn't seem to mean the same thing to anyone
13:26ambientMS-DOS programming with int 13h is old school
13:27mDuffK&R C is old school
13:27albinoI 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:27mDuffPOSIX sh is old school -- not all things old school are bad.
13:27LauJensenint 19h is fresh though
13:28manic12Hi, 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:28LauJensenalbino: It's a cool thing to a lot of people, but in industriel development, old school often frustrates me
13:28manic12is test-is a test framework or a test suite or both?
13:29LauJensenIts 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:30technomancymanic12: it's a framework
13:30technomancybut it's moved out of contrib to clojure.test in recent versions
13:30manic12is there a test suite?
13:30technomancyyes, also used to live in contrib but is now in clojure itself
13:30manic12ok, got any pointers to that?
13:31technomancyit's in the test/ directory?
13:33albinoLauJensen: Well yeah, it's good we moved on from Cobol
13:34manic12technomancy: any docs on the website for that?
13:36technomancymanic12: what are you looking for? how to run the tests? how to contribute new tests? what to do if they fail?
13:36LauJensenalbino: I guess - Just wish I hadn't made so many stops along the way to Clojure
13:36manic12I'm looking for tests that have already been defined
13:36albinoLauJensen: did you do the perl thing? If so I do feel bad for you
13:37LauJensenalbino: I wasn't able to do Perl
13:37technomancymanic12: http://github.com/richhickey/clojure/tree/270185aba54cef1d8ce59ec347b5623f2e502afe/test/clojure/test_clojure
13:55manic12_.
14:02manic12_anybody there?
14:02LauJensenyea?
14:03manic12_...just wondering if this channel was working
14:03ambientwe're all really just figments of your imagination
14:06manic12_I like fig newtons
14:26manic12_I am assuming that clojure-1.0.0 is not compatible with the libraries from git://github.com/richhickey/clojure.git
14:26manic12_if so,
14:26manic12_where are the directions to build that version of clojure
14:28Chousukejust cd to the dir and run "ant"
14:29manic12_where do I get ant?
14:29manic12_sorry for the dumb questions
14:30albinoGrab it from the apache ant website
14:30albinorun the ant executable in the same directory where the build.xml file resides
14:30manic12_ok
14:32stuartsierrahttp://ant.apache.org/
14:34ChouserI 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:37Chouserbut RT.cons doesn't call ISeq.cons -- does ISeq really need to require a cons method?
14:39rhickeyIPersistentCollection.cons is really conj - need to refactor that at some point
14:40rhickeyso, should replace consRight
14:40Chouserok. either way I need to implement the the method called by RT.conj
14:41Chouserok. So I should implement cons and consLeft?
14:41Chouserexcept current conj sometimes goes on the left. so cons and reverseCons?
14:42rhickeysometimes?
14:42Chouserfor persistent list
14:42rhickeyoh, but for fts I thought cons left conj right
14:42ChouserI mean the conj contract doesn't specify which end, so it seems wrong for consLeft to name an end.
14:43rhickeywell, ft will have to declare what conj means for it (right)
14:43Chousersure, 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:44Chouserthis is why I used "left" and "right" explicitly in my code up til now. Would have been hopelessly confused otherwise.
14:44rhickeyyeah, it would be better if it were already refactored, then cons/conj as methods would work.
14:44ChouserI guess it wouldn't be too hard to fix, just a big ugly patch.
14:45rhickeyconsRgith should be called cons in order to get into the refactor, consLeft can stay that until after the refactor
14:45Chouserit makes my head hurt. PersistentList would provide only conj?
14:46rhickeyChouser: yes
14:46Chouseronly double-headed things would provide cons after refactor, consLeft for now.
14:46rhickeywe could do rconj for double ended things
14:47rhickeybut yes, consLeft is fine, I don't anticipate any callers other than the impl
14:48Chouserok, thanks.
14:48ChouserI 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:50ChouserI'll have to spend some time on the performance. I'm pretty sure the complexity is correct, but the speed is unimpressive.
14:50clojurebothttp://clojure.org/java_interop#toc46
14:52LauJensenDouble headed, double ended?
14:52ChouserLauJensen: you can conj onto either end of a finger tree in amortized O(1) time
14:53LauJensenamortized O(1) ?
14:53ChouserLauJensen: "fast"
14:54liwp`:)
14:54LauJensenI just dont see how O(1) could 'amortize', that means slowly decrease in speed right?
14:54liwp`LauJensen: it means that it something not 1, but in time you get really close to one
14:54LauJensenah ok
14:55liwp`i.e. fast
14:55Chousukeusually it means doing an expensive operation every once in a while so that most of the operations can be fast
14:56liwp`yeah, like purely functional queues where once in a while you need to reverse a list
14:56Chouserbecause calling it O(log n) makes it sound worse than it generally is
14:56liwp`but most of the time you can just call first and rest
14:56liwp`Chouser: so how finished are you with finger trees?
14:57liwp`Chouser: and are they difficult to implement
14:57ChouserI bet they're pretty easy to implement compared to, say, PeristentVectors or red-black trees.
14:58Chouserit didn't seem very easy to me, but I think that says more about me than about finger trees. :-)
14:58liwp`Chouser: the impl is in java rather than pure clojure?
14:58Chousernope, pure clojure. I have no interest in spending my spare time writing java code. :-)
14:59liwp`ooh, excellent
14:59liwp`good man
14:59Chousukeyou can spy: http://github.com/Chouser/finger-tree/blob/8b06d89b63c63a446f16314b1859c53f17437b5f/finger_tree.clj
15:00liwp`cool, I'll have to have a look
15:06liwp`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:15Chousukeliwp`: you need to change the option button to not be meta I think
15:15ChousukeI have that in my config somewhere
15:16Chousukeliwp`: (setq mac-option-modifier 'none)
15:17Chousukeyou may also want to configure mac-command-modifier and mac-control-modifier
15:17LauJensenWhat does the concept of a double headed structure cover?
15:19Chouserlike a doubly-linked list -- you can add to either end or iterate from either end.
15:19Chouserexcept this is clojure, so I also mean persistent, which a doubly-linked list is not.
15:19LauJensenOk, so its something in Clojures low-level handling of sequences?
15:20Chouserclojure seqs are not double-headed in this way.
15:20manic12_is this an ok place to ask java questions, if the ultimate reason for is to use clojure?
15:21Chousermanic12_: probably
15:21Chousukemanic12_: well, you can ask about libraries and such of course, but not everyone here is all that familiar with java the language
15:21manic12_ok
15:22manic12_has anyone here ever set up a callback from c into java?
15:23ChouserI've done C++ into java.
15:23Chouserusing SWIG, which I would recommend
15:24ChouserThough for plain C, I'd check JNA first and see if it has anything to offer.
15:24manic12_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:24LauJensenWhat could be the reasons for wanted to do C into Java ?
15:25LauJensens/wanted/wanting
15:25manic12_I have been working with a large c++ library with swig and CL
15:26manic12_now I am thinking to adapt the interface files to work for java, for the purpose of using clojure on the C++ lib
15:27manic12_the CL version I created uses callbacks from c++ so that you extend c++ objects with clos slots
15:27mDuffhttp://en.wikipedia.org/wiki/GNU_Compiler_for_Java#CNI_.28Compiled_Native_Interface.29
15:29Chouserrhickey: I think I may be stumbling on a bridge method issue with reify
15:29Chouser(conj (new [clojure.lang.ISeq] (cons [x] (println "got" x))) 5) ==> java.lang.AbstractMethodError
15:30manic12_cni is an alternative to swig?
15:30Chouserrhickey: that works if I implement IPersistentCollection instead
15:31mDuffmanic12_, ...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:32Chouserrhickey: ok, I can work around it by implementing IPersistentCollection explicitly as well.
15:33manic12_does clojure run on GNU Java?
15:34hiredmanwhat do you mean by gnu java?
15:35manic12_(on a tangent: I just ran clojure-test on jamvm on ARM and it did 178 tests, 0 failures, 5 errors)
15:35hiredmanif you mean gcj, I dunno, but most java people have such a bad opinion of gcj that I wouldn't bother
15:37manic12_swig it is then...with sun jvm
15:38manic12_i have had decent luck with swig
15:39manic12_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:40hiredmanhave you seen clojure-jna?
15:40hiredmanhttp://github.com/Chouser/clojure-jna/tree/master
15:40LauJensenUsing my recently developed algorithm for predicting bugs in C code, that'll give you roughly 260.000 bugs
15:42ChousukeLauJensen: do you consider side-effects bugs or something? :/
15:43LauJensenno, a bug is when your program does something unexpected and that results in incorrect program evaluation
15:44manic12_hiredman: looks interesting
15:47manic12_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:47manic12_and then they would just look like java to clojure
15:50manic12_what does it look like for a java programmer to call into clojure?
15:51manic12_is it unweildy?
15:51Chousermanic12_: if you want it to look good, you provide java classes and interfaces via gen-class and gen-interface respectively.
15:52Chouserotherwise java can poke around in Namespace objects and call .invoke() on functions.
15:52hiredmanmanic12_: crossing the native <-> jvm divide means taking a serious performance hit
15:53manic12_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:54strlendon'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:54strlenerr not really a web service
15:54manic12_hiredman: the C++ library took over ten years to write and is highly mathematical
15:54strlenbut as RPC
15:54strlennow going Clojure->C will be easier as you're going through JNI
15:54hiredmanmanic12_: ah
15:55manic12_strlen: can C call clojure directly?
15:55strlenmanic12_: (def can-c-call-clojure-directly? can-c-call-java-directly?)
15:55manic12_the allegrocl swig version works pretty good albeit slow compared to native
15:56manic12_but I can live with that
15:56manic12_if I can get comparable performance with jvm<->c++
15:57manic12_strlen: that went back to my question about what it looks like calling clojure from java
15:57manic12_so you gen-class/gen-interface and call the java
15:57manic12_from c
15:58hiredmanseems like a lot of indirection
15:58hiredmanclojurebot: literal [?] problem
15:58clojurebot2
15:58hiredmanclojurebot: literal [1] problem
15:58clojurebot<reply>People have a problem and think "Hey! I'll use a regular expression!". Now they have two problems....
15:59manic12_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:00manic12_I bet calling clojure directly from c would look fairly ugly
16:00manic12_and would break when clojure changes
16:03hiredmanclojurebot: literal [0] problem
16:03clojurebot<reply>"There is no problem in computer programming which cannot be solved by an added level of indirection." -- Dr Maurice Wilkes
16:03hiredmanthat's the one
16:03Chouserexcept performance
16:04hiredmanpffft
16:05hiredmanpremature optimization is the root of all evil
16:05hiredman:P
16:05manic12_that being said hiredman, there is something also to be said about code too slow to be useful
16:06hiredmanI kid
16:06manic12_you're mostly right though
16:07ChouserI do my optimizations up front and cache them so they'll be faster to use later.
16:12manic12_somebody tell me what the main java channel on irc.freenode.net is called if any
16:13manic12_i did try the obvious
16:14ChouserI think it's ##java
16:15hiredmanyou have to have your nick registered to join
16:15manic12_ah
16:15manic12_thx
17:06rhickeyChouser: yes, bridge methods are currently a problem for reify. That and non-reflective self-calls are still todo
17:08Chouserok
17:09Chouserthe workaround in this case is trivial
17:10Chouserauto-hinted 'this' will allow removal of almost every type hint
17:10Chouserthe other hint cluster is around deref
17:11ChouserTwo other things I'm thinking about: 1. some kind of compile-time warning for unimplemented methods in reify
17:12Chouser2. how best to use macros to mix in implementations
17:13rhickey1, yeah
17:14rhickey2, I'm still on the fence about this
17:14Chousersheesh. vectors are so fast.
17:14rhickeythe no-arg-ctor-super will still let you do the equiv of abstract classes, iff you can name them
17:15rhickeyChouser: tough to beat them eh?
17:15Chouseryeah. I've avoided that so far, but ASeq would be very handy.
17:15Chouserrhickey: yes!
17:16rhickeyChouser: 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:16Chouseroh
17:16ChouserI guess I should support that.
17:18rhickeythe 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:19hiredmanrhickey: is it true you will be on the ms campus next week, and if so, are you giving some kind of talk/presentation?
17:19Chouserjvm7 interface injection?
17:23rhickeyhiredman: yes, I am giving a talk at MS next week, also an interview I think
17:23rhickeyChouser: yes
17:23hiredmanhmmmm
17:23rhickeyChouser: although I don't think that's making it into 7 is it?
17:24Chouseroh, I dunno. thought it was, but I'm a bad source.
17:24hiredmanrhickey: do you know what day you are giving the talk?
17:25rhickeyhiredman: Monday or Tuesday, I don't have the schedule yet
17:26hiredmanok
17:27rhickeyhiredman: you work for MS?
17:27hiredmanno
17:27hiredmanif I did, I would definitely be there :P
17:28strlenMS Mountain View?
17:28strlenor MS in Sea?
17:28rhickeyRedmond
17:29strlenah. any talks planned around bay area?
17:29strleni've read the transcript of the clojure for lispers talk though, that was *very* helpful.
17:29manic12it made my brain hurt
17:29rhickeyfrom there I go to the JVM language summit, doing keynote and a workshop
17:29hiredmanstrlen: there are videos of the talk online
17:30strlenooh september 16-18
17:30ambientmanic12 my brain still hurts and i've been coding with clojure for a while
17:30ambienti've not even gone into the whole STM/atom/agent thing yet
17:31strleni 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:31strlenbut 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:31ambientyeah, without scheme background it would've definitely been harder
17:32manic12i'm a cl programmer and the talk made my brain hurt
17:32strlen(of course i also do tons of emacs hacking/customizing, but i cheat with (require :cl)
17:32ambientthere'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:33ambientwith C i just had to learn the syntax and i was golden
17:34manic12rhickey: is clojure supposed to work on jamvm on arm?
17:34strleni'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:34rhickeymanic12: don't know much about jamvm
17:34manic12it passed most of the tests
17:37hiredmanmost?
17:46technomancyI'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:46technomancyI'm wondering if it's due to the use of generics.
17:47hiredmanI doubt it
17:47hiredmanGenerics are implemented via type erasure
17:48hiredmanso they effectively only exist at compile time
17:48hiredman(for java)
17:48technomancyI 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:48hiredmantechnomancy: does it show up in the output of .getMethods
17:49technomancyhiredman: repl-utils/show does display it; is that the same thing underneath?
17:49hiredman~def show
17:49hiredmanyep
17:50technomancyit even shows a version that accepts Object, Object
17:50hiredmanare you sure the DocumentID and the DocumentAndOp are actually those things
17:51technomancyyeah, they're definitely coming from the same package as is expected
17:51hiredmancan you paste the exception?
17:52technomancyhttp://p.hagelb.org/collect-not-found.html
17:52Chouserbah, I thought I'd worked around the bridge method issue, but apparently not. landmines lurking in corner cases...
17:54technomancywhat's odd is if I pass an object that is actually the wrong type, I get a different error
17:54Chousertechnomancy: try type hinting the object you're calling .collect on. Might give a better error message
17:54technomancyCannot cast clojure.lang.PersistentVector to org.apache.hadoop.contrib.index.mapred.DocumentAndOp
17:54technomancyit's only with the correct types that I get no matching method
17:55hiredmanohhhh
17:55hiredmanyeah
17:55hiredmantype hint the object you are calling methods on
17:55technomancyhmm... it's an anonymous class.
17:55technomancyis that even possible?
17:55hiredmanorg.apache.hadoop.contrib.index.mapred.IndexUpdateMapper$1 is the class of the object you are calling methods on
17:56technomancyok, will try that
17:56hiredmanthats not what I meant
17:56hiredmanbut yeah, try that I guess
17:57technomancyyou mean hint the args?
17:57hiredmanno hint it with OutputCollector
17:57technomancygotcha
17:58hiredmanor whichever superclass/interface has the collect method
17:58technomancywell I'll be damned.
17:58technomancyhiredman: major kudos.
17:59technomancyis that a java interop bug then?
17:59hiredmannah, it was Chouser
17:59technomancyoh, right
17:59technomancythanks Chouser
17:59hiredmanI think it might be the same thing as something chouser ran into and was talking to rhickey about
18:00technomancythat wasn't a reify thing?
18:02hiredmanno, this was a while back
18:02somniumwhat's the best way to convert between strings and keywords?
18:03somnium,(keyword (str :foo))
18:03clojurebot::foo
18:03Chousukehmm
18:03somnium(rest (str :foo))
18:03hiredmansomething about the actual class being private so method lookups would fail, or something like that
18:03Chousuke,(name :foo)
18:03clojurebot"foo"
18:03somniumah
18:03somniumthanks
18:03Chousuke,(name :foo/bar) ; note this though :P
18:03clojurebot"bar"
18:04Chousukebut for simple keywords that'll do
18:06somniumis there anything like gsub? didn't see one in the re- functions
18:06somniumah, str utils
18:06somniumnm
18:11somniumhow to reconstitute a str after a seq operation?
18:11somnium,(str (rest foo))
18:11clojurebotjava.lang.Exception: Unable to resolve symbol: foo in this context
18:11somnium,(str (rest "foo))
18:11clojurebotEOF while reading string
18:11somnium3rd time the charm
18:12somnium,(str (rest "foo"))
18:12clojurebot"(\\o \\o)"
18:12hiredman
18:12Chousuke:p
18:12hiredman,(apply str (seq "foo"))
18:12clojurebot"foo"
18:59hiredmanhttp://blog.headius.com/2009/08/introducing-surinx.html dynamic language that uses invokedynamic
18:59headius:)
19:00hiredman:)
19:16ambientseems like the rate of new languages popping up is increasing exponentially
19:19hiredmanwell it has become somewhat easier because you can rely on the vm/runtime/platform to provide more and more
19:33kanzenryumorning all
19:33kanzenryuanybody interested in http://rogeralsing.com/2008/12/07/genetic-programming-evolution-of-mona-lisa/
19:34kanzenryuI'm trying to write a reasonably fast piece of code to compare the images
19:34kanzenryuSo far it takes around ~250 milliseconds for a 400x400 image
19:37ambienthmm, i'd think it's just something like (reduce + (map #(- % pic_a) pic_b)) to calculate fitness
19:37kanzenryuMy attempt so far is at http://paste.lisp.org/display/86835
19:37ambientive heard that (+ a (+ b c)) is faster than (+ a b c)
19:38kanzenryuI was trying to do the comparison separately for each of R G B
19:39ambienti would really try to do it in a functional style instead of iterating with dotimes and mutating
19:39ambientthen pic_a becomes the R component of pic_a etc..
19:39kanzenryuI would like to, I'm still learning to twist my brain that way
19:42kanzenryuI couldn't work out how to extract the RGB stuff in a functional way
19:44ambientjust copy the data into a sequence and iterate over that sequence
19:44ambientalthough i've yet to do it myself either :)
19:44Chousukehmm
19:45kanzenryuI'm just wondering if getting the pixels out of the BufferedImage is the slow part... maybe I should time that
19:52Chousukemost likely setting the var is slow
19:52kanzenryureally?
19:52kanzenryunot compared to all the looping and so forth, surely?
19:53Chousukewell you're setting the var once in each iteration of the loop
19:54kanzenryuokay, right... but I do need to keep that running total
19:55Chousukehttp://paste.lisp.org/display/86835#1
19:55Chousukethough hm
19:55ChousukeI'm not sure if the ranges are actually correct :P
19:56Chousukedid dotimes start from 0 or 1?
19:56Chousuke,(dotimes [i 3] (println i))
19:56clojurebot0 1 2
19:56Chousukeright. should be fine :)
19:56kanzenryuokay, looks good...
19:57Chousukethough using for you can't get down to primitive math :/
19:58Chousukeyou need an explicit loop (though using set! is still not what you should do)
19:58Chousukeanyway, the bitops don't support operating on primitives anyway so that optimisation has to wait until they do ;P
19:59kanzenryuokay
19:59kanzenryuthanks for the help
19:59ambientRGB value is basically a vector, and substracting one from another could return the right value
20:00Chousukeoh, so just c1-c2? :P
20:00Chousukeof course.
20:00ambientyes
20:01kanzenryuOkay, I was thinking in terms of squares of differences... maybe that's overkill
20:02ambientthe vector length is the fitness value, or if you want length to the power of two
20:15kanzenryuNow it
20:15kanzenryuit
20:15kanzenryuNow it's taking 1.9 seconds
20:15kanzenryu;-)
20:15ambient:P
20:15ambientwell you could always use a java library like parallel colt
20:17kanzenryuThe 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:18kanzenryuI'll keep fiddling with it...
20:18ambienti really really love python/numpy style for this kind of stuff
20:18ambientjust wish it were a bit faster
20:20ambientit would be basically sum(abs(pic1-pic2)) iirc
20:20kanzenryuIt's the meaning of the minus sign that's critical
20:21ambientif the dimensions match, it just goes through them both and substracts the second from the first step by step
20:21ambientwith highly numerically optimised BLAS lib
20:22kanzenryunifty
20:25ambientradix 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:26ambientarray processing is fun
20:28ambientfound 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:28ambientthats it :D
20:28ambient*two images
20:29ambienti dont know how one would go about setting up an array processing language on top of lisp
20:38hiredmanambient: there is the forkjoin stuff
20:39ambientim just reading a paper of combining J and Lisp :) http://www.cs.trinity.edu/~jhowland/aprol.paper.pdf called APROL
20:39hiredmanI saw a wrapper around some kind of GPU processing stuff which is usually vector based
20:39ambientyes, the opencl one
20:40ambientbut afaik opencl uses c-like syntax which doesnt directly deal in arrays
20:53Chouserah! finally got a use case where finger-trees win. :-)
20:53ambienthuffman?
20:54Chouserqueue!
20:54Chouserof course we also already have a persistent queue...
20:55Chousershoot
20:58lisppaste8Chouser pasted "finger tree as a queue" at http://paste.lisp.org/display/86837
20:59ambientis that a priority queue (PersistentQueue)?
21:00ambientagh, i need sleep
21:00Chousernope, just a straight queue
21:00ambientwell, try doing priorityq with clojure vs. finger trees
21:00ambientim quite sure finger trees win there
21:01Chouserambient: how do you determine the priority of your values
21:01Chouserambient: you have a use case, right?
21:01ambienthuffman encoding with just values between 0-255
21:01ambientor 0-127
21:01ambientwith uneven distribution
21:02hiredmanhttp://github.com/hiredman/clojurebot/blob/c9ae225fd06ce101ecc1470fa62ad845c1525764/hiredman/pqueue.clj
21:02ChouserI'm afraid a clojure sorted map will beat my finger trees for a priority queue.
21:02ambienthiredman cool :)
21:02hiredmanerr
21:03somniumis there a zip-with fn in core or contrib? ... like (zw [1 2 3] [4 5 6]) => [1 4 2 5 3 6] ?
21:03hiredman,(doc zipmap)
21:03clojurebot"([keys vals]); Returns a map with the keys mapped to the corresponding vals."
21:03hiredmanactually
21:03somniumnot the same, no?
21:03hiredman,(doc interleave)
21:03Chouser,(interleave [1 2 3] [4 5 6])
21:03clojurebot"([& colls]); Returns a lazy seq of the first item in each coll, then the second etc."
21:03clojurebot(1 4 2 5 3 6)
21:03somniumthats it
21:05ambientusing cc/stuff is really confusing, because scheme has cc/call
21:06hiredman*shrug*
21:25Chouserhm, a whole lot of var deref'ing and apply'ing...
21:27Chouserrhickey: when you get a chance, could you look at how I have organized my code here? http://tinyurl.com/mdm3rw/finger_tree.clj
21:29Chouserrhickey: 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:31hiredman:(
21:31albinoBrent 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:31rhickey_Chouser: I'd like to see the stats on that. I've been thinking about var perf recently. Have you compared to letfns?
21:40ChouserI haven't compared to one big letfn. that just sounds so ugly
21:41rhickey_Chouser: but you have profiler data indicating var deref?
21:41rhickey_as a bottleneck
21:42Chouseryes, I'm getting a screenshot
21:44rhickey_one of the problems I've had profiling is that I think it disables some optimizations that usually kick in on var deref
21:44Chouserhttp://n01se.net/paste/dwqq -- profiling finger tree
21:44Chouseroh. well, that would be unfortunate.
21:44rhickey_so it looks hot in profiling but if you remove it it make little difference
21:45ChouserI've got an 'apply' or two to get rid of as well I think.
21:46rhickey_apply should be much faster in master now, with specific arity overloads
22:04Chouserbest time with defn: 1330.715023 msecs Best time with letfn: 1028.015362 msecs
22:05Chouserand maybe not as ugly as I thought...
22:21Chouserletfn only seems to be 8 or 9% speedup consistently.
22:29Chouserthe apply arity patch doesn't seem to help
22:52manic12I 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:53dmshttp://clojure.org/java_interop#new
22:53manic12been there
22:55dmsit is not what you want? you are getting an error doing it?
22:56manic12i 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:57hiredmanuh
22:57hiredmanhow do you not know the class name?
22:58manic12I'm in netbeans, I add a directory of .class files to Libraries
22:58manic12is that wrong so far?
22:59manic12in cl it's as difficult as (load "filename")
23:00manic12apparently you have to have a phd in netbeans to know how to have access to a class
23:00clojurebotwith style and grace
23:00hiredmanwhere did you get the class files?
23:00manic12I made them
23:01hiredman
23:01hiredmanhow did you make them?
23:01manic12javac *.java
23:02hiredmanso, how can you possibly not know the names of the classes?
23:02hiredmanyou have the source right there
23:02manic12I know the name of every one of the damn classes
23:03manic12how do i make an instance of one?? (and don't say "new" because I tried that 175 different ways)
23:04hiredmanmanic12: if new doesn't work then you are doing something wrong
23:04manic12i think we have determined that.
23:04hiredmanif want more detail, than please provide more detail
23:04manic12how do I un-wrong it
23:05manic12somebody please just tell me in netbeans how to load a class file
23:05hiredmanI don't use netbeans, and I think the majority of people here don't either
23:06hiredmanenclojure apears to have its own irc channel
23:06hiredmanand its own google group
23:07hiredmanhttp://enclojure.net/Community.html