2010-03-16
| 00:01 | crowbar7 | dnolen: Well, it's the whole aspect of threading not being a complete pita that draws me. |
| 00:01 | technomancy | this is strange... if a .clj file has a corresponding .class file with the same timestamp, the .class file gets ignored |
| 00:02 | technomancy | wouldn't it make more sense to prefer the .class file if they're the same age? |
| 00:02 | fanatico | although clojure's lifespan has yet to be determined, we can at least count on lisp outliving us all. |
| 00:03 | hiredman | technomancy: if they are the same age then the .clj has to be newer |
| 00:04 | hiredman | the class file is generated from the clj file, so it has to be younger unless the clj file was modified since it was generated |
| 00:04 | scgilardi | edited and compiled in the same second is unlikely enough that preferring the .clj file in that case seems the correct choice. somebody artificially manipulating the mod dates? |
| 00:04 | technomancy | hiredman: not necessarily, but in cases where the timestamp is lost (rsync shenanigans, etc) it does make sense to go the safe route and prefer .clj |
| 00:04 | technomancy | now that I think about it |
| 00:05 | technomancy | scgilardi: yeah, in this case coming from a jar file |
| 00:06 | technomancy | I guess if the timestamps are exactly the same it's a good bet that they can't be trusted. |
| 00:06 | scgilardi | but just jarring wouldn't affect the mod date. the loader code uses the timestamps inside the jar. |
| 00:06 | technomancy | scgilardi: well if you don't use java.util.zip.JarFile quite correctly it actually just uses the current time as the modification date, it looks like |
| 00:07 | scgilardi | gotchya, interesting |
| 00:07 | hiredman | :( |
| 00:09 | technomancy | I did just get a patch fixing lein's jar creation, but it made me wonder. |
| 00:13 | crowbar7 | technomancy: Actually what turned me onto clojure originally was when I wrote an IRC bot with it for my old college computer club (pretty much every active member writes one at some point). The thing was not only was my bot the first and only one be multi-threaded, but it was easier for me to just thread the thing then make it serial. |
| 00:15 | crowbar7 | My bot thus is also the only one that does not timeout from the irc server because he is hung up from some http query. |
| 00:17 | technomancy | slick. =) |
| 01:42 | slyphon | gah |
| 02:29 | psykotic | is reify working yet in the experimental branch? |
| 02:32 | hoeck | psykotic: its in the current master |
| 02:32 | psykotic | nice |
| 02:32 | hoeck | psykotic: never used it though, always using deftype to implement interfaces |
| 02:33 | psykotic | deftype calls out to reify though, no? |
| 02:33 | hoeck | yes |
| 02:34 | psykotic | good, thanks! |
| 02:39 | hoeck | psykotic: sorry, both reify and deftype expand to reify* and deftype* forms which are implemented in the compiler |
| 02:39 | rfg | Anyone know which GUI framework or look and feel JVisualVM uses? It's pretty. |
| 02:39 | hoeck | so deftype does at least not in clojure-land expand to reify |
| 02:40 | hoeck | rfg: I would bet it uses plain swing |
| 02:41 | psykotic | hoeck: the assembla page on deftype/reify implies that you still cannot define mutable fields with them. is that still the case? |
| 02:42 | psykotic | i need to interop with some java code that reflect over fields to do some magic--and that magic is only accessibly by that route, due to poor design |
| 02:43 | rfg | JVisualVM's titlebar has a subtle gradient and the font is different from my own swing window. How are those sorts of thing set? |
| 02:44 | psykotic | hoeck: actually, i think i might be better off calling java directly to construct a class on the fly, since i don't need to implement class methods that call clojure--i only need this class as a kind of schema for this java library. |
| 02:44 | hoeck | psykotic: according to the latest master doc, you can |
| 02:45 | psykotic | hoeck: hmm, good to know, i'll try it out, thanks again! |
| 02:45 | hoeck | psykotic: http://github.com/richhickey/clojure/blob/23f612edadfd629315c68d8962eaf86ee177d687/src/clj/clojure/core_deftype.clj#L239 |
| 02:45 | psykotic | hoeck: that is awesome! seems the assembla docs are lagging a bit behind. |
| 02:46 | hoeck | (deftype myType [#^{:volatile-mutable true} field]) will get you a mytype with a volatile .field |
| 02:48 | psykotic | btw, is there a preferred workflow if i want to use the latest clojure, etc, with a lein project? i'm used to setting clojure as a dependency but obviously the latest master isn't a clojar :) |
| 02:49 | hoeck | rfg: maybe by using a customized/subclassed Component, or using decorators to paint the toolbars background |
| 02:51 | hoeck | rfg: btw, there is a lot of swing-related documentation around (I'm not a swing expert) :) |
| 02:51 | hoeck | and jvisualvm definitely uses swing, just took a look at it |
| 02:54 | rfg | Yeah, there's plenty of swing info, but a lot of it is ghastly :) |
| 02:55 | hoeck | psykotic: I have [org.clojure/clojure "1.2.0-master-SNAPSHOT"] in my deps and I think it gets the latest clojure from build.clojure.org |
| 02:55 | psykotic | interesting |
| 02:56 | psykotic | that's really neat, i had assumed it could only pull from clojars, maven central, etc |
| 03:04 | hoeck | there is so much magic in lein, it just said it downloaded clojure-20100311 from clojars, so no dl from build.clojure.org |
| 03:52 | mebaran151 | anybody here use clojure box |
| 03:52 | mebaran151 | I can't seem to get paredit to work.... |
| 03:53 | LauJensen | Morning team |
| 03:53 | mebaran151 | if I got it running, I might even put off installing Ubuntu for a bit |
| 03:53 | mebaran151 | paredit on Windows 7 would be sick |
| 03:59 | TheBusby | mebaran151: I've had the same issue for a while |
| 03:59 | mebaran151 | ah, so it's not a broken install |
| 03:59 | TheBusby | if you discover the fix, be sure to post it somewhere. ;) |
| 03:59 | TheBusby | if it is, I have the same broken install |
| 03:59 | mebaran151 | would it be possible just to install emacs normally? |
| 04:00 | TheBusby | Regarding emacs + Windows, I know little to nothing |
| 04:00 | TheBusby | everything works fine in Ubuntu though ;) |
| 04:01 | rfg | mebaran151: Did you enable it in your .emacs? |
| 04:02 | rfg | mebaran151: Are you using Clojure Box? |
| 04:03 | mebaran151 | rfg, yeah, I just got a nice shiny new VAIO |
| 04:04 | mebaran151 | so I'm playing in Windows 7 and trying out Clojure Box |
| 04:04 | rfg | You have to enable paredit in your .emacs as per the Clojure Box readme. |
| 04:05 | mebaran151 | I need to find a gnome-do replacement for Windows too |
| 04:05 | mebaran151 | rfg: oh alright, I was surprised that paredit-mode wasn't available as per M-x |
| 04:05 | rfg | I don't know this "gnome-do" of which you speak. |
| 04:05 | mebaran151 | it's like Quicksilver, a general launcher |
| 04:05 | rfg | mebaran151: I had the same problem. :) |
| 04:06 | mebaran151 | ah thanks |
| 04:06 | rfg | Windows 7 is nice. |
| 04:06 | TheBusby | rfg: thanks |
| 04:06 | mebaran151 | where's the .emacs file? |
| 04:06 | rfg | Though I've just spent the last ages pulling my hair out trying to get JOGL to behave on it. |
| 04:07 | rfg | mebaran151: it's in c:/Users/<you>/AppData/Roaming/ |
| 04:07 | rfg | The quick way to get to it is in emacs cd to ~ |
| 04:07 | noidi | mebaran151, http://www.launchy.net/ |
| 04:07 | rfg | or directly: C-x-f ~/.emacs |
| 04:08 | mebaran151 | so what do I change? |
| 04:08 | rfg | I think you just need to append (require 'paredit). |
| 04:10 | rfg | mebaran151: You'll want to throw this in as well http://jaguilar.posterous.com/i-get-so-tired-of-searching-fo |
| 04:11 | mebaran151 | I actually don't mind the default color scheme of emacs, but maybe i don't know what I'm missing |
| 04:11 | rfg | :) |
| 04:12 | rfg | TheBusby: my pleasure. |
| 04:14 | mebaran151 | does lein work on windows yet? |
| 04:14 | rfg | pass |
| 04:15 | mebaran151 | anyway I think I got my .emacs file edited; how do I load it? |
| 04:15 | rfg | I've not used lein. What am I missing? |
| 04:15 | mebaran151 | it's a saner version of maven |
| 04:15 | mebaran151 | a far far far saner version of maven |
| 04:16 | rfg | mebaran151: google says |
| 04:16 | rfg | M-x load-file RET ~/.emacs RET |
| 04:17 | rfg | I need to remember that one, I tend just to close emacs and reopen. |
| 04:18 | rfg | Actually what I need is a big red button on my desk, whose sole function is to reload my .emacs. I change it that much. |
| 04:18 | clojurebot | http://www.math.chalmers.se/~rjmh/Papers/whyfp.pdf |
| 04:20 | mebaran151 | cool paredit mode works! |
| 04:20 | rfg | Nice |
| 04:22 | mebaran151 | how do I make it the default for clojure-mode |
| 04:22 | noidi | (add-hook 'clojure-mode-hook (lambda () (paredit-mode +1))) |
| 04:22 | mebaran151 | in my .emacs? |
| 04:23 | noidi | yup |
| 04:26 | mebaran151 | now I just have to get hg working in windows, along with lein and a good launcher, and maybe a shell |
| 04:26 | mebaran151 | and figure out where I'd put screenplay.el |
| 04:36 | mebaran151 | hmph, powershell actually isn't that bad, and the hg install was painless |
| 04:37 | ordnungswidrig | mebaran151: screenplay? |
| 04:38 | mebaran151 | heh, emacs has a nice easy screenplay mode I've been playing with |
| 04:45 | ordnungswidrig | for writing screenplays? |
| 04:45 | mebaran151 | a little bit |
| 04:45 | mebaran151 | as a hobby |
| 04:45 | mebaran151 | I haven't gotten much into it yet |
| 04:45 | ordnungswidrig | I see, I just didn't get the connection to clojure *g* |
| 04:46 | mebaran151 | ah, yeah, I'm setting up a new clojure dev environment in Windows |
| 04:46 | mebaran151 | and I'm trying to see if I can get all the emacs bells and whistles from Linux to play nice in Windows 7, where files are hidden |
| 04:47 | ordnungswidrig | hmm, "files are hidden"? |
| 04:51 | LauJensen | Does anybody know what happened to Cemericks blog ? |
| 04:54 | mebaran151 | *the location of files is not known to me at the moment |
| 04:55 | mebaran151 | like where your .emacs.d belongs and what conventions work, etc |
| 04:55 | mebaran151 | anyway I gotta go to bed: thanks rtg and everybody! |
| 04:59 | psykotic | yay |
| 04:59 | psykotic | my first working compiler hack :) |
| 04:59 | psykotic | i extended deftype/deftype* to take an optional :extends clause for specifying non-Object superclasses |
| 04:59 | LauJensen | Show us the code :) |
| 05:00 | psykotic | i'll post the patch on gist, sec |
| 05:01 | Chousuke | I think extending concrete classes with deftype is dangerous |
| 05:01 | AWizzArd | Why? |
| 05:01 | clojurebot | why not? |
| 05:02 | Chousuke | AWizzArd: you might inherit mutable state that you're unaware of. |
| 05:02 | psykotic | Chousuke: i'm using it for interop |
| 05:02 | psykotic | it might be better to split it into a separate function rather than deftype |
| 05:02 | psykotic | the concrete problem for me is that JNA is a piece of shit |
| 05:03 | psykotic | the only way to hook into their fancy structure type is to implement a subclass of Structure, so their code can reflect over the fields, etc |
| 05:03 | Chousuke | hmm :/ |
| 05:03 | clojurebot | make a note of http://scienceblogs.com/goodmath/2006/11/the_c_is_efficient_language_fa.php it is yet another article about picking c or c++ for performance being naive |
| 05:05 | psykotic | here's the patch: |
| 05:05 | psykotic | http://gist.github.com/333781 |
| 05:10 | LauJensen | Interesting |
| 05:11 | vy | Is deftype/defprotocol the last stone for the beginning of Clojure-in-Clojure? |
| 05:12 | psykotic | LauJensen: no, it's surprisingly tame code, but it took me 2 hours of mistakes to get there :) |
| 05:13 | Chousuke | vy: That's my impression |
| 05:21 | LauJensen | Chousuke: I think that was reify |
| 05:28 | callen | okay. |
| 05:28 | callen | leinengen needs to be preached to the people from on-high. |
| 05:28 | callen | just saying. |
| 05:28 | licoresse | yeah |
| 05:29 | callen | licoresse: would've saved me some pain the other day, but I suppose it's better that I know. |
| 05:29 | licoresse | :) |
| 05:30 | callen | licoresse: the classpath stuff was making me curse up a storm. |
| 05:46 | Chousuke | LauJensen: Reify alone wasn't enough for implementing the data stuctures |
| 05:47 | LauJensen | Right |
| 05:47 | psykotic | reify*/deftype* are more or less the same |
| 05:47 | psykotic | they're very different wrappers around Compiler.java's build() function |
| 05:47 | psykotic | err, very thin |
| 06:18 | LauJensen | ~source deftype |
| 06:18 | clojurebot | Gabh mo leithscéal? |
| 06:18 | LauJensen | ~sourcey reify |
| 06:18 | clojurebot | excusez-moi |
| 06:18 | LauJensen | hehe |
| 06:18 | LauJensen | ~source reify |
| 06:18 | clojurebot | It's greek to me. |
| 06:19 | LauJensen | argh he gonna make me do it myself |
| 06:31 | LauJensen | http://github.com/bagucode/clj-native |
| 06:32 | psykotic | LauJensen: doesn't do much useful :) |
| 06:32 | LauJensen | ok |
| 06:32 | psykotic | okay, maybe that isn't true |
| 06:32 | LauJensen | Chouser did something similar at one point I think |
| 06:32 | psykotic | it does some useful things but not the difficult thing i'm trying to do. |
| 06:32 | LauJensen | Check Github if you need inspiration |
| 06:32 | psykotic | yeah, i looked at his stuff too |
| 06:34 | krainboltgreene | Ta-da. |
| 06:34 | krainboltgreene | Is it me, or is the Clojure website rather...lacking? |
| 06:38 | defn | krainboltgreene: certainly not on information |
| 06:38 | defn | maybe on organization |
| 06:38 | defn | ive been pining for "examples", which sort of happened with autodoc, but not quite |
| 06:39 | defn | i have sort of a plan to take all of the irc logs from #clojure...ever...and parse them for lines of actual code people have written which include various function names, etc. and then tag all of it and make it searchable |
| 06:40 | zmila | ,(doc replicate) |
| 06:40 | clojurebot | "([n x]); Returns a lazy seq of n xs." |
| 06:40 | zmila | ,(doc repeat) |
| 06:40 | clojurebot | "([x] [n x]); Returns a lazy (infinite!, or length n if supplied) sequence of xs." |
| 06:47 | defn | testing logging... |
| 06:48 | krainboltgreene | defn: Agreed, organization and presentation. |
| 06:49 | TDT | Hmm..there has to be an easier way to do this. If I want to map a function onto a list, and just print out that list, I found I have to do something like: (str "my list: " (into [] (map (fn [x] (* 2 x)) mylist))), I'd use mapcar in CL to do something like this, is there a cleaner way of doing what I'm trying to do? |
| 06:50 | Maddas | To just print it out -- is there anything wrong with (print (map (fn [x] (* 2 x)) mylist))? |
| 06:51 | TDT | str concatenates it into a lazy sequence reference, tried that first before doing the into. |
| 06:52 | TDT | Elements in mylist, *2? clojure.lang.LazySeq@f6c2640b <-- example output from that type of call |
| 06:54 | ordnungswidrig | (print (apply str (map #(* 2 %) mylist))) |
| 06:56 | TDT | Parts of that are a bit cleaner, we lose the formatting of the list though as a result. I'll use elements of both, thanks Maddas and ordnungswidrig |
| 06:57 | defn | would someone mind rejoining the channel quick to let me test something? |
| 06:57 | Maddas | (print (map #(* 2 %) mylist)) keeps the formatting :-) |
| 06:57 | defn | after you rejoin just say "tada!" |
| 06:57 | defn | :) |
| 06:58 | Maddas | tada! |
| 06:58 | Maddas | :) |
| 06:58 | defn | thanks much |
| 06:58 | Maddas | You owe me one. |
| 06:58 | Maddas | :-P |
| 06:58 | defn | Haha |
| 06:59 | TDT | Maddas: hmm, so print and println also can concatenate, not just str...intersting |
| 07:00 | TDT | Maddas: (print "foo: " (map #(* 2 %) [1 2 3])) returns "foo: (2 4 6)" |
| 07:03 | Maddas | TDT: I didn't know str worked that way until you asked (I'm a CLer myself) :-) |
| 07:04 | TDT | heh, yeah, str is what's described in the programming clojure book I'm going through. I kinda wish there was just format, format nil and format t feels easier |
| 07:06 | zmila | ,(get {120 [(30 40 50)]} 120 []) |
| 07:07 | clojurebot | java.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn |
| 07:07 | zmila | missed ' ( |
| 07:07 | Maddas | TDT: I've never used it, but there is pprint which claims to be format-compatible (in clojure-contrib) |
| 07:08 | TDT | Maddas: Thanks, that's one thing I think I'll do once I finish the book is read through the API docs for both core and contrib. I'm sure there's a lot of really cool stuff available in there. |
| 07:32 | ordnungswidrig | re |
| 07:32 | ordnungswidrig | grr |
| 07:58 | psykotic | for anyone more familiar with deftype and the compiler: type hinted fields don't seem to be defined as specially typed (beyond Object) in the generated class. is that intended? |
| 08:00 | hoeck | psykotic: thats right, type hinting works only for primitive types |
| 08:00 | cemerick | psykotic: are you getting reflection warnings when referring to those fields in clojure? |
| 08:01 | psykotic | cemerick: no |
| 08:01 | hoeck | that was at least my knowledge which may not be up to date anymore |
| 08:01 | psykotic | the problem is that i'm trying to talk to JNA, which reflects over the public fields and a class and does things depending on types, qualifiers, etc |
| 08:01 | psykotic | this functionality is not exposed through a less insane interface, unfortunately. |
| 08:01 | cemerick | hoeck: That's certainly not the case. |
| 08:02 | licoresse | Why can I not do this? (doto frame |
| 08:02 | licoresse | (.setLayout (FlowLayout.) ) |
| 08:02 | licoresse | (doseq [idx some-vector] (do-something-with-sideeffects frame idx)) |
| 08:02 | licoresse | .pack |
| 08:02 | licoresse | (.setVisible true)) |
| 08:03 | noidi | licoresse, frame will be passed as the first argument to doseq |
| 08:03 | cemerick | licoresse: because doto injects 'frame' as the second symbol in each child form. (doseq frame) is nonsense |
| 08:03 | licoresse | aha |
| 08:03 | licoresse | doto is a macro |
| 08:04 | licoresse | thanks! |
| 08:04 | psykotic | cemerick: so field hints don't actually affect the types of the generated fields? |
| 08:04 | psykotic | or am i doing something wrong? |
| 08:05 | psykotic | (i'm reflecting over the fields using getFields() on the Class to determine that they're just Object rather than my specified types) |
| 08:08 | cemerick | psykotic: yes, that appears to be the case. Non primitives are expressed as Object in the generated class. (maybe this is what hoeck was getting at) |
| 08:09 | psykotic | hmm |
| 08:09 | psykotic | in any case, my intended course won't work because the autogenerated symbols will confuse JNA |
| 08:09 | hoeck | yes, I meant the "type hinting" of fields in deftype |
| 08:10 | hoeck | with the goal to generate class fields of the given type |
| 08:10 | psykotic | it would be nice if the current deftype was built on an intermediate abstraction for building java classes |
| 08:10 | psykotic | something less oo and ugly than the asm stuff |
| 08:10 | cemerick | hoeck: well, the type hinting works just fine, primitive or not. It appears that the expression of that type in the generated classfiles only applies to primitives. |
| 08:11 | psykotic | cemerick: dumb question but how do i specify an integer primitive type hint? i'm new to the jvm, so i had assumed that Integer was it. |
| 08:11 | cemerick | #^int will do it |
| 08:11 | psykotic | ah, i thought that would clash with the coercion function of the same name. thanks. |
| 08:12 | cemerick | psykotic: I'd ping the mailing list about this, or rhickey when he's around next. |
| 08:12 | psykotic | cemerick: okay. |
| 08:13 | cemerick | psykotic: Also, a strenuous reading of the deftype et al. docs might expose the state of play. |
| 08:13 | cemerick | s/strenuous/thorough :-) |
| 08:13 | psykotic | the ones on assembla? |
| 08:13 | cemerick | yeah |
| 08:14 | defn | i need to build a search engine for a ton of text i have locally. 0 to 255 characters in length. any ideas? |
| 08:14 | defn | (each text grouping is 255chars) |
| 08:14 | defn | approximately 15MB of these |
| 08:18 | fogus | defn: How about a trie? |
| 08:18 | psykotic | weird, when i specify the unsynchronized-mutable metadata for a field, it doesn't get generated in the class at all, it seems |
| 08:19 | defn | fogus: could you be more specific? I know about tries, but am totally clueless when it comes to implementing a search engine on top of them |
| 08:19 | defn | fogus: are you thinking of a "suffix tree"? |
| 08:20 | defn | does fnparse do something like this? |
| 08:20 | fogus | defn: I can't say for implementing a DB since I don't know enough about your problem... but Tries are ideal for storing string data. Suffix tries are even better for text searching |
| 08:20 | defn | so many questions... |
| 08:20 | noidi | why not use something like Lucene? I have never used it, so that's a genuine question :) |
| 08:20 | noidi | not a rhetorical one |
| 08:21 | defn | fogus: i got chouser's 12MB or so of IRC logs. I took out all of the nicks (to protect the innocent of course), and now I have a list of lists, where the inner lists contain a day's worth of IRC conversation |
| 08:21 | psykotic | defn: there's a unix search engine called grep. have you tried that? :) |
| 08:21 | defn | inner list* |
| 08:21 | fogus | I imagine there are 37 implementations of suffix trees in Java floating around the interwebs |
| 08:22 | chouser | those speaking in #clojure are rarely innocent |
| 08:22 | defn | :X |
| 08:22 | psykotic | defn: i may be smug but i'm not kidding. |
| 08:23 | defn | psykotic: nono i know you're not kidding |
| 08:23 | defn | but for 12-15MB of text? attached to a web interface with 4-5 users searching simultaneously? |
| 08:23 | fogus | defn: Xach did something vaguely similar to the Naggum archives... you might find something of relevance in his notes. http://www.xach.com/naggum/articles/notes.html |
| 08:23 | defn | fogus: thanks for the help as always |
| 08:23 | noidi | _seems_ simple enough :P http://www.lucenetutorial.com/lucene-in-5-minutes.html |
| 08:24 | fogus | np |
| 08:24 | psykotic | defn: i would use grep and if you find yourself burdened by success (4-5 users searching simultaneously, sustained? that's success), try something fancier |
| 08:24 | defn | noidi: incidental complexity! :) |
| 08:24 | defn | 5 minutes you say? *spends 12 hours tinkering* |
| 08:24 | noidi | true :) |
| 08:25 | defn | nono i dont know anything about it -- im just skeptical when it comes to 5 minutes, 24 hours, etc. |
| 08:25 | fogus | defn: Is there any reason that chouser's Google search on the IRC logs is not sufficient? |
| 08:25 | defn | noidi: that does look quite cool actually |
| 08:26 | psykotic | fogus: have you seen this, by the way? http://conal.net/blog/posts/elegant-memoization-with-functional-memo-tries/ |
| 08:26 | defn | fogus: i want to do it one better |
| 08:26 | cemerick | lucene is great, but don't confuse it for a simple, quick solution to anything :-) |
| 08:26 | noidi | but the converse is also true: spending a week writing a custom db engine is a great way to save 6 hours learning a new API |
| 08:26 | fogus | defn: Fair enough. :) |
| 08:26 | defn | i want to parse for example clojure code |
| 08:26 | fogus | cemerick: +1 |
| 08:26 | psykotic | cemerick: simple, quick - grep! |
| 08:27 | defn | err I want to parse the irc log data for "example" clojure code |
| 08:27 | fogus | psykotic: I have not. Thanks for the link. |
| 08:27 | psykotic | i'm reminded of this old yegge post: http://steve.yegge.googlepages.com/five-essential-phone-screen-questions |
| 08:27 | defn | so when you search for defn, you get a whole bunch of (defn...) blocks |
| 08:27 | psykotic | grep for 'grep' |
| 08:28 | cemerick | defn: if it's really only 15MB of text, then just stream out regex hits. Seriously. |
| 08:29 | defn | cemerick: maybe ive been Doing It Wrong(tm), but running a filter using regex hits has seemed mighty slow for the whole data pie |
| 08:29 | defn | but of course im not streaming |
| 08:29 | Licenser_ | defn: do you precompile the regexp? |
| 08:29 | defn | itd be nice to tag lists with search terms that "work", as they work |
| 08:29 | defn | Licenser_: no |
| 08:30 | Licenser_ | that might speed things up |
| 08:30 | defn | im not even sure what that means TBPH |
| 08:30 | SynrG | http://www.mail-archive.com/clojure@googlegroups.com/msg10884.html |
| 08:30 | SynrG | apparently there are people using solr |
| 08:31 | defn | Solr is the popular, blazing fast open source enterprise search platform from the Apache Lucene project. |
| 08:31 | defn | +2 for Lucene |
| 08:31 | defn | psykotic: great post by yegge btw |
| 08:31 | psykotic | yeah, if you have five hours to slog through the verbiage :) |
| 08:31 | noidi | too bad he stopped blogging |
| 08:32 | cemerick | defn: I just created a 15MB string of spaces, with "duck-streams" in the middle, and (re-find #"duck-streams" mystring) returns in 2ms *shrug* |
| 08:32 | noidi | my theory is that his posts grew longer and longer until one day a post imploded killing him |
| 08:32 | defn | cemerick: maybe i should post my nasty code and see what you all think :) |
| 08:33 | cemerick | sure, but don't bother with lisppaste8, which is borked |
| 08:34 | chouser | if you use a regex literal in Clojure, it's precompiled. |
| 08:35 | Licenser_ | defn: please :D |
| 08:35 | defn | cemerick: err what i was saying was that I have something like this: (("hello cemerick" "oh hello george" "nice to see you" "does anyone know of?" "how many licks does it take to get to the center of a tootsie pop?") ("good morning" "good morning!" "LauJensen: check out this code http://www....")) |
| 08:35 | defn | so it's not like " " * 15MB |
| 08:35 | cemerick | defn: yeah, but that doesn't really matter perf-wise. regexes (as long as they're not pathological) run in linear time. |
| 08:36 | cemerick | er, approximately linear time :-) |
| 08:36 | psykotic | back references are the only thing that require more than linear time |
| 08:36 | defn | hmph -- i dont know anything apparently! :) |
| 08:36 | Licenser_ | cemerick: if you have things like *? it can get very slow |
| 08:36 | chouser | several common patterns can trigger backtracking |
| 08:36 | psykotic | Licenser: "it"? java's regex library? |
| 08:36 | cemerick | Licenser_, psykotic: for his use case, both of those are pathological; you wouldn't let external users submit arbitrary regexes |
| 08:37 | cemerick | I can't remember ever using *?, though :-) |
| 08:37 | psykotic | cemerick: yes, i was mere expanding on your comment re: linear time |
| 08:37 | cemerick | sure, just clarifying :-) |
| 08:37 | Licenser_ | what kind of regexps are you using exactly? |
| 08:37 | psykotic | *? is quite common |
| 08:37 | psykotic | for example .*?<some suffix> |
| 08:38 | defn | Licenser_: #".*zipmap.*" |
| 08:38 | psykotic | defn: don't do that... |
| 08:38 | Licenser_ | defn: try #"zipmap" if that is faster |
| 08:38 | psykotic | that will match the ENTIRE file |
| 08:38 | psykotic | (or the entire line if not in multiline mode i guess) |
| 08:39 | psykotic | any good regexp library will pull out a constant prefix and do boyer-moore string searches to find potential candidates |
| 08:43 | Licenser_ | so precompiling the regexp does not seem tow work |
| 08:44 | chouser | in what way does it fail? |
| 08:45 | defn | http://gist.github.com/333921 |
| 08:45 | defn | feel free to tear me apart. Something is not right in the kingdom |
| 08:45 | Licenser_ | chouser: as in speed |
| 08:45 | Licenser_ | we don |
| 08:45 | Licenser_ | 't tear you apart, we just eat your arms |
| 08:46 | chouser | ,(or nil? "") |
| 08:46 | clojurebot | #<core$nil_QMARK___4328 clojure.core$nil_QMARK___4328@1551d55> |
| 08:46 | chouser | ,(boolean (or nil? "")) |
| 08:46 | clojurebot | true |
| 08:46 | Licenser_ | flatten is in c.c.seq-utils :) |
| 08:46 | defn | i..did not know that! |
| 08:46 | defn | :) |
| 08:46 | chouser | looks like parse-irc-log will always return an empty sequence |
| 08:46 | Licenser_ | I ran into that myself :) |
| 08:47 | Licenser_ | chouser: don't you test if the nil? function exists there |
| 08:47 | defn | it did remove my ""'s, i threw the nil? in there for god know's why |
| 08:47 | chouser | yeah, but ... it does exist. I don't think that's what's intended. |
| 08:47 | defn | i want to remove nils and ""s |
| 08:48 | chouser | try (remove empty? ...) instead |
| 08:48 | defn | beautiful |
| 08:48 | Licenser_ | :) |
| 08:50 | Licenser_ | defn: try <.*?> |
| 08:50 | Licenser_ | that might make it faster |
| 08:50 | defn | as in #"<.*?>"? |
| 08:50 | Licenser_ | #".*<.*?>\s" |
| 08:50 | Licenser_ | or even #".*?<.*?>\s" |
| 08:51 | chouser | or #"[^<]*<[^>]*>\s" |
| 08:51 | defn | wow okay, this is much better -- now if my print-length wasnt so tiny i could tell if i hit anything other than nil :) |
| 08:53 | defn | what's the harm in irc-parser> (remove nil? (map #(re-find #"zipmap" (str %)) parsed)) |
| 08:53 | defn | that seems to bring things to a stand-still |
| 08:54 | chouser | might just be working hard. |
| 08:54 | defn | 4 cores and 8GB of RAM -- if I can't get some results in less than 60sec it's not useful to me either way |
| 08:55 | defn | but still... |
| 08:56 | Licenser_ | if you are looking for a substring there might be a function like pos |
| 08:56 | Licenser_ | defn: on what kind of system do you work? |
| 08:56 | defn | OS-wise? |
| 08:56 | Licenser_ | and you only use 1 core there ;) |
| 08:56 | Licenser_ | I was wanting to ask how large is your dataset :P but I failed |
| 08:57 | defn | OSX, Linux, Windows with a gun to my head |
| 08:58 | defn | oh, it's like 12MB I believe |
| 08:58 | Licenser_ | hmm taht isn't too much |
| 08:59 | defn | no it seems kind of silly im having these problems |
| 08:59 | defn | i think there is something more fundamental I'm missing |
| 08:59 | Licenser_ | is it possible to get a copy of the data? I am kind of curios to experiment :P |
| 09:00 | defn | sure, what's your email |
| 09:00 | Licenser_ | heinz@licenser.net |
| 09:00 | Licenser_ | also if try (def parsed (pmap flatten (map parse-irc-log (rest dates)))) |
| 09:01 | defn | the main issue seems to occur on: (map #(re-find #"zipmap" (str %)) parsed) |
| 09:01 | fogus | defn: Me too if you please: http://fogus.me/images/addy.png |
| 09:01 | Licenser_ | of cause since untill then no code is ever run |
| 09:01 | Licenser_ | the maps are all lazy as hell and don't do a thing untill you actually access some |
| 09:03 | defn | Licenser_: yeah excellent point |
| 09:03 | Licenser_ | so try to replace one of the maps with an pmap, as further out the better |
| 09:03 | Licenser_ | then you might get a good performance boost from your 4 cores |
| 09:03 | defn | ,(doc pmap) |
| 09:03 | clojurebot | "([f coll] [f coll & colls]); Like map, except f is applied in parallel. Semi-lazy in that the parallel computation stays ahead of the consumption, but doesn't realize the entire result unless required. Only useful for computationally intensive functions where the time of f dominates the coordination overhead." |
| 09:04 | defn | ooohh! |
| 09:04 | Licenser_ | pmap runs map just in paralell |
| 09:05 | Licenser_ | clojurebot: can you tell where code is? |
| 09:05 | clojurebot | code-review is <rhickey> yikes |
| 09:06 | Licenser_ | no not exactly |
| 09:06 | defn | "You've got mail!" |
| 09:06 | defn | @fogus, Licenser_ |
| 09:06 | Licenser_ | I hope you compressed it ;) |
| 09:06 | defn | tar.bz2 |
| 09:06 | defn | :) |
| 09:06 | Licenser_ | good good |
| 09:07 | defn | hopefully you get it -- im sending this via gmail which IIRC has a 10mb limit, but for some reason i remember they increased that |
| 09:07 | defn | due to...you know...microsoft word documents which are 20mb |
| 09:07 | defn | :) |
| 09:08 | Licenser_ | did the pmap bring an improvement? |
| 09:08 | defn | I actually don't even get an error |
| 09:08 | defn | it just stops eval'ing and gives me an ;evalkuation aborted |
| 09:09 | Licenser_ | oi |
| 09:10 | defn | which is russian i think maybe |
| 09:10 | defn | ;) |
| 09:11 | Licenser_ | I'll try it out once I get something |
| 09:12 | defn | my client is still churning |
| 09:12 | defn | should send any second hopefully |
| 09:14 | defn | okay i think it send |
| 09:14 | defn | sent* |
| 09:16 | defn | please let me know if you received it |
| 09:16 | defn | if not i can put it on my website |
| 09:16 | defn | annnddd.... you didn't! file is too big for your mail provider. :) |
| 09:17 | chouser | oh, I'm sorry guys -- I haven't been paying attention |
| 09:17 | chouser | defn: the url I sent you originally should still work. |
| 09:18 | defn | http://devinwalters.com/clojure-logs.tar.bz2 |
| 09:19 | defn | chouser: i lost it somewhere over the last couple of days |
| 09:21 | defn | Licenser_: fogus: http://devinwalters.com/clojure-logs.tar.bz2 |
| 09:22 | Licenser_ | defn: :) thanks |
| 09:22 | defn | Licenser_: thank chouser. he's the magic man. |
| 09:22 | Licenser_ | :D chouser you're incredible |
| 09:39 | defn | Anyway... |
| 09:39 | Licenser_ | defn: what I mean is I don't understand what your code wants to know |
| 09:40 | esj | defn: I know what you mean. Sadly I suck ever more at music. |
| 09:45 | defn | my code wants to know the strings which contain mention of zipmap, across all of the lists of strings in the list |
| 09:45 | Licenser_ | ah :) |
| 09:45 | defn | should i chunk this? |
| 09:45 | defn | you might be being too modest. id venture to guess you're better than me by a long intuitive shot at one or the other |
| 09:45 | defn | you're either a natural born killer, or a hopeless romantic |
| 09:45 | Licenser_ | defn: already the parsing stuff seems to take loong |
| 09:45 | defn | Licenser_: yeah, maybe it's the structure? would a vector or a set help? |
| 09:45 | defn | would tagging each list of strings with metadata for "this list contains mention of such-and-such clojure.core functions..." |
| 09:45 | defn | (:defn :def :interleave ("blah" "foo" "bar")) |
| 09:45 | Licenser_ | nah I am still trying to figure it out |
| 09:45 | defn | that was my shot in the dark -- but "There's got to be a better way!" |
| 09:45 | Licenser_ | defn: to me it seems that there is something fundamentally wrong |
| 09:45 | defn | nod |
| 09:47 | defn | could it be the (rest (re-split... ? |
| 09:48 | Licenser_ | I am experimenting with chaning the read mode of files |
| 09:50 | defn | flatten practically triples the time to (parse-irc-log (nth dates 3)) |
| 09:50 | Licenser_ | I try this: (time (count (flatten parsed))) |
| 09:51 | Licenser_ | flatten forces everything to evaluate, which in itself isn't bsad |
| 09:51 | Licenser_ | bad |
| 09:51 | defn | yeah flatten is the problem here |
| 09:51 | defn | i go from .280ms to 1.0msecs the first time i use flatten |
| 09:52 | defn | for (parse-irc-log (nth dates 4)) |
| 09:52 | defn | and that's a small log in comparison |
| 09:54 | defn | ,(tree-seq seq? seq '((1 2 (3)) (4))) |
| 09:54 | clojurebot | (((1 2 (3)) (4)) (1 2 (3)) 1 2 (3) 3 (4) 4) |
| 09:54 | Licenser_ | ouch user=> (time (count (flatten parsed))) |
| 09:54 | Licenser_ | "Elapsed time: 307842.237 msecs" |
| 09:57 | defn | irc-parser> (time (second parsed)) |
| 09:57 | defn | "Elapsed time: 0.108 msecs" |
| 10:01 | defn | so the structure actually looks like (((:1) (:2) (:3)) ((:4) (:5) (:6))) |
| 10:01 | Licenser_ | user=> (time (count (flatten parsed))) |
| 10:01 | Licenser_ | "Elapsed time: 28326.8943 msecs" |
| 10:02 | defn | i wonder if this could be done with reduce, concat, or something like that |
| 10:04 | defn | peek/pop? |
| 10:05 | Licenser_ | brb |
| 10:23 | esj | Consider multimethods where you dispatch using isa? on a class hierarchy. If your specific instance is deep in the hierarchy, is there a way to invoke the dispatch methods for its parents, in the way of say "super" in ruby ? |
| 10:23 | esj | there must be, but I'm having trouble figure out how :( |
| 10:25 | esj | so in the case of (eat my-creature) where type of my-creature is animal->fish->goldfish, i'd like to invoke animal.eat, fish.eat, goldfish.eat in that order (please excuse my OOPish notation) |
| 10:27 | dnolen | esj: you can get the method for a particular dispatch value |
| 10:27 | dnolen | ,(doc get-method) |
| 10:27 | clojurebot | "([multifn dispatch-val]); Given a multimethod and a dispatch value, returns the dispatch fn that would apply to that value, or nil if none apply and no default" |
| 10:28 | esj | aaah, then I construct it manually. |
| 10:28 | dnolen | yeah, you'll have to implement something like super yourself, not difficult. |
| 10:28 | esj | ok, I get it, thanks dnolen. |
| 10:29 | dnolen | super also doesn't always make sense since you can have multiple parents |
| 10:29 | esj | yeah, I'lll have to be a bit careful |
| 10:35 | defn | you could maybe (let [parent-a (fn inner-fn) parent-b (fn inner-fn-two)] ...) |
| 10:35 | defn | so you scope your parents |
| 10:35 | defn | (does that make sense? i dont usually know what im talking about) |
| 10:36 | Licenser_ | defn: look at this |
| 10:36 | Licenser_ | http://gist.github.com/334024 |
| 10:37 | defn | haha! that's cool |
| 10:37 | Licenser_ | it still is waaaay too slow for big data so :() |
| 10:38 | defn | we'll find a way |
| 10:38 | defn | my structure is wrong -- i think that re-split sets me up for failure |
| 10:38 | Licenser_ | but I'm below one minute :) |
| 10:38 | Licenser_ | (time (count (find-lines "zipmap"))) |
| 10:38 | Licenser_ | "Elapsed time: 45084.3956 msecs" |
| 10:38 | defn | not bad! |
| 10:38 | defn | see im actually find with this |
| 10:38 | defn | because id like to build metadata for each log |
| 10:38 | Licenser_ | I wonder if pmap does a big improvement here :) |
| 10:39 | Licenser_ | no not exactlyu |
| 10:40 | ordnungswidrig | I'd guess the execution is more io bound than cpu bound, right? |
| 10:40 | Licenser_ | ah problem is lazyness kilsl pmap |
| 10:40 | dnolen | defn: or if you just dumped your data into CouchDB and used CouchDB-Lucene you could probably get all matches in like 400ms ;) |
| 10:40 | Licenser_ | dnolen: pssst! |
| 10:40 | Licenser_ | it's about making it good! |
| 10:40 | Licenser_ | (time (count (find-lines "zipmap"))) |
| 10:40 | Licenser_ | "Elapsed time: 20181.8055 msecs" |
| 10:40 | Licenser_ | :D 20s |
| 10:40 | defn | :) |
| 10:40 | Licenser_ | second run aka java warmup |
| 10:41 | defn | Licenser_: I respect you, sir. |
| 10:41 | Licenser_ | and likely IO cache of the OS |
| 10:41 | defn | Why does laziness kill pmap? |
| 10:41 | Licenser_ | I think to think that the pmap is killed since I got only one CPU used |
| 10:41 | Licenser_ | defn: this is on a 1.6 GHz system, you'll likely get < 10 |
| 10:43 | Licenser_ | http://gist.github.com/334024 <- the updated code |
| 10:43 | remleduff | Has anyone had leiningen crash for them on Windows if they don't delete -Xbootclasspath/a:"%CLOJURE_JAR%" from the bat file? |
| 10:43 | remleduff | It works fine on my other Windows box, but not this one |
| 10:44 | defn | Licenser_: Hm, I'm not able to get it to work here |
| 10:44 | Licenser_ | oi? |
| 10:45 | Licenser_ | likely the file path of dates is different for you? |
| 10:45 | Licenser_ | I had to change that |
| 10:45 | defn | yeah i edited that |
| 10:45 | Licenser_ | okay |
| 10:45 | defn | but im restarting the repl one sec |
| 10:49 | defn | Unable to resolve symbol: reader in this context |
| 10:50 | defn | oh duh, nvm |
| 10:50 | dnolen | Licenser_: nice your code take < 5s on my machine. |
| 10:50 | Licenser_ | :D |
| 10:50 | Licenser_ | huzza! |
| 10:51 | Licenser_ | thanks dnolen |
| 10:56 | defn | lol gahhh |
| 10:56 | defn | .#irc-parser.clj |
| 10:56 | defn | it keeps trying to find that tmp file i have open lol |
| 10:57 | chouser | you guys do know I have code that parses those files, right? it's on github. |
| 10:57 | chouser | you guys do know I have code that parses those files, right? it's on github. |
| 10:57 | chouser | it doesn't do search or indexing, but my have some useful regex snippets |
| 10:57 | Licenser_ | chouser: that doesn't matter it's about the sport! |
| 10:58 | Licenser_ | at least for me it is |
| 10:58 | chouser | heh, ok good enough. |
| 10:58 | chouser | I mean, I understand, just didn't want anyone to be unaware of a resource that might be useful. |
| 10:58 | LauJensen | chouser: Is that what you call an oxymoron? "useful regex" |
| 10:58 | defn | chouser: actually i didnt know that, but either way it's fun to do a little snipe hunting |
| 10:58 | chouser | well, I parse those raw text logs to generate the .html |
| 11:00 | chouser | http://github.com/Chouser/clojure-irc-log/blob/master/irc-log-to-html.clj |
| 11:00 | chouser | ugh. I really need to convert that to use enlive or something. |
| 11:04 | Licenser_ | I am really scared that a short ruby snipped I wrote for the same code A) finds 10 lines more and B) takes 50% of the time |
| 11:07 | Licenser_ | and neither ruby nor clojure outputs the same as grep :P |
| 11:07 | Licenser_ | which of cause only takes 0.5 seconds to run |
| 11:07 | Licenser_ | so something is very wrong here |
| 11:08 | Licenser_ | I mean 100 times slower then grep is bad <tm> |
| 11:10 | Licenser_ | this is horrible |
| 11:14 | Licenser_ | anyone any idea how that comes? |
| 11:15 | Licenser_ | i mean it is scarry, I'm doing something wrong |
| 11:16 | chouser | same performance considerations as always. Just read chapter 10 of Joy of Clojure ... once fogus has written it of course. |
| 11:17 | fogus | Man I will love that chapter |
| 11:17 | chouser | *warn-on-reflection*, profile the code ... |
| 11:17 | chouser | bbl |
| 11:18 | stuartsierra | The Apress book will have a whole chapter on performance too. |
| 11:18 | Licenser_ | I mean I tried to do things good here but it does not help :( |
| 11:18 | Licenser_ | and no reflections as it seems |
| 11:19 | eevar2 | Licenser_: and no matter what, you'll never match grep for speed |
| 11:19 | Licenser_ | (binding [*warn-on-reflection* true] (time (count (find-lines "zipmap")))) ;=> no warnings |
| 11:19 | stuartsierra | It doesn't work that way. |
| 11:19 | stuartsierra | Call (set! *warn-on-reflection* true) at the top of your source file and reload. |
| 11:19 | Licenser_ | eevar2: I know, I don't want to be as as grep BUT I don't want to be twice as slow as ruby :P |
| 11:19 | Licenser_ | oh |
| 11:19 | fogus | stuartsierra: I'm excited that you're working on the book. Can't wait to read it. |
| 11:20 | Licenser_ | someone over at clojure.de will; have a german book too :d |
| 11:20 | stuartsierra | fogus: Thanks. I wish I could get an updated PDF with my contributions, but Apress has ignored my requests so far. |
| 11:20 | Licenser_ | geez i'll get poor this year |
| 11:21 | fogus | stuartsierra: We're having a similar conundrum |
| 11:22 | psykotic | i've only heard bad things about working with apress from the author side. |
| 11:23 | fogus | I can't say that our (my) experience has been bad... only that our idea of the ideal release frequency of new material differs from our publisher |
| 11:23 | Licenser_ | wow some type hints do wonders |
| 11:23 | Licenser_ | 1/4th of the time |
| 11:24 | Licenser_ | now twice as fast as ruby, that is something that gets in the right direction |
| 11:24 | Licenser_ | and only 20 times slower then grep |
| 11:24 | dnolen | Licenser_: there's a lot of laziness in your solution. But it's beautifully elegant. You can make it blazingly fast but you're probably going to have to move to explicit loop/recur, type-hinting, and Java methods. The question is how much do you care? :) If you can't make it 50X faster I |
| 11:24 | dnolen | 'd be surprised |
| 11:25 | Licenser_ | dnolen: it's for the sports ;) |
| 11:26 | Licenser_ | I want to see what I can do |
| 11:27 | dnolen | When Uncle Bob complained about Clojure convex hull taking 25s, I came up with a real nasty piece of unsafe single-threaded optimization that did it ~500ms. Then I got bored with optimizing silly programs. But it is a good learning experience. I'd rather rhickey solve those problems for me tho :D |
| 11:28 | psykotic | dnolen: he complained in a blog post? got a link? |
| 11:28 | Licenser_ | dnolen: I agree, I like the solution I posted, it is as you say, nice and elegant, but I want to see how much effort it takes to make it fast :P |
| 11:29 | Licenser_ | I'm down to 10s on you rsystem it will be <1 now I think |
| 11:29 | Licenser_ | with only two type hints |
| 11:29 | dnolen | psykotic: checking |
| 11:30 | dnolen | psykotic: http://blog.objectmentor.com/articles/2009/08/11/jarvis-march-in-clojure |
| 11:31 | dnolen | psykotic: and my type-hinted everything inlined via macros mutable optimization, http://github.com/swannodette/convex-hull/blob/master/convex_hull.clj |
| 11:31 | psykotic | thanks |
| 11:32 | psykotic | ,(< [1 2] [2 2]) |
| 11:32 | clojurebot | java.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to java.lang.Number |
| 11:32 | psykotic | that's silly |
| 11:32 | psykotic | i just noticed his point-min. it's silly to have to implement lexicographic comparisons on sequences manually. |
| 11:32 | psykotic | even python offers that by default. |
| 11:33 | Licenser_ | http://gist.github.com/334097 < slightly optimized version |
| 11:33 | psykotic | hopefully with protocols we can have smarter generic primitives like that without hurting performance on average. |
| 11:34 | Licenser_ | down to 8s :D |
| 11:35 | stuartsierra | psykotic: I think that's a major goal of protocols |
| 11:35 | stuartsierra | Won't happen overnight though. |
| 11:35 | psykotic | stuartsierra: alas :) |
| 11:35 | psykotic | it's one of my few pet peeves with clojure currently. will be glad to see that happen. |
| 11:35 | Licenser_ | defn: if you want look at the new paste it is a good bit faster now |
| 11:36 | dnolen | Licenser_: ~50-60ms for me. |
| 11:36 | dnolen | er |
| 11:36 | dnolen | oops |
| 11:38 | psykotic | dnolen: i just looked at your code. my eyes! the goggles, they do nothing! :) |
| 11:38 | dnolen | Licenser_: ~200-250ms for me now. |
| 11:38 | dnolen | pyskotic: it's awful and evil yes. |
| 11:39 | Licenser_ | dnolen: nice :D |
| 11:40 | dnolen | psykotic: it made more sense to just call into Java at that point. The java was still 4x-5x faster. And I don't think that algorithm can be made parallel so nothing to gain there. |
| 11:41 | psykotic | fwiw, the quickhull algorithm has an obvious opportunity for parallelism |
| 11:41 | psykotic | it has a straightforward fork/join structure |
| 11:42 | dnolen | pyskotic: Hmm, I couldn't figure it out. You need to create a linked list of all the previous points to figure out the next one. Perhaps misunderstood the algorithm. Do you have a link to parallel version? |
| 11:49 | psykotic | dnolen: i meant quickhull, not jarvis march. |
| 11:49 | psykotic | anyway i have to run to bed. btw, i'd love to see his code test repeated with -server and escape detection, and a one-minute warm-up. |
| 12:17 | caljunior2 | braindead java api interop question alert: I'm trying to call a java method with two arguments and no class or instance: crack(message sessionID). This what I do: (.crack message sessionID). I'm doing this within a proxy extending a MessageCracker class and it compiles fine. When I send a message I get an exception: "no matching method found for class". |
| 12:17 | caljunior2 | anything obvious I'm missing? |
| 12:18 | caljunior2 | (except for a brain of course) :-) |
| 12:18 | dakrone | caljunior2: did you try (.crack this message sessionID) ? |
| 12:18 | dakrone | your example is equivalent to message.crack(sessionID) |
| 12:18 | caljunior2 | no |
| 12:20 | caljunior2 | dakrone: seems to work. thanks! |
| 12:20 | dakrone | caljunior2: no problem, good luck! |
| 12:37 | caljunior2 | how can I override proxy methods without having to restart an application? |
| 12:40 | arohner | caljunior: can you re-def the functions you passed to proxy? |
| 12:40 | Chousuke | there are some lower-level functions for editing proxies but I'm not sure how to use them |
| 12:40 | Chousuke | search the documentation |
| 12:42 | dakrone | ,(doc update-proxy) |
| 12:42 | clojurebot | "([proxy mappings]); Takes a proxy instance and a map of strings (which must correspond to methods of the proxy superclass/superinterfaces) to fns (which must take arguments matching the corresponding method, plus an additional (explicit) first arg corresponding to this, and updates (via assoc) the proxy's fn map. nil can be passed instead of a fn, in which case the corresponding method will revert to the default behavior. |
| 12:43 | arohner | wow that's cool |
| 12:43 | caljunior2 | drakone: thanks again! |
| 12:47 | arohner | I want xpath for clojure maps |
| 12:47 | dakrone | arohner: what do you mean by that? |
| 12:48 | arohner | I have a tree of clojure maps that I need to transform. I'm getting tired of writing recursive reduces. I'm looking for a better abstraction |
| 12:48 | arohner | I think something like xpath, that can also update nodes, would work well |
| 12:49 | arohner | I wrote this http://gist.github.com/334206 a few weeks ago |
| 12:49 | arohner | so now I'm writing get-in-many, but I just realized the solution should be more general |
| 12:50 | dakrone | yea, if you generalized it, could make a nice library |
| 12:50 | arohner | dakrone: I should probably release my other libraries before I start another :-) |
| 12:50 | dakrone | well, that's true |
| 12:50 | arohner | I have an ORM that I'm going to release soon |
| 12:51 | dakrone | doesn't mapping objects to things kind of defeat functional data structures? |
| 12:52 | arohner | not really |
| 12:52 | dakrone | okay, how's it work? |
| 12:52 | arohner | think of it as sugar for pulling trees of clojure maps out of a DB |
| 12:52 | dakrone | okay, sounds like it could be useful |
| 12:52 | arohner | like a 'normal' ORM, except all the rows are clojure maps |
| 12:52 | dakrone | SQL or NoSQL DBs? |
| 12:53 | arohner | SQL. Right now it's only tested against postgres |
| 12:53 | dakrone | how are you storing the maps? serializing them? |
| 12:53 | dakrone | JSON? |
| 12:53 | arohner | in normal DB columns |
| 12:53 | arohner | a row == a clojure map |
| 12:54 | dakrone | oh okay, you're not storing them in trees then? |
| 12:54 | arohner | no |
| 12:54 | Licenser_ | I found json very slow, is that an impression only I have or is that a known fact |
| 12:54 | Licenser_ | ? |
| 12:54 | arohner | but there's good association support, and you can pull trees out, by loading associations |
| 12:54 | arohner | (foo/find-one :where {:id 10} :load [:bar {:baz :qux}}]) |
| 12:54 | dakrone | oh okay |
| 12:55 | dakrone | Licenser_: in my experiences, JSON can be pretty fast |
| 12:55 | arohner | you define tables, and define associations between tables |
| 12:56 | noidi | is there a function like update-in, but that takes many key/fn pairs? |
| 12:56 | arohner | so that load says 'return a :foo, and load the :bar association. load the :baz association on foo, and load :qux on baz' |
| 12:56 | Licenser_ | hmm I found writing it horribly slow as in slow to cry |
| 12:56 | noidi | like (update-in [:foo] update-foo [:bar :baz] update-baz) |
| 12:56 | noidi | oops |
| 12:56 | dakrone | Licenser_: maybe it's the particular json library you were using? |
| 12:56 | noidi | (update-in my-map [:foo] update-foo [:bar :baz] update-baz) |
| 12:56 | Licenser_ | dakrone: the default clojure one |
| 12:58 | dakrone | Licenser_: http://gist.github.com/316675 |
| 12:58 | dakrone | Licenser_: looks like you might want to check out clj-json |
| 12:58 | hiredman | noidi: you can use -> for that |
| 12:59 | Licenser_ | dakrone: thanks for the advice |
| 12:59 | hiredman | ,(-> {:a 1 :b 2} (update-in [:a] inc) (update-in [:b] dec)) |
| 12:59 | clojurebot | {:a 2, :b 1} |
| 13:00 | noidi | hiredman, that's what I'm using now |
| 13:00 | noidi | but thanks |
| 13:03 | noidi | I'll guess I'll have to write update-in* (for lack of a better name) to get rid of repeating (update-in) |
| 13:03 | Licenser_ | so got to got for a bit dakrone I'll try that out thanks |
| 13:04 | dakrone | no problem, good luck |
| 13:06 | hiredman | ,(reduce (fn [m [p f]] (update-in m p f)) {:a 1 :b 2} {[:a] inc [:b] dec}) |
| 13:06 | clojurebot | {:a 2, :b 1} |
| 13:07 | noidi | hiredman, heh, that's almost identical to my version :) |
| 13:08 | crowb4r | I love irssi and screen. :) |
| 13:08 | crowb4r | me == to crowbar7 |
| 13:24 | dakrone | <3 leiningen |
| 13:24 | dakrone | installed lein, did a lein new, symlinked the classes and libs from a giant enterprise java app, lein repl and hurray debugging REPL |
| 13:31 | polypus | ~ping |
| 13:31 | clojurebot | PONG! |
| 13:32 | polypus | what's the best deftype/defptrotocol doc around right now? |
| 13:32 | polypus | *proto |
| 13:32 | psykotic | i don't think you have much to pick from :) |
| 13:32 | psykotic | the assembla one is outdated in some ways |
| 13:32 | psykotic | i'd suggest looking at the source code, which isn't much to go through |
| 13:32 | polypus | k, ty |
| 13:45 | psykotic | rhickey: i noticed that deftype fields with non-primitive type hints generate Object-typed fields rather than the specified types. is that intended behavior? |
| 13:49 | Chousuke | argghfjkj |
| 13:50 | Chousuke | I posted a reply to the monad question and of COURSE my post gets lost somehow |
| 13:51 | psykotic | speaking of which, i can't remember if i posted my monad code, which uses an alternative implementation method (no symbol macros, for one) |
| 13:51 | Chousuke | I wrote one that uses protocols :D |
| 13:52 | psykotic | http://gist.github.com/331761 |
| 13:52 | Chousuke | http://gist.github.com/312281 |
| 13:53 | Chousuke | rather hacky, but it seems to work |
| 13:54 | psykotic | isn't the dynamic binding dangerous if you combine it with lazy sequences? |
| 13:54 | psykotic | i decided to use explicit dictionary passing (but hidden away) |
| 13:54 | Chousuke | it is, yes. |
| 13:54 | Chousuke | but it was fun to write |
| 13:54 | psykotic | :) |
| 13:54 | psykotic | the best reason! |
| 13:55 | Chousuke | I still don't know how I managed to write that lift function |
| 13:55 | Chousuke | I think it works on functions of arbitrary arity. |
| 13:57 | psykotic | yeah, i can't see why that would be difficult? you just create a var-args wrapper that reduces with 'bind' over the monadic arguments. |
| 13:58 | psykotic | btw, something that felt out of the way i implemented my >> is that the identity monad is actually useful :) |
| 13:58 | psykotic | *fell out |
| 13:59 | psykotic | (run-identity (>>= 42 (- % 2) (* % %))) |
| 13:59 | psykotic | of course, you could easily implement that as a separate macro a la ->/->> that won't require an explicit run-identity |
| 14:05 | S11001001 | Is there a way to make clojure.core/compile *not* compile files required in the file whose compilation was directly requested? |
| 14:08 | cemerick | S11001001: unfortunately not at the moment |
| 14:10 | chouser | (binding [*compile-files* nil] (require '...)) doesn't work? |
| 14:10 | hiredman | binding is runtime |
| 14:12 | cemerick | It's definitely worth an enhancement to the compiler to support both modes -- recursive compilation and only those ns' explicitly named. |
| 14:13 | chouser | it works |
| 14:13 | cemerick | psykotic: as Chousuke said, yes it is. http://muckandbrass.com/web/x/m4BJ |
| 14:14 | chouser | if your only (require 'foo.bar) is wrapped in binding *compile-files* to nil, then foo.bar will not be compiled. |
| 14:14 | cemerick | chouser: oh, right, if the binding is a top level, then compile-time is runtime. |
| 14:15 | chouser | something like that. :-) |
| 14:15 | cemerick | 'course, it's sad to have to put binding around every ns decl that you might AOT compile. |
| 14:15 | chouser | compile-time vs. run-time is really for each top-level form individually. |
| 14:17 | chouser | read-time too, I believe. a top-level form is read, analyzed, byte-code emitted, (saved to a .class file if *comiple-files*), loaded, called, and then the process repeats with the next top-level form. |
| 14:18 | chouser | cemerick: right -- it'd be interesting to have it as a flag or something. |
| 14:26 | LauJensen | cemerick: Your site has been down recently hasn't it ? |
| 14:26 | cemerick | LauJensen: what, the blog? Not that I know of... |
| 14:26 | LauJensen | cemerick: I've been getting a database error of some sort when accessing it earlier today |
| 14:27 | cemerick | hrm, that's no good |
| 14:27 | LauJensen | Something about concurrent connections and a support link |
| 14:27 | cemerick | nothing showing on the monitoring :-/ |
| 14:27 | LauJensen | Oh its fixed now I see |
| 14:35 | S11001001 | chouser: that's how compile is currently implemented (1.1.0), essentially |
| 14:35 | S11001001 | oh, that's not what you were saying |
| 14:36 | chouser | S11001001: you see how to solve your immediate problem? |
| 14:36 | chouser | not pretty I admit, but seems to work. |
| 14:38 | cemerick | it shouldn't actually be a problem, just a matter of bloating one's jar/distribution |
| 14:38 | S11001001 | I would rather just keep compiling the extras until something better comes along |
| 14:44 | chouser | or pinning a jar to particular compile-time behavior you don't want |
| 14:44 | chouser | buy yeah, if it's just a matter of .jar bloat, probably not worth the effort. |
| 14:47 | Licenser | aloa |
| 14:47 | S11001001 | I'm putting together trees of dependencies in Leiningen, and :excludes doesn't really do what you want if the jar includes classes of the thing you're trying to exclude :) |
| 14:48 | S11001001 | or the version clash resolution (shallowest wins) for that matter |
| 15:00 | duncanm | hmm, when i use slime on mac os x (gnu emacs), i don't see a *slime-repl* buffer |
| 15:00 | duncanm | i just get the *inferior-lisp* buffer |
| 15:02 | drewr | your swank process isn't getting synced up properly |
| 15:02 | drewr | do you see an exception in *inferior-lisp*? |
| 15:10 | LauJensen | I blogged, help make this better: http://www.bestinclass.dk/index.php/2010/03/clojure-ides-the-grand-tour-getting-started/ |
| 15:16 | technomancy | LauJensen: looks good; seems to be pretty fair |
| 15:17 | technomancy | I wish you didn't have to paste that big blob of elisp to install package.el, but until it's merged to Emacs trunk it's a necessary evil. |
| 15:17 | technomancy | on the bright side I think it's going to be merged soon |
| 15:17 | LauJensen | Really? :) |
| 15:17 | LauJensen | I'll believe it when I see it |
| 15:18 | technomancy | I have it on good authority (Stefan) that only one feature is blocking its inclusion. |
| 15:18 | LauJensen | Great |
| 15:18 | LauJensen | Would also be nice to see the amount of well maintained packages grow |
| 15:18 | technomancy | yeah |
| 15:19 | technomancy | LauJensen: also: under the Emacs section what about making "git" link to this page? http://alexvollmer.com/posts/2009/01/18/meet-magit/ |
| 15:19 | LauJensen | Hmm - Isn't Magit tricky for newcomers? Compared to Egg I mean |
| 15:19 | LauJensen | Egg is lacking in features, but those that are, are well documented |
| 15:19 | cemerick | LauJensen: are you moderating comments? |
| 15:19 | LauJensen | But ok, the docs are great for magit as well |
| 15:19 | technomancy | I think they are pretty close, but the screencast is pretty thorough |
| 15:19 | Chousuke | egg is pretty much abandoned though :/ |
| 15:20 | LauJensen | cemerick: Yea I approve all first-time commentators |
| 15:20 | cemerick | ah, ok. Glad it didn't drift out of the ether. |
| 15:20 | LauJensen | (there's nothing from you though) |
| 15:20 | cemerick | ugh |
| 15:20 | dakrone | LauJensen: oh hey, thanks for the shout out on your post :) |
| 15:21 | LauJensen | dakrone: I shouted? :) |
| 15:21 | cemerick | LauJensen: I'm anchored to comment 2193. No good, eh? |
| 15:21 | dakrone | Mention? :) |
| 15:21 | LauJensen | dakrone: Who are you ? |
| 15:21 | fliebel | What is the difference between Eclipse and Intellij? |
| 15:22 | LauJensen | cemerick: No, I dont know whats going on - once you succesfully comment I think you actually see the comment, but with a flag that its awaiting moderation |
| 15:22 | dakrone | LauJensen: I write the writequit.org stuff |
| 15:22 | cemerick | bummer. I'll rewrite, I guess. |
| 15:22 | LauJensen | dakrone: Ahhh, then I'm the one thanking you, great blogpost you did |
| 15:22 | LauJensen | cemerick: Put it in the clipboard, if its a system error I'll deal with it immediately |
| 15:22 | LauJensen | (just so it doesnt get lost again) |
| 15:23 | technomancy | that's prompt service for you! =) |
| 15:23 | dakrone | LauJensen: thanks! Yours was the one that inspired it, so I should be thanking you |
| 15:25 | LauJensen | :) |
| 15:26 | cemerick | LauJensen: attempt #2 submitted, FWIW |
| 15:26 | cemerick | in the clipboard this time, too :-) |
| 15:26 | psykotic | LauJensen: btw, i just saw your post on emacs yesterday. re: color-themes, the one thing vim has on emacs is that the aesthetics of the available themes tends to be much higher. inkpot and so on. |
| 15:27 | psykotic | LauJensen: i have a hacked up color-themes-vim.el i did that uses regexp hacks to parse vim themes though, maybe i'll clean it up and gist it tomorrow, if you want it |
| 15:27 | LauJensen | cemerick: If you didn't submit as "Arthur" then I think it got lost, and it might be a local problem, since it just worked for someone else |
| 15:28 | cemerick | heh, no, I'm not arthur |
| 15:28 | LauJensen | And Phil just ranted as well :) |
| 15:28 | LauJensen | psykotic: sounds great - and you dont get any argument from Vim, Emacs has many painful color combinations |
| 15:29 | mabes | for those of of you with a production clojure (compojure in my case) webapp/service what is your preferred form of deployment/serving? |
| 15:29 | mabes | I've been considering glassfish, but more recently I am leaning towards embedded jetty and having nginx reverse proxy to it. |
| 15:34 | psykotic | LauJensen: in your disparaging comments about vim yesterday. remember, it isn't just a text editor. in fact, it mainly does music: http://www.dina.kvl.dk/~abraham/religion/vi-music :) |
| 15:34 | LauJensen | mabes: Haven't tried Glassfish, but I can vouch for the nginx combo |
| 15:35 | mabes | LauJensen: cool.. seems like a nice simple solution. How do you handle deploys/restarts? I'm thinking of wrapping the embedded apps in monit.. |
| 15:36 | LauJensen | Haven't tried that |
| 15:37 | LauJensen | psykotic: Man that link was awfully boring, beep mode... |
| 15:43 | wooby | LauJensen, sweet post on IDEs! |
| 15:43 | LauJensen | Thanks :) |
| 15:44 | dnolen | LauJensen: very nice |
| 15:44 | wooby | i'd be curious, do the visual ide plugins use that IDE's project format or do any of them do lein integration? |
| 15:45 | dnolen | wooby: I saw a recent Lein commit that allows Enclojure to open Lein projects. So hopefully that's just around the corner. |
| 15:45 | wooby | dnolen, awesome i'll keep an eye out, thanks |
| 15:46 | bobo_ | http://gist.github.com/334417 i dont get it. if i uncomment the redirect, the session doesnt get the login and uid values? |
| 15:46 | bobo_ | but without the redirect, it works |
| 15:47 | technomancy | wooby: yeah, stuart H added that last night |
| 15:47 | technomancy | just dump the pom with "lein pom" and you can start a new enclojure, etc. project |
| 15:47 | dnolen | technomancy: looks like some sweet stuff is in the pipeline for lein, swank-clojure, clojure-mode, et. al. |
| 15:48 | technomancy | dnolen: hugod has some awesome swank features coming |
| 15:48 | dnolen | ahh how I miss the old days where I had to hack in macro-expansion myself ... not. |
| 15:48 | Chousuke | bobo_: my brain keeps telling me it's because session-assoc's return value is not actually stored anywhere, but I suppose it's an evil function that has side-effects. |
| 15:49 | technomancy | the new leiningen features won't be interesting unless you've got several projects that you want to be able to hack simultaneously. it's useful for larger projects, but still kind of edge-casey |
| 15:49 | bobo_ | Chousuke: but if i dont redirect, i can navigate to the page later and the session has the correct values? |
| 15:49 | rads | technomancy: how do you make a leiningen task that uses project files from the classpath? write it as a plugin? |
| 15:50 | technomancy | rads: were you the one asking about that yesterday? I noticed the classpath wasn't set up to find lein tasks in src like you mentioned |
| 15:50 | technomancy | so I fixed it |
| 15:50 | rads | yeah, I missed your response though |
| 15:51 | technomancy | oh, I didn't fix it until much later, so I didn't mention it on IRC |
| 15:51 | bobo_ | ah, if i use [] instead of (do ) it works |
| 15:51 | technomancy | but yeah, in general a plugin is better unless the task would never useful for other projects. |
| 15:51 | cemerick | wooby: all of the major IDEs have excellent maven integration, so you could use clojure-maven-plugin and slip right into that. |
| 15:52 | rads | technomancy: in my case it's project specific. good to see that it's fixed now |
| 15:53 | Chousuke | bobo_: huh? so you need to return a seq of values? :/ |
| 15:53 | Chousuke | bobo_: that sounds weird |
| 15:53 | Chousuke | bobo_: unless session-assoc is really a true function and the return value protocol is just something funky :) |
| 15:54 | bobo_ | session-assoc is something in compojure |
| 15:54 | Chousuke | yeah |
| 15:54 | bobo_ | i think it does alter session in a transaction or something similar |
| 15:57 | bobo_ | hm, it is called by the http get, i guess that needs to recieve it. |
| 15:59 | Chousuke | bobo_: ah, no, I don't think it does that |
| 16:00 | Chousuke | bobo_: I found documentation that says (about the return values of handler functions) that if the return value is a vector, each value in the vector is used to update the response map |
| 16:01 | Chousuke | so session-assoc returns an updated session value, and the redirect yet more updates, and because they are returned in a vector, they get merged to the final response map |
| 16:01 | DeusExPikachu | anyone going to the talk in Reston, VA? |
| 16:01 | DeusExPikachu | tomorrow |
| 16:02 | LauJensen | On a positive note I did a talk yesterday which was announced less than 1 month ago, and about 30 people (only 1 with Clojure experience) showed up to learn about, so that was suprising |
| 16:03 | LauJensen | about+it |
| 16:03 | technomancy | http://p.hagelb.org/thomas.html <= new toy, enjoy. (test-coverage report in 25 lines, name is still tentative) |
| 16:04 | wthidden | anyone here use clojure to connect to dbus? |
| 16:04 | chouser | I have |
| 16:04 | chouser | it wasn't pretty |
| 16:04 | wthidden | any luck with removing a sig handler? |
| 16:04 | wthidden | once it was added? |
| 16:04 | chouser | hm ... I don't think I tried that. |
| 16:05 | DeusExPikachu | rhickey and Stu Halloway are supposed to be at the talk tomorrow |
| 16:05 | cemerick | technomancy: heh, that's great :-) |
| 16:05 | hiredman | cemerick: any blog posts for starting a project with the clojure maven plugin? |
| 16:05 | wthidden | i've been using the freedktop dbus java implementation. |
| 16:06 | wthidden | and most of the stuff works, except I can't remove a sig handler. |
| 16:06 | dnolen | technomancy: you generated that from emacs right? how did you do that? (also what color theme is that? very nice) |
| 16:06 | cemerick | hiredman: I keep getting that request :-) Maybe this week, depending on how much downtime I get while in NYC. |
| 16:07 | cemerick | hiredman: until then, the pom here is pretty straightforward: http://github.com/talios/clojure-maven-example |
| 16:07 | cemerick | There's a lot more in the config than is necessary to get started, tho. :-/ |
| 16:08 | cemerick | bleh, and the groupId and version isn't right for the plugin. A lot has changed since August. |
| 16:08 | cemerick | hiredman: so, I guess, nevermind that until I post something. |
| 16:08 | hiredman | happens |
| 16:09 | hiredman | I guess I should fine a maven blog post too |
| 16:09 | Licenser | evening hiredman :) |
| 16:10 | cemerick | hiredman: if you really, really want to understand what's going on, the book is the way to go. It's pretty straightforward to pick and choose the material to read as you go along. |
| 16:11 | hiredman | Licenser: hello |
| 16:11 | Licenser | :) |
| 16:11 | chouser | ok, so now ring is installing again. but ... the classpath to use it is going to be atrocious, isn't it. |
| 16:11 | cemerick | hiredman: that is, http://www.sonatype.com/products/maven/documentation/book-defguide |
| 16:11 | chouser | hm -- maybe I should build an uberjar and use that |
| 16:11 | cemerick | oh, and they've split it up now, that's nice |
| 16:11 | hiredman | right, this is the one that has the oreilly cover? |
| 16:12 | cemerick | hiredman: yeah, but the material has been improved significantly since that publishing. Looks like they're going through lulu now. |
| 16:13 | cemerick | it's all free online, in HTML or PDF *shrug* |
| 16:13 | hiredman | mmm pdf |
| 16:14 | bobo_ | Chousuke: ah, i think i understand then! |
| 16:14 | cemerick | hiredman: oh yeah, full-text-searching goodness. :-) |
| 16:15 | bobo_ | thanks alot |
| 16:28 | technomancy | dnolen: that's scpaste: http://p.hagelb.org |
| 16:29 | dnolen | technomancy: nice thx |
| 16:29 | technomancy | fn-level coverage isn't as interesting as branch-level, but it's a lot less invasive |
| 16:42 | defn | technomancy|away: i like the name "Thomas" |
| 16:42 | etate | hmm, i'm beginning to thread state through functions using maps, along functions that apply to those maps in a succession of "processing" functions, is this basically how monads work or am i confused? |
| 16:43 | defn | what's the old haskell monad joke? |
| 16:43 | defn | "Have you read *all* of the monad tutorials?" |
| 16:43 | defn | something along those lines |
| 16:43 | etate | lol |
| 16:43 | technomancy | defn: Thomas is from here: http://en.wikipedia.org/wiki/The_Protomen#Story |
| 16:43 | etate | i've just read a clojure monad tutorial, a lil |
| 16:44 | defn | technomancy: cool! |
| 16:44 | Chousuke | etate: monads can abstract away threading the state, yes. |
| 16:44 | technomancy | if I release it as Thomas, maybe the groupId will be thomas-light-phd |
| 16:45 | defn | technomancy: For some reason I find "dignified" sounding names make good project names for clojure |
| 16:45 | Chousuke | etate: if contrib monads are too much for you, you can write your own monad infrastructure just for those "stateful" functions. it's not difficult |
| 16:45 | technomancy | defn: generally I take my project names from literature, but I felt I could make an exception for the Protomen |
| 16:45 | defn | like "Terrence", "Thomas", "Frederick" |
| 16:45 | etate | Chousuke: but if you abstract away the state from this you just get 'let-monad' |
| 16:46 | etate | Chousuke: sure but are they necessary if let is essentially a monad anyway? |
| 16:46 | technomancy | I am still waiting to start a project awesome enough for me to name it Thursday: http://en.wikipedia.org/wiki/The_Man_Who_Was_Thursday |
| 16:46 | technomancy | perhaps it's vain of me to ever think I will. |
| 16:47 | LauJensen | Whats the fn which shows me where some other fn is defined? |
| 16:47 | Chousuke | etate: I'm not following |
| 16:47 | etate | LauJensen: M-. |
| 16:47 | hiredman | LauJensen: it's in the metadata on vars |
| 16:47 | defn | technomancy: technomancy :) |
| 16:47 | Chousuke | etate: let is a monad, but it's fixed in clojure. you can't change the monad it operates under |
| 16:47 | hiredman | ,(meta #'+) |
| 16:47 | clojurebot | {:ns #<Namespace clojure.core>, :name +, :file "clojure/core.clj", :line 676, :arglists ([] [x] [x y] [x y & more]), :inline-arities #{2}, :inline #<core$_PLUS___4516 clojure.core$_PLUS___4516@7acb6f>, :doc "Returns the sum of nums. (+) returns 0."} |
| 16:47 | LauJensen | woa, ERC just wnet nuts |
| 16:48 | etate | Chousuke: why would you want to change the monad under let? |
| 16:48 | Chousuke | hm, that's somewhat inaccurate |
| 16:48 | LauJensen | This was a question for #emacs :) |
| 16:48 | ska2342 | technomancy: beware, modern times may break your hinted reference: http://thursdaynext.com/ |
| 16:48 | defn | technomancy: ive always wanted to make a "braille" project, but one piece of the puzzle never works |
| 16:48 | Chousuke | etate: hm, I think this line of thinking will lead to a dead end |
| 16:49 | technomancy | ska2342: oh snap! I read the first of those books and it was fun, but not nearly as awesome as Chesterton's Thusday |
| 16:49 | etate | Chousuke: I'm just trying to work out how monads fit in clojure because its confusing :) |
| 16:49 | Chousuke | etate: so let's restart: basically, the way I see monads is that if something is monadic, it has certain composition behaviour |
| 16:49 | etate | Chousuke: like threading state & function through a let? |
| 16:50 | hiredman | that is almost the deffinition of a monad |
| 16:50 | ska2342 | techomancy: read the rest, it get weirder and weirder. I enjoyed it. But when I'm done writing my book I may consider reading the one you pointed out :-) |
| 16:50 | Chousuke | etate: functions are monadic, and their composition is simple. but operations under the maybe monad are composed differently |
| 16:50 | Chousuke | etate: and similarly, operations in the state monad are composed by threading the state through them |
| 16:51 | etate | Chousuke: oh i see, so the maybe monad has a different combinator? |
| 16:51 | hiredman | functions are monads with comp and identity |
| 16:51 | ska2342 | technomancy: whoa a new fforde came out and I managed to miss it til today?! |
| 16:51 | Chousuke | etate: the big thing with monads is realising that all kinds of composition can be expressed with a few generic functions, and the specific functions determine how operations are composed. |
| 16:52 | Chousuke | the specific implementations of those functions, I mean |
| 16:52 | etate | i think my mind just imploded |
| 16:53 | Chousuke | etate: to bend your mind even further, some operations are composable under different monads, yielding a different composite operation |
| 16:53 | hiredman | http://channel9.msdn.com/shows/Going+Deep/Brian-Beckman-Dont-fear-the-Monads/ this is a very nice video |
| 16:54 | etate | man, and there was I calling everything composite in the code |
| 16:56 | Chousuke | dnolen: if there are any two operations that you can't compose by simple function composition, monads might help you |
| 16:56 | etate | Chousuke: so a function would be a state monad if it took values and yielded a composite operation with a snapshot of immutable state? |
| 16:57 | hiredman | the video is good |
| 16:57 | hiredman | I haven't explicitly used a monad anywhere |
| 16:58 | Licenser | I only have sound here |
| 16:58 | hiredman | Licenser: you can download the video in various formats |
| 16:58 | Chousuke | etate: a value of a state monad is a function (state -> a). if you call it with a state, you get a plain value back |
| 16:58 | hiredman | mp4, wmv |
| 16:58 | Licenser | ahhha |
| 16:59 | serabe | hi |
| 16:59 | Licenser | I really started to love LISPish things |
| 17:00 | dnolen | Chousuke: I mean get that, but where is that useful in Clojure? |
| 17:01 | Licenser | aha I found it |
| 17:01 | etate | i'm starting to think clojure is just a set of monads :D |
| 17:01 | Chousuke | dnolen: that's a good question. I wrote a stateless monadic parser for some ascii codes as an exercise a while back. It made the code clearer because there was less boilerplate :) |
| 17:02 | hiredman | fnparse uses the monad stuff from contrib under the hood |
| 17:02 | Chousuke | dnolen: there's nothing you can't do without monads in clojure, but to say they're useless is just not giving the concept enough credit. |
| 17:03 | hiredman | dnolen: I think the main benefit is having clear composition |
| 17:03 | dnolen | Chousuke: no no. wasn't saying that. yes monads sound good for parsing. It's just that I don't see their utitlity in an impure functional PL like Clojure. |
| 17:03 | serabe | have a problem with proxy method and a JComponent, anybody could help, please? |
| 17:03 | dnolen | utility -> general utility |
| 17:04 | dnolen | Haskell needs em cause you can't write real damn program w/o them. |
| 17:04 | Chousuke | dnolen: for example, suppose you're writing a game that has AI agents that can perform actions. but if they wish to perform two actions in a row, some intermediate code is needed as "plumbing" to combine the actions. It sound monadic to me |
| 17:04 | spreadsheet | Hi Chousuke |
| 17:04 | hiredman | dnolen: that is a big use in haskell, but really monads are about controling composition |
| 17:05 | hiredman | in the case of the IO monad controling the composition of IO operations to perserve order |
| 17:17 | defn | i really wish there was some documentation for compojure |
| 17:17 | defn | like...actual documentation as opposed to dated blog posts and WIP documentation |
| 17:18 | defn | conjure has an absolutely stunning amount of documentation |
| 17:18 | defn | but it's not quite what i was looking for |
| 17:19 | hiredman | compojure is still changing rapidly |
| 17:19 | hiredman | well, relatively rapidly |
| 17:19 | defn | *nod* i suppose that'd be silly to document, only to redo it every few weeks |
| 17:19 | defn | still, would be nice |
| 17:20 | hiredman | yes, I think your best bet is #compojure + the mailing list |
| 17:20 | dnolen | defn: well, it is versioned it would be nice if there was documentation at least for 0.3.2. after 0.4 compojure looks like it will probably settle down since it's attacking a very limited "surface area" now. |
| 17:21 | defn | dnolen: good point |
| 17:22 | dnolen | defn: the main thing to realize is that compojure hardly does anything. minimal is an understatement. |
| 17:22 | dnolen | which is nice. |
| 17:22 | chouser | and yet ... compojure is built on ring, and I'm using a subset of ring's features... |
| 17:30 | alexyk | I want to keep outputting strings to a text file, is duck streams the thing to use? when do you NOT want to use them? |
| 17:33 | dnolen | alexyk: duck streams is definitely one way to do it. |
| 17:33 | alexyk | dnolen: btw loved your Enlive tutorial. Am going through it. |
| 17:35 | dnolen | alexyk: glad to hear it! I'm just the messenger. props to cgrand mostly. |
| 17:35 | alexyk | dnolen: so, is Enlive a stand-alone thing, or does it use Compojure in any way? |
| 17:36 | dnolen | alexky: completely stand alone. Christophe Grand wrote it, http://github.com/cgrand/enlive |
| 17:38 | alexyk | dnolen: can you create fast static pages in Enlive, or is it always populated from a database or something? How can you run it on a high-traffic site, if at all? |
| 17:39 | dnolen | alexky: I've done some unscientific tests and it's seems performant compared to other popularing templating engines. I imagine for heavily trafficked you'll need some kind of caching strategy as usual. |
| 17:39 | remleduff | Isn't enlive often or usually used on top of compojure though? |
| 17:41 | dnolen | remleduff: you can use it to transform un-namespaced XML as well. I know cgrand is thinking about adding xml namespace support at some point. I used it to manipulate Amazon Web Service results, it was great for that. |
| 17:42 | alexyk | so I want to run a simple site with mostly static tables, think puzzles, and results kept in postgres. Can enlive do that? Do I run it stand-alone, in Apache, Tomcat, or what? |
| 17:43 | hiredman | enlive doesn't serve html |
| 17:43 | dakrone | hmm, if I pass a clojure-vector into a java function that takes a Java Vector, will it be able to coerce it without a problem? |
| 17:43 | hiredman | :( |
| 17:43 | hiredman | no |
| 17:43 | hiredman | java Vectors are old and horrible and not to be used |
| 17:43 | dakrone | not my library, I'll have to create one first then |
| 17:43 | hiredman | no connection to the clojure vectors |
| 17:44 | hiredman | dakrone: I think java's Vector was retrofited with Collections stuff |
| 17:44 | dakrone | yea |
| 17:44 | hiredman | ,(import 'java.util.Vector) |
| 17:44 | clojurebot | java.util.Vector |
| 17:44 | hiredman | ,(Vector. [1 2 3]) |
| 17:44 | clojurebot | #<Vector [1, 2, 3]> |
| 17:45 | dakrone | excellent. that saves me a lot of trouble, thanks hiredman |
| 17:45 | alexyk | so my bubble is burst. Is there a PHP-replacement in Clojure serving static or slightly dynamic HTML? |
| 17:45 | rfg | Hello all |
| 17:45 | hiredman | alexyk: you would have to use enlive together with something like compojure |
| 17:45 | dnolen | alexyk: Why not just use compojure? Compojure can serve static pages, you can use Enlive for dynamic pages. |
| 17:46 | dnolen | Jetty has good perf from what I've heard. |
| 17:46 | hiredman | the other option would be to generate your pages batch style |
| 17:46 | hiredman | and just serve using apache |
| 17:46 | eevar | hiredman, nginx you mean? :p |
| 17:47 | dnolen | or Apache plus proxy to Compojure. A lots of ways to handle this. |
| 17:47 | hiredman | eevar: whichever |
| 17:47 | alexyk | ok I'm confused. If enlive doesn't serve HTML, who will? |
| 17:48 | dnolen | alexyk: your webserver, (Apache, nginx, Compojure, etc.) |
| 17:48 | hiredman | compojure isn't actually a webserver |
| 17:48 | hiredman | but it comes with jetty |
| 17:48 | dnolen | ^ what he said. |
| 17:52 | seths | xor what he said? |
| 17:52 | seths | :-P |
| 17:53 | hiredman | ↑ nand. |
| 17:53 | alexyk | is ring another web framework? |
| 17:53 | eevar | there's also conjure or something along those lines |
| 17:54 | dnolen | alexyk: Ring is kind of the plumbing for Compojure. Compojure adds a Rails like route syntax and a couple of other things. |
| 17:55 | alexyk | ok |
| 17:55 | hiredman | ring is like a monad for composing web frameworks |
| 17:56 | eevar | http://github.com/mmcgrana/ring/blob/master/SPEC |
| 17:56 | alexyk | hiredman: love the monad description |
| 17:57 | eevar | hmm.. that link wasn't very descriptive, i guess ;) |
| 17:57 | alexyk | eevar: good too! :) |
| 17:57 | alexyk | later |
| 18:44 | powr-toc | Is there a reason that (apply str nested-lazy-seqs) doesn't realise the whole collection? Instead I just get clojure.lang.LazySeq@1d1f81Aclojure.lang.LazySeq@0 |
| 18:45 | powr-toc | or rather, how can I idiomatically force the above sequence? |
| 18:46 | The-Kenny | powr-toc: Maybe (apply str (flatten coll)) |
| 18:47 | The-Kenny | ,(str (map identity [1 2 3 4])) |
| 18:47 | clojurebot | "clojure.lang.LazySeq@e93c3" |
| 18:47 | The-Kenny | ,(apply str (map identity [1 2 3 4])) |
| 18:47 | clojurebot | "1234" |
| 18:47 | powr-toc | The-Kenny: yeah, that's actually what I had.. but I'm trying to remove the need to flatten... |
| 18:47 | powr-toc | I might just try consing all the seq's into one... rather than nesting them |
| 18:47 | The-Kenny | powr-toc: Maybe recursively applying str? |
| 18:51 | Licenser | powr-toc: how about using prn? |
| 18:54 | Licenser | , (pr-str (map identity [1 2 3 4])) |
| 18:54 | clojurebot | "(1 2 3 4)" |
| 19:25 | seths | ,clojure.contrib.repl-utils/*feeling-lucky* |
| 19:25 | clojurebot | java.lang.ClassNotFoundException: clojure.contrib.repl-utils |
| 19:26 | hiredman | the json file clojurebot pulls contrib docstrings and such out of is broken |
| 19:28 | powr-toc | How would you describe inferior-lisp/slime-style interactive development... as opposed to just a REPL? |
| 19:28 | powr-toc | I mean, what do you guys refer to it as? It feels like it should have a name, as it's such a big productivity win over a plain REPL |
| 19:30 | seths | hiredman: *feeling-lucky* doesn't have a docstring unfortunately |
| 19:31 | seths | and I'm just mystified. There is also feeling-lucky-url |
| 19:33 | hiredman | seths: did you try grepping the source? |
| 19:34 | hiredman | are you just looking for where it comes form? |
| 19:34 | hiredman | from |
| 19:34 | seths | hiredman: sorry, lost connection |
| 19:34 | hiredman | are you just looking for where it comes form? |
| 19:35 | seths | hiredman: nah, I was just curious if it was a serious thing, and if so what it was good for. |
| 19:36 | hiredman | seths: I believe the javadoc namespace uses it for googling for javadocs |
| 19:36 | seths | hiredman: awesome, thanks |
| 20:16 | leifw | rfg is self-referential, and so am me? |
| 21:46 | psykotic | the default Object.hashCode() hashes on the pointer, right? is there a way to call that version on an object even if the object's class has implemented its own hashCode? |
| 21:46 | psykotic | i would like to use this for conservative memoization. |
| 21:48 | jah_ | too weird ... this evaluates to 2, any ideas why? ----> (.length (String. (into-array Byte/TYPE (map byte [-1, -2, 1])))) |
| 21:49 | psykotic | jah: unicode |
| 21:49 | hiredman | jah_: .length on strin is a character count not a byte count |
| 21:51 | jah_ | ah, ok |
| 21:51 | psykotic | ah, i found it. System.identityHashCode(x) |
| 21:53 | jah_ | hmm .. still not sure I understand |
| 21:53 | psykotic | jah: what are you trying to do? |
| 21:53 | psykotic | do you want to decode an ascii string into a String? |
| 21:54 | psykotic | (incidentally, standard ascii only uses the first 7 bits, so values like -1 and -2 would be out of range) |
| 21:54 | jah_ | byte b[] = new {-1. -2, 1}; System.out.println(new String(b).length()) gives me 3 |
| 21:55 | jah_ | i need to send 0xff 0xfe 0x01 as consecutive bytes to an output stream |
| 21:55 | hiredman | actually, it says 3 here |
| 21:55 | psykotic | jah: in that case, don't put them in a string first. |
| 21:56 | psykotic | jah: write the bytes directly. |
| 21:56 | psykotic | a string is not a byte container. like hiredman said, it's a character container. |
| 21:57 | psykotic | OutputStream's write() functions are all byte-based |
| 21:58 | jah_ | trying now ... |
| 22:16 | rfg | I like kotarak's parenthesis highlighting: http://kotka.de/blog/2010/03/memoize_done_right.html |
| 22:17 | hiredman | rfg: rainbow parens |
| 22:17 | rfg | Aye |
| 22:18 | hiredman | vimclojure comes with it, and you can find an emacs mode for it |
| 22:18 | rfg | I've just setup highlight-parentheses on emacs to do rainbow except that only highlights expressions containing the current cursor position. |
| 22:19 | Raynes | With horrible colors to boot. |
| 22:19 | Raynes | I wish I knew how to change them, but I'm too lazy to find out. |
| 22:20 | rfg | hiredman, do you know of an emacs mode that render all the parens like the vim mode? |
| 22:22 | hiredman | rfg: yes, it's called rainbow-pare-mode |
| 22:23 | psykotic | there's also a mode that visualizes the block nesting with different hues of background/foreground color, etc |
| 22:23 | psykotic | all of these seem to me more flashy than useful or comfortable |
| 22:23 | hiredman | I love rainbow parens |
| 22:24 | psykotic | really? do you find it genuinely useful? |
| 22:24 | hiredman | yes |
| 22:24 | hiredman | to be able to visually match up parens |
| 22:25 | hiredman | "this is a whole top level form, I can tell because that paren is red and there is the closing red paren there" |
| 22:25 | psykotic | indentation does that for me |
| 22:25 | Raynes | You indent after every paren? |
| 22:25 | hiredman | well sure, but when you start reading other people's code |
| 22:26 | psykotic | Raynes: i referred to his example |
| 22:27 | JonSmith | i do thatwith paren match highlighting |
| 22:27 | hiredman | but rainbow parens works without have to move your cursor over every line |
| 22:27 | JonSmith | rainbow is probably prettier though :-) |
| 22:27 | psykotic | yeah, paren match is useful when i'm writing code |
| 22:27 | psykotic | once it's written, i just go by indentation to identify structure |
| 22:28 | psykotic | another aesthetic issue is that with the amount of paren nesting in lisp, it's hard to find enough colors that are both easily distinguished but not repulsive in combination :) |
| 22:29 | rfg | psykotic, one could argue that you've gone too deep and you need to separate the code out. |
| 22:29 | JonSmith | clearly you need both :-) |
| 22:30 | psykotic | 6 levels is common in shallow functions |
| 22:30 | JonSmith | also need meta-paren |
| 22:30 | psykotic | btw, http://www.lemonodor.com/archives/001207.html |
| 22:30 | psykotic | i guess you know this post |
| 22:31 | rfg | Aye |
| 22:31 | JonSmith | nobody using pastel colors gets an A? |
| 22:32 | psykotic | haha |
| 22:32 | psykotic | NO SOUP FOR YOU! |
| 22:32 | psykotic | he complains about the pastels and then he calls michaelw's color theme "techy but cold". |
| 22:33 | psykotic | maybe what he wants is disco inferno. |
| 22:38 | JonSmith | I really want my clojure code to be 3-d |
| 22:38 | rfg | JonSmith, heh I was thinking the same thing, weird. |
| 22:39 | psykotic | don't forget the cybergloves |
| 22:39 | JonSmith | well its just the next step after 2-d, right? |
| 22:39 | JonSmith | we've been stuck in 2-d for the duration of coding for the most part |
| 22:39 | JonSmith | 50-60 years |
| 22:39 | rfg | JonSmith, no we're skipping right to 4D. |
| 22:39 | psykotic | i remember all the games following the initial wave of low-end 3d games that were called 4D <whatever> |
| 22:40 | psykotic | like 4D boxing |
| 22:40 | JonSmith | hahaha |
| 22:40 | JonSmith | you can smell the code |
| 22:40 | psykotic | i guess time counts if it animates |
| 22:40 | psykotic | smellocode |
| 22:40 | rfg | Syntax highlighting could be considered 3D. |
| 22:40 | psykotic | i bet there's an RFC for olfactory generators you can program against with emacs |
| 22:41 | rfg | "I'm a paren off, that one's elderberry when it should be apple" |
| 22:42 | psykotic | that would have the same problem of needing to determine too many problems for all the scents to be distinguishable yet pleasant |
| 22:42 | psykotic | or maybe that's a way of encouraging .... |
| 22:42 | psykotic | good code smells |
| 22:42 | rfg | heh |
| 22:42 | psykotic | as you go deeper, it starts to smell more rotten |
| 22:42 | JonSmith | as it gets more difficult to understand |
| 22:43 | psykotic | s/too many problems/too many levels/ |
| 22:43 | psykotic | yeah, durian kicks in at level 8 |
| 22:43 | rfg | psykotic, that is actually a great idea. |
| 22:45 | psykotic | rfg: i'm off filing patents as we speak. this is the wave of the future for IDEs. |
| 22:45 | rfg | http://en.wikipedia.org/wiki/File:Nasal_Ranger.JPG |
| 22:46 | JonSmith | oh man |
| 22:46 | psykotic | haha |
| 22:46 | psykotic | i think he just caught a fart |
| 22:46 | JonSmith | oh man, we better start writing code to invalidate your patents with prior art |
| 22:47 | JonSmith | the smellternet could be the next thing in computing |
| 22:47 | pdk | how do you troll on the smellternet |
| 22:47 | psykotic | for too long, friends, have computers been cold and digital |
| 22:47 | rfg | pdk, with great ease. |
| 22:48 | dnolen | hmm how do you html encode unicode characters in Java? |
| 22:48 | mebaran151 | does anybody here use lein.bat for Windows: I'm getting an odd error about RestFn class |
| 22:49 | hiredman | clojurebot: clojure.lang.RestFn |
| 22:49 | clojurebot | ant clean and rebuild contrib |
| 22:49 | mebaran151 | do lein need contrib? |
| 22:49 | psykotic | dnolen: http://commons.apache.org/lang/api-release/org/apache/commons/lang/StringEscapeUtils.html |
| 22:49 | hiredman | the RestFn means you have a clojure/contrib mismatch |
| 22:49 | psykotic | dnolen: i don't think it's built in (i looked before) |
| 22:50 | dnolen | lame |
| 22:50 | psykotic | actually, there might be a way but it's probably insane |
| 22:50 | mebaran151 | ah alright |
| 22:50 | hiredman | ,(reduce (fn [s [[n h]] (.replaceAll s n h)) "foo>" {">" "<"}) |
| 22:50 | clojurebot | Unmatched delimiter: ) |
| 22:50 | psykotic | something involving container an xml document placeholder ) |
| 22:51 | hiredman | ,(reduce (fn [s [n h]] (.replaceAll s n h)) "foo>" {">" "<"}) |
| 22:51 | clojurebot | "foo<" |
| 22:51 | mebaran151 | oh sweet, I found a different jar from clojurebox, and now everything is working |
| 22:51 | mebaran151 | I have the most functional windows codigin environment I've seen in a while |
| 22:52 | dnolen | I need to encode ´and ˜ |
| 22:52 | mebaran151 | this is the one time I'm glad Emacs is dang monolithic: it actually works decently well in Windows |
| 22:52 | dnolen | luckily some wise soul put org.apache.commons.lang on clojars |
| 22:53 | rfg | mebaran151, yeah it's pretty solid. |
| 22:53 | mebaran151 | can I get clojure highlight in the slime repl |
| 22:53 | mebaran151 | *highlighting |
| 22:53 | psykotic | dnolen: btw you can always pull from maven central too. |
| 22:53 | psykotic | it's a default source for lein. |
| 22:55 | dnolen | yes! man it's so much easier to get things done now than 1 1/2 years :) |
| 22:56 | dnolen | 5 minute turn around from question, to lib acquisition, to working code. |
| 22:57 | psykotic | btw in the java world is there a standard for distributing source code with jars? |
| 22:57 | psykotic | (alongside the classes) |
| 23:07 | rfg | mebaran151, not sure about that. If you find out let me know. |
| 23:37 | psykotic | if anyone's looking for a fun elisp project for a few hours--a command that searches clojars.com and mvnrepository.com, gives a sorted list of candidates, and when a candidate is clicked, it inserts the lein [group/project "1.2.3"] at point |
| 23:37 | psykotic | i'll probably end up doing it myself |
| 23:39 | rfg | I would, but...you know. |
| 23:41 | psykotic | :) |
| 23:42 | rfg | 5 points for anyone guessing what I'm referencing. |