2008-06-29
| 00:09 | spacebat_ | so, I'd like to ask what environments people use, plain REPL, netbeans+enlojure, emacs+ilisp, emacs+slime, or something else? |
| 00:11 | spacebat_ | hi craigoz, whereabouts in .au? I'm in adelaide |
| 04:21 | fanda_ | hello! |
| 04:22 | fanda_ | just trying IRC |
| 05:03 | spacebat_ | hi fanda_ |
| 05:03 | fanda_ | hello spacebat_ |
| 05:04 | spacebat_ | new to clojure? |
| 05:04 | spacebat_ | I am |
| 05:04 | fanda_ | yes, me too |
| 05:04 | fanda_ | just starting with it |
| 05:04 | fanda_ | i used newLISP before |
| 05:04 | fanda_ | but I know little about Java |
| 05:05 | spacebat_ | knowing very little lisp and no functional programming, its a steep curve |
| 05:05 | spacebat_ | but I can see the reasons to keep on with it |
| 05:05 | spacebat_ | I used to work for a java shop, but that was years ago |
| 05:06 | spacebat_ | my day job is perl |
| 05:06 | fanda_ | yes, i love functional programming and LISP especially |
| 05:06 | spacebat_ | newLISP, I haven't heard of that one |
| 05:06 | fanda_ | i used it for explorative programming |
| 05:06 | fanda_ | it is a small dialect of Scheme (LISP) |
| 05:06 | spacebat_ | open or proprietary? |
| 05:06 | spacebat_ | I tend to think that common lisp is a bit on the hulking side |
| 05:07 | fanda_ | yes, common lips is too big |
| 05:07 | fanda_ | http://www.newlisp.org/ |
| 05:07 | spacebat_ | but it does seem to be the most widely implemented standard |
| 05:07 | fanda_ | clojure is more symetrical and more well thought in my eyes |
| 05:07 | spacebat_ | I've liked that common lisp has been easy to start with |
| 05:07 | spacebat_ | because it lets me code imperatively |
| 05:08 | fanda_ | yes, exactly |
| 05:08 | spacebat_ | but that doesn't fly here |
| 05:08 | fanda_ | newlisp is similar |
| 05:08 | fanda_ | (setq x 5) or (set! x 5) ;-) |
| 05:08 | fanda_ | clojure is more pure |
| 05:08 | spacebat_ | I saw an excellent post on the newsgroup today that spelled it out |
| 05:09 | spacebat_ | if you make a new value, either give it a new variable, or pass it directly into a function |
| 05:10 | fanda_ | yes, I also have problems with immutability |
| 05:10 | fanda_ | i am thinking about creating some "cook book" |
| 05:10 | spacebat_ | I've had similar ideas |
| 05:10 | fanda_ | how to mutate or "looks-like-mutate" ;-) |
| 05:11 | spacebat_ | gradually accumulating code snippets in a library, a modest general purpose collection at the moment |
| 05:11 | fanda_ | i have been reading some code from contributions |
| 05:11 | fanda_ | now i am trying to create my first useful something :-) |
| 05:12 | spacebat_ | I haven't even looked into contrib yet |
| 05:13 | fanda_ | here |
| 05:13 | fanda_ | http://groups.google.com/group/clojure/files |
| 05:13 | fanda_ | and here |
| 05:13 | fanda_ | http://clojure-contrib.svn.sourceforge.net/viewvc/clojure-contrib/trunk/ |
| 05:13 | spacebat_ | I see yes I checked that out of svn but its just sitting on disk so far |
| 05:14 | spacebat_ | looking at complete programs has been a bit confusing, trying to get the gist from gradually larger chunks of code |
| 05:15 | spacebat_ | clojure just might be my gateway back to java |
| 05:15 | spacebat_ | using an IDE to get past the static verbosity of java repulses me these days |
| 05:16 | spacebat_ | I've been ruined and made anew by dynamic languages |
| 05:17 | spacebat_ | rhickey was saying that there is a guy in sun who really gets lisp |
| 05:17 | spacebat_ | and wants to put tail recursion and more functional support in the JVM |
| 05:19 | spacebat_ | ok newlisp, I have seen that page before, like a year ago |
| 05:19 | spacebat_ | I've been learning lisp about 3 weeks now |
| 05:20 | spacebat_ | does it have threads? |
| 05:21 | fanda_ | what do you mean - if newlisp has threads? no, it doesn't |
| 05:21 | spacebat_ | ok |
| 05:21 | spacebat_ | yes that's what I meant sorry |
| 05:21 | fanda_ | newlisp is written in C |
| 05:21 | fanda_ | runs on many platforms |
| 05:21 | spacebat_ | what brings you from there to here? |
| 05:21 | spacebat_ | yes portable threading isn't trivial |
| 05:22 | fanda_ | but it has everything on its own - runtime - garbage collector, etc. |
| 05:22 | fanda_ | libraries for one |
| 05:22 | fanda_ | you can import only C libraries or write your own lisp libraries - so much time spent there |
| 05:22 | kotarak | did anyone encounter issues with agents and clojure.lang.Script? |
| 05:22 | fanda_ | i have no idea about this one |
| 05:23 | spacebat_ | me neither sorry |
| 05:23 | fanda_ | don't be sorry |
| 05:23 | spacebat_ | heh |
| 05:23 | fanda_ | :) |
| 05:23 | fanda_ | if you have any lisp questions, i might answer |
| 05:23 | fanda_ | map, apply, filter... |
| 05:23 | fanda_ | lambda (meaning fn) functions |
| 05:24 | spacebat_ | is there something you don't like about newlisp? |
| 05:24 | spacebat_ | not asking you to trash it or anything |
| 05:24 | kotarak | No. 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:24 | fanda_ | hi kotarak :-) |
| 05:25 | kotarak | hello fanda_ |
| 05:25 | spacebat_ | sounds like something a tad advanced |
| 05:25 | kotarak | ok. never mind |
| 05:25 | spacebat_ | maybe the REPL is doing some sync that's needed and not in Script |
| 05:26 | fanda_ | don't know why he left... |
| 05:26 | spacebat_ | hunting rather than gathering |
| 05:26 | fanda_ | hm |
| 05:27 | spacebat_ | newlisp looks like it has potential |
| 05:27 | fanda_ | yes, its cool in its own terms |
| 05:27 | spacebat_ | if its fast, then with the right libs for coordinating processes it could be a real workhorse |
| 05:28 | fanda_ | here are my creations: |
| 05:28 | fanda_ | http://intricatevisions.com/index.cgi?page=newlisp |
| 05:28 | fanda_ | just click on the left for code, code-tk, ... |
| 05:28 | spacebat_ | does it generate binaries? |
| 05:28 | fanda_ | no, it does not |
| 05:28 | fanda_ | its only interpreted |
| 05:28 | spacebat_ | what tipped lisp over the interest threshold recently was seeing Language::Lisp::ECL on the cpan |
| 05:28 | fanda_ | but you can make wrappers - wrap newlisp.exe with your script |
| 05:28 | spacebat_ | ok |
| 05:29 | spacebat_ | ECL uses gcc as a backend and can compile standalone exes |
| 05:30 | fanda_ | can be interesting |
| 05:30 | spacebat_ | a small naive fibonacci program compiled to 24k on disk |
| 05:30 | spacebat_ | its common lisp, so I guess it leaves out all the stuff that isn't being called |
| 05:30 | fanda_ | ok, that's interesting! |
| 05:30 | spacebat_ | it also makes it easy to embed, all common lisp functions are callable from C |
| 05:31 | spacebat_ | the fib program ran about 10 times slower than a C program with the same gcc, for fib(39) |
| 05:32 | spacebat_ | but it was still about 6 times faster than the fastest interpreter I tried, which was python |
| 05:32 | fanda_ | quite interesting |
| 05:33 | spacebat_ | time to give my boy a bath |
| 05:33 | spacebat_ | nice chatting fanda_ |
| 05:34 | fanda_ | wait |
| 05:34 | spacebat_ | yupo |
| 05:34 | fanda_ | save this link |
| 05:34 | fanda_ | http://groups.google.com/group/clojure/browse_thread/thread/69b781ffe805a7de/b60673e9d4436ce0 |
| 05:34 | spacebat_ | will do |
| 05:34 | fanda_ | comparison CL - Clojure ;-) |
| 05:34 | fanda_ | might use it |
| 05:34 | spacebat_ | thanks, bye |
| 05:34 | fanda_ | nice chatting! |
| 05:34 | fanda_ | bye! |
| 05:40 | kotarak | sorry, got disconnected. maybe the output of the agent goes somewhere else in the Script compared to the REPL. |
| 06:22 | spacebat_ | possibly, you said it hangs though |
| 06:22 | spacebat_ | whereas it returns in the REPL? |
| 08:31 | Chouser | kotarak: you might just try adding (flush) after your print or prn |
| 08:33 | kotarak | Chouser: 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:34 | rhickey | kotarak: your script may be ending before your agent is done? |
| 08:36 | kotarak | huh? It can? Ok.... Hmmm... I (await) the agent, but let me add some sleep there. |
| 08:37 | rhickey | if you await in the same thread you sent, then it's done. Who flushes - - the agent or main? |
| 08:37 | kotarak | the agent |
| 08:39 | kotarak | also tried a (flush) in the main thread, didn't help |
| 08:40 | rhickey | can you paste a small case? |
| 08:41 | kotarak | I'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:44 | kotarak | Ahh. 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:44 | rhickey | heh, I used to do that for you, but GUI app devs complained... |
| 08:46 | kotarak | rhickey: 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:47 | kotarak | rhickey: btw. good job with clojure. It brought me back to the lispy side of life. :) |
| 08:47 | rhickey | thanks, glad you worked it out |
| 09:11 | Chouser | calls 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:13 | rhickey | you mean your rest expression manipulates a ref? |
| 09:13 | Chouser | right |
| 09:13 | rhickey | Clojure will force you to be in a transaction, else throws |
| 09:14 | Chouser | well, reads a ref, but yeah. Ok, that's what I thought. |
| 09:14 | rhickey | I though you said set |
| 09:15 | Chouser | I did! I'm sorry, I mis-typed. |
| 09:15 | Chouser | actually, I mis-thought. |
| 09:16 | Chouser | sorry, 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:16 | rhickey | You can do non-transactional reads of refs |
| 09:17 | rhickey | as long as you don't require a relationship between that read and another |
| 09:18 | Chouser | I 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:20 | rhickey | Don't ignore things like java.util.concurrent.ArrayBlockingQueue |
| 09:25 | Chouser | hard not to ignore things I've never heard of |
| 09:26 | rhickey | Clojure doesn't duplicate the workflow tools of java.util.concurrent because they are really good |
| 09:27 | rhickey | queues/barriers/latches/exchangers etc |
| 09:29 | meredydd | rhickey: Ahh...so, that's really the answer to my question a few days ago |
| 09:29 | rhickey | meredydd: which question? |
| 09:30 | meredydd | about thread pools in Clojure...but java.util.concurrent does one, so Clojure doesn't have its own |
| 09:30 | kotarak | that'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:30 | meredydd | (so you just have to do the magic proxy fiddle to turn a (fn) into a Runnable) |
| 09:30 | rhickey | actually Clojure does abstract thread pools with agents |
| 09:30 | rhickey | fns are Runnable |
| 09:30 | rhickey | and Callable |
| 09:31 | meredydd | They are now? Oh, great! |
| 09:31 | meredydd | (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:32 | rhickey | there is some casting required now to disambiguate for the executor methods which are overloaded on both Callable and Runnable |
| 09:33 | rhickey | that hassle was the only reason, but the tradeoff is worth it since half the java library uses one, and half the other |
| 09:33 | meredydd | Ah, excellent. |
| 09:34 | meredydd | Thank-you, then. |
| 09:34 | meredydd | And, by the way, did you do any more thinking about the relational algebra stuff in set.clj? |
| 09:34 | meredydd | Because I've been thinking a little about that |
| 09:35 | rhickey | no, what are your thoughts? |
| 09:35 | meredydd | and how, of course, the nil-for-empty convention is fine, provided one uses seqs rather than sets |
| 09:36 | rhickey | you mean seqs of maps as rels? |
| 09:36 | meredydd | yeah |
| 09:36 | rhickey | but won't they have to keep being made into sets anyway? |
| 09:36 | meredydd | Just thinking that, if you were willing to forgo the mathematical warm-and-fuzzies of exact correspondence to the un-augmented relational algebra |
| 09:36 | meredydd | Well, for what purpose? |
| 09:36 | rhickey | efficiency |
| 09:37 | meredydd | Of which operations? (Sorry, haven't poked around enough in set.clj to see how you do this stuff) |
| 09:37 | meredydd | Joins, I suppose. |
| 09:37 | rhickey | right |
| 09:37 | meredydd | Ah, bugger. The man has a point. |
| 09:37 | meredydd | Damn it - it's just that I was thinking |
| 09:37 | rhickey | also I like the rel is a set of maps rule, i.e. no dupes |
| 09:38 | meredydd | yep. As I say, nice mathematical warm-and-fuzzies with the exact correspondence to the RA |
| 09:38 | rhickey | with the twist of a non-fixed set of columns |
| 09:39 | meredydd | yeah, well...it's that, or a set of vectors, which wouldn't be as nice to work with. |
| 09:39 | rhickey | that's the special sauce of Clojure rels - non rectangular/sparse |
| 09:39 | meredydd | indeed. |
| 09:40 | meredydd | Anyway - 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:40 | meredydd | and, because the seqs are lazy, you could have ops like joins, pi, sigma, etc fold themselves into the SQL statement |
| 09:40 | rhickey | seq->set once on load seem not too bad |
| 09:40 | rhickey | seems |
| 09:41 | meredydd | which is only actually executed when (first) is actually called on the seq |
| 09:41 | meredydd | which would, neatly, allow you to keep all the relational operations Clojure-idiomatic. |
| 09:42 | meredydd | (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:44 | kotarak | Hmmm... Is there something in using agents, which turns off flushing? Suddenly I have to add (flush)es all over the place. |
| 09:44 | kotarak | Or is java.lang.System.exit discarding unflushed stuff? |
| 09:45 | meredydd | kotarak: 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:45 | rhickey | If 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:47 | kotarak | I 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:48 | kotarak | Yep. It's java.lang.System.exit. Is there some way of a sane shutdown? (Ie. doing things like flushing output.) |
| 09:48 | rhickey | await/flush/exit doesn't work? |
| 09:49 | kotarak | it does. |
| 09:49 | kotarak | The flush is a bit anoying |
| 09:49 | kotarak | But maybe this is again my different background. Just have to get used to it. |
| 09:50 | rhickey | there have been requests that the pr* fns flush |
| 09:52 | kotarak | I'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:19 | Chouser | tomhickey_: on clojure.org's left-hand menu, the clickable area for each link extends the full width of the menu. Top notch! |
| 13:15 | rhickey | new essay: http://clojure.org/state |
| 15:40 | abrooks_ | Chouser: Good observation regarding tomhickey_ 's good UI. Nicely done tomhickey_! |
| 16:20 | scgilardi | pjb3: I liked the picture of Rich you posted the other day captioned "State: You're doing it Wrong" |
| 16:26 | scgilardi | I 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:28 | scgilardi | I also like the idea I saw for "dbg*" functions that auto-flush as debugging is often a case where flushing matters |
| 16:46 | rhickey | scgilardi: *flush-on-newline* whose global binding is to "true" works for me |
| 16:51 | scgilardi | cool, thanks. |
| 17:39 | rhickey | user=> *flush-on-newline* |
| 17:39 | rhickey | true |
| 18:17 | Chouser | hmph. can't properly store nulls in an ArrayBlockingQueue |
| 18:18 | rhickey | aargh |
| 18:31 | Chouser | but false works fine, so using that as an end sentinel, this does what I want: |
| 18:31 | Chouser | (for [e (repeatedly #(.take q)) :while e] e) |
| 19:40 | rhickey | gotta love repeatedly |