#clojure log - Aug 22 2012

The Joy of Clojure
Main Clojure site
Google Group
IRC
List of all logged dates

0:00 grizlo42: O.o

0:00 xeqi: I strongly recommend leinigen.org

0:00 for building a project, it will handle downloading the dependencies for you

0:00 tmciver: leiningen.org

0:01 grizlo42: ergh. i tried that at one point

0:01 xeqi: * http://leiningen.org/

0:01 tmciver: thanks

0:01 grizlo42: i just want to mess around with getting used to clojure

0:01 sigh

0:03 xeqi: then download http://search.maven.org/remotecontent?filepath=org/clojure/data.json/0.1.3/data.json-0.1.3.jar and use -cp ~/path/to/clojure-1.4.0.jar:/path/to/data.json-0.1.3.jar

0:03 grizlo42: so i tried lein repl, but still not sure how to install those deps

0:04 emezeske: grizlo42: In your project.clj file there is a :dependencies vector

0:04 grizlo42: ":dependencies [[org.clojure/data.json "0.1.3"]]"

0:04 grizlo42: I found the :dependencies entry by looking at https://github.com/clojure/data.json/

0:04 grizlo42: ohhhhh

0:05 xeqi: grizlo42: lein new testproject ; edit project.clj add [org.clojure/data.json "0.1.3"] to the :dependencies map

0:05 emezeske: grizlo42: Most clojure libraries will tell you "put this in your :dependencies"

0:05 grizlo42: got it. and then if i start up in that dir, it will know to use those deps?

0:05 emezeske: grizlo42: Yep!

0:06 grizlo42: ahhh

0:06 emezeske: grizlo42: It will automatically download them if necessary

0:06 grizlo42: its starting to make sense now

0:08 emezeske: Leiningen *is* one extra thing to learn, but it pays off pretty quickly

0:08 Without it, you'd end up writing shell scripts to launch java with the right classpath, etc. That works just fine, but at a certain point is less convenient.

0:09 grizlo42: emezeske: yeah this is true. im just being a baby. thanks for the pointers

0:13 samflores: I'm back just to say midje + lazytest do a great job :)

0:13 michaelr`: good morning clojurianians!

0:14 casion: good evening

0:28 * technomancy wonders why no one has ported lazytest to plain old clojure.test

0:31 emezeske: technomancy: From the readme: "The lazytest.deftest namespace is a drop-in replacement for the clojure.test library"

0:31 technomancy: Or is that not what you mean?

0:31 technomancy: emezeske: oh, I didn't know that

0:31 I've only heard of lazytest in the context of midje

0:32 wait, does that require code changes?

0:32 emezeske: You're such a midje hater ^_^

0:32 technomancy: I meant a drop-in replacement for lein test that has a filesystem watch loop

0:33 emezeske: Ah, I see

0:42 arohner: emezeske: midje has...problems

0:42 technomancy: I realize the irony of someone who goes by the moniker "technomancy" criticizing something for having too much magic, but I'm going to do it anyway.

0:43 midje lacks obviousness.

0:43 casion: the name itself could bear some obviousness

0:44 technomancy: I always accidentally type midge and then have to go back and fix it.

0:50 arohner: for a while, I've been threatening my cofounder that I'll write a testing library

0:50 emezeske: arohner: I certainly don't think that midje is perfect, but I find there to be a lot to like

0:50 arohner: actually, about 3 testing libs

0:51 technomancy: I think the reason everyone wants to write testing libraries is that you can achieve metacircularity (which feels awesome) without writing an entire interpreter.

0:51 err--self-hostedness, rather

0:52 frio: is clojure.test not preferred?

0:52 arohner: meh. I'm already self-hosted: https://circleci.com/

0:52 technomancy: heh

0:52 frio: IMO clojure.test is the best

0:53 arohner: I found clojure because I was researching writing my own lisp

0:53 technomancy: because it's obvious; you learn two macros, and for the rest of it you just use clojure. then for advanced features you learn use-fixtures, which is great.

0:54 frio: cool technomancy :)

0:54 is it decent/preferred for TDD? im starting a small project atm and would like to write some cursory tests first

0:56 technomancy: sure, the main thing to watch for with TDD is that you can't wait for the JVM to launch every time, so you have to keep a running process

0:56 usually that's lein repl or editor integration like clojure-test-mode

0:59 Scriptor: I wonder if there's a paredit coffee mug

0:59 frio: yeah; ive got a decent emacs setup currently technomancy, so im not too worried about that :)

0:59 brainproxy: Scriptor: thought would be cool!

0:59 *that

0:59 frio: (and am feverishly waiting on a new laptop to turn up, because doing development on my windows box makes me want to tear my eyes out)

1:00 Scriptor: brainproxy: from the size of the cheatsheet...that'd be a lot of coffee

1:01 brainproxy: Scriptor: I did take the .png of the cheat sheet and turned it into a PDF w/ looks nearly decent in full-screen on my macbook

1:01 https://github.com/michaelsbradleyjr/prelude/raw/master/personal/cheatsheets/PareditCheatsheet-letter.pdf

1:02 Scriptor: brainproxy: a little blurry here, but that might just be my computer

1:03 brainproxy: used photoshop to smooth out the enlargement.. still, it would be nice if someone could recreate it in the same way the official Emacs cheat sheets are composed

1:03 Scriptor: it is a bit blurry, but less jagged than simply blowing up the .png

1:20 technomancy: frio: there's always virtualbox =)

1:28 Scriptor: brainproxy: true, although browsers are getting better with smoothing out enlarged images

1:28 have you tried printing it out?

1:50 technomancy: swank clojure: officially deprecated. http://groups.google.com/group/swank-clojure/browse_thread/thread/c73bc8fe409a78d2

1:55 amalloy: all right! now i can stop telling people i think maybe you officially deprecated it

1:56 tomoj: huh, I just discovered nrepl.el yesterday :)

1:56 wmealing_: me too

1:56 it seems to start up a little slower than slime though

1:57 Scriptor: how tightly is nrepl bound to clojure?

1:59 tomoj: https://gist.github.com/d624bc7151cd2c789e58 - wonder if this is piggieback or cljs

1:59 I didn't even notice the extra nils until now

2:26 cemerick: tomoj: sorry, are you using leiningen or nrepl.el?

2:34 tomoj: cemerick: leiningen there, hadn't tried nrepl.el

2:36 cemerick: tomoj: You won't get the exception there; the leiningen REPL (via reply) uses the Clojure reader to determine when to actually send an expression to nREPL, thus the failure reading the #queue literal.

2:36 But, it does look like the extra nils are probably piggieback's fault.

2:37 tomoj: maybe file an issue?

2:38 tomoj: will do

2:41 cemerick: oh, I know why the nils are an issue. Also related to #queue not being available on the Clojure side. :-/

2:44 arohner: cemerick: thanks for the tweet!

2:44 cemerick: tomoj: yeah, definitely file that issue. That's going to be a PITA, I'm afraid...

2:44 arohner: Sure thing :-)

2:48 tomoj: fwiw it doesn't really bother me one bit, I was just confirming the existence of #queue[]

2:59 amalloy: there's a reader literal for queues now, at last?

3:01 tomoj: in cljs only it seems

3:01 surprisingly..

3:02 amalloy: btw, you were right long ago, a tiny patch makes the defcurrieds work with reduce-kv

3:02 amalloy: i'm glad i was right, but i don't remember what you're talking about

3:03 tomoj: well, the defcurrieds don't work with reduce-kv :)

3:03 amalloy: like uh, r/take?

3:03 tomoj: "reducer combinators"?

3:03 yeah

3:03 cemerick: tomoj: well, it'll happen for any literal that exists in cljs but not in clojure

3:04 amalloy: cool. well, submit that patch!

3:04 and one adding #queue for clojure too, so we can all stop doing this stupid c.l.PersistentQueue/EMPTY crap

3:05 cemerick: amalloy: http://dev.clojure.org/jira/browse/CLJ-976

3:06 "#queue" :-(

3:06 amalloy: *shrug* #queue is fine

3:07 personally i'd be inclined to have it output as #queue (a b c) rather than #queue [a b c], but i don't have a good reason

3:09 clgv: amalloy: I would name ordering as reason, since the order in a queue matters to its basic operation whereas a vector is random access

3:09 amalloy: so? ordering matters in queues, vectors, and lists

3:10 clgv: I mean you choose a queue because you want to put elements to the end and take them from the front^^

3:11 amalloy: uhhh

3:11 we're not talking about why you'd want to use a queue

3:11 obviously there are algorithms where queues are useful. i'm just saying how i'd prefer it to print

3:11 clgv: I wanted to support you with a reason for the #queue (a b c) notation instead of #queue [a b c] ;)

3:11 tomoj: isn't the atom reducer stuff like (swap! cnt dec) (if neg? @cnt ...) potentially buggy?

3:12 amalloy: tomoj: yes

3:13 alternatives are probably worse, tomoj, and cnt won't overflow until 2^63 elements have been dropped, so it's not a problem in practice, unless you see some other bug?

3:13 Scriptor: clgv: but vectors are better than lists for placing an element at the end, so I think it still goes both ways

3:14 tomoj: I mean the bug where something else swaps in between the swap! and the deref

3:14 amalloy: no, not a problem. only one thread ever has a handle on that atom

3:14 tomoj: sure, with the core reducibles

3:15 couldn't some other reducible do something different?

3:15 amalloy: with any of them ever, i think

3:15 tomoj: oh, hmm

3:15 amalloy: that code is in take, right?

3:15 tomoj: yeah

3:15 amalloy: and take isn't foldable, just reducible, iirc

3:15 tomoj: yeah

3:16 amalloy: so any reducer "source" that fiddles with take's atom in multiple threads is in error

3:17 Sgeo: How good/bad is Clojure with modifying code at run-time

3:17 tomoj: well

3:17 Sgeo: I think that's a thing people think of with Common Lisp and Smalltalk

3:17 Or at least that's the sort of thing I'm aiming for.

3:17 tomoj: I have one candidate for a reducer that might wind up using multiple threads

3:18 ..but I'm not sure if it makes sense as a reducer

3:19 if cljque had reducers integration, I would think the bug in take could be exposed

3:19 amalloy: Sgeo: people who think that about common lisp are not wrong implementation-wise - it can do that afaik - but are usually using a bad algorithm

3:19 tomoj: CollFold doesn't make sense there (afaik) but CollReduce, uh, might

3:19 Sgeo: amalloy, I mean for purposes of developing while it's running

3:20 Rather than restarting on each change

3:20 amalloy: Sgeo: clojure is maybe not absolute-top-notch with that, but it's very good

3:20 clgv: Sgeo: you dont have access to a functions code from the compiled functions without doing anything "special" but you can easily redefine functions

3:21 Sgeo: clgv, like CL and Scheme then, I guess. I can live with that.

3:22 clgv: Sgeo: someone on #clojure told that he is doing "genetic programming" with clojure

3:22 muhoo: it's an exciting time to be alive

3:23 Sgeo: Are there any subtle issues with macros vs CL? I remember reading something about the reader vs. CL's reader and Clojure's does ... something different with regards to placement of symbols in whatever the equivalent of packages is?

3:23 But I don't really remember it

3:24 amalloy: &`x

3:24 lazybot: ⇒ clojure.core/x

3:24 clgv: ,`x

3:24 amalloy: and macrolet doesn't have first-class compiler support, but is implemented in a library instead, so there are some quirks there

3:24 clojurebot: sandbox/x

3:25 Sgeo: How well/poorly does Clojure support code-walking? If for example some crazy person wanted to implement cl-cont in Clojure?

3:26 Is it easier than CL? Because afaik CL has some quirks that make it difficult

3:26 amalloy: poorly afaik

3:27 tomoj: https://github.com/swannodette/delimc

3:27 amalloy: Sgeo: but check out clojure.tools.macro/mexpand, which is a code-walker to include [symbol-]macrolet

3:28 * Sgeo vaguely wonders if there's a JVM standalone thing somewhere

3:28 Sgeo: In case I wanted to run something on a computer that didn't have it installed

3:30 amalloy: are you talking about gcj? throw it in the trash immediately; it is awful

3:30 Sgeo: amalloy, didn't have anything specific in mind

3:30 Just a concept

3:31 As in, looking for something similar to Tcl's tclkits and most CL implementation's... compileness

3:31 amalloy: doesn't exist. you need the jvm

3:32 clgv: in leiningen 2 :hooks do not work when I specify them in a profile :my-profile and execute with lein2 with-profile my-profile uberjar?

3:33 Sgeo: amalloy, and the JVM can't just be bundled into a .exe alone with the bytecode of a Clojure project?

3:34 amalloy: probably possible, but any sane person would murder you

3:35 clgv: Sgeo: you want >100MB *.exe files? :P

3:38 Sgeo: Why do protocols exist if you have multimethods? Is it for efficiency and interop with Java?

3:38 amalloy: yes

3:38 Sgeo: :/

3:39 Two distinct features, one of which is theoretically usable in place of the other (discounting interop).

3:39 amalloy: *shrug* if you take out all the efficiency and java-interop features, you're left with something that's as popular as common lisp

3:39 Sgeo: I'd use it over Common Lisp due to the immutable data structures, I think

3:40 michaelr`: i used multimethods yesterday, for string it would redirect for number it would return a http status code, should i have used a protocol instead?

3:41 amalloy: neither would be wrong

3:58 joneaves: hey all - quick question about strings - i seem to be missing something fundamental

3:59 (str "\\")

3:59 expected return?

3:59 tomoj: &(str "\\")

3:59 lazybot: ⇒ "\\"

3:59 joneaves: then how do i get a single backslash?

3:59 tomoj: &(println (str "\\"))

3:59 lazybot: ⇒ \ nil

4:00 amalloy: joneaves: "\\" is a one-character string, containing the single character backslash

4:00 joneaves: amalloy: thank you

4:00 so - it's a visual representation thing

4:00 amalloy: &(count "\\")

4:00 lazybot: ⇒ 1

4:00 amalloy: yes

4:00 joneaves: right

4:00 that is incredibly confusing

4:01 amalloy: that is how pretty much every language ever works

4:01 noidi: "\n" is a one character string as well, containing just the newline

4:01 amalloy: "\n" is different from "\\n"

4:01 joneaves: i'm pretty sure it's because my experience is (mostly) with Java - and to get the string, you have to evaluate it via a print

4:02 and i'm examining this in the REPL

4:02 amalloy: yep

4:02 joneaves: so - i really should compare it to a debugger - which of course would have the \\

4:02 but.... that's not been my world - so hence my confusion

4:03 thank you all very much

4:03 amalloy: yes, good insight in comparing it to the debugger

4:04 clgv: joneaves: you can use `pr` instead of `print` - that way the excaping is printed as well ##(do (pr "\\") (print "\\"))

4:04 lazybot: ⇒ "\\"\nil

4:05 joneaves: thanks clgv, what i'm doing is creating a mapper.js string to pass to a MongoDB which has a regexp in it - so i don't actually want to print it, but to have it evaluated later

4:05 but the (println foo) is a great trick to force evaluation - these are the little idiomatic things i need to keep learning

4:05 clgv: joneaves: I meant for examining on the repl ;)

4:06 joneaves: right

4:06 amalloy: joneaves: yep, so long as you don't refer to it as forcing evaluation it's a good way to get what you want

4:07 joneaves: amalloy: can you give me a better expression to use - that's what it seems like it's doing

4:07 noidi: joneaves, it's not really about evaluation. the string can either be displayed using its readable representation (e.g. "foo\\bar\n") or with all special characters in place (e.g. foo\bar<newline>)

4:07 amalloy: interpreting escapes? presenting a user-friendly string?

4:07 noidi: the repl does the former

4:07 joneaves: amalloy: interpreting escapes seems like the best phrase - cheers

4:08 amalloy: but if you imagine the string-escape grammar to be a simple programming language, then i suppose it's not unreasonable to call it "forcing evaluation" - it's just not what is usually meant by the phrase in a lisp, so everyone will be confused

4:09 noidi: yeah

4:09 joneaves: amalloy: i want to reduce confusion - hence the clarification - and yes - it makes reasonable semantic sense to phrase it "my way" - but i'd prefer to communicate clearly

4:10 tomoj: if I want a reify that takes args like extend, am I doing it wrong?

4:11 noidi: one more analogy: if you look at a text file in a hex editor, you'll get a different view of it than if you printed it using `cat` or `type`, but they both still represent the exact same contents

4:11 amalloy: tomoj: not necessarily, i think, but you can't have it

4:12 noidi: what the repl shows you (or any function calling pr) is a bit like the hex version of the text file, it doesn't really look like it does when printed out, but it gives you a more precise view of the contents

4:12 tomoj: amalloy: because of jvm impl specifics?

4:12 joneaves: noidi: yeah - i'm pretty familiar with the way things are encoded/stored etc - what i lacked was both the language to ask the question, and the idioms to understand how to verify my work in lisps

4:13 the "REPL is the debugger" helps me quite a bit

4:13 amalloy: mmmm, no, it should be technically feasible in the same way that it works for deftypes

4:13 Cr8: more so that things the repl prints out, you could reasonably copy-paste back in and get the same data again

4:13 amalloy: but for deftypes extend gives you core features you can't get otherwise (your functions can be lexical closures), whereas for reify you can close over whatever you want already

4:14 plus, because you need to close over things in a reify, passing it extend-like args usually wouldn't be very helpful

4:15 tomoj: for shared impls you can just call a shared helper fn in the reify

4:16 that was the only reason I knew to use extend

4:16 well extend is still more flexible that way, ignoring lexical closures, but I probably don't need it anyway

4:20 kral: hola

4:36 tomoj: Sgeo: I think protocols are about more than just interop

4:37 I dunno

4:37 * Sgeo vaguely notes that Clojure-style multimethods are doable in CL

4:37 tomoj: could you somehow bake defmulti/defmethod into the language and use them to define everything else?

4:38 Sgeo: Although writing macros for such has hit a bit of a snag

4:38 defmulti/defmethod is multiple-dispatch, which could be taken to be a more general case of protocol's single-dispatch

4:39 tomoj: right

4:41 but..

4:42 take (defprotocol ISeq (-first [coll]) (-rest [coll]))

4:42 (defmethod ISeq-first (comp type first)) ?

4:42 er

4:43 (defmethod ISeq-first type) ?

4:44 hmm

4:45 I guess you'd just do (defmulti first type)

4:45 with a (defmethod first :default) that calls seq

4:47 you lose satisfies? ?

4:47 guess you could replace it, and modify reify/deftype?

4:55 Raynes: Man serpent.

4:55 Oops, wrong channel.

4:55 Wow, I bet that sounded great out of context.

4:56 ejackson: spectacular.

4:57 core.logic problem: figure out a context where that doesn't like like.... well, like it sounds.

6:56 clgv: I try to create an object of a class generated with (:gen-class ...) but get an InvocationTargetException with cause "nth not supported on ...". My constructor defn juest returns a map

6:57 ro_st: antares_: is there a cheatsheet for validateur? or do i have to spelunk in the tests? :-)

6:58 antares_: ro_st: docstrings

6:59 and http://clojurevalidations.info

7:09 ro_st: ah, do you not have a marginalia doc for it?

7:10 antares_: ro_st: I can put codox reference up today

7:11 ro_st: that'd be handy, i reckon

7:14 antares_: do you have plans to put codoxen up for all the clojurewerkz projects?

7:14 antares_: ro_st: when all the guides are ready, probably

7:14 most projects have docstrings but they hardly offer much value over the guides

7:14 but I understand their purpose

7:15 ro_st: in val's case specifically i think it's valuable having a plain ole api ref available

7:16 great little library

7:19 kilon: can anyone link me to the well known clojure poll ?

7:20 michaelr`: try looking for "the clojure survey"

7:20 kilon: the one that shows what people use and suck

7:20 clgv: kilon: chas emericks survey?

7:20 kilon: michaelr`: thank you very much mate

7:20 clgv: yeap thats the one thanks

7:21 I want to recommend such a survey for Pharo

7:22 http://www.pharo-project.org/home

7:22 because i find that survey real eye opener and very useful

7:22 http://cemerick.com/2012/08/06/results-of-the-2012-state-of-clojure-survey/

7:39 antares_: ro_st: http://reference.clojurevalidations.info

7:40 ro_st: ah awesome!!

7:40 perfect :-)

7:40 thanks antares_

8:04 antares_: when presence-of gets a vector of symbols instead of a symbol, is that a way to combine multiple presence-of calls into one?

8:04 antares_: ro_st: just use presence-of multiple times

8:04 all it does is returning a function

8:04 ro_st: what does the vector do, then?

8:05 antares_: ro_st: nesting of attributes

8:05 ro_st: ahhh

8:05 handy!

8:05 antares_: [:address :street] will validate presence of (get-in m [:address :street])

8:06 ro_st: thanks

8:06 is it possible to nest validation sets?

8:07 antares_: ro_st: no. I cannot think of how that would work.

8:07 ro_st: cool

8:07 antares_: a validation set is a list of functions + a fancy way of reducing over the lsit, basically

8:08 ro_st: is there a way to use length-of to check for a minimum but no maximum?

8:08 ie, > 0

8:11 ah. length of is strings. i thought it was for checking the count in a sequence

8:15 antares_: ro_st: you can trivially write a function that will check for sequence length, too

8:18 ro_st: what about :at-least and :at-most variants for length-of?

8:18 just an idea :-) i'll make do with a fn of my own

8:18 antares_: ro_st: there are gt, gte, lt, lte

8:19 ro_st: ah so use numericality-of, somehow?

8:19 how would i tell it to use that on the (count (f m attribute)) ?

8:21 antares_: ro_st: length-of works for strings only

8:26 ro_st: rigt

8:27 antares_: ro_st: I would consider collecting good validators in validateur.seq/*, validateur.seq/length-of and so on

8:27 and similar namespaces

8:29 Sgeo: One of the criticisms I've seen of Lisp-1s is that they make unhygienic macros more problematic. Since Clojure is a Lisp-1 and uses CL-style macros, how well/poorly does that work out?

8:30 _fogus_: Sgeo: In theory Clojure macros are unsafe, in practice they work wonderfully

8:32 Sgeo: ...Clojure uses the typical try/catch rather than a CL-style condition system, doesn't it?

8:35 _fogus_: Yes

8:37 Sgeo: :(

8:38 _fogus_: Others have created condition-style systems as libraries however

8:38 Sgeo: Hmm, but I can't expect libraries to use them

8:39 Do those libraries intercept traditional Java/Clojure exceptions somehow?

8:39 _fogus_: That's the nature of libraries

8:42 Chousuke: Sgeo: Clojure solves most hygiene issues with a combination of two features: 1) you can't create namespace-qualified local variables and 2) syntax-quote automatically namespace-qualifies all literal symbols (and this can be circumvented if necessary)

8:43 so in practice it's very difficult to create hygiene issues with clojure macros if you explicitly don't attempt it.

8:56 osener: technomancy: I can't get nrepl-current-ns to return something other than "user", is that normal?

9:04 nevermind, looks like it is dependent on the current buffer

9:09 michaelr`: can i do an outer join in korma?

9:15 hmpf

9:15 can i?

9:15 can i do an outer join in korma?

9:17 ro_st: michaelr`: https://github.com/korma/Korma/blob/master/src/korma/core.clj#L217

9:18 the third example in that docstring gives you what you want i think

9:19 michaelr`: haha

9:19 thanks mate!

9:19 this has to be in the docs

9:19 ro_st: may the source be with you *waves hand*

9:19 michaelr`: i actually searched the source for "outer"

9:19 heh

9:20 oops train is at the station gotta go

9:22 cshell: wish I could take a (short) train to work

9:23 ro_st: antares_: if you want it https://www.refheap.com/paste/4549

9:28 S11001001: ,42

9:28 clojurebot: 42

9:29 duck11231: so 42 is also the question?

9:29 naeg: I'm missing a term...is there a special term for a procedure like (map * [1 2] [3 4])? it's not the scalar/dot product

9:32 igstan: naeg: zipWith usually, if I understand what you're asking

9:33 naeg: igstan: I'm not sure. I mean a mathematical term that describes it. It may not even exist, I'm just unsure whether there is one

9:33 S11001001: duck11231: in this case

9:35 duck11231: I could see Deep Thought using logic programming. Like it said, the hard part was asking the right question, after that, the answer came easy

9:36 cshell: matrix product?

9:41 edlothiol: naeg: componentwise product (or just "product" in contexts where it's unambiguous)

9:41 naeg: matrix multiplication seems to be what I looked for

9:47 samrat: how do I upgrade my nrepl package (its installed with emacs-starter-kit, using defvar my-packages)?

9:56 clgv: can I define new public methods with `proxy`?

10:05 seems that I need an interface

10:06 _fogus_: ,(doc definterface)

10:06 clojurebot: "([name & sigs]); "

10:07 _fogus_: Super helpful

10:12 clgv: _fogus_: what's better definterface + proxy or gen-class? I only want to implement an eventlistener that has an additional query method

10:12 naeg: scriptor: piranha_: Gave up comparing clojure collections vs. python collections - could reproduce every example I could think of for the last 3 hours in python almost 1:1 (beside some examples with hash tables)

10:12 AWizzArd: This one was probably already linked a few times, but anyway: http://sweaxis.org/stats/lang?src=hn10

10:13 naeg: I'm focusing on comparing different implementations of conways game of life in clojure vs. python

10:13 piranha: naeg: heh, interesting :-)

10:13 _fogus_: I don't know. But at least with definterface+proxy you can reuse the interface if needed.

10:13 clgv: gen-class requires aot. if I have definterface + proxy in the same namespace this should work without aot, right?

10:13 scriptor: naeg: can you paste some examples?

10:13 _fogus_: Ah yes! That too

10:13 naeg: http://pastebin.com/AEmg7JLM

10:14 clgv: well. then definterface + proxy seems better for that little task

10:15 naeg: I was able to boil down most of the examples similar to this one

10:16 since python supports some FP you'll most likely find many ways to reproduce such simple examples

10:16 but I don't think that's what most python programmers do

10:16 scriptor: naeg: of course, but at the same time I don't think you see a lot of type() calls in idiomatic python code

10:16 naeg: indeed, I haven't actually seen this before at all

10:17 scriptor: naeg: you should take some of the more challenging 4clojure problems and try to do the same

10:18 naeg: scriptor: I'm currently reading that paragraph about conways game of life - i'll try to compare some implementations of this algorithm

10:18 (Clojure Programming)

10:19 the clojure solution in the book is very neat and general, can't wait to find out what python has to offer

10:19 acheng: hello all. if your Mac is 32 bit and thus limited to Snow Leopard, would you keep it that way or install a linux distro? assume machine use includes clojure and other dev work. multimedia is not a high priority. i can take my answer off the air with /msg if this is too off topic :)

10:20 naeg: I'd always prefer a linux distro

10:20 S11001001: good way to start an os war in #clojure :)

10:20 naeg: :D

10:21 * naeg ...keep...your...mouth...shut...

10:23 wmealing_: acheng: are you more productive in OSX or Linux ?

10:23 acheng: you can always /msg me :-P i have zero Mac experience and some Linux experience. my priority is to continue to develop skills for future jobs

10:23 wmealing_: so linux it is

10:24 acheng: found my 20" iMac on the curb.

10:24 wmealing_: just laying around

10:24 naeg: it also depends on your environment. I guess if the company you work for creates only products for mac...

10:24 acheng: just seems so odd to have an iMac running something other than OS X. yes just sitting there on the corner surrounded by nice landscaping. like some kind of commercial

10:25 scriptor: a lot of companies these days develop on macs

10:25 so it's useful to at least get familiar with the environment

10:25 acheng: my workplace is primarily windows. there's maybe 3 macs around

10:25 naeg: I did so too for some time, it's not that bad afterall if you got used to it

10:30 acheng: ok. so i won't cancel my $20 order for snow leopard :-P good to know there's a lot of companies who dev on macs.

10:31 next question: someone hands you an xsd and some xml. do you use jaxb xjc to generate some java classes on your side? if not, what do you use?

10:31 jake__: good morning

10:32 edw: acheng: You use the cyanide capsule conveniently hidden in a molar.

10:33 acheng: edw: that might explain the vague feeling i've been having

10:34 jake__: Can I use the 'tools.namespace' library to get a list of which files have changed?

10:35 I would like to use it to write an auto testing loop?

10:35 acheng: jake__: did you check out lazytest?

10:37 jake__: I did, but namespace seems to be better at reloading namespaces (it deletes functions) then lazy test. the only piece of functionality i am missing is whether I should rerun the test or not

10:39 rhickey: http://sweaxis.org/ - they only have 7 Clojure participants so far: http://sweaxis.org/stats/lang

10:40 edw: amalloy_: ping

10:41 TimMc: rhickey: What's the difference between those first two scatter charts?

10:43 Ugh, question #2 needs to be split.

10:43 scriptor: TimMc: x-axis has a different range

10:44 estebann: has anyone had any luck using sqlite's ATTACH statement with java.jdbc

10:45 chouser: rhickey: clojure still doesn't seem to be an option in the survey. I wonder how it's in the chart at all.

10:45 TimMc: Meh, too many of those questions are weirdly stated and feel like trick questions. Not bothering.

10:46 joly: it wasn't in the list when I originally took the survey (picked "other"). It was in the list when I redid it just now

10:46 chouser: oh, I see it now. Yeah, it wasn't there when I did the survey either.

10:47 I reject the premise anyhow.

10:47 scriptor: I hope nobody is going to actually take this survey seriously

10:47 considering how biased the questions are

10:48 chouser: pretty charts though

10:48 TimMc: Sure, I'd love to be able to statically check my Clojure code if the type system didn't get in my way... but that's not what the language has. So I would answer "Agree", but still use Clojure.

10:48 hyPiRion: oh, the Yegge case yet again

10:49 dnolen: I'm 100% liberal!

10:49 TimMc: So am I a conservative whose favorite language is liberal? -.-

10:49 I desire things that so far I have not found practical.

10:49 Bronsa: i'm 54% liberal :(

10:49 hyPiRion: I believe this is a good representation of Yegge: http://abstrusegoose.com/483

10:50 joly: 76% liberal here

10:50 AWizzArd: TimMc: optional type checking is the right thing. And the progress on Typed Clojure is also very nice.

10:51 TimMc: I should take a look at Typed Racket one of these days.

10:52 edw: 84.72% liberal. That's what happens when HTTP becomes your ABI.

10:52 `fogus: The survey sounds like fun

10:52 edw: And you're a Lisper.

10:52 mattmoss: Question: if you have different namespaces/modules relying on maps, how do you prevent or deal with spelling/typos?

10:52 rhickey: Yes, very broken in that the title of some questions if often contradicted or exceeded by the descriptive paragraph

10:52 edw: Imagine if SOAP had won?

10:52 rhickey: Those problems were i nthe original essay

10:53 mattmoss: Example: I pass a map from one namespace {:hint 3}, but a typo in the other namespace is expecting {:himt ...}

10:53 `fogus: At least it retains the spirit of the original :p

10:53 AWizzArd: TimMc: Typed Racket is the parent of Typed Clojure so to speak.

10:53 clgv: lol clojure got younger in the past 10mins on that survey ;)

10:53 mattmoss: In many cases, no error is thrown or noticed, because (:himt m) will return nil.

10:53 Which isn't an error and, in some cases, is validd.

10:54 rhickey: clgv: yes, it will take a few of you to pull the age back from my having participated :)

10:54 clgv: rhickey: already done. ;)

10:54 scriptor: did my part

10:55 `fogus: Clojure is a great language for that 35-50 age range. As a parent I prefer Clojure... I often have time to sit and think, but very little time in front of the computer. ;-)

10:55 rhickey: flawedas it is, I think the result will be interesting as Clojure devs assess Yegge's original criteria

10:55 mattmoss: In C++, I could (roughly) const char* kHint = "hint"; then the compiler would alert me to the typo.

10:55 edw: I'm checking out the ordered project, and its ordered-map reader reads literals like this: #ordered/map([:a 42] [:b 'snafu]). Any idea why there's a seeming extra level of structure there?

10:55 mattmoss: In Clojure, I could do (def hint :hint) and use {hint 3} rather than {:hint 3}, but that seems like polluting the namespace.

10:56 rhickey: `fogus: I loved the tweet that went by the other day - five year old girl says "Daddy's not working, he's just typing"

10:56 * `fogus LOLs

11:00 xeqi: mattmoss: I solve that with tests

11:00 mattmoss: Anyone? How do you deal with typos in map keywords, when (:misspelled-keyword a-map) doesn't generated an error, but rather a nil, which may often be valid?

11:01 oops, sorry

11:01 hyPiRion: mattmoss: find

11:01 mattmoss: find?

11:02 `fogus: mattmoss: You can add a precondition on a function that checks for the existence of important keys.

11:02 hyPiRion: ,[(find {:hint 1} :hint) (find {:hint 1} :himt)]

11:02 clojurebot: [[:hint 1] nil]

11:02 ejackson: oh dear, only 54% liberal... see you guys....

11:03 hyPiRion: ,(if-let [[_ v] (find {:hint 1} :himt)] :key-exists! :key-not-there)

11:03 clojurebot: :key-not-there

11:03 `fogus: ,((fn [m] {:pre [(contains? m :a)]} (:a m)) {:aa 42})

11:03 clojurebot: #<RuntimeException java.lang.RuntimeException: java.lang.AssertionError: Assert failed: (contains? m :a)>

11:04 dnolen: ejackson: haha, it's important to read the description below the questions. The survey cunning flips directions halfway through. Also the descriptions are more nuanced then the question itself.

11:05 mattmoss: xeqi, `fogus, hyPiRion: So basically, I need to, in a test/precondition, name all fields just to say "Are you there?"

11:05 dnolen: ejackson: in anycase, anyone crazy enough to use core.logic and to encourage others to do so can't possibly be very conservative ;)

11:06 `fogus: mattmoss: If those keys are important for correct calculation, then it's not so bad.

11:06 jsabeaudry: Is lein2 still being hold off because clojars is not ready?

11:06 xcv: I'm facing a rather strange decision at my company - we have to make an offline app, and the options are a cross-platform desktop GUI app (in which case I would probably choose Swing and Clojure) or an iPad app. Does anyone here have an opinion? Is Swing an outdated bag of crocodiles? Or will iOS and Objective C drive me insane? We are developer-constrained, so the productivity of Clojure would be a big plus, provided that one of

11:06 the java GUI frameworks is kosher.

11:07 TimMc: `fogus: The trouble is typos in optional keys. :-/

11:07 mattmoss: `fogus: I come from many years of C++, where I wrote things such that the compiler told me when I typo'd and other similar basic mistakes.

11:07 `fogus: OK

11:07 scriptor: xcv: what does the app need to do?

11:07 mattmoss: So I understand TDD and the like, but my mind doesn't quite work that way yet.

11:08 TimMc: mattmoss: You could make a little fn that checks a map's keys for anything outside of a known set.

11:08 ejackson: dnolen: thank heavens !

11:08 scriptor: it took me a while to realize I was doing a bastardized form of TDD for a while

11:08 I always liked writing the code to use an interface first

11:08 xeqi: mattmoss: if you want the computer to verify against programmer intent, then you have to write that intent somehow. Static typing is one way, preconditions another, tests another still

11:09 * ejackson confesses that he does sometimes miss Types.

11:09 ejackson: static ones !

11:09 xcv: scriptor: highlight and annotate text, the rest is probably doable with built-in widgets. And background sync with the server when online, but of course that's outside the GUI.

11:09 TimMc: 21. "Bag of crocodiles" sounds exciting. [Agree <-> Disagree]

11:09 mattmoss: xeqi: But I don't know that I'd classify a typo as programmer intent. So, simplistically, in order to make sure I use the same string repeatedly in C++, you bind it to a const char* and use that.

11:10 A typo in the identifier will flag a compiler error

11:10 rbxbx: xcv there's always offline ClojureScript.

11:10 mattmoss: A typo in a string literal won't.

11:10 `fogus: Can C++ type checking help against misspelled map keys?

11:11 xeqi: mattmoss: you don't take it a step further and make objects for each string value so they can be type checked?

11:11 * objects with a common parent interface

11:11 `fogus: mattmoss: Clojure supports that same pattern.

11:12 mattmoss: My use of const char* was just an illustration... more likely, yes, I'd use an object.

11:12 xcv: rbxbx: Would that be run in a browser, then? The offline storage stuff in HTML5 didn't charm me when I looked into it... Am I wrong there? Or is there some new hotness in the offline web space that I've missed?

11:12 mattmoss: And I do realize I could do that in clojure do, with (def hint :hint)

11:12 chouser: `fogus: no, but you don't use maps in C++ because they're so painful :-)

11:12 mattmoss: chouser: good one :)

11:12 `fogus: chouser: zing!

11:13 mattmoss: But, in trying to learn Clojure "The Right Way" (tm), doing (def hint :hint) seemed to be wrong, and so I came asking how Clojurians did things the right way.

11:13 rbxbx: xcv not that I know of, that was basically my idea. I've not interfaced with it via cljs but I didn't think the api for offline storage was bad.

11:13 hyPiRion: ,(let [get-or-die (fn [map key] (if-let [[_ v] (find map key)] v (throw (Exception. "key not found"))))] (get-or-die {:hint 1} :himt))

11:13 clojurebot: #<RuntimeException java.lang.RuntimeException: java.lang.Exception: key not found>

11:13 chouser: I do miss static checking. I do not miss required static checking, nor munging everything that need to be checked into a type system.

11:14 hyPiRion: I don't know if there's an equivalent in core.

11:14 xcv: rbxbx: Ok. I was just worrying that it was experimental or not getting enough love and attention from the browser devs, but if you've used it in anger and been satisfied I'll give it an honest go.

11:14 xeqi: in general its not worried about

11:14 mattmoss: A precondition looking for expected keys on each function seems the way to go.

11:15 TimMc: mattmoss: (def foo-keys #{:flurb :grovel :norc}), (defn ok-keys [m allowed] (set/subset? (keys m) allowed)), (defn [foo] {:pre [(ok-keys foo foo-keys)]} ...)

11:15 `fogus: chouser: I'm still trying to figure out a way to encode "Make sure that my system handles 10,000 simultaneous connections" in a type system.

11:15 chouser: :-)

11:15 xeqi: but determining a typo in a key is definintly determinining intent

11:15 mattmoss: It's mostly something I want to add for myself, because when I do mistype a key, I then start littering code with println, and that just bugs me.

11:15 rbxbx: xcv don't let too much of your choice ride on my opinion, I just think it's an okay option. If nothing else you could do a 2-4 hour timeboxed spike on it and probably form your own opinions :)

11:16 mattmoss: TimMc: Yeah, something like that is what I'm thinking.

11:16 ejackson: chouser: yeah, exactly ! Every now and then I want to put a line around stuff and say only let the following types through.

11:16 TimMc: Throw in a (set ...) around (keys m).

11:16 xcv: rbxbx: Of course :) I had just dismissed it some time ago, what you said might make me whip up a minimal prototype to see how I like it.

11:17 rbxbx: xcv awesome. Please report back with your findings if you get a chance :)

11:17 ejackson: chouser: I end up using :pre and :post, but it feels like compiler work.

11:17 chouser: ejackson: It's sometimes worth using assert or pre/post conditions for that

11:17 yeah

11:17 ejackson: he !

11:19 xcv: rbxbx: I will :)

11:19 mattmoss: Thanks guys... gotta run for now.

11:20 `fogus: ejackson: Are you limiting yourself to type checking?

11:20 ejackson: fogus: in some cases - but I do use them for other sanity checking

11:26 dnolen: mattmoss: another approach would be explicit access protocol + defrecord. use pre / post everywhere for type checking always seemed yucky, at least to, to me.

11:32 chouser: I think an explicit access protocol to retrieve data is also yucky.

11:34 hyPiRion: It's much work just to ensure you don't do typos.

11:34 chouser: it would be interesting to have an easy-to-use technique for getting/setting map keys that requires the key to exist, and try to get used to using that everywhere

11:34 hyPiRion: I think it would be better to just fix the typo.

11:34 dnolen: chouser: perhaps but less invasive if all you want is to avoid typos & get immediate failure. But I'm very biased since I work a lot w/ deftype.

11:34 chouser: would have to be as fast as (:foo bar) and nearly as convenient.

11:35 TimMc: hyPiRion: Even better would be to never make typos!

11:35 But that's now people work.

11:35 *not

11:35 hyPiRion: TimMc: We are only humans, not machines.

11:35 TimMc: *not how <-- wow, that's an interesting one

11:36 hyPiRion: Speaking of the devil, eh.

11:36 jsabeaudry: Anyone knows if crate works well with advanced compilation?

11:37 `fogus: Trammel has defconstrainedrecord, but it's far from speedy. But at least it can be turned off if the need arose.

11:37 chouser: the value of the static checking is proportional to ratio of the pain felt later (that is, the difficulty in identifying and fixing the problem) if the checking is not done over the pain felt in encoding the required checking.

11:37 `fogus: interesting to consider the difference between associating the checking with the collection vs. the operation

11:38 dnolen: chouser: for me also just currently defining ILookup + case serves the same purpose over access protocols. keyword access syntax + immediate failure.

11:38 `fogus: chouser: I went with the operation

11:38 chouser: dnolen: yes, that's an interesting option.

11:39 `fogus: oh, you use a different lookup fn to get checked vs non-checked, even when using a defconstrainedrecord?

11:39 dnolen: chouser: of course that won't work w/ defrecord.

11:39 `fogus: chouser: but it could just as easily go with the record

11:40 mk: what's the reduce/fold that works for associative binary operations? And does it use multiple threads?

11:40 `fogus: chouser: No. I modify assoc/etc. to look up the constraint checker in the record's metadata

11:41 chouser: `fogus: oh, I meant the other option would be to provide two different versions of each op -- checked and unchecked, allowing users to do what they want.

11:42 `fogus: chouser: That is a nice idea. I might add that.

11:42 chouser: I don't know which is better; just pondering

11:42 `fogus: Me too

11:43 That might be a different library in any case since Trammel is meant as an all or nothing thing

11:44 * chouser nods

11:56 ostens: +cnt

12:02 jaley: hi! is there a way to implement a protocol for an array type? like [I, for example?

12:02 chouser: awesome question!

12:03 jaley: the reader doesn't like [I, clearly

12:03 chouser: You might try it in quotes, I don't know the answer.

12:04 * nDuff knows it can be done, but doesn't know the cleanest approach syntax-wise.

12:04 jaley: my goal is to create a version of sort that calls Arrays.sort() on an integer array, because it's 10x faster than Collections.sort(), by the way

12:04 if I'm already in crazy-person territory with that, reign me in :)

12:05 jsabeaudry: Well if type metadata is an indicator i specify that a variable is an array of bytes using: ^bytes

12:07 jaley: obligatory microbenchmark from a colleague: https://gist.github.com/73878a2fec73a6a3dbb4

12:07 jsabeaudry: jaley, have you tried "ints"?

12:08 jaley: jsabeaudry: on it now

12:08 `fogus|eats: For multimethods dispatching on (class foo) you need to put something like (Class/forName "[Ljava.lang.String;") in the method definition

12:08 jaley: no, ints is not a class

12:08 relevance.engine.core> (class ints)

12:09 clojure.core$ints

12:09 `fogus|eats: Maybe this is something to explore

12:09 dnolen: jaley: http://dosync.posterous.com/51626638

12:10 jaley: arrays are an open set so you have to do something dynamic. but it works and it's fast.

12:10 jaley: fogus|eats: that works

12:11 ostens: I'm noobish to clojure, and I had a question regarding strategies for function definition.

12:11 jaley: dnolen: ok thanks

12:11 ; (extend-type (Class/forName "[I") Sortable (sort [this] ... ))

12:11 ostens: I'm interested in writing a music library (notation), and have been writing functions for things like converting MIDI to frequency

12:12 ejackson: ostens: I'm pretty sure you'll find all of that in Overtone...

12:12 fwiw

12:13 edw: Anyone have advice for a poor sod stupid enough to type "(read)" into their Emacs *nrepl* buffer?

12:13 ostens: thanks, ejackson, but I'm specifically interested in notation, similar to PWGL (an algorithmic composition environment in common lisp)

12:13 technomancy: edw: are you on 0.1.3? I think it might have been fixed.

12:15 ostens: My question is this: for conversion functions like that, should I write the function to handle single values and then just map it where appropriate, or should I build it to deal with vectors?

12:15 edw: technomancy: An nrepl-version fn might be handy. :P

12:15 technomancy: edw: it shows when you connect

12:15 edw: Yeah, 0.1.3

12:16 technomancy: huh, ok... must be something else then

12:16 edw: C-c C-b doesn't do the trick.

12:16 ejackson: ostens: i'd go with the former, but thats IMHO.

12:16 edw: Oh wait...

12:16 technomancy: you could always try entering something in the *nrepl-server* buffer

12:16 edw: No, that's _available_, I have 0.1.2 _installed_.

12:16 ostens: Just wondering what was idiomatic. Thanks!

12:19 jkkramer: with nrepl.el, can arg lists be shown in the echo area when editing code in non-repl buffer?

12:19 edw: Ah, much better, technomancy!

12:19 technomancy: jkkramer: I think turning on eldoc-mode should do the trick

12:20 jkkramer: technomancy: that gives me arg lists for emacs lisp functions

12:20 edw: Interestingly, if an exception occurs while reading, and another READ is preformed, nrepl.el uses the existing (mini)buffer.

12:25 technomancy: any windows users want to debug what's going on here? https://github.com/technomancy/leiningen/issues/674

12:26 jkkramer: technomancy: think the eldoc-mode thing this warrants creating an nrepl.el issue or am I doing something wrong?

12:28 technomancy: jkkramer: yeah, just confirmed it here. it used to work in an earlier version

12:28 jkkramer: actually it looks like nrepl-eldoc-enable-in-current-buffer does it

12:28 jkkramer: so you just need that in a clojure-mode hook

12:30 jaley: so... would there be anything wrong with having clojure.core/sort use Arrays.sort() when passed a primitive array?

12:32 chouser: jaley: does that mutate the array? clojure.core/sort always returns a new sorted collection.

12:32 edw: amalloy_: ping

12:33 jaley: chouser: yeah... I guess it would need a copy? though Collections.sort() also mutates the collection i think?

12:33 chouser: both have void return type

12:33 pepijndevos: I remember several clojure projects getting a free yourkit thing, how does that work?

12:33 jaley: chouser: wait... it already uses Arrays.sort

12:34 dnolen_: pepijndevos: your project needs to be open source, email them - that's about it

12:34 jaley: chouser: but it uses to-array, so it will always box the ints

12:35 pepijndevos: dnolen_, does it need to be a well known and widly used?

12:36 dnolen_: pepijndevos: not as far I can tell.

12:36 pepijndevos: cool

12:57 dansalmo: instead of (-> 1 comp (repeat 3 inc)) is there something like this that works? (-> 1 comp (repeat 3 inc))?

12:57 instead of (-> 1 comp inc inc inc) is there something like this that works? (-> 1 comp (repeat 3 inc))?

12:58 chouser: (+ 3) ?

12:58 clojurebot: 3

12:58 jsabeaudry: While in a clojure-jack-in session, what is the best way to search all files of the project for a specific string?

12:59 chouser: C-x RET git grep "your string" # :-)

13:00 jsabeaudry: "C-x RET g is undefined"

13:01 technomancy: M-x rgrep

13:01 chouser: Oh. that just shells out so you can run git grep

13:01 Mine does, I mean. I don't know what technomancy's does

13:01 Probably something better :-)

13:03 technomancy: hyperlinked grep <3

13:03 jsabeaudry: technomancy, That works

13:03 Thanks

13:04 technomancy: there's a half-baked find-usages in swank-clojure, but I recommend rgrep

13:15 jsabeaudry: As of now I have a bit of ui code in my noir defpages and a lot of ui code in my clojurescript, I'm pondering wether or not I should move all ui code to clojurescript by making use of crate. Anyone has input regarding this?

13:16 xeqi: is there an elisp equivalent for (some #{'clojure-mode 'clojurescript-mode} major-mode) ?

13:18 emezeske: jsabeaudry: I use crate a lot. The only reason I'd hesitate to recommend it is that it does not appear to be maintained at the moment.

13:19 jsabeaudry: emezeske, is it mature? lots of bugs left?

13:19 emezeske: jsabeaudry: No, it is definitely not mature

13:20 jsabeaudry: Right now I have to run my own branch of crate that has bug fixes applied, etc

13:20 jsabeaudry: emezeske, I see, thank you very much for the input, I'll definitely hold off crate usage or now

13:21 I'm not too experienced with web development, is it very common for web servers to serve only javascript and no html at all?

13:22 stuartsierra: It is not *very* common, but it is becoming more popular for some kinds of applications.

13:23 http://en.wikipedia.org/wiki/Single-page_application

13:26 jsabeaudry: stuartsierra, Ah! Exactly what I had in mind! Thanks!

13:26 mmitchell: Anyone have any good approaches for configuring a clojure web app (ring) at runtime? For example, I have a namespace that needs a few variables to be configurable at runtime, without re-deploying.

13:27 jsabeaudry: mmitchell, I think drawbridge is aimed exactly at that purpose

13:27 mmitchell: jsabeaudry: interesting, i'll have a look

13:29 technomancy: drawbridge is something else

13:29 you might want environ

13:43 the-kenny: lynaghk: I think crate had the problem that it doesn support stuff like [:ul (for [i (range 100)] [:li (str i)]] while hiccups (what I use in the job) just spits out strings which makes attaching fns very hard

13:43 lynaghk: the-kenny: the latest singult snapshot handles exploding seqs fine. I'm pushing out a new release later today.

13:43 the-kenny: Ah, nice!

13:44 lynaghk: the-kenny: also, singult is 20--100 times faster, since it's written in plain JavaScript.

13:44 the-kenny: Another thing I always wanted is some syntactic sugar for events: [:input {:type :button, :onclick #(js/alert "ohai!")}]

13:44 francis: man grep

13:44 of course, not in shel

13:45 lynaghk: the-kenny: I've thought about that, but I'm not sure what I want the semantics to be there. In particular, should re-rendering remove old event handlers or complement them?

13:46 the-kenny: The big feature of singult is that it does DOM merges to update state. If it was just plain create+append new elements only, then sugar for event handlers would be doable.

13:47 the-kenny: lynaghk: I haven't had a look at singult, I'll take a look later today :)

13:47 lynaghk: the-kenny: (obligatory disclaimer: I'm the author, so take everything with a grain of salt).

13:47 the-kenny: I know :)

13:47 I'm back in about 20-30minutes, I'll have a look then

13:47 lynaghk: the-kenny: most of the time you'll want to use it through c2's dom namespace. Take a look at https://github.com/lynaghk/c2-demos/blob/master/todoMVC/src/cljs/imtodo/list.cljs for some use case.

13:48 naeg: someone willing to give me some feedback on this explanation of conway's game of life: http://i.imgur.com/dP0Zf.png

13:50 jsabeaudry: naeg, what sort of feedback? ("an initial state" vs "a initial state" ?)

13:51 naeg: jsabeaudry: whether you basically understand what conways game of life is about after reading it

13:51 and thanks for that, corrected. also removed the "Then" at "Then the same procedure [...]"

13:52 casion: naeg: besides the copying from wikipedia, it's good

13:52 naeg: casion: I'm lazy :P does copying those four rules matter that much?

13:53 casion: and the images? and similar word choices

13:53 it's no big deal, I'd have done the same thing… no use rewriting a good explanation more than is needed

13:53 amalloy: edw: what's up?

13:53 casion: but at the same time, it's no more of an explanation than linking to wikipedia

13:54 naeg: casion: yeah, I'm just doing this for a blog post. so I don't focus on this explanation too much, more on the implemenations in Clojure and Python

13:54 but for a blog post, it's better to write such things myself then just say "read it up on wikipedia", isn't it?

13:55 I tried to compress is to all the reader needs to know, and the wikipedia article is huge

13:55 casion: naeg: when I wrote something similar I felt it important to explain the patterns a bit more

13:56 chouser: A lot of programmers know what Conway's Game of Life is. Does your audience need more than one sentence a link to wikipedia?

13:56 naeg: casion: for example how the glider moves along?

13:56 casion: naeg: for example, yes

13:56 chouser: I agree

13:56 naeg: chouser: i'm actually explaining a few more things before coming to the code, and I created a note that said that reader who e.g. know what clojure or conways is, can safely skip those paragraphs

13:57 casion: I did soemthing similar writing life in supercollider, and I figured anyone reading it would have a decent clue

13:57 but in my context, algorithmic composition, explaining the patterns more in depth than wiki was helpful

13:58 naeg: they will see the algorithm implemented in Clojure and Python and with further explanation

13:58 casion: at the very least, a paragraph on gliders probably would keep a mildly imformed reader interested

13:58 since they're the simplest interesting spaceship

13:59 naeg: I'll think about doing so. But as I said, this blog post should actually be about comparing cownays game of life implementations written in clojure and python

14:00 but thanks for your feedback, at least I know that people will most likely understand what the game is about

14:03 firesofmay: Which is the recommended library in clojure for image manipulation/matching?

14:03 casion: firesofmay: imageJ is very good if you don't mind plain java

14:05 firesofmay: casion, I do mind plain java :p It would be better if there is something in plain clojure.

14:06 casion, Basically I am trying to do image comparison testing of websites. For normal testing i am using clj-webdriver, but I don't know if there is anything good in clojure for image comparison testing.

14:06 casion: other thank using imagemagick or imagej, I don't know anything particularly useful

14:07 not sure why someone would rewrite imagej anyway, it's very easy to use and I thought much of the purpose of clojure was java interoperability anyway

14:09 firesofmay: casion, cool. I'll check them out. Anyway I have a very simple use-case.

14:09 casion, thanks for your help :)

14:10 casion: sure, there maybe something whipped uf clojure that I don't know about

14:10 but imageJ is pretty standard

14:35 dansalmo: :chouser - thanks, but answer by clojurebot was more succinct.

14:36 what is the correct way to do something like this: (-> 1 comp (repeat 3 inc))

14:36 so that is does this (-> 1 comp inc inc inc)

14:36 amalloy: not use an arrow

14:37 and (-> 1 comp inc inc inc) is nonsense that will throw an exception

14:37 drewr: ,(-> 1 inc inc inc)

14:37 clojurebot: 4

14:38 dnolen: dansalmo: you asked this earlier, it cannot be done. -> is not about composing functions, it's syntax transformation.

14:38 dansalmo: something more general than 4?

14:38 \

14:38 sorry, I am new to clojure

14:39 drewr: ,((comp inc inc inc) 1)

14:39 clojurebot: 4

14:39 dansalmo: I want to call a fn n times, feeding the results forward

14:39 amalloy: &(nth 4 (iterate inc 1))

14:39 lazybot: java.lang.ClassCastException: clojure.lang.Cons cannot be cast to java.lang.Number

14:39 amalloy: &(nth (iterate inc 1) 4)

14:39 lazybot: ⇒ 5

14:41 dansalmo: :amalloy - thanks, that's what I needed.

16:00 stuartsierra: Hey y'all, when you're working at the REPL, and you want to switch namespaces, do you use 'in-ns' or just 'ns'?

16:00 * nDuff just uses ns

16:01 stuartsierra: (This is for a class I teach)

16:01 dnolen: stuartsierra: in-ns, mostly 'cause Chouser said it was more idiomatic ;)

16:01 * metajack uses in-ns

16:01 chouser: ns is dangerous is the namespace you're switching to did some :refer-clojure stuff

16:01 metajack: i was under teh impression ns did seoms refers or something when you used it

16:01 chouser: s/is/if/

16:01 duck11232: in-ns if I'm not using C-c M-p

16:02 stuartsierra: Yes, `ns` automatically refers `clojure.core`

16:02 chouser: so, in-ns

16:02 stuartsierra: Chouser's example is a good one.

16:02 chouser: stuartsierra: are you in the class now? Tell 'em hi for me!

16:02 stuartsierra: no, in a few weeks

16:03 chouser: oh, oh well.

16:03 :-)

16:03 stuartsierra: But I'll tell them you said hi.

16:06 jweiss: does anyone remember what lib lets you organize ns use/requires into re-usable groups? i saw that somewhere and can't find it again

16:07 stuartsierra: Just define a function that refers/imports what you want. DON'T create new Vars.

16:07 technomancy: jweiss: nstools

16:09 stuartsierra: I usually do (doto 'my.ns require in-ns) because I enjoy feeling like a smartass

16:10 stuartsierra: ha

16:10 chouser: stuartsierra: wow, that's a really good idea.

16:10 * chouser thinks about it more

16:11 jweiss: stuartsierra: you mean move that stuff out of the in-ns macro and replace it with a require for a function that does all the rest?

16:11 steveo: ls

16:11 stuartsierra: jweiss: yes

16:11 technomancy: it sucks that you have to resort to hacks to make it declarative inside the ns form like nstoos

16:11 steveo: *oops

16:11 stuartsierra: or just make bigger namespaces, which is the sane solution

16:12 jweiss: big namespaces have drawbacks too, harder to find stuff in them

16:12 especially when it does break down logically into smaller ones

16:12 stuartsierra: Split it across files with `load` if you want.

16:13 technomancy: ugh; no

16:13 jweiss: yeah i tried that too, don't like it

16:13 edw: amalloy: ping

16:13 jweiss: nstools is not quite what i want, i don't want to totally clone the whole set. i'll try the function approach

16:14 amalloy: pong again

16:14 technomancy: nstools is egalitarian in that it allows you to get close to promoting your own namespace choices as default alongside clojure.core

16:15 edw: Oh hey. Sorry, amalloy. I was looking at your ordered map imeplementation and was wondering what the rationale behind the "extra" vector container for each pair is.

16:16 amalloy: edw: in the vector used to keep ordering?

16:17 edw: In e.g. "#ordered/map([:a 42] [:b true])" I'm referring to the inner brackets.

16:17 amalloy: that's just an artifact of the printing, not the internal representation

16:18 ([:a 42] [:b true]) is what (seq m) would look like; (:a 42 :b true) isn't what anything would look like

16:18 edw: But your reader fn gets that nested datastructure from the reader, correct?

16:18 amalloy: yes.....?

16:19 edw: As opposed to a flat list...

16:19 Raynes: ............

16:19 amalloy: right. i could choose either format for serialization

16:19 Raynes: <3

16:19 edw: ........

16:19 amalloy: i chose to wrap vectors because it looks like the seq of a map, which is familiar

16:19 and helps you tell what pairs with what

16:19 edw: I was thinking that this may cause unnecessary memory allocations on reading.

16:19 amalloy: *shrug* sure

16:20 clojure is an exercise in mostly-unnecessary allocations

16:20 the reader is abominably slow compared to what you spend most of your time doing; i chose the serialization format to optimize for legiibility, not minimizing tiny allocations

16:21 * edw makes a Marge Simpson-like pained noise.

16:22 edw: It's not clear to me that that format is more legible, as it is noisier than Clojure's map syntax e.g. {:a 42 :b true}.

16:22 amalloy: i'd be calling partition 2 on the seq anyway

16:23 the allocations just show up in the reader instead of in my literal-reader-function

16:24 and you're of course free to not find it more legible, since it's clearly a close choice that mostly doesn't matter, but i'm not going to change it

16:24 edw: amalloy: Fear not, I'm wasn't going to ask you to change it.

16:25 * edw flips some bits

17:21 naeg: what am I doing wrong when source can't find the code of my function?

17:23 edw: Could you provide us a bit more context? In SLIME?

17:23 naeg: edw: clj

17:24 edw: Right. What source can't find what function?

17:24 naeg: ehm, not sure whether this was clear, but I'm talking about the (source) macro from clojure.repl

17:24 (source n)*

17:25 edw: Did you redefine it at the repl? Or in SLIME or nrepl?

17:26 If you did, there's no source file info associated with it.

17:26 C-c C-k from Emacs will recompile the file, which will associate file and lineno info.

17:27 For nrepl; I've forgotten the SLIME binding.

17:27 naeg: edw: I'm now in emacs or something, just clj, the clojure repl

17:27 what I'm really trying to do is to see the actual code of a function that is returned by another funtion

17:27 edw: So did you type in the func like ">(defn my-inc [n] (+ 1 n))"

17:27 naeg: yes

17:29 edw: That's not going to work. Unless the fn has lineno and filename metadata, there's no way to get the source. Are you trying to see what some anonymous function returned by a closure looks like?

17:30 naeg: nope, just a "regular" HOF

17:30 nvm then, will figure out without actually seeing it then

17:30 llasram: naeg: To elaborate on what edw is saying, `source` doesn't work by way of the actual source being saved in-memory and associated with each var. Instead just the file & lineno is saved, and `source` uses that. So something needs to come from a file for `source` to work

17:31 Which I guess really is exactly what edw said in the first place. I think time to go home...

17:31 edw: Thanks, llasram. To further elaborate, it's not like WebKit's inspector which will show you the de-tokenized JavaScript fn when you inspect it.

17:32 amalloy: you can take a look at technomancy's serializable-fn, which creates functions (including closures) that print as their source code

17:32 naeg: it's not that important actually, I was just wondering if and how it's possible

17:32 thanks for the answers though

17:49 mk: what's the reduce/fold that works for associative binary operations? And does it use multiple threads?

17:59 TimMc: mk: You're thinking of the upcoming reducers library?

17:59 It uses Fork/Join.

18:00 mk: TimMc: I'm not sure at all, I thought it would already be in clojure

18:01 TimMc: IIRC it is in Clojure master, but not in an extant release.

18:01 amalloy: the 1.5 alphas

18:01 TimMc: Oh hey, we have alphas?

18:02 amalloy: four of them, i think

18:02 mk: what's the actual function called, if there is one? Presumably the same form as reduce, but due to assoc, can be run in parallel?

18:03 jkkramer: mk: https://github.com/clojure/clojure/blob/master/src/clj/clojure/core/reducers.clj

18:03 amalloy: fold

18:03 it needs more information than reduce does

18:05 mk: TimMc jkkramer amalloy: thanks

18:19 nathanmarz: technomancy: hey, have a leiningen question for you

18:20 mk: nathanmarz: ask away

18:21 nathanmarz: i have a somewhat difficult build problem

18:21 i'm trying to write a test for dependency isolation in storm

18:22 we have some code that does some funky classloader stuff to distinguish between user code and storm system code

18:22 so i want to write a test that ensures that the right classes are loaded at the right times

18:22 so i want to have a "subproject" in storm that defines a user topology

18:23 it should build a jar (using lein jar), except use the classes from the parent project

18:23 i tried doing something like this: http://pastie.org/4570814

18:23 but it looks like you can't override the classpath like that

18:24 so the question is, how do you disable leiningen's auto-construction of the classpath and just specify it yourself?

18:26 technomancy: nathanmarz: it sounds like the same problem you have with hadoop where you want one set of jars visible during runtime inside leiningen, but a different set of jars included in the uberjar; is that right?

18:27 nathanmarz: mmm

18:28 well, not really

18:28 leiningen handles that case without issue

18:28 the way our custom classloader works

18:28 technomancy: what's the root problem? you want to be able to use a given version of a dependency in storm in a way that doesn't preclude a different version in the project?

18:28 nathanmarz: is that when we launch storm, we don't include any user code on the classpath, and instead set the location for that in a custom environment variable

18:29 i want to test that our custom classloader works

18:29 so i need to build a test topology in a separate jar

18:29 but i want to build that test topology against exactly what's in the Storm project at the moment

18:29 so i have a subfolder

18:30 storm/test/test-topology

18:30 which has its own project.clj (my attempt is in that pastie)

18:30 and i want it to build against the classpath of storm, which i'm computing with (with-sh-dir "../.." (:out (sh "lein" "classpath")))

18:31 that way i can build my topology jar against the version of storm in the project, and write tests that test my custom classloader

18:31 technomancy: ok, so you aren't really nesting it in that case?

18:31 nathanmarz: what do you mean by nesting?

18:31 technomancy: you could link the top-level project into the checkouts/ dir of the test project

18:32 nathanmarz: oh

18:32 let me try that

18:32 technomancy: I mean if you want storm's classpath on the classpath of the project, then you're not isolating it

18:32 nathanmarz: it should be there on compile time, the isolation will happen at runtime

18:33 technomancy: ok, so whatever you're using as your -main is going to handle that; the classpath leiningen calculates isn't going to be used to run project code then?

18:34 well, try the checkouts approach; if I understand the problem that should take care of it

18:34 nathanmarz: yea, that sounds about right

18:34 so with checkouts, i guess i can just put some fixed version of storm in :dependencies

18:35 and then it will always compile against the latest?

18:35 does that apply to "lein jar" too?

18:35 technomancy: no, checkouts are only a dev-time convenience

18:36 you'll want to bump the storm version in :dependencies if storm's dependencies change

18:36 since checkouts aren't transitive

18:36 nathanmarz: so if i do "lein jar" it will ignore checkouts?

18:36 technomancy: yeah

18:36 nathanmarz: ok

18:36 yea, so i need this behavior during lein jar

18:37 SegFaultAX|work2: I'm only just scratching the surface of datomic, but from what I've seen so far it appears that your application has to have a fully copy of the database to run queries. Is that correct?

18:37 nathanmarz: i gotta run, i'll dig into this more later

18:37 thanks for the help technomancy

18:37 SegFaultAX|work2: If it is, what if you have millions or tens-of-millions of facts? The network load would be immense, no?

18:42 TimMc: SegFaultAX|work2: I think the client only has a cache of the data. Not sure what that implies for full table scans, though...

18:42 *partial cache

18:44 SegFaultAX|work2: TimMc: Still seems like each new applciation server spikes the hell out of your network traffic.

18:44 TimMc: Even if it's just caching the working set for that node.

18:46 * nDuff 's current project is such that he could prevent application servers from running overlapping queries quite trivially.

18:46 SegFaultAX|work2: nDuff: Example?

18:46 nDuff: ...to be sure, workloads and needs differ, but then, datomic doesn't necessarily _try_ to be for everyone.

18:47 SegFaultAX: I'm running statistical analysis on a number of incoming streams. Each node can be assigned a slice of the namespace in terms of which stats it's responsible for handling.

18:47 holo: hi

18:48 nDuff: SegFaultAX: ...but all that applies only if you can't write your queries to be able to winnow down the data they need with the indexes effectively.

18:50 SegFaultAX|work2: nDuff: Who would do the load balancing?

18:50 nDuff: Would you have to encode a portion of your application logic into nginx/apache/whatever?

18:50 (The portion that selects the appropriate application server eg consistent hashing)

18:50 nDuff: SegFaultAX: I'm not a webapp.

18:51 SegFaultAX|work2: nDuff: Well generally then, where in the architecture do you route incoming requests to the appropriate application server?

18:51 nDuff: SegFaultAX: "requests"?

18:51 SegFaultAX|work2: nDuff: Inbound packets.

18:52 nDuff: SegFaultAX: Servers use AMQP topic queues to subscribe to the messages they're interested in handling.

18:52 holo: is it happening to anyone here, after importing an existing eclipse project (this case a git project), the option to convert to a leiningen project (ccw plugin) doesn't work on eclipse 4.2. but anyhow, the leiningen option appears in the package explorer contextual menu, as if it was automatically detected. i wonder if it's *just* working

18:52 SegFaultAX|work2: nDuff: Ah, cool. So it's kind of encoded into their subscription?

18:52 holo: when i said it doesn't work, i really mean, the option configure -> convert o a leiningen project doesn't exist

18:53 nDuff: SegFaultAX: Right -- the subscription includes information on what they want to handle, and the queue only routes them things that match.

19:02 TimMc: nDuff: And each of your nodes is configured to ask for a different slice?

19:04 nDuff: TimMc: ...well -- I'm not using datomic, just pointing out that my use case could be conducive to it. :)

19:04 TimMc: ...oh, you mean a different slice of the incoming stream? Yes.

20:25 Frozenlock: If I start `lein repl', how can I load a library? I've put the jar in the same directory, but it doesn't seem to work

20:28 technomancy: Frozenlock: you would have to declare pomegranate as a dependency and use that

20:28 most people just restart

20:28 Frozenlock: Restart? The repl?

20:28 technomancy: =\

20:29 lynaghk: aperiodic: new c2 + reflex + singult releases out, just for you!

20:30 xeqi: oh, I was gonna try c2 the other day, but ran into https://github.com/lynaghk/c2/blob/master/src/cljs/c2/dom.cljs#L52 dieing on non-webkit

20:31 lynaghk: xeqi: yeah, I'm pretty much targeting webkit only.

20:31 xeqi: I'm happy to accept shims via pull requests, though, assuming they don't uglify the code too much.

20:32 Frozenlock: technomancy: Restart doesn't seem to do it either...

20:33 xeqi: reflex looks neat, almost frpish

20:33 are reflex/singult also webkit only?

20:33 lynaghk: xeqi: that's the primary testing platform

20:34 xeqi: there's nothing in there that's webkit only that I'm aware of, though. I'm a bit surprised you ran into that with c2 so quickly, since I think that's the only webkit specific thing in there.

20:35 xeqi: lynaghk: I was trying out the c2demo and it used it

20:35 imtodo I think

20:35 technomancy: Frozenlock: you added a library to :dependencies and it didn't show up when you restarted your repl?

20:36 lynaghk: xeqi: ahhh, yes. I'll open up an issue about fixing that. Hopefully the newer goog closure abstracts that matchesSelector stuff away

20:36 Frozenlock: technomancy: No, I don't have the project.clj or anything, I just have lein in a folder with a particular jar

20:37 technomancy: oh, outside a project

20:37 you can do that with pomegranate

20:37 Frozenlock: Yeah. Kind of "on-the-fly" if you will.

20:40 xeqi: lynaghk: not that I meant to only complain about it, c2 looks neat

20:40 * brehaut (cons 'pomegranate look-at)

20:42 xeqi: Frozenlock: (cemerick.pomegranate/add-classpath "name.jar") I think

21:18 Kowboy: is there some good online documentation for the ns macro?

21:18 I see so many different ways of use and require that I am confused as to what is idiomatic

21:18 I'd like to have a nice reference

21:19 mk: Kowboy: clojure.org/cheatsheet links to one

21:19 Kowboy: you would think the "Namespaces" section on clojure.org would make it clear

21:20 adamvh: If I want to hack on a package to add functionality, how do I get my other projects to pull in my new-and-improved version instead of whatever Leiningen magically fetches?

21:20 Kowboy: ah, clojuredocs.org

21:20 http://clojuredocs.org/clojure_core/clojure.core/ns

21:20 adamvh: Like say I clone the incanter github

21:20 and want to add plotting functionality

21:21 how do I actually use my new-and-improved incanter?

21:21 mk: Kowboy: I actually didn't find it all too informative in the end, though, since I was a bit confused about the various other functions

21:21 Kowboy: also confusing is when to use vs require

21:21 mk: Kowboy: do you understand namespaces, generally?

21:22 Kowboy: generally, yes

21:22 mk: Kowboy: ok. Here's how it works:

21:22 Kowboy: I understand use pulls the public var from the "used" namespace into your namespace

21:22 xeqi: adamvh: change the version in your local incanter's project.clj; then lein install; then change the dependency for your other projects

21:22 mk: ns is just a convenience function for a bunch of other functions that always end up being invoked right after namespace, at the top of files

21:23 xeqi: adamvh: using the checkouts feature is another way

21:23 adamvh: xeqi: So I would edit incanter's project.clj, bumping the version number

21:23 Kowboy: where require only makes the namespace accessible in your file, so you have to qualify access unless you use :as

21:23 mk: there's a global map between names (basically symbols) and Namespaces. You need to create a namespace before you can use it.

21:23 Kowboy: but it would be nice if this was stated clearly somewhere

21:23 adamvh: xeqi: and then change my deps to point to the bumped version number

21:23 Kowboy: mk: I got that

21:23 adamvh: xeqi: and then run lein install?

21:24 xeqi: adamvh: and possibly changing the group name, esp if you want to deploy them somewhere

21:24 mk: *ns* is used for symbol resolution

21:24 Kowboy: I understand the concept, and I've been using them for awhile...

21:24 I just always forget the particulars

21:24 adamvh: xeqi: ...group ... name?

21:24 mk: right. So in-ns will switch and do create-ns if the ns doesn't exist

21:24 xeqi: incanter/incater -> org.clojars.adamvh/incanter for example

21:25 Kowboy: mk: I am more concerned with the details of :require and :use in the ns macro

21:25 adamvh: xeqi: Ah, I see

21:25 The Java ecosystem

21:25 I don't fully understand it yet

21:25 mk: require loads the namespace from the classpath, and it might alias the namespace

21:25 Kowboy: I think what I normally want to use is :require [something :as s] or whatever

21:26 mk: loading means that it just reads the file (there are other load functions)

21:26 xeqi: no links to http://blog.8thlight.com/colin-jones/2010/12/05/clojure-libs-and-namespaces-require-use-import-and-ns.html yet?

21:26 Kowboy: right, so without :as, you have to fully qualify symbols from the required namespace

21:26 correct?

21:27 whereas :use pulls the symbols into your namespace, possibly stomping on other symbols

21:27 mk: alias does something special. Each namespace has a mapping from symbols to vars, or classes (this is actually a bit complicated). But it also has a mapping of symbols-to-symbols, alias-to-proper - when it's doing namespace resolution for a symbol, it will replace the alias with the proper namespace name, and then continue with resolution

21:28 Kowboy: :use is a little more lazy, so you don't have to prefix the symbols

21:28 mk: does that make sense?

21:28 Kowboy: yes

21:28 mk: it's basically a list (map) of replacements

21:29 Kowboy: underneath it's all fully-qualified symbols

21:29 mk: refer will unceremoniously dump all matching vars from the other namespace's ns-publics into this namespace

21:31 Kowboy: use is like require + refer?

21:31 I think I saw that in the docs

21:31 mk: ns-publics is a filter on a namespace's mapping that returns only: vars that are interned in the same namespace and are public (so classes, and things refer'd into that other namespace are never imported by refer)

21:31 amalloy: the is exactly what use is, yes

21:31 Kowboy: I think 2 things are confusing to a newbie

21:32 amalloy: as of clojure 1.4, you never need use or refer, though: require supports a :refer option

21:32 mk: yep - requires (which loads, maybe aliases) and then refers (dumps publics into current)

21:32 Kowboy: 1. That require doesn't work like Java's import. You still have to qualify the symbols or use :as to create a shortcut prefix

21:33 I can see a lot of users doing (:require foo.bar) and expecting to have access to those symbols

21:33 mk: Kowboy: you can think of java imports as compile-time - they tell the compiler that whenever you type Map you actually mean java.util.Map

21:34 Kowboy: 2. The difference between :use and :require

21:34 right, and I think that's what people initially assume require does

21:34 instead, that is the refer part

21:35 refer is a non-intuitive name, just my opinion

21:35 at least, it doesn't translate for me relative to other programming langauges (not just Java)

21:35 mk: Kowboy: it means that the namespace makes reference to another - if a namespace makes reference, then that other one must be loaded (maybe aliased). That's what refer does

21:36 sorry, that's wrong

21:37 Kowboy: refer doesn't load

21:37 mk: I was thinking of require. Refer is called refer rather than import because import is reserved by clojure for referring to classes

21:38 yes, it's probably confusing, but there's not much that can be done

21:39 Kowboy: I think something can be done

21:39 mk: Kowboy: what do you propose?

21:39 Kowboy: the documentation can be put in layman's terms a little more than it is today

21:39 maybe I'll take a shot at this in a blog post or something

21:40 if it can be turned into official documentation somewhere, great

21:40 mk: Kowboy: you might ask who's responsible for the docs you have in mind, and then suggest your changes

21:41 Kowboy: OK, I run into some of the core developers every now and then at the TriClojure meetups in Durham

21:44 thanks mk and amalloy, this was really useful information

21:44 mk: Kowboy: the documentation might be a good place to address this, since the actual names won't change. The best you can do is come up with interpretations of the names that help you remember what the functions do

21:45 Kowboy: np

21:46 jrajav: Has anyone used Clojure with Android recently?

21:47 And no I don't have a specific question, I'm just looking for experience and advice. From what I can see there have been performance issues with it in older versions

21:47 close-paren: I've been meaning to. working on a game, and can't stand writing Java

21:47 at least not for entity scripts

21:53 xeqi: jrajav: might try to get in touch with the person behind http://clojure-android.blogspot.com/

21:53 was/is a gsoc person working on clojure+android

21:54 jrajav: Thanks

22:08 Kowboy: so, I have this in an ns macro: (:require [clj-webdriver.taxi :as taxi])

22:08 then (defn driver []

22:08 (taxi/start-driver! {:browser :firefox}))

22:08 No such var: taxi/start-driver!

22:09 did I miss something here?

22:13 xeqi: Kowboy: (taxi/set-driver! ...) ?

22:13 Kowboy: set-driver! is a method in clj-webdriver.taxi namespace

22:14 Iceland_jack: Well is it set-driver! or start-driver!?

22:14 xeqi: sorry, you pasted "start-driver", I was suggesting "set-driver"

22:15 Kowboy: sorry, start-driver!

22:16 whoops.

22:16 set-driver!

22:16 * Kowboy facepalm

22:16 Iceland_jack: haha

22:16 Kowboy: it's getting late. I blame the clock. Stupid clock!

22:17 Iceland_jack: Or just blame Past-You, that person never does anything right

22:17 adamvh: is there a way for me to get leiningen to not use a checksum?

22:18 Kowboy: I think you can add :checksum :warn or :checksum :ignore to your project.clj

22:19 mmitchell: is memoize thread safe?

22:19 i'm using delay to lazy load data from a db, just wondering if i should be using memoize instead

22:23 Kowboy: I think it would be pretty terrible if Clojure, of all languages, had a non-thread-safe memoize

22:24 or you could look at the source code online

22:24 I'm sure you will be able to tell at a quick glance whether it is using STM

22:26 adamvh: Kowboy: Thanks, that did it.

22:27 Kowboy: Woohoo! I helped someone

22:30 dnolen: Kowboy: it doesn't use STM, it uses an atom.

22:55 yankov: can anyone explain the difference between refs and atoms?

22:57 casion: yankov: my understanding is that atoms are uncoordinated, and refs are coordinated

22:58 you can have 2 threads operating on an atom at the same time, but you can with a ref

22:58 I may however be limited in this understanding as I'm still new

22:59 nkkarthik: yankov: well, I am no expert either but, suppose we have two slots transaciton-no and balance

22:59 yankov: casion: hm.. but what happens if two transactions are operating on an atom, which value get accepted

22:59 nkkarthik: when ever i have to change balance I have to change transaction-no, say

23:00 then balance and transaction-no should be coordinated... that's what casion means by coordinated

23:00 when there is no such coordination needed then we can go with atoms

23:02 yankov: so, suppose I have two refs. I can have a transaction which will require to update both refs?

23:02 nkkarthik: yankov: yeah dosync

23:03 aezop: anybody know any good IDE's for linux?

23:03 looking for something very lightweight

23:03 yankov: nkkarthik: gotcha. thanks!

23:03 nkkarthik: yankov: :)

23:03 frio: aezop: for what purpose?

23:03 aezop: uh, writing clojure?

23:03 just simple stuff

23:03 frio: the canonical answer for clojure is always going to be emacs :)

23:04 * nkkarthik never knew he could explain something

23:04 frio: but if you're just looking for a simple text editor to get familiar with, sublime text 2 is nice

23:04 Raynes: Eh

23:04 Sublime Text 2 is a furious mess for Clojure.

23:04 aezop: how so raynes?

23:04 Raynes: It can't even indent things properly.

23:04 yankov: nkkarthik: you did a good job :)

23:04 aezop: oh ha

23:04 Raynes: You're code will be a mess and people will complain and you'll be sad and we'll be sad and everybody will be sa.d

23:04 sad*

23:04 frio: shrug Raynes; my guess is aezop is new to Linux

23:04 * nkkarthik seconds emacs on any platform it is available for

23:04 aezop: I'm really looking for simple syntax highlighting and low memory footprint

23:05 I'm not new to linux

23:05 frio: (because the rest of us have a pretty good idea of what tools we use in linux; vim, emacs, etc.)

23:05 aezop: I was just asking the clojure community what they would recommend

23:05 frio: so ST2 would probably feel quite familiar

23:05 cemerick: frio: There's nothing canonical about tools, and especially editors. Only personal preferences.

23:05 frio: fair enough aezop :)

23:05 cemerick: People should use whatever they're used to already if they're just getting started with Clojure.

23:05 davejacobs: what's the best way to dry up handlers in a ring-based webapp -- the way you would dry them up with before_filter in rails, for example?

23:05 frio: i agree cemerick :)

23:06 Raynes: Except if it can't indent Clojure properly.

23:06 * cemerick puts all his closing parens, brackets, and braces on their own new lines, just for Raynes

23:06 frio: for a learner Raynes, that's less of a stumbling block than figuring out emacs chords, or the fact vim is modal

23:07 Raynes: Nobody helping you because your code is a mess and impossible to read is an even bugger stumbling block.

23:07 yankov: there we go. editor wars :)

23:07 Raynes: But really, once light table can save files properly, it'll probably be an excellent starting point.

23:07 * yankov grabs popcorn

23:07 Raynes: I do not care in the slightest what editor people use.

23:08 frio: not being able to write code because you don't know that you need to press "i", or "ctrl-x-s", is... um, big

23:08 but!

23:08 davejacobs: i only care what editor people use when they try to convert me -- which is always a no go

23:08 Raynes: I just don't want to suggest something to someone that will make their code a mess if they're not careful.

23:08 frio: i do agree about light table

23:08 im very excited about that :)

23:08 Raynes: You can get working with Emacs pretty fast though.

23:08 Vim is another story.

23:08 davejacobs: vim is actually quite easy now

23:08 i finally figured out the perfect config

23:09 lein2 + lein-tarsier + vimclojure + paredit = bliss

23:09 frio: alias vim="emacs" :p?

23:09 davejacobs: the missing piece was lein-tarsier

23:09 cgag: yep

23:10 jkdufair: does anyone have slime-ritz working in aquamacs?

23:10 cemerick: Raynes: is there something about jiraph that answers the "why not neo4j?" question?

23:10 Raynes: cemerick: I think it's pretty much revisions.

23:11 But for a more detailed answer, catch amalloy_ when he doesn't have the underscore.

23:11 cemerick: That'll do for now, thanks :-)

23:11 I know as much about one as the other at the moment.

23:12 Frozenlo`: I have a little problem... I'm trying to send a packet from clojure. Usually it works fine, but on a particular machine, I can't send anything. I can bind with the port, no error whatsoever. But when I'm "sending", if I check a traffic sniffer, there's nothing going there. Is it possible for clojure/java to send something that will never reach the real world? Could a firewall do that?

23:12 frio: Raynes: so you really dislike ST2 for clojure? (not asking in an inflammatory way; I've been trying to setup a decent Clojure env on my windows box without having to go through the pain of cygwin to get emacs)

23:13 Raynes: frio: I think ST2 is a great editor, but it has terrible Clojure support.

23:13 jkdufair: or does anyone recommend a setup on mac os for aquamacs or emacs?

23:13 frio: fair enough :)

23:13 Raynes: It probably wouldn't be hard to fix, but nobody wants to touch textmate bundles.

23:13 yankov: Raynes: just curious, what kind of things you are lacking in ST2 for clojure?

23:13 Raynes: jkdufair: nrepl.el is nice.

23:13 frio: yeah, that last part is true enough Raynes

23:13 Raynes: yankov: It can't indent Clojure properly.

23:14 And the syntax highlighting is broken on regexes.

23:14 jkdufair: Raynes: thank you

23:18 ivan: frio: would vanilla Windows Emacs work?

23:19 I gave up on "decent dev env on Windows" because of Emacs/git slowness and java opening jars without share mode FILE_SHARE_DELETE

23:20 davejacobs: all right so drying up ring handlers -- how do i do that?

23:20 by "drying up" i'm thinking of before filters in rails

23:21 frio: ivan: I've largely given up too; I'd use *nix but for the fact it's my gaming box. it's not normally an issue, but my ancient laptop finally died and im still waiting on the replacement :)

23:24 cemerick: davejacobs: Not sure if there are any Rails people here; I presume you're referring to DRY?

23:25 …and bizarrely conjugating it to a verb? ;-)

23:31 samrat: are there any clojure libraries to convert numbers to base64?

23:33 cemerick: samrat: https://github.com/clojure/data.codec …or, there's 2 or 3 Java libs with reasonable APIs and good perf.

23:33 cgag: i used org.apache.commons.codec.binary.Base64

23:38 samrat: cemerick: cgag thanks, I'll check both of those

23:39 davejacobs: cemerick -- sorry, left the computer for a sec

23:39 haha yeah, that's fairly common in the Ruby community

23:39 kindof like restful ;-)

23:40 cemerick: hrm, perhaps :-)

23:40 davejacobs: basically -- i am building a ring app and am going to be repeatedly doing things at the beginning of the handler actions -- loading database results, checking for authentication, etc.

23:40 brehaut: restful won because apparently restafarian isnt cool

23:40 davejacobs: in rails and other frameworks, there are typically callbacks that are called at different points in a request lifecycle

23:40 what about restalicious?

23:40 TimMc: davejacobs: It helps if you say "DRYing".

23:41 brehaut: davejacobs: thats middleware / handlers in ring

23:41 cemerick: davejacobs: just create a function for each of the operations you will commonly need to do, and compose those with the route-specific handlers you write

23:41 davejacobs: sorry -- i didn't know that was ruby-only

23:41 sure i can do that

23:42 re: middleware, i think that it has to go past middleware, no? because many of the things to DRY up will relate to authentication and other app concerns

23:42 jkdufair: Raynes: thx for the nrepl tip. works really nicely

23:42 cemerick: The Ring "request lifecycle" is approximately: request -> function -> response. Done. :-)

23:42 davejacobs: cemerick: i thought about (comp), but am I going to have to do that to every handler?

23:42 brehaut: davejacobs: middleware is just a handler that might delegate to another handler

23:42 jkdufair: funny think about clojure. you go away for 6 months and everything changes

23:42 cemerick: davejacobs: sure, middleware is just a special case of composition

23:42 davejacobs: but there is the understanding that middleware decides what's happening before it ever touches the app's business logic, no?

23:42 at least in mvc

23:43 cemerick: Middleware can do whatever it wants; it's just a function.

23:43 davejacobs: my view could be uber skewed by rails. ps, i'm not new to clojure, just clojure web dev

23:43 brehaut: davejacobs: have you read my rambling introduction?

23:43 cemerick: skewed?

23:43 davejacobs: right -- i guess my question is about best practices. i'm wondering if there are going to be any unforseen consequences to mixing middleware logic with business logic

23:44 brehaut, i don't know that i have

23:44 brehaut: davejacobs: http://brehaut.net/blog/2011/ring_introduction

23:44 cemerick: What if middleware *is* your business?

23:44 brehaut: davejacobs: its worth taking some time to have a look at how compojure does things

23:44 you'll learn a lot about what middleware can let you do

23:44 davejacobs: okay will do

23:44 cemerick: touche

23:44 adamvh: Does clojure have some equivalent to functionp?

23:45 davejacobs: i guess i always thought of middleware in the same way i think of libraries

23:45 cemerick: davejacobs: don't mind me; yes, read brehaut's post (it's tops), and don't stress too much about "best practices"

23:45 brehaut: davejacobs: compojure is basically a bunch of utilities to make specific types of ring handlers

23:45 xeqi: cemerick: hammer hammer

23:45 davejacobs: i see

23:45 well the thing i'm worried about is composability i guess -- not necessarily "best practices"

23:45 brehaut: davejacobs: in my article i say that i prefer moustache to compojure; thats changed. big fan of compojure now

23:46 davejacobs: brehaut -- ah okay, i did skim this article this morning. will delve into it now

23:46 oh yeah? why is that?

23:46 more opinionated/less a la carte decision making?

23:47 brehaut: first up its more popular by a massive factor, and more actively developed as a result

23:47 xeqi: I haven't seen a db related middleware; but you could checkout friend for auth

23:47 davejacobs: i see

23:47 cemerick: xeqi: hammer-time?

23:47 davejacobs: is that friend-by-cemerick? haha

23:47 brehaut: secondly, moustache has some nice tricks, but compojure has acquired pretty much all of them since i wrote the article, and its got a bunch (route destructuring ftw!) that moustache has no analogy

23:47 jkkramer: adamvh: fn? or ifn?

23:47 davejacobs: we should really be branding our OSS projects like they do with clothing

23:48 ooh route destructuring. it did not have that abt a year ago when i looked into compojure

23:48 brehaut: and compojure is a much more natural ring citizen

23:48 davejacobs: nice

23:48 cemerick: davejacobs: also, a thought: http://cemerick.com/2011/01/13/how-should-clojure-applications-be-structured/

23:48 davejacobs: okay, excellent

23:48 thanks cemerick, i'll check it out

23:49 samrat: I require'd clojure.data.codec.base64 but (b64/encode (.getBytes "hello")) gives me #<byte[] [B@168c660d>. How do I get the base 64 value?

23:49 davejacobs: ah okay, yeah that's great advice. i'm already feeling that

23:49 any clojure expertise that i've built up transfers all the way -- which doesn't happen with Ruby/Rails

23:49 i'm happy with that

23:50 and what about noir? does it have a broader scope than compojure?

23:50 brehaut: narrower scope

23:50 its sort of opinionated compojure

23:50 plus sugar

23:50 davejacobs: gotcha

23:51 brehaut: (its built on top of compojue)

23:51 davejacobs: well, i don't like other people's opinions all up in my code, so compojure it is ;-)

23:51 * jkkramer likes straight compojure

23:51 akhudek: I also like straight compojure

23:51 cemerick: It does seem to have pleasantly won the day.

23:52 Perhaps mixed with certain specialized additions like bishop.

23:52 davejacobs: does noir take care of XSS, CRSF, etc.? i guess that's one thing i don't want to opine about on my own

23:54 akhudek: davejacobs: the session stuff is handled by ring

23:54 jkkramer: there's middleware for csrf. xss depends on how you render views

23:54 cemerick: davejacobs: jkkramer is referring to https://github.com/weavejester/ring-anti-forgery, I presume

23:55 davejacobs: okay awesome

23:55 middleware saves the day huh

23:55 jkkramer: yeah, that

23:55 functions save the day

23:55 brehaut: once you drink the pure functional middleware kool-aid, there is no going back ;)

23:55 jkkramer: I still find compojure's (GET …) syntax a little too macro-y but one gets used to it

23:56 akhudek: also, if you need html input sanitization, it is easy to use http://code.google.com/p/owasp-java-html-sanitizer/

23:56 davejacobs: you don't have to tell me to like a pure functional request-response cycle

23:56 haha

23:56 akhudek: e.g. for rich text editor inputs

23:56 davejacobs: akhudek: awesome, thx

23:57 akhudek: speaking of security/attack/web layers, I also wrote an updated in memory session library https://github.com/diligenceengine/aging-session

23:57 davejacobs: final question: any suggestions to auto-generate restful routes?

23:57 akhudek: haven't gotten many comments on it yet

23:58 davejacobs: i.e., in rails, there's a macro resources that generates the five restful routes + routes for new and edit

23:58 akhudek: I don't think there is any synthesis for that

23:58 casion: you web guys make my head spin lol

23:59 akhudek: It's worth pointing out that the recent github hack was also due to unsafe defaults in the generated route handlers

23:59 davejacobs: which hack? not the protected attributes hack

Logging service provided by n01se.net