2011-10-02
| 00:00 | amalloy | you are never going to get that from clojure |
| 00:00 | Arafangion | amalloy: I find that hard to believe. |
| 00:01 | amalloy | it is a hosted language, and C isn't really a "host" so much as "someone who, if you're polite, won't murder you" |
| 00:01 | jli | haha |
| 00:01 | amalloy | and java lacks the capability to talk to hardware except through native libraries which have to be written in C (or something else native) anyway |
| 00:01 | Arafangion | amalloy: I'm very comfortable with such bindings. |
| 00:02 | Arafangion | amalloy: As comfortable as one can be, anyway... |
| 00:02 | S11001001 | Arafangion: why not require mono on mac? |
| 00:02 | Arafangion | S11001001: It's a large, unusual download. |
| 00:02 | amalloy | great, then deploy your clojure app with the jvm or .net dependency and your native libraries |
| 00:02 | ibdknox | fwiw |
| 00:02 | Arafangion | On windows I use .net, so that's fine there. |
| 00:02 | ibdknox | I think there are at most a handful of people doing gui's in clojure |
| 00:03 | Arafangion | Oh, I'm not doing the gui in this! |
| 00:03 | Arafangion | I'm doing the GUI natively on each platform. (For better or for worse) |
| 00:03 | amalloy | nobody will ever write a clojure->C compiler because clojure depends on the host to do all kinds of things that C just doesn't do. if you wrote such a thing, it wouldn't be at all like clojure by the time you were done |
| 00:04 | Arafangion | amalloy: How so? |
| 00:04 | amalloy | (or, you would realize that what you wrote turned out to be the jvm) |
| 00:04 | Arafangion | amalloy: Actually, I suspect that what the 'C target' ends up writing could well be a javascript host. |
| 00:05 | amalloy | memory management, for example |
| 00:05 | miwillhite | hey all…what are people using for clojure and mysql? |
| 00:05 | Arafangion | memory management is a minor point. |
| 00:07 | ibdknox | miwillhite: you have a few options: clojureql, clj-record, or writing against clojure.java.jdbc |
| 00:07 | S11001001 | Arafangion: you might consider common lisp or scheme; some implementations have great C binding support and compile to standalone binaries |
| 00:08 | jli | Arafangion: hm, what do you mean it's a minor point? |
| 00:08 | ibdknox | haha, could you imagine clojure with explicit memory management? *shudders* |
| 00:08 | amalloy | (inc S11001001) |
| 00:08 | lazybot | ⟹ 2 |
| 00:09 | amalloy | ibdknox: i actually read about a lisp someone had written without garbage collection |
| 00:09 | miwillhite | thanks ibdknox |
| 00:10 | S11001001 | you can still turn off the gc in some lisps |
| 00:10 | Arafangion | ibdknox: There are a number of ways to manage memory in C, including adding a garbage collector. |
| 00:10 | S11001001 | then it's your fault if you don't turn it back on :) |
| 00:10 | ibdknox | haha |
| 00:10 | Arafangion | The best non-GC way of managing memory I've seen is probably that with the ObjC legacy runtime, but ugh, it still falls massively short of true GC. |
| 00:10 | ibdknox | Arafangion: I really hope you do use Clojure, but based on what you've described so far, I don't think Clojure is currently the right tool to solve your problem |
| 00:10 | Arafangion | NSAutoreleasePools are awesome. |
| 00:11 | jli | Arafangion: I wonder if trying to use clojure for your problem is really the best solution :( |
| 00:11 | Arafangion | ibdknox: Actually, it's not the right tool - I'm mostly exploring and learning for my own education. |
| 00:11 | jli | haha |
| 00:11 | ibdknox | Arafangion: party on then :D |
| 00:11 | amalloy | but yes. lisp was the first language do to a lot of things, including garbage collection. there's a reason this is the case, and also a reason why gc is the lisp-innovation most commonly used by mainstream languages |
| 00:11 | Arafangion | The rest of the people I'm working with are still learning Python, pushing yet *another* language isn't going to work. :( |
| 00:13 | ibdknox | lol |
| 00:13 | ibdknox | especially one this different |
| 00:14 | Arafangion | I'm basically the languages geek, it seems. :( |
| 00:14 | Arafangion | Despite never using erlang, or haskell. (Both are on my TODO list!) |
| 00:14 | jli | Arafangion: what's the program, if you can discuss any more detail? |
| 00:15 | Arafangion | jli: I can't really discuss, and it's not really relevant save that it requires the GUI to be written in the native toolkit (whatever that means), and that it interacts with hardware. |
| 00:16 | jli | Arafangion: what does interacting with hardware entail? |
| 00:16 | Arafangion | jli: From my perspective, it entails interacting with a C++ library. |
| 00:16 | srid | in enlive, can I select all <p> nodes that come after a <h2> node? |
| 00:17 | Arafangion | jli: Which I tend to handle by wrapping it, badly, into a more convenient library. |
| 00:18 | amalloy | $google java compute md5 |
| 00:18 | lazybot | [Java simple class to compute MD5 hash] http://www.anyexample.com/programming/java/java_simple_class_to_compute_md5_hash.xml |
| 00:18 | amalloy | ugh. someone have a link to a real library? |
| 00:18 | Arafangion | http://stackoverflow.com/questions/415953/generate-md5-hash-in-java |
| 00:19 | Arafangion | amalloy: Despite SO's poor reputation on this network, they are remarkably good at answering dumb questions. :) |
| 00:19 | ibdknox | amalloy: it's relatively simple with MessageDigest |
| 00:19 | jli | srid: you mean the equivalent of the CSS selector "h2 + p" ? |
| 00:19 | srid | jli: yup |
| 00:19 | jli | should be. let's see. |
| 00:19 | srid | enlive docs are sadly insufficient |
| 00:19 | srid | http://enlive.cgrand.net/syntax.html is terrible to understand for humans |
| 00:20 | ibdknox | srid: https://github.com/marick/enlive-tutorial |
| 00:20 | ibdknox | srid: https://github.com/swannodette/enlive-tutorial |
| 00:20 | ibdknox | muuuuuch better intros |
| 00:20 | srid | i read them |
| 00:21 | amalloy | ah, excellent. i'm already depending on commons-codec for base64; i might as well use their md5 |
| 00:21 | jli | srid: seems like there's no "+" in enlive, but you could just use seq processing I think |
| 00:21 | ibdknox | I don't think you need + |
| 00:22 | ibdknox | :h2 :p should work? |
| 00:22 | Arafangion | What kind of lisp is Clojure? Is it feasible to write "lisp code" that happens to be run by different lisp implementations? (Eg, Clojure, ChickenScheme, etcetera) |
| 00:22 | jli | ibdknox: wouldn't that only match <p>'s inside <h2>'s? |
| 00:22 | khaliG | ibdknox, curious, why are there only a handful? |
| 00:23 | srid | jli: seq processing? you mean tree processing? what is the simplest way to select <p>'s that come after the <h2>? |
| 00:23 | ibdknox | jli: oh, whoops, it helps if I read what he wants |
| 00:23 | jli | :) |
| 00:23 | scottj | Arafangion: any clojure code more than a simple like (+ 2 2) isn't going to run on scheme w/o changes |
| 00:23 | ibdknox | khaliG: swing sucks, and I don't know that Clojure makes it particularly easy to write GUI code |
| 00:24 | amalloy | Arafangion: clojure picked different keywords for a lot of the low-level primitives, so there will be issues with a "direct transplant" even on the most common lisps |
| 00:24 | amalloy | eg, fn instead of lambda |
| 00:25 | amalloy | def and defn instead of define or defun |
| 00:25 | ibdknox | makes things so much easier to read |
| 00:25 | Arafangion | amalloy: That sucks - but I suppose that is a minor point? The more serious concern is probably the object system? |
| 00:25 | khaliG | ibdknox, hmm i think it does - miglayout + swing + clojure is pretty nice if you ask me as far as lisps go. Then again, I haven't tried for example lispworks CAPI so that might be better |
| 00:26 | amalloy | *shrug* the host interop, the standard libraries, the data types... |
| 00:26 | jli | Arafangion: I think it'd be a headache to try to compile clojure to another lisp |
| 00:26 | Arafangion | jli: What about compiling "another lisp" to clojure? |
| 00:26 | amalloy | livingstone was writing a scheme->clojure translator to help him learn clojure |
| 00:27 | jli | scheme is easy though :) |
| 00:27 | amalloy | don't know how that turned out |
| 00:27 | Arafangion | jli: Yeah, infact, scheme is the lisp I'm thinking of. |
| 00:27 | amalloy | jli: it's the most similar, i think, but there are plenty of pitfalls |
| 00:27 | jli | well, maybe modulo continuations |
| 00:27 | Arafangion | Business logic isn't exactly that damanding. |
| 00:27 | Arafangion | *demanding |
| 00:27 | khaliG | Arafangion, btw CAPI might be a good fit for your problem (native look and feel GUI on different platforms) |
| 00:28 | amalloy | continuations, tail calls, reified environments, "real" cons cells... |
| 00:28 | Arafangion | khaliG: The GUI isn't that difficult to do on the native platforms, honestly. |
| 00:28 | jli | amalloy: yeah. hmm, I wonder how macro -> macro compilation would work out. seems hairy. |
| 00:28 | Arafangion | khaliG: Modern toolkits more or less let you just click-click-click and you have the UI done. |
| 00:29 | jli | Arafangion: the GUIs can self-replicate now? it is truly the end of days |
| 00:29 | Arafangion | jli: Consider - it's also a good way to ensure separation of UI from business logic. |
| 00:30 | srid | jli: (drop-while #(= :p (:tag %)) (select dom [#{:h2 :p}])) does it. |
| 00:30 | khaliG | btw offtopic question perhaps - but what are some warm and fuzzy things about using the JVM for you guys? |
| 00:30 | srid | thanks to 4clojure, i didn't reinvent drop-while |
| 00:31 | miwillhite | exit |
| 00:31 | scottj | khaliG: very few bugs in my experience compared to common lisp and smalltalk environments I've used. |
| 00:31 | Arafangion | khaliG: It's generally easy to use anywhere, except perhaps, most smartphones. |
| 00:32 | S11001001 | khaliG: it made our language of choice sound enterprisey when akamai bought us :) |
| 00:33 | jli | srid: it seems like that would select all <p>'s? |
| 00:34 | amalloy | srid: fwiw, (comp #{:p} :tag) is a prettier way to write #(= :p (:tag %)) |
| 00:34 | khaliG | scottj, true, it's easy to take the extensive work that has gone into the JVM for granted but it's quite impressive if you reflect on it! S11001001 nice! :) |
| 00:34 | srid | jli: yes, but only those that come after <h2> |
| 00:34 | srid | amalloy: thanks |
| 00:35 | srid | i tend to forget the comp way of doing things |
| 00:35 | jli | amalloy is just a comp fanboy |
| 00:35 | jli | :) |
| 00:35 | amalloy | in a fight between comp and juxt, on the MOON, who would win? |
| 00:35 | srid | ,(doc juxt) |
| 00:35 | clojurebot | "([f] [f g] [f g h] [f g h & fs]); Alpha - name subject to change. Takes a set of functions and returns a fn that is the juxtaposition of those fns. The returned fn takes a variable number of args, and returns a vector containing the result of applying each fn to the args (left-to-right). ((juxt a b c) x) => [(a x) (b x) (c x)]" |
| 00:35 | jli | srid: hm, I thought #{:h2 :p} would match all h2 and p elements, without regard for ordering. |
| 00:36 | jli | amalloy: juxt |
| 00:36 | khaliG | yea i follow amalloy on 4clojure and noticed his use of comp a few times.. made me use it myself since :P |
| 00:36 | srid | jli: seems like the ordering is top to bottom (no nested <p>'s in the HTML here) |
| 00:36 | amalloy | jli: i know, it's a no-brainer. i just put it out there so i could /ignore anyone who thinks comp would win |
| 00:37 | jli | my 4clojure solutions have a hideous amount of partial, apply, comp, and generally pointlessness. just getting it out of my system, I hope. |
| 00:37 | amalloy | jli: he's getting a list of all the h2s and ps; then he throws them away until he gets an h2 |
| 00:37 | khaliG | jli, i think that's the point, to learn the language better imho |
| 00:39 | jli | amalloy: oh, I see now. srid: so there's only 1 h2? |
| 00:40 | srid | jli: yes. |
| 00:40 | srid | this webpage was created in frontpage |
| 00:40 | srid | i'm trying to convert it to to epub for reading on the phone |
| 00:41 | srid | specifically - Microsoft FrontPage 4.0 |
| 00:41 | brehaut | srid: thats what, Mesozoic? |
| 00:41 | brehaut | or cretaceous. i never can remember |
| 00:41 | srid | late 1990's I think |
| 00:42 | Arafangion | Ancient! I was 5! |
| 00:42 | Arafangion | (And still learning to talk) |
| 00:43 | amalloy | so was frontpage |
| 00:43 | Arafangion | That's depressing. |
| 00:43 | ibdknox | that was back when frontpage would overwrite any html changes you made |
| 00:43 | Arafangion | Maybe that was why my speech was delayed. |
| 00:45 | scb | anybody doing anything serious on the web using clojure? |
| 00:45 | amalloy | www.4clojure.com |
| 00:45 | amalloy | for certain values of "serious" |
| 00:46 | jli | is there anything that does this? https://gist.github.com/1257064 |
| 00:46 | jli | basically, partition but overlapping groups |
| 00:46 | amalloy | &(partition 3 1 (range 1 9)) |
| 00:46 | lazybot | ⇒ ((1 2 3) (2 3 4) (3 4 5) (4 5 6) (5 6 7) (6 7 8)) |
| 00:46 | jli | oh, darn. |
| 00:47 | jli | haha |
| 00:47 | cark | =) |
| 00:48 | srid | how this made any more concise? |
| 00:48 | srid | (filter #(not (empty? (select % [:span :a :> text-node]))) nodes) |
| 00:48 | jli | srid: anyway. so, you could also use partition. (filter #(= (:tag (first %)) :h2) (partition 2 1 dom)) |
| 00:49 | jli | I think at least. |
| 00:49 | jli | that would get you all (h2, p) pairs |
| 00:49 | amalloy | srid: (filter seq (...))? |
| 00:49 | scottj | srid: filter not is remove |
| 00:50 | amalloy | scottj: and empty is not seq... |
| 00:50 | S11001001 | Arafangion: so you mean like bigloo, which compiles to C, java, and .net? |
| 00:50 | srid | filter seq works for enlive returning () |
| 00:50 | Arafangion | S11001001: Yes. |
| 00:50 | srid | my filter must always return one result. |
| 00:50 | srid | i wish there was something like pick-first |
| 00:51 | jli | srid: I think some contrib library defines filter-first |
| 00:51 | jli | srid: I find myself using destructing for this a lot. (let [[result1] (filter ...)] ...) |
| 00:51 | Arafangion | S11001001: Although bigloo gives me low confidence, I'd trust 'C# generation' more than 'Experimental bytecode generation'. |
| 00:53 | Arafangion | Hmm, also, #bigloo is practically empty. |
| 00:53 | srid | ok, in actuality it turns out that i don't need filter |
| 00:53 | srid | (take-while #(not (seq (select % [:span :a :> text-node]))) (drop-while (comp #{:p} :tag) (select x [#{:h2 :p}]))) |
| 00:53 | S11001001 | a moment ago, you were considering starting your own such project, Arafangion |
| 00:53 | srid | that gets all paras after <h2> but stops at the para with a <span><a> link (which is the footer) |
| 00:53 | srid | this becomes a chapter in epub |
| 00:54 | Arafangion | S11001001: Considering, yes, but I'm not planning on actually using it professionally. |
| 00:54 | Arafangion | S11001001: Because the rest of the team would probably move to get me fired. ;) |
| 00:55 | S11001001 | as I understand, you only are interested in the C part though |
| 00:55 | Arafangion | C is one of my targets. |
| 00:55 | Arafangion | ObjC and .NET are my primary targets. |
| 00:56 | ibdknox | I target awesome. |
| 00:56 | ibdknox | *rimshot* |
| 00:56 | scb | ibdknox: how ready do you think clojure is for the web? Like in comparisson to other solutions like Django, Rails, Lift, ..., that seem to come with batteries included? I mean I have been using Clojure for a while but I am still not decided whether to pursue working with it on webapps. |
| 00:57 | jli | scb: you should probably just do it :) |
| 00:57 | brehaut | is there any point specifically targeting objc? doesn't it all come down to c + objcMsgSend anyway |
| 00:57 | ibdknox | brehaut: he likely means cocoa :) |
| 00:58 | scb | jli: you think? |
| 00:58 | ibdknox | scb: yeah, I'd say just try it: http://www.webnoir.org |
| 00:58 | Arafangion | There are a lot of nice things provided by Cocoa. |
| 00:58 | brehaut | ibdknox: not that you have an oar in the game :P |
| 00:58 | ibdknox | not at all! |
| 00:58 | ibdknox | :D |
| 00:58 | S11001001 | I believe the gnustep people put a message-sending thing in guile |
| 00:58 | brehaut | scb: clojure's web story is very compelling |
| 00:58 | scb | ibdknox: just when i thought that compojure was the way to go... |
| 00:58 | scb | brehaut: is it? how so? |
| 00:59 | ibdknox | it's beautifully succinct |
| 00:59 | brehaut | scb: toot toot http://brehaut.net/blog/2011/ring_introduction |
| 01:00 | brehaut | (does not include any noir stuff; sorry chris) |
| 01:00 | ibdknox | ! |
| 01:00 | brehaut | ibdknox: noir was either very new or not on my radar when i wrote that. its had already gotten way out of control :P |
| 01:01 | S11001001 | I hope clojure is ready for the web |
| 01:01 | ibdknox | brehaut: haha :) |
| 01:01 | ibdknox | S11001001: it is |
| 01:01 | brehaut | ibdknox: would you believe i cut stuff from that blog? |
| 01:01 | ibdknox | lol |
| 01:01 | scb | Well, heh, this is arguably the most biased place to ask :) |
| 01:01 | ibdknox | it's a great post |
| 01:02 | scottj | scb: according to state of clojure survey 62% of clojurians are using it for web dev |
| 01:02 | brehaut | scb: i do django for a day job. django is great, but its also very 2005 |
| 01:02 | brehaut | ibdknox: thanks |
| 01:02 | ibdknox | scb: I've done web dev in all the common languages |
| 01:02 | ibdknox | scb: I may be biased, but that's because I know from experience that Clojure is beautiful |
| 01:03 | brehaut | scb: in terms of breadth closures web ecosystem is not as complete as python or ruby frinstance, but the tools that are there of a very high quality |
| 01:03 | ibdknox | we're missing a solid ORM |
| 01:03 | ibdknox | which I started earlier :) |
| 01:03 | brehaut | ibdknox: in lets call it a data mapping layer ;) |
| 01:03 | brehaut | s/in// |
| 01:03 | lazybot | <brehaut> ibdknox: lets call it a data mappg layer ;) |
| 01:03 | ibdknox | yes |
| 01:03 | scottj | ibdknox: oh so by database layer do you mean only sql? |
| 01:03 | ibdknox | not really an ORM |
| 01:04 | brehaut | ibdknox: clojureql is very promising though |
| 01:04 | scb | brehaut: was just about to ask that. for example i always check for pre-made stuff for common tasks (like authing, users, stuff that has been made over and over and you just reconfigure, you know) |
| 01:05 | ibdknox | scottj: it's hard for me to imagine what a database layer that covers more than SQL would look like |
| 01:05 | ibdknox | scottj: maybe I'm misunderstanding though |
| 01:05 | brehaut | scb: the ring layer provides a lot of commonality |
| 01:06 | brehaut | scb: however, very few of the tools prescribe particular data 'types' |
| 01:06 | scottj | ibdknox: nosql dbs. see clojurize I think it supported sql and mongo or maybe couch |
| 01:07 | ibdknox | scottj: the semantics of something like redis are totally different than SQL |
| 01:07 | ibdknox | I would use them in entirely different ways |
| 01:08 | scottj | http://anvil.io/posts/clojurize-the-data-not-the-database |
| 01:09 | ibdknox | that doesn't appear to solve the thing that's annoying to me |
| 01:09 | ibdknox | which is managing relations between tables |
| 01:09 | Arafangion | Abstracting the database has other advantages, anyway. |
| 01:10 | justinus | hi, I need to consume messages from a JMS Queue….. is there any idiomatic clojure code which uses the standard javax.jms interface ? |
| 01:10 | srid | what is the alternative for (for [item items]) that doesn't return the values? |
| 01:10 | srid | more like loop |
| 01:10 | amalloy | doseq |
| 01:14 | jli | ibdknox: well-known fact, clojurians are only biased by truth and beauty :) |
| 01:15 | ibdknox | jli: truth |
| 01:16 | brehaut | jli: it helps that clojure is young enough that most people who are interested in it have come from at least one other language (and its a broad range of other langues) |
| 01:17 | Arafangion | And that such people aren't terrified of lisps. |
| 01:19 | scb | Well I guess I'll have to check Clojure for the web eventually. the no solid orm point raised by ibdknox is kind of a put off. |
| 01:19 | amalloy | scb: it's hard to have a standard orm when your standard is to not have objects |
| 01:20 | ibdknox | yeah, sorry I shouldn't have said ORM |
| 01:21 | jli | what's an orm? something that takes SQL queries and returns language-native data structures? |
| 01:21 | cark | i think functional programming works well with databases |
| 01:21 | brehaut | jli:it stands for object/relational mapping |
| 01:21 | ibdknox | from object to table back to object |
| 01:21 | companion_cube | jli: objects map to some database table row |
| 01:22 | ibdknox | the advantage is primarily that it handles relations for you |
| 01:22 | cark | instead of thinking in a object/single row fashion, you think in termns of streams of data |
| 01:22 | brehaut | ibdknox, jli: via insurmountable impedance mismatch |
| 01:22 | ibdknox | yes |
| 01:22 | ibdknox | I firmly believe that ORM is an anti-pattern |
| 01:22 | ibdknox | relation management isn't |
| 01:22 | jli | ibdknox: how does it handle the relations? do you feed it a schema? |
| 01:23 | cark | ibdknox: i agree, but then again i might have given up on these before finding the right one |
| 01:23 | Arafangion | Yes - I think ORM gives programmers an excuse NOT to separate the layers. |
| 01:24 | ibdknox | for those interested: http://seldo.com/weblog/2011/08/11/orm_is_an_antipattern |
| 01:24 | ibdknox | jli: yeah simple relation definitions |
| 01:25 | cark | this post was severly flammed on /r/programming |
| 01:25 | jli | hum, interesting |
| 01:25 | scb | ibdknox: what do you use for databases in clojure? |
| 01:25 | ibdknox | https://gist.github.com/1257094 |
| 01:25 | ibdknox | cark: sure |
| 01:25 | ibdknox | cark: some points he brings up are true though |
| 01:26 | ibdknox | scb: I screwed around with clj-record |
| 01:26 | ibdknox | it works, sort of |
| 01:26 | ibdknox | clojureql is neat |
| 01:26 | ibdknox | but is missing a lot and tries to be like clojure instead of accurately representing what it is |
| 01:26 | ibdknox | I used redis a lot |
| 01:26 | cark | i'd love to have a clojureql with a more "functional" interface |
| 01:27 | brehaut | ibdknox: thats a good summary of the problems with clojureql. |
| 01:27 | cark | i use postgres and sqlite |
| 01:27 | ibdknox | cark: what would that look like? |
| 01:27 | ibdknox | since I'm starting on this.. |
| 01:27 | ibdknox | lol |
| 01:27 | brehaut | ibdknox: also, the ordering of operations matters sometimes and i inevitably get confused by it |
| 01:27 | cark | well |
| 01:27 | ibdknox | brehaut: yeah. it could be cleaner |
| 01:28 | Arafangion | That said, some ORM's are really useful in providing database abstraction. |
| 01:28 | Arafangion | In theory, the code does not depend on the database provider. |
| 01:28 | cark | what i'm always doing an half-assed implementation to is this : query building |
| 01:28 | ibdknox | cark: so something like this gist? https://gist.github.com/1257094 |
| 01:28 | Arafangion | In practice, I find writing SQL to be simple enough. |
| 01:28 | cark | i would love to have a well thought out way to compose parts of queries |
| 01:29 | kevinburke | Hey, have a quick question about http-agent. I can't seem to get it to return properly |
| 01:29 | kevinburke | I posted most of the details here http://stackoverflow.com/questions/7624686/get-body-of-http-response-in-clojure |
| 01:29 | brehaut | Arafangion: the advantage of a layer like clojureql is that it can make your queries composable |
| 01:29 | cark | ibdknox: if these are not macros, then yes |
| 01:29 | brehaut | Arafangion: e.g. this the select, where, from etc clauses could all come from different functions, and without string bashng |
| 01:29 | Arafangion | brehaut: That's pretty cool. |
| 01:30 | cark | ibdknox: i don't care about the defentity stuff, i want to make a function that will return a "select object" then use it as part of another select |
| 01:31 | cark | ibdknox: or maybe construct the where parts in several functions, then put it all together later |
| 01:31 | Arafangion | brehaut: Personally, I think the biggest problem with ORM's is that they try to return instances of dynamically generated *classes*. |
| 01:32 | cark | last time i checked, clojureql was documenting a mostly macro oriented , static queries oriented, interface |
| 01:32 | brehaut | Arafangion: its the giant awkwardness of expression that grinds my gears |
| 01:32 | cark | it was a while back tho |
| 01:32 | brehaut | Arafangion: easy things are easy, hard things are maddenning |
| 01:32 | ibdknox | cark: that is the intent of what I'm building |
| 01:33 | brehaut | cark: they did scrap the entire thing and rebuild from scratch onto of relational algebra |
| 01:33 | ibdknox | cark: select is a macro of convenience, but it has a function behind it to do the same thing |
| 01:33 | cark | brehaut: ok well i was "away" for a while, i might have to look back into it |
| 01:33 | amalloy | ibdknox: do you actually need sql? i've been using mongodb for all my clojure projects and it's been much simpler |
| 01:33 | Arafangion | brehaut: I can agree with that, too. |
| 01:33 | cark | ibdknox: make sure to document the functional interface as well as the macro interface |
| 01:34 | ibdknox | cark: of course :) |
| 01:34 | cark | ibdknox: for any serious work you'll want to fall back to it anyways |
| 01:34 | ibdknox | amalloy: result of history, not choice |
| 01:34 | Arafangion | OO databases are a fad. :( |
| 01:35 | cark | i won't start again on the sql vs nosql stuff, siuffice it to say that sql isn't hard at all, and eliminate most book keeping |
| 01:35 | ibdknox | cark: both have their uses :) |
| 01:35 | cark | the world is big enough for both, yes |
| 01:36 | Arafangion | OO databases are a poor reinvention of heirchical databases. |
| 01:36 | cark | oo databases aren't a bad concept |
| 01:36 | cark | there is none which is both free and good that i know of |
| 01:38 | cark | ibdknox: so what's behind the scene of this syntax you showed us on your gist ? |
| 01:38 | ibdknox | a map :) |
| 01:38 | cark | yes |
| 01:38 | ibdknox | https://gist.github.com/1257106 |
| 01:40 | cark | i think the defentity stuff shoudl be a completely different layer than the query building stuff |
| 01:42 | ibdknox | it's not dependent on it |
| 01:42 | cark | brehaut: indeed clojureql is nothing like it was oO |
| 01:43 | brehaut | cark: I still use raw SQL for inserts because I've found cql a bit quirky with its insert and update fns |
| 01:43 | cark | which raises the question, why doesn't it fit ibdknox' needs ? |
| 01:43 | brehaut | (in particular returning last index etc) |
| 01:43 | cark | brehaut: ah yes |
| 01:44 | cark | does clojureql work with different kind of databases ? |
| 01:44 | ibdknox | cark: because it doesn't handle relations, and tries to be clever |
| 01:44 | cark | like sqlite/mysql/postgres? |
| 01:44 | ibdknox | cark: yes |
| 01:45 | brehaut | cark: some crappy clojureql code i wrote: https://github.com/brehaut/burningbot/blob/master/src/burningbot/db.clj |
| 01:50 | cark | brehaut: i see your ql/where clause in query-logmarks-for-day |
| 01:51 | cark | and i'm wondering how i could compose two of these in a single one |
| 01:51 | cark | let's say i would have the start-date and end-date part coming from one function |
| 01:51 | cark | then the channel part from another function |
| 01:54 | brehaut | cark: i stopped when i got it working |
| 01:54 | cark | hehe ok |
| 01:54 | brehaut | i agree that it should be nicer ;) |
| 01:55 | cark | see a common use case for a query builder is for providing a filtering option to your end-user |
| 01:55 | brehaut | to be clear, i got the SQL running quickly in the DB, but porting it to clojureql took some time |
| 01:55 | cark | so you want to compose those where clauses in a nice way |
| 01:56 | cark | brehaut: well that's to be expected for any dsl, should be easier once you know what you're doing |
| 01:57 | cark | think about the common lisp loop macro ... takes a while to know much about it, bu once you do it's very powerfull |
| 01:57 | ibdknox | cark: eh, I think cql didn't get to the right level of prettiness |
| 01:57 | brehaut | yeah, although, part of the promise of clojureql is that if you can write the SQL, its a straight forward mapping because its the same conceptual model |
| 01:57 | Arafangion | Then again, you could do an sql->clojure transformation to give you a hint. |
| 01:57 | Arafangion | That involves parsing sql, though. |
| 01:58 | cark | hehe yes, the whole problem is with the sql language itself, it's horrible for computer generation |
| 01:58 | brehaut | and human generation (unless the human is willing to devote their life to typing) |
| 01:59 | cark | why couldn't they choose a lisp syntax, it's beyond me ! |
| 01:59 | brehaut | cark: committee, lisp doesn't have enough syntax to let everyone get their own fillip in |
| 01:59 | Arafangion | Perhaps the problem with SQL is that people use too much of it on the client side. |
| 02:00 | cark | Arafangion: what do you mean ? |
| 02:00 | Arafangion | Rather than defining views, and other convenient routines on the server side. |
| 02:00 | brehaut | views are (historically) out for performance reasons on many smaller SQL DB imps |
| 02:01 | cark | think again about my use case, providing filtering options to your end-user ...there is no way around building the sql on the client side |
| 02:01 | brehaut | a lot of people went to stored procs but thats a different can of horror |
| 02:01 | Arafangion | brehaut: Is performance really a primary consideration for smaller SQL DB's? |
| 02:01 | Arafangion | brehaut: If it's an issue, surely, the right place to improve that is in the database implementation? |
| 02:02 | brehaut | Arafangion: not everyone can afford a MSQL or oracle license |
| 02:02 | Arafangion | There are other alternatives. |
| 02:02 | cark | postgres is fast enough, and free |
| 02:02 | brehaut | yeah postgres is good |
| 02:02 | Arafangion | Exactly. |
| 02:02 | brehaut | but if you are using mysql (because for whatever reason you can't get or install pg) you were screwed |
| 02:03 | Arafangion | I've never had a good opinion for mySQL, though - although I am using sqlite3, but not because I want a "real" database. |
| 02:03 | cark | i never had to use mysql ... that's living a happy life isn't it ? |
| 02:03 | Arafangion | And yeah, mySql has never been reputable. |
| 02:04 | Arafangion | It's probably a good implementation, but how can you trust a database implementation that claims 'ACID is crap', along with other relational database theories... Without justifying it!?" |
| 02:04 | Arafangion | I mean, there's arguably good reasons to avoid ACID, but dammit, *justify it*! |
| 02:04 | brehaut | Arafangion: if you are just building this months hot new blog engine, does it matter? :P |
| 02:04 | Arafangion | brehaut: You could use flat files, even. |
| 02:05 | cark | i thought there was a mysql backend which is acid complient ? innodb or some such ? |
| 02:05 | Arafangion | brehaut: Does it matter? ;) |
| 02:05 | Arafangion | cark: There are, but that's besides the point. |
| 02:05 | brehaut | Arafangion: yes, relational querying is much easier than multiple flat files when you want to cross cut your data :P |
| 02:05 | Arafangion | brehaut: Frankly, I'd probably use sqlite3. :) |
| 02:06 | cark | my current project is serverless application, and i'm using sqlite |
| 02:07 | cark | lol |
| 02:07 | Arafangion | cark: Yeah, sqlite's pretty impressive for what it is. |
| 02:07 | cark | Arafangion: do you know if its query planner is any good |
| 02:07 | cark | ? |
| 02:08 | Arafangion | cark: I have no idea, to be honest, I only use it for small databases. |
| 02:08 | michaelr525 | hey |
| 02:08 | Arafangion | cark: It's too implicit for my liking for large stuff. |
| 02:09 | cark | what other embedded database is there which are a good fit for clojure ? |
| 02:09 | Arafangion | (Heck, it can generate tables on-the-fly without a CREATE TABLE) |
| 02:10 | Arafangion | cark: sqlite3's pretty much the choice, these days. There are other alternatives, but while sqlite3 exists, there isn't any point. |
| 02:11 | cark | that was my conclusion, but you never know, might have missed something =P |
| 02:12 | Arafangion | Keep in mind that I've yet to use or learn clojure... But I think this is a fairly language-agnostic discussion. |
| 02:12 | cark | well you have to consider the runtime, we're ont he jvm |
| 02:13 | Arafangion | Even so. |
| 02:13 | Arafangion | Then again, I'm probably too happy with doing native binding, but that said, I'm sure sqlite3's well supported on the jvm. |
| 02:13 | Arafangion | I'm off for some crappy "thai". |
| 02:14 | cark | have a good meal |
| 02:14 | Arafangion | Thanks. It's "thai" because it does'nt have much fish sauce, soy sauce, chilli, herbs, or other spices. |
| 02:14 | Arafangion | It's all... westernised. |
| 02:15 | cark | yuk =/ |
| 02:15 | Arafangion | But at least they don't make the sauce gummy, it's otherwise good. (Although they *do* add too much sugar) |
| 02:15 | cark | it's 8am here, i'm more looking at some croissants =) |
| 02:15 | Arafangion | It's 5:15pm here. :) |
| 03:18 | justinus | anybody here used clamq? |
| 03:40 | michaelr525 | justinus: what's that? |
| 04:04 | jli | whoo hoo, I'm in the top 100 on 4clojure |
| 04:19 | justinus | https://github.com/sbtourist/clamq |
| 04:20 | Blafasel | Is clojure-clr a reality (i.e. usable, at least for exploration and tests) or more of an experiment? |
| 04:22 | amalloy | jli: congrats dude. now go sign up for a gravatar! we just added that feature |
| 05:05 | Blafasel | amalloy: Any plans to increase the session timeout? I often end up doing real work *cough*, get back, submit something and get the 'please log in to record that' message. The header is still showing my username, so no way to see that I'm logged out before that |
| 05:06 | amalloy | Blafasel: it's not actually a session timeout; as far as i know we only break sessions when we deploy a new version |
| 05:06 | amalloy | which we did tonight |
| 05:08 | Blafasel | Nope, happened just now. |
| 05:08 | amalloy | yep |
| 05:09 | amalloy | it's 2am here; that counts as tonight to me :P |
| 05:09 | Blafasel | Oh. Right :) |
| 05:09 | Blafasel | Sorry |
| 05:10 | amalloy | well, i'm sorry our deploy involves breaking sessions. if you know how to fix that, let us know with a pull request :) |
| 05:11 | cark | amalloy: you should have a bit of advertisement on this web site |
| 05:11 | amalloy | never |
| 05:11 | cark | something not too intrusive would not be any trouble to your users |
| 05:12 | cark | this work is usefull and deserve some reward |
| 05:13 | amalloy | there are much less annoying ways to generate revenue than ads. eg, if someone designs some t-shirts for us, we can sell them on zazzle |
| 05:13 | cark | well then you still need to advertise them on your site, that's the same thing really |
| 05:14 | cark | anyways i don't care, that just popped into my head when visiting the site |
| 05:14 | amalloy | well, thanks for your interest |
| 05:25 | jli | amalloy: yeah, I noticed. are gravatars keyed on email? |
| 05:25 | amalloy | jli: yeah. if you've registered, with gravatar.com, the email address you use on 4clojure, you get an image |
| 05:26 | amalloy | they have a nice scheme which enables us to get your image from them without ever sending your email address over a public channel, in case you're worried about that |
| 05:29 | jli | amalloy: no, I was just trying to figure out why my gravatar wasn't already showing up. |
| 05:54 | thorwil | root-cause is in both clojure.stacktrace and clojure.repl?! |
| 05:54 | Blafasel | Huh? |
| 05:55 | Blafasel | Looks like I scored _good_ this time in the golf ranking? |
| 06:05 | jli | hurray, #70 |
| 07:03 | Blafasel | Hmm.. :) 183. But makes "work" bearable at least. |
| 07:22 | fliebel | How would you write a webmail client in Clojure? |
| 07:23 | fliebel | I see 3 routes. One is to talk over SMTP and IMAP to a server, the other option is to interact with the datastore used by the server, the last is to *be* the server. |
| 07:27 | Arafangion | (Not all routes are practical!) |
| 07:30 | cark | is there a predicate that will tell is a value is Seqable ? |
| 07:31 | cark | ,((supers (type [])) clojure.lang.Seqable) |
| 07:31 | clojurebot | clojure.lang.Seqable |
| 07:31 | cark | something that does what i just did |
| 07:32 | kzar | What would be the Enlive selector for the last script tag inside the head? I've got [:head :> :script (last-of-type)] but it's not working |
| 07:35 | cark | ,(sequential? [1 2 3]) |
| 07:35 | clojurebot | true |
| 07:35 | cark | ,(coll? [1 2 3]) |
| 07:35 | clojurebot | true |
| 07:38 | kzar | oh, got it [:head [:script last-of-type]] |
| 07:44 | fliebel | Arafangion: Which one are (not) in your opinion? |
| 07:46 | kzar | fliebel: I would take the "talk over SMTP and IMAP" option, make an RESTful API that let you do things like send mail and list messages. Then I would make the webmail interface with Javascript |
| 07:46 | krl | what is the cleanest way to get a list of a form repeated n times? |
| 07:47 | kzar | fliebel: But on the otherhand who am I to decide |
| 07:48 | fliebel | kzar: One way to look at it is that HTTP and IMAP are both a V in MVC. Which is how I came to the talk to the datastore option. |
| 07:49 | fliebel | kraft: Like... ##(repeat 3 4) ? |
| 07:49 | lazybot | ⇒ (4 4 4) |
| 07:49 | fliebel | *krl |
| 07:51 | fliebel | I think writing a custo mail server in Clojure is to painful to even consider. |
| 08:14 | Arafangion | fliebel: Bingo. |
| 08:14 | Arafangion | fliebel: Actually, the writing of the custom mail server isn't that big a deal. |
| 08:14 | Arafangion | fliebel: But running it is. |
| 08:15 | fliebel | Arafangion: Why? I imagined the building to be the problem. Esp. IMAP. |
| 08:15 | Arafangion | Far from it. :) |
| 08:16 | Arafangion | It's the spammers that are - and how the email infrastructure has had to cope with it. |
| 08:22 | joelehmann | Hello |
| 08:44 | kzar | Is there a way to do a regexp replace of a string, the replace value being a call to a function that takes the matching sub-string? |
| 08:49 | dabd | I expected ,(/ 47.8486 100) to return 0.478486 |
| 08:49 | dabd | ,(/ 47,8486 100) |
| 08:49 | clojurebot | 47/848600 |
| 08:50 | dabd | ,(/ 47,8486 100.0) |
| 08:50 | clojurebot | 5.538534056092387E-5 |
| 08:50 | dabd | well the clojurebot returns the result in scientific notation but my repl returns 0.47848599999999997 |
| 08:51 | dabd | why is it that clojure does not return the exact value 0.478486? |
| 08:51 | opqdonut | 0.478486 is not representable as a floating point number |
| 08:51 | cark | http://download.oracle.com/docs/cd/E19957-01/806-3568/ncg_goldberg.html |
| 08:51 | cark | oops |
| 08:51 | opqdonut | and btw, you shouldn't use , as the separator |
| 08:52 | opqdonut | ,(/ 1,100 10) |
| 08:52 | clojurebot | 1/1000 |
| 08:52 | opqdonut | ,(/ 1 100 10) |
| 08:52 | clojurebot | 1/1000 |
| 08:52 | opqdonut | "," is just whitespace in clojure |
| 08:52 | stoneg | hi, how can I ref to a object in clojure (like I want to create a db connection, then do operations using that connection, how can I do this in clojure)? |
| 08:52 | cark | stoneg: do you mena a java object ? |
| 08:52 | dabd | opqdonut: is there some way I can obtain the exact value? |
| 08:53 | cark | ,(/ (rationalize 47.8486) 100) |
| 08:53 | clojurebot | 239243/500000 |
| 08:53 | opqdonut | dabd: depends very much on what you mean by "exact value", but for example clojure's rational numbers are exact |
| 08:53 | stoneg | no, I come from oo background, not that familiar with functional way of doing this kind of things. |
| 08:54 | dabd | well I just wanted to get 0.478486 not a fraction |
| 08:54 | opqdonut | representing and printing a number are quite different |
| 08:54 | cark | (let [a (String. "hello")] (.toString a)) |
| 08:54 | cark | now that's a silly example |
| 08:55 | cark | but you have the value a, which is bound to the string object |
| 08:55 | cark | and you can work with it |
| 08:55 | cark | i'm not quite sure that's what you're saking |
| 08:55 | cark | asking* |
| 08:55 | Chousuke | stoneg: the standard way is to have your procedures take a db connection object as the argument and work on that |
| 08:56 | Chousuke | then you just create a db connection and call your procedures |
| 08:56 | stoneg | so you mean it's like first set the connection to a var, and then using it like : (operation conn params) ? |
| 08:56 | Chousuke | or just use let |
| 08:57 | cark | stoneg : yes juste like in java or c# |
| 08:57 | cark | but chousuke's way is the most important |
| 08:57 | dabd | opqdonut: but shouldn't this return the true? (= (Float/parseFloat "0.478486") (/ (Float/parseFloat "47.8486") 100)) |
| 08:57 | opqdonut | no |
| 08:57 | opqdonut | wait a sec, I'll give you a link |
| 08:58 | stoneg | Chousuke: let is for def local bindings , right? |
| 08:58 | cark | dabd: you really need to learn about the pitfalls of floating point arithmetics |
| 08:58 | opqdonut | dabd: http://download.oracle.com/docs/cd/E19957-01/806-3568/ncg_goldberg.html |
| 08:58 | Chousuke | stoneg: local binding, yes |
| 08:58 | opqdonut | oh, cark pasted that above |
| 08:58 | stoneg | Chousuke: But a connection acts as a global thing. |
| 08:58 | Chousuke | you can also bind the connection to a global dynamic *db* variable that is used in procedures |
| 08:58 | cark | stoneg: gloal things are evil |
| 08:58 | cark | global* |
| 08:59 | dabd | opqdonut: looks heavy I'll read it thx |
| 08:59 | opqdonut | ,(= (float 1.0) (* (/ (float 1.0) (float 3.0)) (float 3.0))) |
| 08:59 | clojurebot | true |
| 08:59 | Chousuke | or you can use some database library :) clojure has a couple |
| 08:59 | cark | first you learn to do without globals, then you break the rule when needed |
| 08:59 | opqdonut | ,(= (float 1.0) (* (/ (float 1.0) (float 11.0)) (float 11.0))) |
| 08:59 | clojurebot | true |
| 08:59 | stoneg | cark: Is it ok using curring ? |
| 08:59 | opqdonut | hmm, I could've sworn those weren't true |
| 08:59 | cark | stoneg: what has currying got to do with that ? |
| 09:00 | cark | opqdonut: that's the point, you never know with floating point numbers |
| 09:01 | stoneg | cark: sorry, I mean some techniques like using currying to memorize the initialized connection, and do operations against the conn later. |
| 09:01 | opqdonut | cark: indeed |
| 09:02 | Chousuke | stoneg: what matters is how well you can keep the stateful thing (the connection) separate from the rest of the code |
| 09:02 | Chousuke | if the db connection is always an explicit parameter to procedures then it's easier to follow what happens to it |
| 09:02 | cark | stoneg: for what it's worth, i'm using clojure.java.jdbc for connections and database interactions, and it is setting a dynamic var up for connections and transactions |
| 09:03 | cark | then the actual queries do not require a connection parameter |
| 09:03 | cark | as it is in the dynamic scope |
| 09:03 | cark | is defined* |
| 09:03 | cark | or bound really |
| 09:03 | cark | ohwell |
| 09:06 | stoneg | cark: http://clojure.org/vars , says Functions defined with defn are stored in Vars, and Vars are global like thing, so is functions evil ? |
| 09:06 | stoneg | cark: http://clojure.org/vars , says Functions defined with defn are stored in Vars, and Vars are global like thing, so are functions evil ? |
| 09:06 | cark | so in practice : (sql/with-connection db-settings (sql/transaction (with-query-results rs ["select * from blah"] (do-something rs))) |
| 09:07 | cark | stoneg: at some point you need some form of global state |
| 09:07 | cark | but you're trolling now =) |
| 09:10 | stoneg | cark: In the example, it has many level of nesting, will it affect code readability ? |
| 09:10 | cark | sorry couldn't properly indent on irc |
| 09:13 | cark | https://gist.github.com/1257440 |
| 09:13 | cark | there you go, see that's not that bad =P |
| 09:15 | stoneg | cark: thanks. |
| 09:15 | stoneg | cark: but for real code, I saw many nestings that that, like : https://github.com/nathanmarz/storm/blob/master/src/clj/zilch/virtual_port.clj |
| 09:16 | stoneg | cark: and this: https://github.com/nathanmarz/storm/blob/master/src/clj/backtype/storm/clojure.clj |
| 09:16 | cark | it's not so bad |
| 09:16 | cark | you may clean that up a bit by decomposing a bit more |
| 09:17 | stoneg | cark: I am learning clojure and reading some real code. But it looks to messy (sorry just the feeling as a new functional guy). :-( |
| 09:17 | cark | i'm guessing it's all still very alien to you |
| 09:18 | stoneg | cark: yes. kinda of. |
| 09:18 | cark | to me it's weirder reading java code =) |
| 09:19 | stoneg | cark: Actually, I learned lot of FP languages(haskell, erlang, clojure, scala), but not wrote a lot using it in production and real project. |
| 09:19 | cark | i've been using common lisp and clojure almost exclusively for 10 years now |
| 09:20 | stoneg | cark: Maybe I need use it more, think in functional style, and read more fp code. |
| 09:20 | cark | the good way to learn is start a project |
| 09:20 | cark | and suck it up until you're done with it =) |
| 09:20 | cark | and ask advice |
| 09:20 | stoneg | cark: that's cool. I started fp from 2008. first is erlang. |
| 09:21 | stoneg | cark: Thanks! very good advice. |
| 12:08 | srid | how do I refer java static methods as first class object? this doesn't work: ((comp Integer/valueOf trim) "12 ") |
| 12:09 | TimMc | srid: memfn is the old way, but #() is the current idiom |
| 12:09 | srid | so this code can't be improved to use comp instead of #() http://stackoverflow.com/questions/7623633/how-do-i-convert-a-string-into-two-integers-in-clojure/7624355#7624355 |
| 12:09 | TimMc | Integer/valueOf becomes #(Integer/valueOf %) |
| 12:10 | TimMc | Right, there's not much you can do. |
| 13:14 | mister_roboto | ,(seq? [:x]) |
| 13:14 | clojurebot | false |
| 13:14 | mister_roboto | ,(seq? '(:x)) |
| 13:14 | clojurebot | true |
| 13:15 | mister_roboto | I thought from reading the docs that a vector is an ISeq. Can someone tell me what I'm not understanding ? Why does the first return false? |
| 13:16 | mister_roboto | ,(coll? [:x]) |
| 13:16 | clojurebot | true |
| 13:21 | TimMc | mister_roboto: All the collection types as well as seqs are coll? -> true. |
| 13:22 | TimMc | Vectors are seqable: ##(seq [1 2 3]) |
| 13:22 | lazybot | ⇒ (1 2 3) |
| 13:23 | TimMc | and the reason (seq? '(:x)) is true is that lists are implemented as seqs |
| 13:23 | mister_roboto | TimMc: but why does (seq [:x]) for example return false? vectors are not seqs i guess? |
| 13:24 | mister_roboto | just seqable? |
| 13:24 | TimMc | right |
| 13:24 | mister_roboto | ok thx |
| 13:24 | TimMc | "seqable" is a confusing topic, though |
| 13:24 | TimMc | ,(seq? "foo") |
| 13:24 | clojurebot | false |
| 13:24 | TimMc | ,(seq "foo") |
| 13:24 | clojurebot | (\f \o \o) |
| 13:26 | TimMc | ,(seqable? "foo") |
| 13:26 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: seqable? in this context, compiling:(NO_SOURCE_PATH:0)> |
| 13:27 | TimMc | ,(use 'clojure.contrib.core) |
| 13:27 | clojurebot | #<RuntimeException java.lang.RuntimeException: java.io.FileNotFoundException: Could not locate clojure/contrib/core__init.class or clojure/contrib/core.clj on classpath: > |
| 13:27 | TimMc | ,(use 'clojure.contrib) |
| 13:27 | clojurebot | #<RuntimeException java.lang.RuntimeException: java.io.FileNotFoundException: Could not locate clojure/contrib__init.class or clojure/contrib.clj on classpath: > |
| 13:27 | TimMc | bah |
| 13:27 | mister_roboto | TimMc: is it safe to say that you should use (coll?) to determine if you have a seqable thing? and not seq? |
| 13:27 | TimMc | &(clojure.contrib.core/seqable? "foo") |
| 13:27 | lazybot | ⇒ true |
| 13:27 | TimMc | Use seq: (if (seq foo) ... ...) |
| 13:28 | TimMc | Or even better, (if-let [sfoo (seq foo)] ... ...) |
| 13:28 | mister_roboto | TimMc: why not just (coll? foo) is there a downsie? |
| 13:28 | mister_roboto | if i just want to test it, that is |
| 13:29 | TimMc | Usually you want to *do* something with it. |
| 13:29 | mister_roboto | ,(coll? '(:x)) |
| 13:29 | clojurebot | true |
| 13:29 | mister_roboto | ,(coll? [:x]) |
| 13:29 | clojurebot | true |
| 13:29 | TimMc | If you want to test... well, I'd have to go back and look at the intricacies of seq, seqable, coll?, seq? and ISeq |
| 13:30 | TimMc | ,(if (seq 5) 'seq 'not-seq) |
| 13:30 | clojurebot | #<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Long> |
| 13:30 | mister_roboto | TimMc: sure. np. i need to read up more |
| 13:30 | TimMc | Right, so seq blows up on non-seqables. |
| 13:30 | TimMc | One of the Clojure experts needs to write a blog post explaining this once and for all. (Or maybe there is a book chapter?) |
| 13:33 | TimMc | ,(seqable? nil) |
| 13:33 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: seqable? in this context, compiling:(NO_SOURCE_PATH:0)> |
| 13:33 | TimMc | &(clojure.contrib.core/seqable? nil) |
| 13:33 | lazybot | ⇒ true |
| 13:56 | dabd | why there is not function to extract a subsequence between two elements. afaik there is only subvec for vectors but there is nothing for lists |
| 13:56 | dnolen | huzzah match uses efficient backtracking except in the presence of recur (still efficient in time, just possibly more code for certains kinds of patterns) |
| 13:58 | dabd | of course it is trivial to implement with drop/take |
| 13:59 | dnolen | dabd: because subvec has a constant time guarantee |
| 13:59 | dnolen | ,(doc subvec) |
| 13:59 | clojurebot | "([v start] [v start end]); Returns a persistent vector of the items in vector from start (inclusive) to end (exclusive). If end is not supplied, defaults to (count vector). This operation is O(1) and very fast, as the resulting vector shares structure with the original and no trimming is done." |
| 14:00 | dabd | dnolen: yes but sometimes you are working with vectors but when you use a seq function it becomes a list |
| 14:00 | Blkt | good evening everyone |
| 14:01 | jeremyheiler | Blkt: good afternoon :-) |
| 14:01 | Blkt | :) |
| 14:01 | dabd | for example ,(map identity [1 2 3]) transforms the vector into a list |
| 14:02 | dabd | then you cannot use subvec unless you turn it into a vector with into []. Does 'into' run in constant time or O(n)? |
| 14:03 | dnolen | dabd: if you want to keep working w/ vectors put it back into vector. O(n) |
| 14:03 | dabd | Then this is somewhat cumbersome |
| 14:03 | dnolen | dabd: not saying that the functionality you're talking about is not useful, but it shouldn't be called subvec |
| 14:03 | dabd | But why clojure changes the types of objects like this |
| 14:04 | dabd | It goes against the referential transparency of functional languages imho |
| 14:04 | dnolen | dabd: it doesn't change types, the map is lazy. |
| 14:04 | dabd | but map turns the vector into a list |
| 14:05 | dnolen | dabd: not a list, a lazy sequence. |
| 14:05 | dabd | but a lazy sequence is not a vector |
| 14:06 | dabd | so i guess the original type changed |
| 14:06 | dnolen | dabd: consider why map has to be lazy - Clojure doesn't have TCO |
| 14:07 | pbiggar | hi folks, quick question: from within noir/defpage, how can I get access to a user's session id? |
| 14:07 | glob157 | seven programming languages in seven weeks is the best book on clojure ive read (im new) ... do you guys agree ? |
| 14:08 | glob157 | \ |
| 14:08 | dabd | well at least a map-vec would be useful to avoid the O(n) into [] every time you use map on a vector and need a vector afterwards |
| 14:08 | dnolen | dabd: if map wasn't lazy, you would still need to construct the new vector - O(n) |
| 14:08 | dnolen | if you wrote a loop/recur that updated vector in place, stlll O(n) |
| 14:09 | dnolen | dabd: so you either want subvec, or you want something new for sequences that does something similar which doesn't have O(1) guarantee |
| 14:10 | dabd | dnolen: but if the mapping function preserved the type you would traverse the structure once not twice, once for the 'map' and another one for 'into' |
| 14:10 | dnolen | dabd: *lazy* sequences |
| 14:10 | dnolen | dabd: there is only one traversal. |
| 14:12 | dabd | dnolen: ok thx |
| 14:13 | zerokarmaleft | glob157: i haven't read that book, but i imagine the coverage is pretty light |
| 14:14 | chouser | dnolen: in the abstract, backtracking is sometimes less fast, right? |
| 14:14 | zerokarmaleft | glob157: Joy of Clojure is great if you're looking to go deeper |
| 14:15 | dnolen | chouser: a backtrack is equal to longjmp, I haven't seen any discernible performance difference. And for complex pattern, there's a massive performance gain, since JVM refuses to inlining magic on large methods. |
| 14:15 | chouser | dnolen: very interesting! |
| 14:16 | chouser | I assumed backtracking would mean checking the same input element multiple times. Hard to see how that's not slower. |
| 14:18 | dnolen | chouser: the algorithm groups as many patterns as possible for testing them together. |
| 14:18 | dnolen | [1 2 3] [1 3 4] [1 & r] grouped together for testing, if that fails, we backtrack like to something completely different. |
| 14:19 | chouser | so tries to fail fast on each group |
| 14:19 | dnolen | chouser: it's tougher with guards (arbitrary tests), where grouping is less clear. I need to work that out still. |
| 14:19 | clojurebot | Ok. |
| 14:20 | dnolen | but mostly likely guards will involve retesting a element. |
| 14:21 | chouser | sounds great. We've got a project at work that I think might benefit a lot from match. Hoping to try it this week or next. |
| 14:23 | dnolen | chouser: cool! would love to hear your input. There's still a lot of details left, but I think the big picture stuff is falling into place. |
| 14:24 | TimMc | Shouldn't (vec (seq some-vector)) be O(1)? |
| 14:25 | TimMc | I would assume that vec could peek at the seq's implementation and see that it is backed by a vec. |
| 14:26 | Chousuke | I don't think that's really an issua :/ |
| 14:26 | Chousuke | how often will you seq a vector and then immediately make it a vector again? |
| 14:26 | chouser | TimMc: it potentially could be, and I wouldn't be shocked if someday Clojure has that kind of thing built in. But not today. |
| 14:27 | TimMc | Chousuke: I'll get back to you on that. :-) |
| 14:27 | chouser | Hm, actually, maybe Chousuke's right. |
| 14:27 | chouser | I was thinking it might happen across different function-call boundaries. |
| 14:28 | Chousuke | yes, it might happen, but I don't think it's very likely |
| 14:28 | chouser | but to happen would require something to call seq (but nothing else -- not map, take, drop, anything) and return that. |
| 14:28 | TimMc | hmm |
| 14:28 | chouser | maybe (drop-while odd? [2 3 4]) |
| 14:29 | TimMc | Would it be bad for (drop (seq some-vector)) to maintain the backing vector? |
| 14:29 | Chousuke | maybe clojure will some day have lazyvectors :P |
| 14:30 | TimMc | I guess the feasabiity would depend on how much the implementing seq is asked to do. |
| 14:30 | Chousuke | so when you do (vecmap foo somevector) you get back a vector instantly but the calculation only happens when you index the vector |
| 14:30 | chouser | TimMc: what if the first element in the vector is a really large object that you're specifically trying to GC? |
| 14:30 | gtrak`` | didn't it have lazy vecs at some point? or a placeholder at least? |
| 14:30 | TimMc | Right, that's what I'm worried about. |
| 14:30 | chouser | today you could say (vec (next the-vec)) |
| 14:31 | TimMc | Whereas subvec would not allow GC of out-of-range portions of the backing vec. |
| 14:31 | chouser | gtrak``: no, it had a thing that would act like a vector while holding a backing array, and then if you used assoc or conj it would then create a real vector. |
| 14:31 | chouser | not really lazy in the lazy-seq sense. |
| 14:32 | gtrak`` | ah |
| 14:32 | TimMc | It would be cute if a vector could know just how much of itself was accessible and could wipe the out-of-range portions. |
| 14:33 | TimMc | I guess then you'd be getting into the GC business. |
| 14:35 | dnolen | pushing match-0.2.0-alpha1 out the door |
| 15:02 | kencausey | dnolen: yay! |
| 15:43 | Bronsa | dnolen: wouldn't it be better if clojure.core.match.core was clojure.core.match? |
| 15:43 | dnolen | Bronsa: hmm not a bad idea |
| 15:44 | Bronsa | i find it annoying to write core twice in a ns |
| 15:45 | Bronsa | anyway, i'd like to thank you for your excellent work :) |
| 15:55 | ibdknox | +1 for removing the extra core :) |
| 16:02 | ibdknox | dnolen: awesome! :D |
| 16:07 | srid | has anyone used core.match with enlive? |
| 16:15 | srid | (first (.getBytes "’")) returns -43. to convert that to a byte, I do this: (apply str (reverse (take 8 (reverse (Integer/toBinaryString -43))))) |
| 16:15 | srid | is that too much? |
| 16:18 | TimMc | What does that get you? |
| 16:19 | raek_ | srid: you want it in binary form? |
| 16:19 | srid | that gets me "11010101" |
| 16:19 | srid | i'm playing with char encoding conversions in clojure/java |
| 16:20 | srid | enlive has a bug where it always reads a URL as utf-8 |
| 16:20 | srid | but a webpage is encoded in ISO/IEC 8859-2 |
| 16:20 | S11001001 | getBytes takes an encoding arg, and String has a bytes[], encoding constructor |
| 16:20 | raek_ | ,(Byte/toString -43 2) |
| 16:20 | clojurebot | #<CompilerException java.lang.IllegalArgumentException: No matching method: toString, compiling:(NO_SOURCE_PATH:0)> |
| 16:20 | raek_ | ,(Byte/toString (byte -43) (int 2)) |
| 16:20 | clojurebot | #<CompilerException java.lang.IllegalArgumentException: No matching method: toString, compiling:(NO_SOURCE_PATH:0)> |
| 16:21 | duck1123 | toString only takse 1 param according to the javadoc I'm looking at |
| 16:21 | S11001001 | ,(String. (byte-array [-43]) "ISO-8859-2") |
| 16:21 | clojurebot | #<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.Byte> |
| 16:21 | raek_ | srid: aren't URLs always suposed to be in UTF-8? |
| 16:21 | S11001001 | cute |
| 16:21 | srid | S11001001: ok, am I right in thinking that the java String also 'remembers' the original encoding of the string? |
| 16:21 | S11001001 | srid: no. |
| 16:21 | srid | IOW, is the constant inside the form, and the value returned by it different? (String. (.getBytes "’" "UTF-8") "UTF-8") |
| 16:21 | S11001001 | a string is an array of codepoints, encoded in UTF-16 |
| 16:22 | S11001001 | (not the same as ucs2, by the way) |
| 16:22 | duck1123 | ,(Byte/parseByte "-43") |
| 16:22 | clojurebot | -43 |
| 16:22 | raek_ | ,(Integer/toBinaryString -43) |
| 16:22 | clojurebot | "11111111111111111111111111010101" |
| 16:22 | S11001001 | so some codepoints actually take two chars |
| 16:22 | S11001001 | maybe 3, I forget |
| 16:22 | srid | raek_: i was referring the page content, not page url |
| 16:22 | raek_ | ,(subs (Integer/toBinaryString -43) 24 32) |
| 16:22 | clojurebot | "11010101" |
| 16:23 | S11001001 | ,42b |
| 16:23 | clojurebot | #<ExecutionException java.util.concurrent.ExecutionException: java.lang.NumberFormatException: Invalid number: 42b> |
| 16:23 | S11001001 | haven't used 1.3 enough yet |
| 16:23 | raek_ | srid: enlive uses some "magic" to recognize the coding of the page. I think you can give it a reader with the correct encoding specified manually |
| 16:24 | raek_ | ,11010101r2 |
| 16:24 | clojurebot | #<ExecutionException java.util.concurrent.ExecutionException: java.lang.NumberFormatException: Invalid number: 11010101r2> |
| 16:24 | raek_ | ,2r11010101 |
| 16:24 | clojurebot | 213 |
| 16:24 | S11001001 | ,(String. (to-array Byte/TYPE [-43]) "ISO-8859-2") |
| 16:24 | clojurebot | #<ArityException clojure.lang.ArityException: Wrong number of args (2) passed to: core$to-array> |
| 16:24 | srid | ,(seq (.getBytes "’" "UTF-16")) |
| 16:24 | clojurebot | (-2 -1 32 25) |
| 16:24 | srid | (seq (.getBytes "’" "ISO 8859-2")) |
| 16:25 | S11001001 | missed a hyphen and a comma |
| 16:25 | srid | (seq (.getBytes "’" "ISO-8859-2")) |
| 16:25 | srid | works for me in repl. what comma? |
| 16:25 | srid | it returns (63) |
| 16:25 | S11001001 | ,(seq (.getBytes "’" "ISO-8859-2")) |
| 16:25 | clojurebot | (63) |
| 16:25 | srid | oh |
| 16:25 | kij | ,(clojure-version) |
| 16:25 | clojurebot | "1.3.0-master-SNAPSHOT" |
| 16:25 | raek_ | ,(seq "åäö") |
| 16:25 | clojurebot | (\å \ä \ö) |
| 16:26 | S11001001 | uri, incidentally, doesn't proscribe your charset choices |
| 16:26 | S11001001 | though even at the character it must be aware of the encoding you intend to use so it can urlencode/decode correctly |
| 16:26 | S11001001 | s,character,character level, |
| 16:27 | srid | so how do I read a file encoded in "ISO-8859-2" into a string that uses utf-8/16 codepoints?? |
| 16:27 | lazybot | srid: Definitely not. |
| 16:27 | srid | i didn't enter the second ? |
| 16:27 | raek_ | srid: ideally, a string is not in any coding |
| 16:27 | S11001001 | srid: clojure.java.io/reader lets you specify the input encoding |
| 16:27 | TimMc | srid: InputReader or somesuch allows an encoding |
| 16:27 | raek_ | it is just a sequence of characters |
| 16:28 | raek_ | in java/clojure, this is true for characters in the Basic Multilingual Plane (code points below 65536) |
| 16:28 | srid | https://github.com/cgrand/enlive/blob/master/src/net/cgrand/enlive_html.clj#L36 is hardcoding utf-8 |
| 16:29 | S11001001 | yeah, people tend to do that |
| 16:29 | srid | i need to pass a stream that is encoded in utf8, not some other encoding |
| 16:29 | raek_ | srid: where you write the filename, you should be able to pass something like (io/reader "filename" :encoding "ISO-8859-2") |
| 16:30 | srid | ok, this is how I am using enlive's html-resource: (html-resource (InputStreamReader. (FileInputStream. url) "ISO-8859-2")) |
| 16:30 | srid | but that doesn't help at all. |
| 16:31 | srid | does InputStreamReader "decode" the url content and stream a sequence of characters to html-resource? |
| 16:31 | raek_ | yes |
| 16:31 | raek_ | InputStream = bytes |
| 16:31 | raek_ | Readerr = chars |
| 16:31 | S11001001 | do you mean the %things? |
| 16:32 | raek_ | InputStreamReader = bridge between the two |
| 16:32 | raek_ | srid: your row should be equivalent to (html-resource (io/reader (io/as-file url) :encoding "ISO-8859-2") |
| 16:33 | raek_ | but since the argument is called "url", I'm gettings suspicious that it's actually not a filename but a url... :-) |
| 16:33 | srid | its file:// url for now |
| 16:34 | srid | html-resources returns a map that contains strings. when I copy paste the subset of that string in to repl, i see the .getBytes on that character returns -43 |
| 16:34 | raek_ | you might need to pass it as (io/reader (io/as-url url) ...) then |
| 16:34 | srid | which means, .getBytes somehow "knows" that it is supposed to return bytes encoded in "ISO-8859-2" |
| 16:34 | raek_ | srid: what did you pass as the encoding argument to .getBytes? |
| 16:35 | srid | nothing |
| 16:35 | raek_ | if you did not pass any encoding argument, it guesses |
| 16:35 | raek_ | and defaults to whatever is the "default encoding" of your platform |
| 16:35 | srid | why should it guess at all when getBytes is passed a string (character stream) as opposed to bytes? |
| 16:35 | raek_ | you should never use this "default encoding" |
| 16:35 | srid | default encoding is certainly not "ISO-8859-2" which is the file's encoding |
| 16:36 | raek_ | imho, that method (without the encoding parameter) is broken and should be deprecated |
| 16:36 | raek_ | srid: to see what characters are in a string, use 'seq' to look at them individually, or (map int ...) to see their codepoints |
| 16:36 | srid | (System/getProperty "file.encoding") returns "MacRoman", btw |
| 16:37 | raek_ | in this case, no encoding of the string is done. all you see is the characters. |
| 16:37 | raek_ | ,(map int "abcåäö") |
| 16:37 | clojurebot | (97 98 99 229 228 ...) |
| 16:38 | raek_ | ,(.getBytes "abcåäö" "UTF-8") |
| 16:38 | clojurebot | #<byte[] [B@9f2146> |
| 16:38 | raek_ | ,(seq (.getBytes "abcåäö" "UTF-8")) |
| 16:38 | clojurebot | (97 98 99 -61 -91 ...) |
| 16:38 | srid | ,(map int "’") |
| 16:38 | clojurebot | (8217) |
| 16:39 | srid | i'll write a simple program with data file to reproduce my problem. |
| 16:43 | srid | how do I find the default encoding used by InputStreamReader? |
| 16:43 | srid | (System/getProperty "file.encoding"). yup. MacRoman is it. and it is screwing up files that are utf8 encoded as well |
| 16:46 | ibdknox | Noir 1.2.0 is out :D |
| 16:46 | ibdknox | https://github.com/ibdknox/noir/blob/master/history.md |
| 16:48 | cgroza | I see you have a pretty big community... |
| 16:49 | cgroza | clojurebot: |
| 16:49 | clojurebot | #<ClassCastException java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [Ljava.lang.String;> |
| 16:56 | dnolen | wow throw is cheap in JS if you don't construct an error |
| 16:58 | ibdknox | Help me get the word out about Clojure web stuff and comment/vote: http://news.ycombinator.com/item?id=3063973 :) |
| 16:58 | dnolen | done |
| 16:58 | brehaut | done |
| 16:59 | ibdknox | Thanks gentlemen :) |
| 17:00 | dnolen | releasing core.match 0.2.0-alpha2, ClojureScript support in |
| 17:01 | brehaut | dnolen: excellent :) |
| 17:02 | ibdknox | Happy release day haha |
| 17:10 | ibdknox | having a server agnostic framework is pretty damn cool |
| 17:10 | ibdknox | here's noir running on aleph (and thus Netty) |
| 17:10 | ibdknox | https://gist.github.com/1257857 |
| 17:17 | wink | cool. upvoted :) |
| 17:21 | ibdknox | now time to work on korma |
| 17:25 | brehaut | dnolen: would i be right in assuming that predicate dispatch would make a url routing library (eg moustache) trivial to write? |
| 17:27 | dnolen | brehaut: probably haven't really dug into that use case. |
| 17:33 | brehaut | ibdknox: re your common on the HN thread, has noir overtaken compojure for community activity? |
| 17:34 | brehaut | s/common/comment/ |
| 17:34 | lazybot | <brehaut> ibdknox: re your comment on the HN thread, has noir overtaken compojure for community activity? |
| 17:34 | brehaut | amalloy: how can i get added to the regexp exclusion list for lazybot? |
| 17:34 | amalloy | brehaut: ask me or Raynes nicely; there's no user-facing way atm. i'll make it so |
| 17:35 | Raynes | amalloy: Call it the whiner-list. |
| 17:35 | Raynes | So that we can be polite and snarky at the same time. |
| 17:35 | amalloy | good call |
| 17:36 | amalloy | $login |
| 17:36 | lazybot | You've been logged in. |
| 17:36 | amalloy | $reload |
| 17:36 | lazybot | Reloaded successfully. |
| 17:36 | amalloy | $logout |
| 17:36 | lazybot | You've been logged out. |
| 17:36 | amalloy | brehaut: fire away |
| 17:36 | brehaut | foobar |
| 17:36 | brehaut | s/foo/baz/ |
| 17:36 | ibdknox | brehaut: I think they're about equal, I've been getting messages a tad bit more frequently on the noir group than compojure lately, but I don't think there's a clear winner |
| 17:36 | brehaut | awesome, thanks |
| 17:37 | amalloy | wait, now i'm confused. should i spam the noir group to make it more popular than compojure, or because i want to annoy people reading it? |
| 17:38 | ibdknox | readies* |
| 17:47 | amalloy | ibdknox: accidentally ban yourself from #clojure? |
| 17:47 | brehaut | dropped the ban hammer on his foot |
| 17:47 | ibdknox | amalloy: got a little overzealous with the hammer ;) |
| 17:48 | ibdknox | or I forgot to plug my computer in... turns out it *will* shutoff if you don't |
| 17:49 | brehaut | ibdknox: #2 on the HN front page |
| 17:50 | ibdknox | I was #1 until just a couple minutes ago |
| 17:50 | ibdknox | :) |
| 17:50 | brehaut | sorry to be the bearer of bad news then |
| 17:50 | ibdknox | More exposure for Clojure! :D |
| 17:50 | ibdknox | wow |
| 17:50 | ibdknox | I hate the way that sounds |
| 17:50 | brehaut | ha |
| 17:58 | Twey | Expojure |
| 17:58 | Twey | That's going to be a library at some point… |
| 17:59 | ibdknox | I think leiningen actually prevents you from creating projects that are *jure |
| 17:59 | ibdknox | :D |
| 17:59 | TimMc | yep |
| 17:59 | TimMc | I think I approve of that. |
| 18:00 | Zolrath | ibdknox: There's something wrong with the pinot on clojars methinks |
| 18:00 | ibdknox | oh? |
| 18:00 | Zolrath | whenever I try to compile with it it tells me that pinot.dom was never provided |
| 18:00 | Twey | Nice. |
| 18:00 | Twey | So how did Compojure happen? :þ |
| 18:00 | TimMc | Grandfathered in. |
| 18:00 | Zolrath | but I downloaded the source and compiled it myself earlier and if I use that copy it works |
| 18:00 | ibdknox | Zolrath: yes it is screwed up |
| 18:00 | Twey | Haha. |
| 18:01 | TimMc | http://clojars.org/jrill <- I'm ashamed to admit that I'm responsible for this name |
| 18:01 | ibdknox | haha |
| 18:01 | TimMc | It was a throwaway joke when someone asked for a name, but no one else had any suggestions.. |
| 18:01 | ibdknox | tsk tsk :p |
| 18:02 | ibdknox | I can't say much, I just keep picking food names |
| 18:02 | Twey | Pinot is food now? |
| 18:02 | TimMc | I'm going to start using species names. |
| 18:02 | TimMc | (and variants on them) |
| 18:03 | ibdknox | Zolrath: should be fixed |
| 18:03 | TimMc | I picked "chelydra" (snapping turtle) for a personal bookmarking site. |
| 18:03 | ibdknox | Twey: Pinot noir |
| 18:03 | Twey | Yes |
| 18:03 | Twey | Drink ≠ food |
| 18:03 | Twey | Food substitute, sometimes, but not food :þ |
| 18:03 | ibdknox | lol |
| 18:04 | ibdknox | Twey: http://en.wikipedia.org/wiki/Food |
| 18:04 | ibdknox | incorrect ;) |
| 18:04 | ibdknox | the internets says so |
| 18:05 | Twey | Haha.Haha |
| 18:06 | wink | ibdknox: some caveat? I just noticed, maybe it's documented or intended, but I forgot to do a models.clj (like in noir_blog) but :require'ing the models and the result (FileNotFoundException for resources\public (Access Denied)) left me very clueless |
| 18:07 | ibdknox | wink: hm? those two things don't sound related |
| 18:07 | ibdknox | wink: the resources/public issues is usually the result of not having any routes defined |
| 18:07 | ibdknox | I should fix that in compojure |
| 18:07 | amalloy | TimMc: jrill? i don't get it |
| 18:07 | TimMc | drill |
| 18:07 | TimMc | It's an XPath wrapper. |
| 18:08 | TimMc | Breaking out of the standard s->j transform. |
| 18:08 | wink | ibdknox: basically the same code you looked at yesterday, just with another :require to a file in the models namespace |
| 18:09 | wink | then I put a models.clj next to server.clj with just (ns x.models (:require [x.models.y :as y])) and it worked |
| 18:09 | ibdknox | hm |
| 18:09 | ibdknox | that shouldn't be necessary |
| 18:13 | ibdknox | wink: what you just described would be an issue at the Clojure level, I don't do any special stuff with require. If you come up with a small repro for it, I'll gladly look into it |
| 18:13 | wink | ibdknox: yup, trying just now |
| 18:22 | ibdknox | woah, what happened ther? |
| 18:22 | ibdknox | there* |
| 18:24 | TimMc | Netsplit? |
| 18:25 | Zolrath | ibdknox: the pinot snapshot it pulls still gives the same pinot.dom error |
| 18:25 | ibdknox | Zolrath: did you remove the cached copy in ~/.m2/ |
| 18:25 | ibdknox | ? |
| 18:25 | ibdknox | Zolrath: it only checks for updates once a day |
| 18:25 | Zolrath | yeah |
| 18:25 | ibdknox | hm |
| 18:25 | ibdknox | ok |
| 18:26 | ibdknox | Zolrath: which version of pinot? |
| 18:27 | Zolrath | Downloading: pinot/pinot/0.1.0-SNAPSHOT/pinot-0.1.0-20110809.143608-17.jar from clojars |
| 18:27 | ibdknox | you need 0.1.1 |
| 18:27 | ibdknox | Zolrath: fixing readme now |
| 18:28 | Zolrath | Ah, thanks |
| 18:28 | Zolrath | 0.1.1, no snapshot? |
| 18:28 | ibdknox | Zolrath: sorry, 0.1.1-SNAPSHOT |
| 18:29 | Zolrath | And all is well again, working great. |
| 18:54 | wink | ibdknox: gah, ofc it was just me bein stupid, there was a ] missing after the last require. But why creating the models.cls with that missing import inside it fixed it instead of still erroring out due to syntax error.. no clue |
| 18:55 | ibdknox | lol |
| 18:55 | ibdknox | wink: those sorts of errors are really, really finicky |
| 18:55 | wink | on the plus side, I've read the noir_blog source from top to bottom now |
| 18:56 | ibdknox | hehe |
| 21:30 | brehaut | just watched brenton ashworth's browser repl intro video (http://vimeo.com/29535884) thats fantastic stuff |
| 21:43 | sjl | Is Marginalia supposed to pick up docstrings and comments inside functions? |
| 21:47 | amalloy | docstrings inside functions? |
| 21:47 | sjl | amalloy: yep |
| 21:48 | amalloy | ...what would that look like? |
| 21:48 | sjl | amalloy: looks like it's not just me being dumb for a change :) https://github.com/fogus/marginalia/issues/57 |
| 21:49 | sjl | amalloy: like this: http://fogus.me/fun/marginalia/ for this: https://github.com/fogus/marginalia/blob/master/src/marginalia/core.clj#L92 |
| 21:52 | amalloy | i would just describe those as docstrings. docstrings inside functions sound like they must be something else. but anyway, sounds like a bug; go fix it! :) |
| 21:54 | sjl | amalloy: ahh, heh, "... pick up (docstrings) and (comments inside functions)" |
| 21:54 | sjl | stupid english language |
| 22:15 | scottj | reading a cljs article says using namespace name as function or param name is a problem. if your ns is foo.bar.tar what can't you use, foo or tar? |
| 22:16 | amalloy | scottj: tar, i think |
| 22:16 | amalloy | er, maybe not. i have no experience, don't listen to me |
| 22:17 | amalloy | ask Raynes, in fact |
| 22:18 | Raynes | scottj: I don't know exactly how it works, but I had a project called 'portal' and my namespaces were 'portal.foo', wherein I had a 'portal' function that made the word explode. |
| 22:18 | Raynes | Therefore, I say that amalloy is likely incorrect here. |
| 23:12 | dzderic | is there any way I can run a compojure from a shared hosting account with only JSP enabled? |
| 23:13 | dzderic | sorry if it's a stupid question but I know nothing about JSP |
| 23:14 | brehaut | dzderic: im going to be guessing here, but i believe that JSP is ontop of / compiles to servlets. Servlets is the most basic requirement you need to host a ring based app (which a compojure site is) |
| 23:14 | brehaut | JSPs themselves dont really feature in the clojure web stack |
| 23:15 | dzderic | I know that much, it's just that I'm doing work for a client and it must be hosted on their shared hosting account |
| 23:15 | dzderic | I found a script which starts swank (here: http://paste.lisp.org/display/71209), but I'm not sure if I can do something similar to run the actual webapp |
| 23:15 | ibdknox | there's a good chance that they will have locked down a bunch of stuff |
| 23:17 | ibdknox | dzderic: can you upload a war to it? |
| 23:17 | clojurebot | Cool story bro. |
| 23:17 | ibdknox | clojurebot: shutup |
| 23:17 | clojurebot | Huh? |
| 23:17 | ibdknox | clojurebot: smack |
| 23:17 | clojurebot | It's greek to me. |
| 23:17 | ibdknox | hm |
| 23:17 | amalloy | ~botsmack |
| 23:17 | clojurebot | Owww! |
| 23:17 | dzderic | ibdknox: I'm not sure because the account hasn't been set up yet |
| 23:17 | ibdknox | ah |
| 23:17 | dzderic | ibdknox: how does this sort of thing normally work? |
| 23:18 | ibdknox | which sort of thing? hosting a clojure website? |
| 23:18 | dzderic | JSP |
| 23:18 | dzderic | I've used compojure with jetty and tomcat |
| 23:18 | ibdknox | I have no idea, I stayed as far away from JSP as I possibly could |
| 23:19 | dzderic | fair enough |
| 23:19 | dzderic | I'll ask the hosting company |
| 23:20 | mrh0057 | If you want to do hosting on the JVM you probably want to have a vertical dedicated server. |
| 23:20 | dzderic | unfortunately the client wants it done on their shared hosting |
| 23:21 | dzderic | if I can't get compojure working, I guess I'll have to go with (shudder) PHP |
| 23:21 | brehaut | wee bit of a step down there |
| 23:21 | mrh0057 | There can be problems that can cause the container to crash then you have to wait for the hosting company to reset it. |
| 23:21 | dzderic | :S that doesn't sound pleasant |
| 23:21 | ibdknox | in general, shared hosting is scary with something as memory intensive as java |
| 23:22 | gtrak`` | dzderic, if they have a servlet hosting, you can most likely aot-compile stuff and build a WAR |
| 23:22 | dzderic | I just sent them an email asking if I can just upload a war (I really hope the answer is yes :) |
| 23:22 | amalloy | brehaut: linode ftw |
| 23:23 | dzderic | brehaut: good luck finding something as good in australia |
| 23:23 | brehaut | dzderic: im in new zealand |
| 23:23 | gtrak`` | i mess around with virpus, it's hella cheap |
| 23:23 | dzderic | then have fun with the latency |
| 23:23 | gtrak`` | 512MB at $4/month |
| 23:24 | brehaut | the entire internet has latency for me, and this way the majority of the visitors to my site dont experience any :P |
| 23:24 | mrh0057 | dzderic: The most import thing is being able to restart the container yourself. |
| 23:24 | brehaut | gtrak``: thats cheap |
| 23:24 | gtrak`` | hells yea it is |
| 23:24 | amalloy | brehaut: maybe he means disk space. only 640k of RAM |
| 23:24 | brehaut | amalloy: i looked at linode, i understand that its better than prgmr (faster io in particular) but its not as cheap |
| 23:24 | ibdknox | lol |
| 23:24 | dzderic | gtrak11: but does it work? |
| 23:24 | gtrak`` | I wouldn't use it for anything serious, but I use it for a personal site |
| 23:24 | gtrak`` | dzderic, sure |
| 23:25 | gtrak`` | i think like 40GB of disk and you have root access |
| 23:25 | dzderic | mrh0057: I'll ask and see how much access I can get |
| 23:25 | mrh0057 | dzderic: If you deploy multiple time in tomcat, the jvm can run out of permspace. |
| 23:25 | brehaut | amalloy: 640k should be enough for anyone |
| 23:25 | amalloy | brehaut: yeah, linode is charging a premium. mostly for reliability and customer service, i thought |
| 23:25 | brehaut | amalloy: im sure; prgmr is bare bones. although their customer service has been completely adequate for my needs |
| 23:25 | gtrak`` | like i said... if you just want to mess around with something virpus is totally cheap, or heroku if you don't care about disk |
| 23:26 | amalloy | my linode is almost a year old now. crashed once, brief network outages maybe three times |
| 23:26 | brehaut | amalloy: thats about the same as my prgmr |
| 23:26 | amalloy | and it's hosting lazybot, 4clojure, tryclojure, and a few personal websites without breaking a sweat |
| 23:26 | ibdknox | I've only had one issue on EC2 |
| 23:26 | brehaut | nice. mines only hosting my site and burningbot |
| 23:27 | amalloy | brehaut: what is this "burningbot"? |
| 23:27 | brehaut | amalloy: i pay about $9/mo for 512mb ram, 12gig of disk |
| 23:27 | brehaut | amalloy: its an irc bot for the burning wheel rpg channel on a different server |
| 23:27 | brehaut | amalloy: built on raynes irclj |
| 23:28 | ibdknox | I was surprised how easy it was to build and IRC bot from scratch |
| 23:28 | brehaut | likewise |
| 23:28 | ibdknox | an* |
| 23:28 | amalloy | we have 1.5gb ram, 60gb disk. $60/mo but who cares, right |
| 23:28 | brehaut | (at least if you leave the arrows out of it ;) |
| 23:28 | ibdknox | the protocol is stupid simple |
| 23:28 | Raynes | ibdknox: Mostly just stupid. |
| 23:29 | brehaut | Raynes: lol |
| 23:29 | ibdknox | Raynes: haha, true |
| 23:29 | gtrak`` | if i'm expecting to make money off of something, obviously i'll pay more than $4 a month :-) |
| 23:29 | Raynes | A million and one edge cases. |
| 23:29 | brehaut | gtrak``: likewise :) |
| 23:29 | brehaut | Raynes: whats with you trying to implement libs for shitty protocols? irc, xmlrpc |
| 23:30 | Raynes | Just wanted 'em. |
| 23:30 | brehaut | Raynes: for your own sake, dont try to write a soap lib |
| 23:30 | Raynes | Luckily, somebody else write an xmlrpc lib that deprecated mine. |
| 23:30 | brehaut | so not a masochist then |
| 23:30 | brehaut | haha what a tool |
| 23:31 | brehaut | (him, not you) |
| 23:32 | brehaut | Raynes: ironically when i search for clojure xmlrpc your lib is ranked higher by google |
| 23:33 | Raynes | That's because he opted for a clever name while I recognize that the inherent boringness of the protocol isn't worthy of a clever name. |
| 23:33 | jli | oh noes, 4clojure problems? |
| 23:34 | jli | getting "502 Bad Gateway". amalloy: friendly ping :) |
| 23:34 | amalloy | jli: yeah, thanks. i actually had noticed already, but usually i don't |
| 23:35 | Raynes | brehaut: I am a masochist. |
| 23:35 | Raynes | brehaut: I do not, under any circumstances, know any Python. That said, I've spent the last 4 hours writing a sublime text 2 plugin for Clojure (it supports highlighting, but I'm adding fun stuff like evaluation). |
| 23:35 | amalloy | we have several components that probably consume memory without bound. would love to see some of those replaced :P. anyway jli, back up |
| 23:36 | brehaut | Raynes: huh? whats hard about python? |
| 23:36 | Raynes | Nothing. The problem is that sublime text's API is utter undocumented. |
| 23:36 | jli | brehaut: you have to remember to type "return" at the end of all your functions |
| 23:36 | Raynes | utterly* |
| 23:37 | jli | amalloy: woot, thanks |
| 23:37 | brehaut | jli: i have to remember to put the paren after the first identifier :P |
| 23:37 | amalloy | brehaut: i don't think he said it was hard. he just said he didn't know any |
| 23:37 | amalloy | i think remembering return is trickier |
| 23:38 | technomancy | explicit return is such a goof |
| 23:38 | brehaut | Raynes: that sounds like most python except for some of django |
| 23:38 | technomancy | newbie mistake among language designers |
| 23:38 | brehaut | technomancy: not as much of a goof as non anon functions |
| 23:38 | ibdknox | hashmaps in JS are what always screw me up, stupid trailing colon |
| 23:38 | brehaut | s/non/no/ |
| 23:39 | jli | amalloy: I seriously blow between 30 seconds to 10 minutes on that every time I do anything in python, because I've forgotten it by the time I have to write python again |
| 23:39 | amalloy | technomancy: more important feature for imperative language, right? |
| 23:39 | brehaut | technomancy: and mutable iterators. |
| 23:39 | technomancy | brehaut: I dunno; explicit return is usually caused by a statement/value distinction |
| 23:39 | technomancy | which really betrays a lack of exposure to good languages |
| 23:40 | jli | ibdknox: trailing colon, hmm? you mean trailing commas? |
| 23:40 | ibdknox | {mykey: "hey"} |
| 23:40 | ibdknox | instead of {:mykey "hey"} |
| 23:40 | amalloy | jli: {foo: 1} vs {:foo 1} |
| 23:40 | technomancy | it's actually more work to introduce a statement/value distinction |
| 23:40 | technomancy | you have to actively screw it up |
| 23:40 | jli | oh, haha |
| 23:41 | technomancy | lack of λ is a simple omission |
| 23:41 | brehaut | technomancy: i'll give you that, but the iterators are still busted |
| 23:42 | technomancy | brehaut: sure... I haven't actually used iterators. |
| 23:42 | ibdknox | there are a number of things busted in python, ever try to make a decorator that takes a parameter? |
| 23:42 | ibdknox | lol |
| 23:42 | jli | seems like people are done with messing up scoping |
| 23:42 | brehaut | ibdknox: hahaha |
| 23:42 | jli | oh, except for js :(:(:(:(:( |
| 23:44 | brehaut | technomancy: to get a value out of the iterator you have to call next, theres no current value, and the iterator throws an exception to indicate that its done. your fine if you can use a comprehension, for… or itertools, but you are hosed otherwise. |
| 23:44 | brehaut | its a perfect storm of bad mutation |
| 23:45 | technomancy | brehaut: people actually do this? |
| 23:45 | napping | sounds like Java Iterators |
| 23:46 | brehaut | technomancy: yes :( |
| 23:48 | jli | truly excellent: http://countercomplex.blogspot.com/2011/10/algorithmic-symphonies-from-one-line-of.html |
| 23:49 | ibdknox | brehaut: they want the lowest possible barrier to entry. For many rails turned into that |
| 23:49 | Raynes | brehaut: Also, if you set something to read-only, apparently not even your own plugin code can write to it. |
| 23:49 | Raynes | Something that I just spent about 30 minutes debugging. |
| 23:50 | brehaut | ibdknox: rails is a low barrier to entry‽ |
| 23:50 | ibdknox | Raynes: I was playing with sublime text 2 today |
| 23:50 | ibdknox | brehaut: It was, but less so now |
| 23:51 | Raynes | ibdknox: This has been editorweek for me. I've learned to use Vim, gotten bored, and now I'm screwing with Sublime Text. |
| 23:51 | brehaut | ibdknox: ive never learnt rails; more ceremony than a church |
| 23:51 | ibdknox | brehaut: Rails popularized scaffolding, which was a site in a box :) |
| 23:51 | brehaut | ibdknox: yeah, djangos similar with its models + admin magics |
| 23:51 | Raynes | ibdknox: I'd use Sublime Text, but no paredit makes me cringe. I no longer understand how to write Clojure code without it. |
| 23:51 | ibdknox | Raynes: I couldn't deal with the fact that it indented incorrectly |
| 23:51 | Raynes | My finger don't work this way. |
| 23:51 | ibdknox | lol |
| 23:52 | Raynes | What doesn't it indent properly? |
| 23:52 | Raynes | It doesn't seem to do much in the way of auto-indent at all. |
| 23:52 | ibdknox | pretty much anything |
| 23:52 | brehaut | technomancy: does emacs easily support having scoped modes within a file yet? |
| 23:53 | Raynes | brehaut: What editor do you use? |
| 23:53 | brehaut | Raynes: i hate emacs and textmate in equal quantities; i hate all other editors in larger quantities |
| 23:53 | Raynes | That is wonderfully vague. |
| 23:53 | ibdknox | vim is still my favorite :D |
| 23:53 | Raynes | But I'm guessing that means you use Emacs and/or textmate? |
| 23:54 | brehaut | Raynes: both |
| 23:54 | ibdknox | that's mostly because I can't convince myself to be at 10% efficiency for a couple weeks to learn emacs |
| 23:54 | brehaut | emacs for clojure, textmate for python + js |
| 23:54 | cemerick | brehaut: I'm stealing that answer, and just replacing the particulars. :-) |
| 23:54 | brehaut | cemerick: hah awesome :) |
| 23:54 | brehaut | cemerick: which one becomes eclipse? |
| 23:55 | Raynes | ibdknox: My experiments with Vim have led me to not hate it. That said, editing Clojure with it is as much of a pain as doing it with Sublime for me, because I have to switch to command-mode to do paredit commands, and I always forget where my leader character is on my blank keyboard. |
| 23:55 | Raynes | I'm giving it all time though. |
| 23:55 | Raynes | I'm just happy that I don't care about swank anymore and don't have to deal with that crap. |
| 23:55 | ibdknox | Raynes: you could map those commands to something in insert mode |
| 23:56 | cemerick | that wasn't supposed to happen |
| 23:56 | Raynes | Yeah, but I might have to learn VimScript. |
| 23:56 | cemerick | ,(format "i hate %s and %s in equal quantities; i hate all other editors in larger quantities" "eclipse" "sublime text") |
| 23:56 | clojurebot | "i hate eclipse and sublime text in equal quantities; i hate all other editors in larger quantities" |
| 23:57 | cemerick | jrabbit: it's the duplo of string interpolation in clojure :-) |
| 23:57 | cemerick | (just FYI) |
| 23:57 | ibdknox | speaking of... you performance people, should I resort to a stringbuilder to get efficient string concatenation? |
| 23:57 | jrabbit | cemerick: I don't know what that is but it works like python string formatting which is nice |
| 23:57 | brehaut | cemerick: the giant brightly colored blocks of string interpolation? |
| 23:58 | cemerick | ibdknox: StringBuilder |
| 23:58 | ibdknox | k, that's what I figured :( |
| 23:58 | cemerick | oooh, I'm tired enough that I thought ibdknox wrote 'StringBuffer" |
| 23:58 | ibdknox | lol :p |
| 23:59 | cemerick | brehaut: the not-very-powerful, not-very-flexible, but anyone-can-understand-it approach. |
| 23:59 | brehaut | cemerick: aha, whats the technic version? |