#clojure logs

2008-06-29

00:09spacebat_so, I'd like to ask what environments people use, plain REPL, netbeans+enlojure, emacs+ilisp, emacs+slime, or something else?
00:11spacebat_hi craigoz, whereabouts in .au? I'm in adelaide
04:21fanda_hello!
04:22fanda_just trying IRC
05:03spacebat_hi fanda_
05:03fanda_hello spacebat_
05:04spacebat_new to clojure?
05:04spacebat_I am
05:04fanda_yes, me too
05:04fanda_just starting with it
05:04fanda_i used newLISP before
05:04fanda_but I know little about Java
05:05spacebat_knowing very little lisp and no functional programming, its a steep curve
05:05spacebat_but I can see the reasons to keep on with it
05:05spacebat_I used to work for a java shop, but that was years ago
05:06spacebat_my day job is perl
05:06fanda_yes, i love functional programming and LISP especially
05:06spacebat_newLISP, I haven't heard of that one
05:06fanda_i used it for explorative programming
05:06fanda_it is a small dialect of Scheme (LISP)
05:06spacebat_open or proprietary?
05:06spacebat_I tend to think that common lisp is a bit on the hulking side
05:07fanda_yes, common lips is too big
05:07fanda_http://www.newlisp.org/
05:07spacebat_but it does seem to be the most widely implemented standard
05:07fanda_clojure is more symetrical and more well thought in my eyes
05:07spacebat_I've liked that common lisp has been easy to start with
05:07spacebat_because it lets me code imperatively
05:08fanda_yes, exactly
05:08spacebat_but that doesn't fly here
05:08fanda_newlisp is similar
05:08fanda_(setq x 5) or (set! x 5) ;-)
05:08fanda_clojure is more pure
05:08spacebat_I saw an excellent post on the newsgroup today that spelled it out
05:09spacebat_if you make a new value, either give it a new variable, or pass it directly into a function
05:10fanda_yes, I also have problems with immutability
05:10fanda_i am thinking about creating some "cook book"
05:10spacebat_I've had similar ideas
05:10fanda_how to mutate or "looks-like-mutate" ;-)
05:11spacebat_gradually accumulating code snippets in a library, a modest general purpose collection at the moment
05:11fanda_i have been reading some code from contributions
05:11fanda_now i am trying to create my first useful something :-)
05:12spacebat_I haven't even looked into contrib yet
05:13fanda_here
05:13fanda_http://groups.google.com/group/clojure/files
05:13fanda_and here
05:13fanda_http://clojure-contrib.svn.sourceforge.net/viewvc/clojure-contrib/trunk/
05:13spacebat_I see yes I checked that out of svn but its just sitting on disk so far
05:14spacebat_looking at complete programs has been a bit confusing, trying to get the gist from gradually larger chunks of code
05:15spacebat_clojure just might be my gateway back to java
05:15spacebat_using an IDE to get past the static verbosity of java repulses me these days
05:16spacebat_I've been ruined and made anew by dynamic languages
05:17spacebat_rhickey was saying that there is a guy in sun who really gets lisp
05:17spacebat_and wants to put tail recursion and more functional support in the JVM
05:19spacebat_ok newlisp, I have seen that page before, like a year ago
05:19spacebat_I've been learning lisp about 3 weeks now
05:20spacebat_does it have threads?
05:21fanda_what do you mean - if newlisp has threads? no, it doesn't
05:21spacebat_ok
05:21spacebat_yes that's what I meant sorry
05:21fanda_newlisp is written in C
05:21fanda_runs on many platforms
05:21spacebat_what brings you from there to here?
05:21spacebat_yes portable threading isn't trivial
05:22fanda_but it has everything on its own - runtime - garbage collector, etc.
05:22fanda_libraries for one
05:22fanda_you can import only C libraries or write your own lisp libraries - so much time spent there
05:22kotarakdid anyone encounter issues with agents and clojure.lang.Script?
05:22fanda_i have no idea about this one
05:23spacebat_me neither sorry
05:23fanda_don't be sorry
05:23spacebat_heh
05:23fanda_:)
05:23fanda_if you have any lisp questions, i might answer
05:23fanda_map, apply, filter...
05:23fanda_lambda (meaning fn) functions
05:24spacebat_is there something you don't like about newlisp?
05:24spacebat_not asking you to trash it or anything
05:24kotarakNo. It's more about using agents for concurrency. In the REPL I see the agent output, calling the script "hangs". I'm not sure where or why.
05:24fanda_hi kotarak :-)
05:25kotarakhello fanda_
05:25spacebat_sounds like something a tad advanced
05:25kotarakok. never mind
05:25spacebat_maybe the REPL is doing some sync that's needed and not in Script
05:26fanda_don't know why he left...
05:26spacebat_hunting rather than gathering
05:26fanda_hm
05:27spacebat_newlisp looks like it has potential
05:27fanda_yes, its cool in its own terms
05:27spacebat_if its fast, then with the right libs for coordinating processes it could be a real workhorse
05:28fanda_here are my creations:
05:28fanda_http://intricatevisions.com/index.cgi?page=newlisp
05:28fanda_just click on the left for code, code-tk, ...
05:28spacebat_does it generate binaries?
05:28fanda_no, it does not
05:28fanda_its only interpreted
05:28spacebat_what tipped lisp over the interest threshold recently was seeing Language::Lisp::ECL on the cpan
05:28fanda_but you can make wrappers - wrap newlisp.exe with your script
05:28spacebat_ok
05:29spacebat_ECL uses gcc as a backend and can compile standalone exes
05:30fanda_can be interesting
05:30spacebat_a small naive fibonacci program compiled to 24k on disk
05:30spacebat_its common lisp, so I guess it leaves out all the stuff that isn't being called
05:30fanda_ok, that's interesting!
05:30spacebat_it also makes it easy to embed, all common lisp functions are callable from C
05:31spacebat_the fib program ran about 10 times slower than a C program with the same gcc, for fib(39)
05:32spacebat_but it was still about 6 times faster than the fastest interpreter I tried, which was python
05:32fanda_quite interesting
05:33spacebat_time to give my boy a bath
05:33spacebat_nice chatting fanda_
05:34fanda_wait
05:34spacebat_yupo
05:34fanda_save this link
05:34fanda_http://groups.google.com/group/clojure/browse_thread/thread/69b781ffe805a7de/b60673e9d4436ce0
05:34spacebat_will do
05:34fanda_comparison CL - Clojure ;-)
05:34fanda_might use it
05:34spacebat_thanks, bye
05:34fanda_nice chatting!
05:34fanda_bye!
05:40kotaraksorry, got disconnected. maybe the output of the agent goes somewhere else in the Script compared to the REPL.
06:22spacebat_possibly, you said it hangs though
06:22spacebat_whereas it returns in the REPL?
08:31Chouserkotarak: you might just try adding (flush) after your print or prn
08:33kotarakChouser: no, doesn't help.... Everything worked before, until a packed the output into an agent (since I have to some sync here). Then it stopped working. In the Script. In REPL it still works.
08:34rhickeykotarak: your script may be ending before your agent is done?
08:36kotarakhuh? It can? Ok.... Hmmm... I (await) the agent, but let me add some sleep there.
08:37rhickeyif you await in the same thread you sent, then it's done. Who flushes - - the agent or main?
08:37kotarakthe agent
08:39kotarakalso tried a (flush) in the main thread, didn't help
08:40rhickeycan you paste a small case?
08:41kotarakI'll try to strip it done. Just noticed, that the hitting ctrl-c gives me the output. Maybe a have to issue an explicit exit?
08:44kotarakAhh. Got the problem!!! When using agents, the script doesn't terminate, when reaching the end. You have to explicit call a (. java.lang.System (exit 0)).
08:44rhickeyheh, I used to do that for you, but GUI app devs complained...
08:46kotarakrhickey: well, I'm mostly a non-GUI guy, so I expect a script to exit, when it is end is reached. But that also comes from things like C or sh. There you also have a non-returning function for GUIs. So maybe I just have a differnt point of view.
08:47kotarakrhickey: btw. good job with clojure. It brought me back to the lispy side of life. :)
08:47rhickeythanks, glad you worked it out
09:11Chousercalls to the "rest" part of a lazy-cons are synchronized, but I suppose I still need to wrap them in sync if I want to use set! on a ref, right?
09:13rhickeyyou mean your rest expression manipulates a ref?
09:13Chouserright
09:13rhickeyClojure will force you to be in a transaction, else throws
09:14Chouserwell, reads a ref, but yeah. Ok, that's what I thought.
09:14rhickeyI though you said set
09:15ChouserI did! I'm sorry, I mis-typed.
09:15Chouseractually, I mis-thought.
09:16Chousersorry, still sketching this out in my head. the rest expr will only need to read the ref (and perhaps block on something). so no sync there! cool.
09:16rhickeyYou can do non-transactional reads of refs
09:17rhickeyas long as you don't require a relationship between that read and another
09:18ChouserI don't think so. I'm going to try to build a vector in a background thread, while providing a lazy-seq as access to it in the main thread.
09:20rhickeyDon't ignore things like java.util.concurrent.ArrayBlockingQueue
09:25Chouserhard not to ignore things I've never heard of
09:26rhickeyClojure doesn't duplicate the workflow tools of java.util.concurrent because they are really good
09:27rhickeyqueues/barriers/latches/exchangers etc
09:29meredyddrhickey: Ahh...so, that's really the answer to my question a few days ago
09:29rhickeymeredydd: which question?
09:30meredyddabout thread pools in Clojure...but java.util.concurrent does one, so Clojure doesn't have its own
09:30kotarakthat's my main problem with clojure: when you have to fallback to some java stuff, I pretty lost.... (I have no clue about java whatsoever)
09:30meredydd(so you just have to do the magic proxy fiddle to turn a (fn) into a Runnable)
09:30rhickeyactually Clojure does abstract thread pools with agents
09:30rhickeyfns are Runnable
09:30rhickeyand Callable
09:31meredyddThey are now? Oh, great!
09:31meredydd(Must have been looking at an old discussion...could have sworn I'd seen you saying that there was a good behind-the-scenes reason (fn)s weren't Runnable)
09:32rhickeythere is some casting required now to disambiguate for the executor methods which are overloaded on both Callable and Runnable
09:33rhickeythat hassle was the only reason, but the tradeoff is worth it since half the java library uses one, and half the other
09:33meredyddAh, excellent.
09:34meredyddThank-you, then.
09:34meredyddAnd, by the way, did you do any more thinking about the relational algebra stuff in set.clj?
09:34meredyddBecause I've been thinking a little about that
09:35rhickeyno, what are your thoughts?
09:35meredyddand how, of course, the nil-for-empty convention is fine, provided one uses seqs rather than sets
09:36rhickeyyou mean seqs of maps as rels?
09:36meredyddyeah
09:36rhickeybut won't they have to keep being made into sets anyway?
09:36meredyddJust thinking that, if you were willing to forgo the mathematical warm-and-fuzzies of exact correspondence to the un-augmented relational algebra
09:36meredyddWell, for what purpose?
09:36rhickeyefficiency
09:37meredyddOf which operations? (Sorry, haven't poked around enough in set.clj to see how you do this stuff)
09:37meredyddJoins, I suppose.
09:37rhickeyright
09:37meredyddAh, bugger. The man has a point.
09:37meredyddDamn it - it's just that I was thinking
09:37rhickeyalso I like the rel is a set of maps rule, i.e. no dupes
09:38meredyddyep. As I say, nice mathematical warm-and-fuzzies with the exact correspondence to the RA
09:38rhickeywith the twist of a non-fixed set of columns
09:39meredyddyeah, well...it's that, or a set of vectors, which wouldn't be as nice to work with.
09:39rhickeythat's the special sauce of Clojure rels - non rectangular/sparse
09:39meredyddindeed.
09:40meredyddAnyway - I was just musing that if you were to work with seqs, you could create a nice hack to use a proper SQL back-end for these things
09:40meredyddand, because the seqs are lazy, you could have ops like joins, pi, sigma, etc fold themselves into the SQL statement
09:40rhickeyseq->set once on load seem not too bad
09:40rhickeyseems
09:41meredyddwhich is only actually executed when (first) is actually called on the seq
09:41meredyddwhich would, neatly, allow you to keep all the relational operations Clojure-idiomatic.
09:42meredydd(at the cost of some "Is it a bird? Is it a plane? Is it a seq, or an SQL wrapper?" hackery in the back-end.)
09:44kotarakHmmm... Is there something in using agents, which turns off flushing? Suddenly I have to add (flush)es all over the place.
09:44kotarakOr is java.lang.System.exit discarding unflushed stuff?
09:45meredyddkotarak: I think java.lang.System.exit is just killing the VM before the agents get a chance to run what you've sent them
09:45rhickeyIf you have multiple thread writing to the same stream you're likely to get a mess at some point. Maybe confine your I/O to a single place and have the agents just create the to-be-output values?
09:47kotarakI have one agent, which does the output stuff. So this is in sync. It's also (await)ed by the main thread. So there should be no problem here. I think exit just kills the VM, with flushing. Give me a second.
09:48kotarakYep. It's java.lang.System.exit. Is there some way of a sane shutdown? (Ie. doing things like flushing output.)
09:48rhickeyawait/flush/exit doesn't work?
09:49kotarakit does.
09:49kotarakThe flush is a bit anoying
09:49kotarakBut maybe this is again my different background. Just have to get used to it.
09:50rhickeythere have been requests that the pr* fns flush
09:52kotarakI'm used to "newlines flush" and also exit() flushes. So flush is somehow the default for me. Now java.lang.System.exit does not flush. *poof* I have problem. But that's simply the wrong default on my side.
12:19Chousertomhickey_: on clojure.org's left-hand menu, the clickable area for each link extends the full width of the menu. Top notch!
13:15rhickeynew essay: http://clojure.org/state
15:40abrooks_Chouser: Good observation regarding tomhickey_ 's good UI. Nicely done tomhickey_!
16:20scgilardipjb3: I liked the picture of Rich you posted the other day captioned "State: You're doing it Wrong"
16:26scgilardiI have a thought about the flushing issue: it's often a good thing to flush on newline, but sometimes the inefficiency matters. How about a var *flush-on-newline* whose global binding is to "true" which is used to control whether or not some subset of the "pr*" functions flush on newline (or flush with each call).
16:28scgilardiI also like the idea I saw for "dbg*" functions that auto-flush as debugging is often a case where flushing matters
16:46rhickeyscgilardi: *flush-on-newline* whose global binding is to "true" works for me
16:51scgilardicool, thanks.
17:39rhickeyuser=> *flush-on-newline*
17:39rhickeytrue
18:17Chouserhmph. can't properly store nulls in an ArrayBlockingQueue
18:18rhickeyaargh
18:31Chouserbut false works fine, so using that as an end sentinel, this does what I want:
18:31Chouser(for [e (repeatedly #(.take q)) :while e] e)
19:40rhickeygotta love repeatedly