2010-08-18
| 01:22 | technomancy | so, how 'bout that leiningen 1.3 documentation, eh? http://github.com/technomancy/leiningen/commit/77d8a5c4ef26e5d01ea69fd70c0b1eb5d065a364 |
| 01:22 | technomancy | pretty good, if I may say so myself. |
| 01:25 | lancepantz_ | ,(let [bits [1 0 1 0 1 0]] (map (partial take-nth 2) [bits (rest bits)])) |
| 01:25 | clojurebot | ((1 1 1) (0 0 0)) |
| 01:26 | lancepantz_ | can any on see a better way to do that? |
| 01:26 | lancepantz_ | i was thinking the [bits (rest bits)] part may be able us some clojure magic |
| 01:30 | tomoj | seems fine to me |
| 01:32 | lancepantz_ | alright, thanks tomoj |
| 01:32 | lancepantz_ | how have you been? |
| 01:32 | tomoj | goodly, and you |
| 01:32 | lancepantz_ | same, finished up my clojure project |
| 01:32 | lancepantz_ | doing some solr stuff now |
| 01:33 | lancepantz_ | still going to do my plugins in clojure :P |
| 01:33 | lancepantz_ | still doing cake too i guess |
| 01:34 | tomoj | oh? |
| 01:34 | tomoj | I've done a bit of work with clojure and solr |
| 01:34 | lancepantz_ | really!? |
| 01:34 | tomoj | would be interested to hear about your approach and/or share mine |
| 01:35 | tomoj | though my current approach is terrible |
| 01:35 | lancepantz_ | what were you attempting to do? |
| 01:35 | lancepantz_ | so i'm still really early with solr |
| 01:35 | lancepantz_ | just started today |
| 01:36 | tomoj | all I'm really doing now is generating function queries using java interop to the solr classes |
| 01:36 | tomoj | which is really nasty |
| 01:36 | tomoj | what I'd like to see is pure clojure value sources |
| 01:36 | lancepantz_ | but it look you can set it up and put it in a war, and not even write a line of code |
| 01:36 | tomoj | but I'm not sure if that's really feasible :( |
| 01:39 | lancepantz_ | so you mean you're using interop to interface the java api? |
| 01:40 | lancepantz_ | tomoj: actually i have to run, lets discuss tomorrow |
| 01:41 | tomoj | okey |
| 02:39 | LauJensen | Morning all |
| 02:43 | slyrus | morning LauJensen |
| 02:54 | scottj | /exit |
| 03:55 | esj | Morning Good People |
| 03:55 | esj | the rest of you can have a bad morning... |
| 04:03 | cgrand | Morning esj! |
| 04:03 | esj | hello cgrand |
| 04:03 | esj | oh I owe you a link.... |
| 04:36 | zmila | ,(comment not calculated 3/0 really?) |
| 04:36 | clojurebot | Divide by zero |
| 04:36 | zmila | ,(comment not calculated 3/7 really?) |
| 04:36 | clojurebot | nil |
| 04:39 | tomoj | ,(read-string "(comment 3/7)") |
| 04:39 | clojurebot | (comment 3/7) |
| 04:39 | tomoj | ,(read-string "(comment 3/0)") |
| 04:39 | clojurebot | java.lang.RuntimeException: java.lang.ArithmeticException: Divide by zero |
| 04:41 | zmila | nice :) |
| 04:41 | tomoj | ,(comment {1 2 3}) |
| 04:41 | clojurebot | 3 |
| 04:41 | tomoj | -> (comment {1 2 3}) |
| 04:41 | sexpbot | => () |
| 04:42 | tomoj | heh |
| 04:42 | tomoj | for me, (comment {1 2 3}) returns nil |
| 04:42 | tomoj | even though (read-string "(comment {1 2 3})") throws an error |
| 04:58 | bsteuber | is is allowed to use a gen-class inside do? |
| 04:58 | bsteuber | *it |
| 05:16 | AWizzArd | bsteuber: what happens when you try it? |
| 05:17 | bsteuber | hm, it didn't work, but I think the problem is somewehere else :) |
| 05:17 | Bjering | Is there a way to undef an entire namespace? |
| 05:19 | bartj | er, I forgot the macro to comment an expression |
| 05:19 | smokecfh | what would be a good data structure in clojure for 2d images (32 bit, rgba)? |
| 05:20 | bartj | oh it is the #_ |
| 05:23 | bsteuber | AWizzArd: http://gist.github.com/534131 |
| 05:23 | bsteuber | so I'm trying to generate a class from a macro |
| 05:24 | bsteuber | I think the {:static true} might be the problem |
| 05:24 | bsteuber | as I'm not sure how meta-information interacts with compile vs. runtime |
| 05:31 | bartj | smokecfh, maybe this can help - http://nakkaya.com/2010/01/12/fun-with-clojure-opencv-and-face-detection/ |
| 05:35 | smokecfh | bartj: thanks. it seems that most people wrap low level libraries to do image processing. (including akkaya) |
| 05:36 | smokecfh | other people use the java image classes, such as BufferedImage. |
| 05:36 | smokecfh | but is there no 2d array data structure in clojure? |
| 05:37 | hoeck | bsteuber: the metadata thing will work in macros |
| 05:37 | bsteuber | hoeck: ok, thx - then I'll have to look somewhere else |
| 05:37 | bsteuber | oh, in the snippet I positioned the metadate wrong |
| 05:37 | hoeck | bsteuber: maybe you want to look at reify if you are not using subclassing and other java features |
| 05:39 | Raynes | Bjering: In case nobody mentioned it yet: (doc remove-ns) |
| 05:40 | Bjering | Raynes: thank you |
| 05:40 | bsteuber | hoeck: hm, also for pure Java-interop classes? |
| 05:40 | bsteuber | I thought somehow they're more for clojure-internal use |
| 05:42 | hoeck | my understanding may be wrong but to me reify is like a faster but limited proxy |
| 05:44 | bartj | smokecfh, as far as I know, no |
| 05:45 | hanDerPeder | how can I write this predicate: "The square root of x is a whole number" |
| 05:45 | bsteuber | hoeck: hm, looks good - I just have to generate an extra interface per class |
| 05:45 | bsteuber | but that's not a real problem with macros :) |
| 05:46 | hoeck | bsteuber: and what about using deftype? |
| 05:46 | bsteuber | still needs to have all methods in interfaces, no? |
| 05:46 | bartj | smokecfh, see this http://clj-me.cgrand.net/2009/10/15/multidim-arrays/ for multidimensional arrays |
| 05:46 | bsteuber | but yeah, I might use defrecord |
| 05:47 | hoeck | bsteuber: or in protocols |
| 05:47 | bsteuber | erm yes, that's what I meant to say :) |
| 05:47 | hoeck | but you can change them at runtime |
| 05:47 | bsteuber | anyways, I think using defrecord is much nicer than gen-class |
| 05:48 | bsteuber | because of slime + AOT awkwardness, for example |
| 05:48 | bsteuber | so thanks :) |
| 05:49 | smokecfh | bartj: thanks |
| 05:52 | bartj | hanDerPeder, here is my attempt - (= (Math/sqrt 10) (int (Math/sqrt 10))) |
| 05:52 | bartj | hanDerPeder, substitute 10 for any number |
| 05:53 | hanDerPeder | ok, so you just try casting it? |
| 05:53 | bartj | hanDerPeder, yeah |
| 05:54 | hanDerPeder | cool |
| 05:54 | hoeck | bsteuber: yes |
| 05:54 | hanDerPeder | but why doesn't this work (not same semantics, i know) (defn is-whole-number [x] (= (x (Math/floor x)))) |
| 05:55 | hanDerPeder | gives me ClassCastException.. |
| 05:55 | hoeck | hanDerPeder: one paren too much |
| 05:55 | hoeck | (= x (Math/floor x)) |
| 05:55 | hanDerPeder | ah, thanks :) |
| 05:57 | smokecfh | i read that add-classpath is deprecated, but it does not say what i should use instead? |
| 05:59 | hoeck | smokecfh: add everything to the classpath before starting clojure |
| 06:00 | smokecfh | hoeck: i'm using the slime repl, and would like to read a jar dynamically -- is that still possible? |
| 06:03 | hoeck | its still possible, you have to put the jar somewhere in your classpath and then just :require or :import the namespaces or classes |
| 06:04 | hoeck | maybe you have ~/.clojure/jar/ directory which is included in the classpath by default |
| 06:06 | Bjering | What am I doing wrong here: https://gist.github.com/51144e1c64ff615ff854 |
| 06:06 | Bjering | last test fails, count is 1 but I expected 2. |
| 06:13 | ordnungswidrig | what is the content of the ref at line 36? |
| 06:13 | Bjering | Marcus |
| 06:13 | Bjering | {#<core$name clojure.core$name@4ba4d6> {:username Marcus}} |
| 06:13 | ordnungswidrig | what is "name" at line 11? |
| 06:14 | Bjering | ah, that one is wrong.... copy-paste error from last attempt... should be username |
| 06:14 | ordnungswidrig | *g* |
| 06:14 | Bjering | pass :) |
| 06:15 | Bjering | thank you |
| 06:16 | ordnungswidrig | shuldn't it read then (alter (users :by-name) conj new-user) |
| 06:18 | Bjering | nah, it should be map from username -> the map of users. Currently user only contains its name, but it will change.. after lunch :) |
| 06:19 | Bjering | map username-> user I mean. |
| 06:19 | ordnungswidrig | I see |
| 06:19 | ordnungswidrig | you conj onto the map |
| 06:19 | Bjering | bbl |
| 06:20 | LauJensen | Gents - Im very happy to announce that Conj Labs is partnering with InnoQ to provide the next Conj Labs session in Frankfurt, Germany! See http://conj-labs.eu for more info! |
| 06:20 | Bjering | yes, this is the way right? |
| 06:35 | ordnungswidrig | great news! |
| 06:35 | ordnungswidrig | I'd love to see more adoption in .de |
| 06:40 | LauJensen | With any luck its coming :) |
| 06:49 | LauJensen | Sweet, hope to see you there - Are you a native of Frankfurt? @bobo_ |
| 06:50 | bobo_ | no, sweden |
| 06:50 | bobo_ | but was cheap to fly |
| 06:50 | LauJensen | Yea, Central European flights are crazy cheap these days |
| 06:51 | bobo_ | its the hotell that quickly can get expensive, but 99eur didnt seem that crazy |
| 06:51 | LauJensen | No its a good deal - Same standard hotel as the one we used in Brussels (very good) but I think we paid 145 per night in Brussels |
| 06:51 | LauJensen | Still - Was worth it |
| 06:58 | ordnungswidrig | I just returned from berlin — a combined trip rail + hotel — the trip (4 days) cost just 70€ more than the pure rail ticket. |
| 06:58 | ordnungswidrig | so 70€ for 4nights standard hotel is a good deal :-) |
| 06:58 | LauJensen | ok - its not that kind of hotel :) |
| 06:59 | LauJensen | I assume Berlin and Frankfurt should be pretty similar in terms of pricing? |
| 07:03 | ordnungswidrig | LauJensen: I don't know, Berlin is actually very cheap. "Poor but sexy" they us as a slogan |
| 07:04 | ordnungswidrig | (the citiy, not the hotels) |
| 07:04 | LauJensen | oh - I didnt know |
| 07:04 | LauJensen | hehe, gotcha |
| 07:04 | LauJensen | It was our German partners that pushed for Frankfurt, so I think we're in for a good time |
| 07:05 | ordnungswidrig | frankfurt is fine because it is as central as you can be in germany, I think. At least regarding transportation |
| 07:07 | esj | last time I was in Frankfurt I was inadvertently booked into the "Stay and Learn" hostel, due to its cheapness and proximity to the rail station. |
| 07:07 | ordnungswidrig | LauJensen: which role does InnoQ play regarding the sessions? |
| 07:07 | esj | Turns out it as on floors 4-5 of a buliding where 1-3 were the "World of Sex" |
| 07:07 | esj | it was my wife who made the booking.... |
| 07:07 | ordnungswidrig | esj: I guest it was a special experience |
| 07:07 | bobo_ | esj: sounds like a trap! |
| 07:08 | LauJensen | ordnungswidrig: They help make arrangement with the venue as well as marketing through various channels + misc |
| 07:08 | esj | I was offered all sorts of dessert that night. |
| 07:08 | ordnungswidrig | esj: was there a seperate entrance? |
| 07:08 | esj | yeah |
| 07:19 | LauJensen | ordnungswidrig: no need, you can register directly on conj-labs.eu |
| 07:26 | ordnungswidrig | LauJensen: oh, you got me wrong. I had to talk to my carrier to stop them sending me offers via sms. |
| 07:26 | LauJensen | I know, I was just joking :) |
| 07:26 | LauJensen | (we dont have registration by phone) |
| 07:27 | ordnungswidrig | LauJensen: then you got me |
| 07:28 | ordnungswidrig | I still think that a german clojure user group would be a good idea. Perhaps you can collect some feedback when you do the session |
| 07:28 | LauJensen | There's one in Berlin |
| 07:29 | Bjering | Does anyone knows if there is any clojure user groups in Sweden? |
| 07:29 | LauJensen | Haven't heard of any |
| 07:29 | LauJensen | But the danish group has about 30 members, so its not unlikely |
| 07:29 | ordnungswidrig | LauJensen: Really? That would be a start. I'm sitting on the other end of germany |
| 07:30 | LauJensen | ordnungswidrig: you should check with @pbholdings on twitter |
| 07:30 | bobo_ | Bjering: yes in stockholm |
| 07:30 | ordnungswidrig | on #clojure.de we are about 10 regulars who do manage to organize a "get together" :) |
| 07:30 | bobo_ | we hade one meeting before the summer, but will start soon again i hope |
| 07:31 | Bjering | bobo_: Cool, how does one get in touch with it? |
| 07:31 | LauJensen | ordnungswidrig: You guys should come meet up a Conj Labs then |
| 07:31 | bobo_ | Bjering: http://groups.google.com/group/stockholm-clojure-user-group?pli=1 |
| 07:32 | Bjering | bobo: Do you live in Stockholm? |
| 07:32 | bobo_ | yehs |
| 07:32 | Bjering | Ok, I live in Skövde, but I travel to Stockholm often enough. |
| 07:32 | LauJensen | Bjering: I've been to Skövde! :) |
| 07:32 | ordnungswidrig | LauJensen: although it's not expensive, me budget is exhausted for this year. |
| 07:33 | Bjering | LauJensen: Really, do you have aclient here? |
| 07:33 | LauJensen | ordnungswidrig: Ah ok, I understand - Would be great if you could let them know its going on though |
| 07:33 | LauJensen | Bjering: No - It was years ago |
| 07:37 | ordnungswidrig | LauJensen: I do not find @pbholdings on twitter |
| 07:37 | LauJensen | lemme chek |
| 07:37 | LauJensen | check |
| 07:38 | LauJensen | sorry, I imagined the 'b' |
| 07:38 | LauJensen | pholdings |
| 07:43 | fogus_ | LauJensen: Sorry, just received your question. The advantage is that if they work, then I do not have to define my own. |
| 07:44 | LauJensen | oh ok. I imagine they'll work fine, the only reason I opted for the custom exception was because of clarity - you dont need to read more than 'Clash' |
| 07:50 | fogus_ | understood. For me it's not worth the AOT in this case since the semantics of the existing execpts fit |
| 07:59 | LauJensen | Sure I understand |
| 07:59 | ordnungswidrig | new topic: any news about a clojure prevalence layer? I don't lose the feeling that persistent data structures are the perfect match on this. |
| 08:02 | Bjering | hmm, when I google prevalence to understand what it is it is all about diseases, I suspect this isn't what you are after? |
| 08:06 | ordnungswidrig | Bjering: prevayler.org basically a form of event sourcing. You do not store the state of the system on disk, but only the stream of operations on the systems state. The state of the system is typically held in memory only, and rebuilt from the operation log if needed. Like bookkeeper does since hundret of years :-) |
| 08:07 | ordnungswidrig | s/hundret/hundred/ |
| 08:07 | sexpbot | Bjering: prevayler.org basically a form of event sourcing. You do not store the state of the system on disk, but only the stream of operations on the systems state. The state of the system is typically held in memory only, and rebuilt from the operation log if needed. Like bookkeeper does since hundred of years :-) |
| 08:09 | srj | Hi all |
| 08:09 | srj | i am a post-grad student looking for a good project in compilers, anywhere i can start digging? |
| 08:09 | Bjering | Very interesting |
| 08:10 | ordnungswidrig | bbl, lunch |
| 08:12 | fogus_ | srj: Clojure-specific? |
| 08:25 | Bjering | Alright, I have build a datastructure with circular refs, is there a print method available that dont expand refs? |
| 08:30 | chouser | Hm, I wrote one once. Where did I put it... |
| 08:32 | chouser | well, not expanding refs is easy enough. I wrote one that expanded only non-circular ones |
| 08:34 | Bjering | even nicer |
| 08:34 | Raynes | chouser: Check under the sofa cushions. |
| 08:36 | chouser | Bjering: http://paste.lisp.org/display/83647#2 |
| 08:36 | zmila | ,(time (reduce + (range 1000))) |
| 08:36 | clojurebot | 499500 |
| 08:36 | clojurebot | "Elapsed time: 0.918 msecs" |
| 08:36 | zmila | ,(time (reduce unchecked-add (range 1000))) |
| 08:36 | clojurebot | 499500 |
| 08:37 | clojurebot | "Elapsed time: 112.321 msecs" |
| 08:37 | zmila | ,(time (reduce unchecked-add (range (int 1000)))) |
| 08:37 | clojurebot | 499500 |
| 08:37 | clojurebot | "Elapsed time: 106.836 msecs" |
| 08:37 | zmila | why simple + is quicker than unchecked-add |
| 08:37 | zmila | ,(clojure-version) |
| 08:38 | clojurebot | "1.2.0-master-SNAPSHOT" |
| 08:39 | chouser | Bjering: note you have to use 'binding' around the print to define the scope in which refs should be checked for repetition |
| 08:39 | Bjering | chouser: Please excuse my newbieness, but it complains it cannot resolve classname Writer, something I neet to import first? |
| 08:40 | Bjering | need |
| 08:40 | chouser | oh, sorry. I hate it when people paste broken code. :-P |
| 08:40 | zmila | Bjering - java.io.Writer |
| 08:41 | chouser | just use #^java.io.Writer instead of #^Writer |
| 08:42 | Bjering | next unresolved is print-sequential |
| 08:42 | chouser | heh |
| 08:43 | chouser | you're on 1.1 or 1.2 (not that it matters for this question) |
| 08:43 | Bjering | 1.2 |
| 08:43 | zmila | print-sequential is private in core_print.clj |
| 08:45 | chouser | Bjering: you want this for normal REPL printing, right? So that it doesn't spew uselessly deep structures? |
| 08:46 | chouser | Try just this: (defmethod print-method clojure.lang.IDeref [o w] (.write w (format "#<%s@%x>" (.getSimpleName (class o)) (System/identityHashCode o)))) |
| 08:46 | Bjering | Yes, it nothing critical though, I was just bummed when I tried to print my structure. And I thought perhaps there was a util somewhere that solved it. |
| 08:48 | raek | setting *print-level* can be a cheap workaround |
| 08:48 | Bjering | ah now REPL dont expand |
| 08:48 | Bjering | print-method is what the REPL calls? |
| 09:16 | chouser | Bjering: yes, print-method is what the REPL calls. |
| 09:21 | chouser | to that more complex solution working would require customizing the REPL a bit. Not particularly hard, but incrementally more complex and fragile. |
| 09:21 | chouser | to get that |
| 09:38 | bmh | Could someone steer me toward a good namespace tutorial? |
| 09:39 | Raynes | I would, but I haven't written it yet. ;) |
| 09:41 | bmh | Raynes: get crackin'! |
| 09:55 | arkh | I'm in the process of trying to wrap some Java UDP networking code in clojure. Any reviewing and/or critiquing of my first 31 lines would be much appreciated. Thank you. http://gist.github.com/534794 |
| 10:28 | LauJensen | arkh: I think it looks good. You alternate between (.method obj) and (. obj method) and you use a ref in a scenario where there's no need for coordination. Although Im sure I dont understand the concurrency situations you'll be facing, you should perhaps consider an atom |
| 10:33 | defn | hugod: love your dependency graph library |
| 10:33 | arkh | LauJensen: I think I'm struggling between trying to make something general purpose and trying to just make it fit my needs. That may not be evident in what I posted but it's what's in my head. Anyway, I like what you brought up and probably repost more of an end-result later. |
| 10:34 | defn | LauJensen: aren't atoms uncoordinated though? |
| 10:34 | hugod | defn: glad you're finding a use for it - btw, it doesn't find dynamic dependencies |
| 10:35 | defn | LauJensen: network traffic seems like it ought to be coordinated |
| 10:36 | chouser | close-udp-server has a bit of a race, I think. |
| 10:37 | chouser | it might not matter in this particular case, but may be worth thinking about now anyway. |
| 10:37 | arkh | what I have in mind is keeping with clojure's verb-style and having agents sit in a (listen) and (send) where they can fill and drain separate vectors (or whatever) of packets. The main routine will take them in, process, and put them in a queue to be sent back out. |
| 10:37 | defn | chouser: enjoyed your interview @ strange loop btw |
| 10:37 | defn | chouser: precisely what i was thinking |
| 10:37 | chouser | defn: thanks :-) |
| 10:38 | arkh | .. which is totally not what I posted so far : / |
| 10:38 | chouser | arkh: if you indend for udp-server being nil to indicate the server's closed, you have a race |
| 10:38 | defn | chouser: i have questions for you, have been compiling as i re-read my favorite parts of coders at work :) |
| 10:39 | arkh | chouser: thank you - will change |
| 10:39 | chouser | putting .close inside dosync isn't an options, as .close is impure |
| 10:39 | arkh | yeah : ( same with .connect |
| 10:40 | defn | is there anyway to sanitize those with what currently exists in 1.2 chouser? |
| 10:40 | chouser | I wrote a little thing when I did my own clojure network stuff -- it worked, but I'm not comfortable recommending it. |
| 10:41 | defn | http://github.com/aberant/clojure-networking/blob/master/server/udp.clj |
| 10:41 | defn | looks like what you're doing arkh is par for the course |
| 10:42 | chouser | defn: oh dear. well, shoot 'em to me whenever you want so I can start procrastinating. |
| 10:42 | defn | heh -- chouser forgive me, but-- is JoC fully released now? |
| 10:42 | defn | i havent been paying close attention the last couple weeks |
| 10:43 | chouser | all the chapters are out, yes. All the chapters will be re-released as MEAP soon (this week?) to reflect additions, changes, etc. |
| 10:43 | defn | congratulations |
| 10:43 | defn | even if it's a bit premature |
| 10:43 | chouser | thanks |
| 10:43 | defn | no small feat to finish a book :) |
| 10:44 | chouser | indeed! And I'm so greatful fogus as done exactly that. :-) |
| 10:44 | defn | haha, so modest |
| 10:45 | chouser | no seriously, he's the only reason the book is anywhere close to on schedule. |
| 10:45 | defn | :F |
| 10:46 | chouser | that udp.clj start-udp-server is scary. looks quite wrong to me |
| 10:46 | arkh | I hope to make something better, unless you beat me to it ;) |
| 10:46 | chouser | arkh: no fears, I won't |
| 10:47 | defn | that's the beauty of the current clojure community -- not a lot of competition. people will eat your garbage gladly :) |
| 10:47 | defn | i of course mean so respect, there are some niches which are quite saturated with well-rounded mature code |
| 10:48 | defn | but you can get away with a bit more given our size right now :) |
| 10:48 | arkh | perfect for me :) |
| 10:48 | defn | s/so/no |
| 10:48 | chouser | so I think what you have to do to make something like close-udp-server correct is to atomically nil udp-server, and then (knowing that yours is the thread that did that) mutate the real resource with .close |
| 10:49 | arkh | chouser: I like the sound of that. clojure 'sentinel' objects to be the face of java objects |
| 10:49 | chouser | arkh: I think 'sentinel' was a word being considered for what has most recently been called "pods" |
| 10:49 | defn | like...cells? </ignorance> |
| 10:50 | chouser | and are probably the right solution here. |
| 10:50 | chouser | defn: nope, I think that's right. |
| 10:50 | defn | "sentries", "sentinels" |
| 10:50 | defn | "pods", "cells" |
| 10:50 | defn | have cells -> pods? |
| 10:50 | chouser | yes |
| 10:50 | defn | ah, interesting |
| 10:50 | defn | i like that |
| 10:50 | chouser | me too. less baggage |
| 10:51 | defn | i remember being in here trying to get the whole cell, sentry story correct and it felt a bit forced |
| 10:54 | chouser | ok, so I'm looking at this swap!-when thing I wrote, and it did seem to work but it really does scare me. Perhaps it'd be better to work with some unreleased version of pods (cells) and hope the final API is similar. |
| 10:55 | chouser | http://paste.lisp.org/display/81237 |
| 10:57 | chouser | the idea being you could do something like (when (swap!-when server #(deref server) (constantly nil)) (.close @server)) |
| 10:58 | chouser | but again, there's got to be a better way |
| 11:00 | chouser | hey look, there's an early implementation of 'promise' |
| 11:12 | rhickey | chouser: yes, that's scary |
| 11:13 | chouser | heh. good to know. |
| 11:13 | chouser | It's been removed from our code base for some months now. |
| 11:13 | chouser | as has await-iref |
| 11:14 | rhickey | I think you might want a version of swap! that takes a fn that returns 2 values, the one to swap and a return. You could use that more general thing to do swap-when |
| 11:15 | chouser | That's an interesting measure -- is the code produced by the person in question, after a few months, discarded in shame or does it become a cherished part of a popular language. |
| 11:16 | arohner | is there a "group-by" function that works like sort-by, but for things that aren't Comparable, like keywords? |
| 11:16 | chouser | rhickey: seems reasonable. But in genearl, providing concurrency protection for real mutable resources is one thing pods are meant for, right? |
| 11:17 | defn | "Are you sick of cracking eggs all the time? There's got to be a better way!" |
| 11:17 | defn | "New, from Minoku, the egg cracker!" |
| 11:17 | rhickey | chouser: right, plus pods do true coordination of activity, by associating it with a place |
| 11:19 | rhickey | chouser: above, server is an atom that holds another reference? |
| 11:20 | Raynes | defn: Yeah, I was sitting here thinking about how bad life is when you have to manually crack eggs. |
| 11:20 | chouser | an atom that holds a DatagramSocket |
| 11:20 | chouser | like udp-server here: http://gist.github.com/534794 but an atom instead of a ref |
| 11:21 | chouser | in my code I had an atom holding a map with a bunch of things including a socket and some IO streams |
| 11:21 | defn | how do you mean associate it with a 'place'? |
| 11:22 | fogus_ | rhickey: "a place"? |
| 11:22 | rhickey | fogus_: the pod |
| 11:22 | defn | ah |
| 11:22 | chouser | how conceptualy different is a place from an identity? |
| 11:22 | rhickey | chouser: and multiple calls to .close are bad? |
| 11:23 | chouser | rhickey: in that gist, probably not. But it seems like a dangerous pattern -- I was just pointing out to the author that he may want to be careful there. |
| 11:24 | chouser | in my code I had a whole series of things I had to shut down in order, queues to drain, etc. |
| 11:24 | defn | chouser: but with a ref he is okay, no? |
| 11:25 | chouser | defn: he's ok only if he never assumes a non-nil udp-server is open |
| 11:26 | chouser | that is, there is a moment as the code stands where @udp-server is a non-nil object, but is closed. |
| 11:26 | defn | ahhh |
| 11:26 | defn | thank you |
| 11:27 | defn | fogus_: link? |
| 11:27 | chouser | moving .close into the transaction would fix that, but then .close may be called multiple times. Which is probably not a problem for .close, but in general making changes to or using a socket in a transaction may be unsafe because of retries. |
| 11:27 | fogus_ | defn: just arrived on the google group |
| 11:28 | defn | chouser: yeah, didn't consider retries |
| 11:28 | chouser | fogus_: seems like I remember explaining something about this once... |
| 11:28 | rhickey | chouser: a pod is still an identity. It differs from the other references in that change is not speculative, i.e. you don't have the potential parallel work of STM or atoms (which is the problem above, since any speculative work should be pure and .close isn't). Instead, pods have stricter "you've gotta be in it to win it" semantics, like physical (Newtonian) places |
| 11:28 | fogus_ | chouser: We should probably put that in the book. ;-) |
| 11:29 | chouser | rhickey: ah, very good. |
| 11:30 | defn | i have to suggest there ought to be a common tag in IRC to mark where a question which involves considerable effort is fully answered for the person posing the original question |
| 11:30 | chouser | fogus_: maybe call the section "Don't create Boolean objects" and use memorable words like "evil-false" and "landmine" |
| 11:30 | fogus_ | chouser: I like it! Stop the presses! |
| 11:31 | rhickey | there is only one 'process' associated with a pod at a time, working on its transition from value to value |
| 11:31 | chouser | fogus_: seriously, can we paste a section of our markdown straight into the response? Surely we're allowed... |
| 11:32 | fogus_ | chouser: I think so yes |
| 11:47 | Bahman | Hi all! |
| 12:25 | technomancy | should it be considered a bug that clojure.contrib.find-namespaces only checks for namespaces where ns is the first form? |
| 12:26 | technomancy | I know it's crazy to do otherwise, but we had to work around a last-var-wins issue with ns-unmap that had to preceed the ns form |
| 12:26 | technomancy | and it caused our tests to be skipped =\ |
| 12:27 | technomancy | on the other hand, reading through the whole file until you hit an ns form is not so hot either for perf reasons. =\ |
| 12:56 | cemerick | technomancy: To that, I'd say rip the offending use/require(s) out of the ns. It really needs to be the first form. |
| 13:06 | technomancy | cemerick: right; I did that for now, I'm just wondering if there's a good general solution to be less strict in the future. |
| 13:14 | pdk | (doc read) |
| 13:14 | clojurebot | "([] [stream] [stream eof-error? eof-value] [stream eof-error? eof-value recursive?]); Reads the next object from stream, which must be an instance of java.io.PushbackReader or some derivee. stream defaults to the current value of *in* ." |
| 13:14 | pdk | (doc load) |
| 13:14 | clojurebot | "([& paths]); Loads Clojure code from resources in classpath. A path is interpreted as classpath-relative if it begins with a slash or relative to the root directory for the current namespace otherwise." |
| 13:14 | technomancy | the perf probably wouldn't be too bad for searching the whole file |
| 13:14 | pdk | (doc load-file) |
| 13:14 | clojurebot | "([name]); Sequentially read and evaluate the set of forms contained in the file." |
| 13:18 | pdk | (doc print) |
| 13:18 | clojurebot | "([& more]); Prints the object(s) to the output stream that is the current value of *out*. print and println produce output for human consumption." |
| 13:20 | cemerick | Are there any good reasons to not have a set-field in clojure.contrib.reflect? The patch is a git invocation away... |
| 13:28 | LauJensen | chouser: link to interview? |
| 13:30 | polypus | is 1.2.0-RC3 or 1.2.0-SNAPSHOT more up to date? |
| 13:33 | hiredman | ping? |
| 13:33 | clojurebot | PONG! |
| 13:35 | polypus | which will include the most recent changes, clojure 1.2.0-RC3 or 1.2.0-SNAPSHOT? |
| 13:35 | dnolen | polypus: RC3 |
| 13:36 | polypus | dnolen: ty. so what's SNAPSHOT for? |
| 13:37 | bmh | Are there style guidelines for contributing to contrib? I'm working on a suite of stream ciphers / pseudo-random number generators |
| 13:39 | MrHus | @bmh http://www.assembla.com/wiki/show/clojure/Clojure_Library_Coding_Standards |
| 13:39 | bmh | thanks MrHus |
| 13:39 | LauJensen | bmh: also, dont implement whats already in /proc/sys/kernal/random :) |
| 13:39 | LauJensen | kernel.. |
| 13:40 | bmh | LauJensen: Different situations call for different randomness guarantees. |
| 13:40 | LauJensen | Yea I know - Look forward to seeing your contribution |
| 13:40 | AWizzArd | Something that can run under all major OSes sounds good |
| 13:41 | technomancy | bmh: probably better to start it as an independent lib |
| 13:41 | AWizzArd | So, /p/s/k/r should maybe not be the only way to read random nums. |
| 13:41 | jfields | is there a way to get the current ns? |
| 13:42 | bmh | technomancy: That's the plan. I'm writing this all for a procedural generation project and figure that the random numbers would be of general interest |
| 13:42 | LauJensen | AWizzArd: Well. No serious application runs on Windows |
| 13:42 | bmh | LauJensen: Cygwin? ;-) |
| 13:42 | LauJensen | haha, good one |
| 13:43 | bmh | technomancy: Thanks for lein, by the way. |
| 13:52 | ordnungswidrig | jfields: *ns* |
| 14:00 | jfields | ordnungswidrig, thanks |
| 14:01 | craigmarshall9 | I love this quote: |
| 14:01 | craigmarshall9 | Lisp turned out to be a bit like chocolate mousse. At first sight, it might look like dog shit. But once you put aside your prejudices, it turns out to be delicious! |
| 14:02 | craigmarshall9 | source: http://groovyguts.wordpress.com/2010/01/08/10-reasons-to-learn-clojure-or-any-other-lisp/ |
| 14:02 | craigmarshall9 | :-) |
| 14:12 | Chousuke | The first five points are basically all summarised with the word "macros" |
| 14:12 | Chousuke | I suppose It's good that they're elaborated :P |
| 14:14 | kilofu | I'm a bit of a clojure / lisp noob, and trying to get better about writing idiomatic clojure. I've written a function that, for each element in a sequence, returns the sum of a parameter function applied to that element and each other element (excluding the element). Could anyone take a look and see if I'm on the right path? I've thrown a gist up at http://gist.github.com/535261 |
| 14:15 | craigmarshall9 | Chousuke: I guess so, but for a non-lisper, that means nothing and for a C or C++ programmer, it's meaning is even less clear than that. |
| 14:16 | Chousuke | kilofu: You shouldn't put closing parens on their own lines. Other than that, I can't really see anything wrong with that |
| 14:16 | craigmarshall9 | Chousuke: You could summarise all 10 as "It's lispy" :-) |
| 14:16 | Chousuke | eh :( |
| 14:16 | Chousuke | craigmarshall9: yeah. :P |
| 14:17 | Chousuke | but to me it kind of read like, "ten reasons to learn lisp: 1. macros 2. macros 3. macros 4. macros 5. macros 6. functions 6. functions ..." |
| 14:17 | Chousuke | and while I agree it was kind of amusing |
| 14:18 | Chousuke | also, the last 6 is supposed to be 7 |
| 14:18 | Bjering | ,(dorun (map print [:a :b])) |
| 14:19 | clojurebot | :a:b |
| 14:19 | Bjering | is there a better way? |
| 14:19 | Chousuke | Use doseq |
| 14:19 | Bjering | thanks :) |
| 14:19 | craigmarshall9 | Chousuke: yeah - I see what you mean about the macros |
| 14:21 | Bjering | ,(doseq [:a :b] print) |
| 14:21 | clojurebot | nil |
| 14:22 | Bjering | ah |
| 14:22 | Bjering | ,(doseq [x [:a :b]] (print x)) |
| 14:23 | clojurebot | :a:b |
| 14:26 | pdelgallego | Is there any other option, besides google app engine, to host freely clojure websites ? something like heroku ? |
| 14:33 | natesbrain | hi, I'm writing a form like this (.. elt getAttributes (getNamedItem attr) getValue) |
| 14:33 | natesbrain | which works pretty good unless one of those methods returns nil |
| 14:33 | natesbrain | is there a form that returns nil if any of them return nil ? |
| 14:35 | chouser | I think it's called -?> in contrib somewhere |
| 14:35 | natesbrain | awesome, thanks |
| 14:37 | chouser | clojure.contrib.core/-?> |
| 14:37 | chouser | (-?> elt .getAttributes (.getNamedItem attr) .getValue) |
| 14:37 | kencausey | If I was going to buy just one Clojure book and I'm an experienced user with some CL/Scheme experience but relatively little Java in the last decade, I've studied Clojure somewhat already, and I would prefer more advanced info... Which would you recommend? |
| 14:38 | chouser | Joy of Clojure, no question. :-) |
| 14:38 | kencausey | no bias? ;) |
| 14:39 | chouser | honestly though, you sound like just the sort of person we were aiming for. We didn't want to write another intro text -- the other three have that pretty well covered. |
| 14:40 | arkh | three? |
| 14:40 | chouser | I don't know if perhaps you'd find Clojure in Action compelling -- that intends to cover a wider range of practical applications that JoC does. |
| 14:40 | kencausey | http://gist.github.com/535261 |
| 14:40 | kencausey | oops, wrong URL |
| 14:40 | Bjering | ,(do (let [a (agent 0)] (send a (fn [_] 42)) (send a print))) |
| 14:40 | clojurebot | #<Agent@8e83f6: 0> |
| 14:41 | kencausey | http://stackoverflow.com/questions/2578837/comparing-clojure-books |
| 14:41 | kencausey | arkh: that lists all 4 |
| 14:41 | kencausey | the main answer anyway |
| 14:41 | chouser | Programming Clojure is very good, but is missing some of the newer Clojure features. I've heard good things about Practical Clojure -- it's up to date. Both those are meant as more introductory books I believe. |
| 14:41 | Bjering | is the above the best way to SET an agent, ie I must pass an anonymous function like that, no shorthand for that? |
| 14:41 | kilofu | Chousuke: Thanks for taking a look |
| 14:42 | chouser | Bjering: (constantly 42) instead of (fn [_] 42). But wanting to do that would cause to to question if an agent is the right approach. |
| 14:43 | Bjering | chouser: Yes, I question it myself, 30 min more and I hope to show the code "working" and then learning here how I do it all wrong :) |
| 14:43 | chouser | :-) |
| 14:44 | technomancy | kencausey: I vote for JoC too |
| 14:54 | kencausey | thanks guys |
| 15:05 | Bjering | Alright, time to enter total humbleness mode, please point me in the right directions how to do this: https://gist.github.com/a4b57f89783fa9f50922 in a more clojuresque way. |
| 15:06 | Bjering | In particular I know I am doing one very bad thing, I am invoking methods with side effects inside dosync, thats why I dabbled with agents, but I did not find a clean way to do it. |
| 15:06 | LauJensen | Bjering: You are aware that transactions can respin? |
| 15:07 | Bjering | Yes, that is a known bug in there, I need to fix that in a good way. |
| 15:08 | LauJensen | Bjering: Interesting. We actually had an entire lab on how to build a thread-safe chat-bot for Conj Labs Brussels |
| 15:10 | Bjering | I have written this whole very basic chat-server in C++ with boost::asio, using normal locking strategies. Now Ive read Programming in clojure and Pragmatic clojure and then read up on Netty online. Yet it feels like very much like I am fumbling blindly. |
| 15:11 | Bjering | My goal is to prove to my team I can use clojure, the C++ one handled 50k emulated clients on localhost with 3% CPU , if clojure/Netty is withing 500% of that I much rather go with clojure then spend the next 18 months worrying about locking... |
| 15:13 | Bjering | but ofc, I have the whole thing with me beeing clojure newbie agains me :) But one always has to start somewhere... |
| 15:14 | chouser | It's difficult, especially at first, to think clearly about where the line is between identity and value. Code intimately wrapped up in real resources like channels and sockets muddles things even further. |
| 15:14 | Bjering | Yes, yet it is necessary |
| 15:14 | chouser | nevertheless, that's likely the crux of a "clean" solution over one that feels fumbly. |
| 15:14 | chouser | exactly. |
| 15:16 | LauJensen | Bjering: Im afraid I dont have time to spar with you on this, but skimming your code makes me think that you should try and read up on the reference types and when/where to apply them. Also note, that if you put a mutable thing inside of a reference, that reference isnt doing much for you |
| 15:16 | chouser | so, the fact the so many of your functions have dosync is hint that perhaps too much of your code is manipulating identities instead of values. |
| 15:18 | kencausey | technomancy: one annoyance I have with Leiningen on cygwin is that if I forget to background lein swink (&) then I can't background it at all or even cleanly exit without using the task manager or killing it from another bash session |
| 15:19 | Bjering | chouser: First, the two "global" state arrays I have, user and channels, adding to them implicitly when calling create-user and create-channel, this isn't wrong is it? It seems to me the way to do it. |
| 15:21 | technomancy | kencausey: I've never used cygwin, but if there's a swank bug could you file an issue on github? |
| 15:22 | Bjering | I don't see how I can get rid of users and channels as identities as I want them to be referenceable over the network. |
| 15:22 | kencausey | OK, it seems like the write thing for lein swank to do is to background itself and log to a file if needed, but I'm not sure I understand how it might be used or why it presents somethign that at least looks like a REPL at the command line |
| 15:22 | kencausey | s/write/right/ |
| 15:22 | sexpbot | OK, it seems like the right thing for lein swank to do is to background itself and log to a file if needed, but I'm not sure I understand how it might be used or why it presents somethign that at least looks like a REPL at the command line |
| 15:24 | technomancy | kencausey: you mean because cygwin doesn't provide enough process control? |
| 15:24 | technomancy | C-z + bg works fine here. |
| 15:24 | kencausey | technomancy: it doesn't respond to C-z, C-d, C-c on cygwin |
| 15:25 | kencausey | or anything else I can think of |
| 15:25 | technomancy | =\ |
| 15:26 | kencausey | I'm inclined to just work around it and fix my habits since using it on cygwin is just temporary for me |
| 15:32 | dnolen | Bjering, have you looked at Aleph at all? |
| 15:34 | Bjering | dnolen: Very little, just enough to convince me Netty was a good idea. As it is a HTTP-server I doubt it has my issues with mutable state? |
| 15:34 | Bjering | I am looking more now, seems its more than an http server. |
| 15:35 | dnolen | Bjering: yes it's more than http server. It's a young project but perhaps you have some thoughts to contribute to it's direction |
| 15:36 | Bjering | dnolen: Well atleast perhaps I could contribute questions ;) |
| 15:36 | dnolen | Bjering: it abstracts away the low-level aspects of Netty in an interesting manner |
| 15:38 | Bjering | Alright, sounds like a good idea, I'll replace my own Netty code with aleph and see if I can then see the forest again. |
| 15:38 | technomancy | kencausey: might want to try http://p.hagelb.org/lein-swank.html |
| 15:38 | kencausey | technomancy: thanks |
| 15:40 | dnolen | Bjering: there's an aelph google group, ztellman's a pretty responsive guy. |
| 15:41 | Bjering | dnolen: Thanks, just reading this source code wil be enlightening I am sure |
| 15:52 | kencausey | technomancy: this is complicated by the fact that you can run emacs either as a unix/cygwin process or as a windows process and in either case it has a mix of dos/unix conventions, not a nice situation to have to deal with overall. |
| 16:38 | dakrone | can someone tell me what I'm doing wrong with the trampoline here: http://gist.github.com/536105 ? |
| 16:39 | mefesto | hey everyone. is it possible to override the :arglist metadata ? |
| 16:39 | qbg | Override how? |
| 16:40 | mefesto | qbg: i have a macro that creates a function and i'd like to specify the arglist myself but i keep getting an error related to "unable to resolve symbol ..." |
| 16:40 | mefesto | which is about the :arglist metadata that im trying to set |
| 16:40 | qbg | I once did something like that |
| 16:41 | qbg | It turns out that the :arglist part of the metadata is double evaluated for some reason |
| 16:41 | qbg | So you have to quote it an extra time |
| 16:41 | mefesto | qbg: thanks i'll give that a try! :) |
| 16:41 | qbg | It is weird... |
| 17:01 | LauJensen | I have this weird situation with mysql where I have a user table containing 8 columns with various info. I added an extra column named 'group' of the type 'TEXT'. Subsequent updates to this table fail with a 'syntax error near group' if I try to update that column as well. An update that does not affect group suceeds. Anybody seen that before? |
| 17:01 | apgwoz | group is a reserved word |
| 17:01 | ordnungswidrig | LauJensen: group might be a reserved word in sql |
| 17:01 | apgwoz | so, you have to quote it |
| 17:02 | LauJensen | ah right, thanks |
| 17:02 | ordnungswidrig | LauJensen: you know, select x from a group by b |
| 17:02 | LauJensen | yes yes got it. I thought they where shielded somehow |
| 17:04 | ordnungswidrig | do you build your SQL by hand or do you use some clojure lib to "abstract the pain away" |
| 17:04 | LauJensen | I was trying out contribs sql |
| 17:07 | mefesto | I'm trying to override the arglists metadata and thanks to qbg I'm able to. But I was wondering if someone could explain _why_ it's like this or point out a better way? https://gist.github.com/91e161a8c5da96faa217 |
| 17:10 | ordnungswidrig | LauJensen: AFAIK jdbc does not provide a general way to quote reserved names |
| 17:13 | raek | mefesto: why what is like what? |
| 17:13 | mefesto | raek: the extra quoting of the :arglists in metadata |
| 17:15 | raek | in a macro, the returned code is evaluated. you don't want the arglist to be evaluated like an ordinary function application, so you need to generade a quote form around it |
| 17:15 | raek | you can try (macroexpand-1 '(defthing my-test <stuff>)) to see what the macro expands to |
| 17:16 | mefesto | raek: yea i was using that but it didn't show the ~(with-meta ...) portion |
| 17:17 | mefesto | raek: thanks though, I think you cleared up the mystery for me |
| 17:18 | raek | mefesto: (def *print-meta* true) |
| 17:18 | raek | the metadata is in the symbol, but is not printed by default... |
| 17:18 | mefesto | raek: oh neat! :) |
| 17:19 | mefesto | wish i knew about *print-meta* earlier today :) |
| 17:20 | raek | oh, maybe def is bad to use there... |
| 17:20 | raek | (alter-var-root #'*print-meta* (constantly true)) |
| 17:21 | mefesto | (set! *print-meta* true) is what i used |
| 17:21 | raek | ah, rigth. |
| 17:21 | raek | those variables are automatically locally bound by the repl |
| 17:22 | raek | set! is the preferred way. I think.. :) |
| 17:22 | Bjering | How do I do the javacode: new byte[10] in clojure? |
| 17:23 | mefesto | Bjering: (byte-array 10) |
| 17:23 | Bjering | thank you |
| 17:23 | pdk | you can do this for all java primitives |
| 17:24 | pdk | though note that when clojure code works on a java primitive it takes in |
| 17:24 | pdk | it'll box it again automatically |
| 17:28 | Bjering | ,(.String (byte-array 10)) |
| 17:28 | clojurebot | java.lang.IllegalArgumentException: No matching field found: String for class [B |
| 17:28 | Bjering | nope... :( |
| 17:29 | raek | what did you want to do? new byte[10].toString()? new String(new byte[10])? |
| 17:29 | Bjering | dnolen: aleph's tcp-server initial channel feeds me java.nio.HeapByteBuffer, how do I get from this one to a String? |
| 17:30 | dnolen | Bjering: you've already dived a bit further than I 've gone :) I would post on the Aleph ML :) |
| 17:30 | Bjering | raek: This is just a test to demo my type trouble, what Ireally want todo is the above (ie convert from HeapByteBuffer) |
| 17:30 | raek | then you also need to decode the bytes into some characters |
| 17:31 | Bjering | yes, but that isnt the issue |
| 17:31 | Bjering | ,(.String (byte-array 10) "UTF-8") |
| 17:31 | clojurebot | java.lang.IllegalArgumentException: No matching method found: String for class [B |
| 17:31 | Bjering | no better... |
| 17:31 | raek | ,(String. (byte-array 10) "UTF-8") |
| 17:31 | clojurebot | " |
| 17:32 | Bjering | its like the String ctor dont see the result of (byte-array) as a byte[] |
| 17:32 | Bjering | :) |
| 17:32 | Bjering | AHHH |
| 17:32 | Bjering | its so frustrating beeing this newbie :) |
| 17:32 | Bjering | thanks |
| 17:33 | raek | ,(String. (.getBytes "hello world" "UTF-8") "UTF-8") |
| 17:33 | clojurebot | "hello world" |
| 17:34 | raek | I dunno if there is a constructor fore ByteBuffers |
| 17:34 | Bjering | well you helped me |
| 17:34 | Bjering | I had the . on the wrong side of String! |
| 17:34 | Bjering | now it works |
| 17:35 | pdk | yeah . is kind of an oddball |
| 17:35 | pdk | could do (.x y) (. x y) (x. y) etc with subtly different usage cases |
| 17:36 | raek | I think it's nice that clojure manages to make java interop look lispy :) |
| 17:57 | dunpeal | Can you define classes in a Clojure code file that would be reusable from Java? |
| 17:58 | pdk | dunpeal look at clojure protocols |
| 17:58 | raek | there are several ways |
| 17:58 | raek | one is gen-class: http://clojure.org/compilation "Ahead-of-time Compilation and Class Generation |
| 17:59 | raek | one is deftype/defrecord |
| 17:59 | raek | and then there's proxy and reify |
| 18:01 | raek | gen-class and proxy has been around for a while |
| 18:01 | raek | deftype, defrecord and reify are new in 1.2 |
| 18:01 | pdk | has 1.2 gone gold yet |
| 18:02 | raek | not yet |
| 18:02 | raek | currently at Release Candidate 3 |
| 18:03 | dunpeal | raek: thanks. seems like it's still a bit less straightforward and trivial than reusing Scala classes, right? |
| 18:04 | raek | yes, scala is object oriented itself, but clojure mostly provide those features for interop |
| 18:04 | raek | the new 1.2 things, however, are designed to be for clojure |
| 18:04 | pdk | clojure tries not to be OO within its own idioms |
| 18:05 | raek | ...and is biased towards clojure's ideals |
| 18:06 | raek | dunpeal: do you need to interface with a java lib from clojure or the other way around? |
| 18:06 | dunpeal | raek: both. |
| 18:07 | raek | (Programming Clojure has a great chapter about this, if you happen to have it) |
| 18:07 | dunpeal | we have Java code that will have to call Clojure code. |
| 18:08 | raek | if you do a java program and need to implement a class in clojure, then gen-class is probably what you are looking for |
| 18:09 | raek | if you need to implement a class in order to use a java lib from clojure, proxy can be used |
| 18:10 | raek | one third option is to interact with the clojure runtime from java, if you just want to call some functions and don't need a new class |
| 18:10 | dunpeal | raek: thanks. basically, I'm wondering how much code re-usability I can get between Clojure and Java, particularly compared to Scala. |
| 18:11 | dunpeal | my investigations show that Scala has nearly perfect re-usability vis-a-vis Java; it's almost as easy as reusing Java code in Java. |
| 18:11 | dunpeal | I wonder how much cost I would incur over that if I go with Clojure instead. |
| 18:12 | raek | well, clojure is not OO... :) I think that make re-usability much harder |
| 18:12 | raek | scala is much closer to java |
| 18:12 | dunpeal | yup, that it is. |
| 18:21 | raek | programming in Clojure is done in a different programming paradigm (i.e. Functional Programming) |
| 18:21 | raek | so if you are looking for something that is very Java-transparent, I'm afraid you won't find it to be Clojure |
| 18:21 | raek | I would still like to encourage you to check out Clojure |
| 18:21 | raek | I believe that it solves some very fundamental issues with Object Oriented Programming |
| 18:21 | raek | and that learning it can be eye-opening |
| 18:23 | raek | I hope you find the right tool for the job |
| 18:35 | gfrlog | is there a formal description of clojure syntax anywhere? |
| 18:43 | akhudek | does anyone here use enclojure? |
| 18:43 | akhudek | if so are you encountering problems after the last netbeans update |
| 19:08 | bobbytek | what is the coolest feature of clojure that sets it apart from other lisps? |
| 19:12 | mefesto_ | dunno about the coolest, but for me the fact that it runs on the jvm and interops very well is pretty cool :) |
| 19:14 | mefesto_ | i'd imagine the stm is probably _the_ coolest |
| 19:15 | tomoj | persistent data structures |
| 19:30 | bobbytek | doesn't scala have persistent data structures? |
| 19:30 | bobbytek | lazy sequences seem pretty cool |
| 19:37 | tomoj | scala stole them from us I think |
| 19:37 | tomoj | and it's not a lisp, anyway |
| 19:38 | technomancy | tomoj: that was just a proposal; it hasn't been applied yet |
| 19:38 | tomoj | you mean scala doesn't really have them yet, they've just been ported to scala? |
| 19:39 | hiredman | ~scala {((x: Any, y: Any) => (f: Function2[Any, Any, Any]) => f(x, y))(1, 2)((x: Any, y: Any) => x)} |
| 19:39 | clojurebot | Any = 1 |
| 19:42 | bobbytek | ~scala |
| 19:42 | bobbytek | :( |
| 19:42 | hiredman | ~scala 1 + 1 |
| 19:42 | clojurebot | Int = 2 |
| 19:42 | bobbytek | clojurebot can eval scala too? |
| 19:42 | bobbytek | ~groovy 1+! |
| 19:42 | clojurebot | Huh? |
| 19:42 | bobbytek | ~groovy 1+1 |
| 19:43 | clojurebot | Excuse me? |
| 19:43 | bobbytek | :( |
| 19:43 | bobbytek | ~1+1 |
| 19:43 | clojurebot | No entiendo |
| 19:43 | bobbytek | ~(1+1) |
| 19:43 | clojurebot | Gabh mo leithscéal? |
| 19:43 | technomancy | tomoj: scala has them, but they're an independent implementation from Clojure's |
| 19:43 | bobbytek | ~clojure (+ 1 1) |
| 19:43 | clojurebot | http://www.thelastcitadel.com/dirt-simple-clojure |
| 19:43 | bobbytek | :( |
| 19:44 | technomancy | but someone proposed replacing them with that had been ported from clojure for better perf |
| 19:44 | hiredman | ,(+ 1 1) |
| 19:44 | clojurebot | 2 |
| 19:44 | tomoj | technomancy: ah, I see |
| 19:49 | hiredman | ,(doc instance?) |
| 19:49 | clojurebot | "([c x]); Evaluates x and tests if it is an instance of the class c. Returns true or false" |
| 19:50 | bobbytek | , (/ 1 0) |
| 19:50 | clojurebot | java.lang.ArithmeticException: Divide by zero |
| 19:50 | bobbytek | yes! |
| 20:57 | summersault | should i learn java before clojure? |
| 21:01 | wwmorgan | summersault: what languages are you coming from? |
| 21:07 | laurus | Can anyone here give me a reason to use Clojure as opposed to Scheme? |
| 21:09 | arkh | laurus: watching a video or three of Rich Hickey explain clojure makes for some compelling reasons |
| 21:09 | polypus | laurus: datastructures. they rock in clojure, both semantically because of persistence, and syntactically because of concise syntax and regularity of interface |
| 21:09 | scottj | laurus: clojure.org/features |
| 21:10 | laurus | Basically, here's my thing: I used to use a program called XLispStat, which was abandoned in favor of R... and I just found out today about something new called Incanter, which is Clojure-based. |
| 21:10 | laurus | So I guess I'm wondering if it is worth learning Clojure to use Incanter. |
| 21:11 | itistoday | so, given just an open .clj file in emacs, how do i launch slime and load it? |
| 21:12 | itistoday | M-x slime... i think that's it |
| 21:12 | laurus | Is Incanter just a small project, or is it likely to become important in the future? |
| 21:12 | polypus | laurus: is there an R replacement for scheme? the incanter page gives some prettu compelling reasons for learning clojure and using incanter. |
| 21:13 | polypus | pretty* |
| 21:13 | laurus | polypus, there isn't, but I've considered porting some of the XLispStat code over to Scheme |
| 21:13 | arkh | laurus: I've heard some people rave about Incanter (enough so that I purchased R in a Nutshell) but I haven't used it yet so I can't speak from personal experience |
| 21:14 | laurus | arkh, well that's worth something |
| 21:15 | laurus | :) |
| 21:15 | polypus | laurus: you might find this an interesting read. he pretty much nails why i coded in ruby for years and then switched to clojure, even though i loved scheme. datastructures. http://programming-puzzler.blogspot.com/2010/08/racket-vs-clojure.html |
| 21:15 | laurus | XLispStat was so great, I'm still sad about it being abandoned |
| 21:15 | laurus | polypus, thanks, that is *exactly* the kind of thing I'm looking for! |
| 21:15 | laurus | By the way, does Clojure work on OpenJDK? |
| 21:16 | arkh | yes |
| 21:16 | arkh | (running on that now) |
| 21:16 | laurus | And OpenJDK is sort of the successor to GCJ right? |
| 21:17 | scottj | laurus: no |
| 21:17 | arkh | openjdk is the eventual successor to the sun jdk, afaik |
| 21:17 | laurus | Ah okay |
| 21:17 | arkh | it's the reference implementation now (I think) |
| 21:18 | laurus | arkh, ah, good to know, thanks |
| 21:18 | laurus | I haven't done anything related to Java for a little while |
| 21:18 | laurus | "Something about Java seems to turn every library into an insanely complex explosion of classes" - that is one reason I haven't used it in a while :P |
| 21:19 | arkh | I find writing java in clojure to be way better than java in java |
| 21:19 | laurus | Hehe |
| 21:19 | laurus | Well I doubt I'd ever explicitly use any of the Java stuff |
| 21:19 | arkh | the java interop is very good |
| 21:20 | polypus | laurus: problem is you might have to dabble every once in a while. sometimes you have no choice |
| 21:20 | arkh | there's libraries that are handy or sometimes required for functionality. Rich has mentioned that he's not trying to reinvent wheels already well-made in Java space |
| 21:21 | laurus | arkh, what's the best Clojure book in your opinion? |
| 21:21 | arkh | laurus: others have said it better than I can - http://stackoverflow.com/questions/2578837/comparing-clojure-books |
| 21:22 | arkh | I've currently only read Programming Clojure but I look forward to JoC |
| 21:23 | polypus | laurus: i'd also recommend http://www.amazon.com/Java-Practical-Guide-Programmers-Guides/dp/1558609091 |
| 21:23 | polypus | you can get it for a buck used, and it's a weekend read |
| 21:23 | laurus | polypus, I already know Java actually |
| 21:23 | laurus | But thank you |
| 21:23 | polypus | np. i was confusing you for summersault who asked about java above |
| 21:24 | laurus | Oh no problem |
| 21:24 | arkh | with knowledge of scheme and java, I bet you'll find clojure a breeze |
| 21:24 | laurus | arkh, I actually don't have much knowledge of Scheme :) Hahaha. It's just something I'm very interested in learning but haven't been able to justify diving into yet... |
| 21:25 | laurus | polypus, by the way, I learned Java from a certification book that is actually pretty excellent: http://www.amazon.com/SCJP-Exam-J2SE-Comprehensive-Programmer/dp/1590596978/ref=sr_1_6?ie=UTF8&s=books&qid=1282181084&sr=8-6 |
| 21:25 | arkh | laurus: clojure has been my first functional language and it presented a learning curve (for me) |
| 21:25 | laurus | It's reasonably short but very good |
| 21:26 | arkh | by far my favorite language now |
| 21:26 | laurus | arkh, well it looks like I'm going to have to try it out, asap. |
| 21:26 | laurus | :) |
| 21:26 | laurus | Thanks for your recommendation |
| 21:26 | polypus | cool. always looking for a quick java read. don't need to know every nook and cranny to hack in clojure |
| 21:26 | laurus | polypus, you can preview it here: http://books.google.com/books?id=YH8UbBTEaOQC&printsec=frontcover&dq=SCJP+Exam+for+J2SE+5&hl=en&ei=HIhsTNCrKoGAnwfTlsnNBw&sa=X&oi=book_result&ct=book-thumbnail&resnum=1&ved=0CDUQ6wEwAA#v=onepage&q&f=false |
| 21:27 | polypus | ty |
| 21:27 | laurus | yw ) |
| 21:27 | laurus | :) |
| 21:29 | laurus | arkh, so which one of those books did you end up using? |
| 21:30 | laurus | I'm looking for something pretty straightforward, I don't know if you've ever seen the book "The Scheme Programming Language" by Dybvig, but something like that |
| 21:34 | arkh | laurus: I'd recommend Programming Clojure or Practical Clojure (though I haven't read the latter). Learning to think in clojure, i.e. functionally, is a hurdle all it's own |
| 21:34 | laurus | Ok, thanks! :) |
| 21:34 | arkh | laurus: np! |
| 22:02 | laurus | Why do the plots from Clojure look so ugly? Is there a way to change that? |
| 22:02 | laurus | http://wiki.github.com/liebke/incanter/sample-plots-in-incanter |
| 22:02 | laurus | Those are atrocious |
| 22:04 | ninjudd | hmm... clojure.lang.PersistentHashSet/asTransient returns an ITransientCollection, but it should be an ITransientSet, right? |
| 22:05 | hiredman | laurus: it's the library incanter uses to draw charts |
| 22:06 | laurus | hiredman, right, I'm wondering if there's a way to avoid that |
| 22:06 | laurus | If they have plans to use a good library instead of that one :P |
| 22:06 | hiredman | laurus: figure out which library it uses and find out the options for it |
| 22:06 | laurus | OK! :) Thanks! |
| 22:06 | hiredman | or figure out if incater has a mailing list and irc channel and ask there |
| 22:08 | laurus | Thanks hiredman |
| 22:08 | laurus | :) |
| 22:09 | danlarkin | that's a first |
| 22:09 | danlarkin | someone thanking hiredman |
| 22:09 | danlarkin | :-D |
| 22:09 | laurus | danlarkin, why? |
| 22:10 | hiredman | ~hiredman |
| 22:10 | clojurebot | hiredman is slightly retarded |
| 22:14 | laurus | LOL |
| 22:15 | summersault | wwmorgan: scheme |
| 22:15 | arohner | laurus: incanter uses JFreeChart |
| 22:15 | laurus | arohner, yeah, I saw that |
| 22:15 | laurus | It just looks pretty bad, to me |
| 22:16 | laurus | Gotta go! Take care |
| 22:21 | summersault | what is the difference between c and clojure in speed? |
| 22:29 | wwmorgan | summersault: if you're coming from just scheme, I would recommend learning java or any OO language before learning clojure. The error messages are pretty cryptic otherwise |
| 22:37 | summersault | wwmorgan: i will learn java so |
| 23:00 | summersault | Is clojure good for embedded programming ? |
| 23:03 | scottj | summersault: do you have java and a lot of memory on yoru device? |
| 23:04 | summersault | scottj: Is a pic microcontroller enought ? |
| 23:05 | summersault | scottj: A top level series... |
| 23:05 | scottj | summersault: no clue |
| 23:08 | summersault | scottj: How much ram is required ? |
| 23:11 | scottj | summersault: I really have no clue. Basically clojure is fine in most situations where java (full not ME) is fine. otherwise no. |
| 23:12 | wwmorgan | the google results for "pic microcontroller java" don't look too promising |
| 23:18 | summersault | but linux microcontroller is fine |
| 23:36 | callen | http://dpaste.org/EfdZ/ clojure makes me write python like a nob. |
| 23:56 | technomancy | Licenser: hey! I just started using lein-search |
| 23:56 | technomancy | it's nice |
| 23:57 | technomancy | patch coming yoru way |
| 23:58 | bmh | Is the selection algorithm in contrib? |