#clojure logs

2012-08-22

00:00grizlo42O.o
00:00xeqiI strongly recommend leinigen.org
00:00xeqifor building a project, it will handle downloading the dependencies for you
00:00tmciverleiningen.org
00:01grizlo42ergh. i tried that at one point
00:01xeqi* http://leiningen.org/
00:01xeqitmciver: thanks
00:01grizlo42i just want to mess around with getting used to clojure
00:01grizlo42sigh
00:03xeqithen 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
00:03grizlo42so i tried lein repl, but still not sure how to install those deps
00:04emezeskegrizlo42: In your project.clj file there is a :dependencies vector
00:04emezeskegrizlo42: ":dependencies [[org.clojure/data.json "0.1.3"]]"
00:04emezeskegrizlo42: I found the :dependencies entry by looking at https://github.com/clojure/data.json/
00:04grizlo42ohhhhh
00:05xeqigrizlo42: lein new testproject ; edit project.clj add [org.clojure/data.json "0.1.3"] to the :dependencies map
00:05emezeskegrizlo42: Most clojure libraries will tell you "put this in your :dependencies"
00:05grizlo42got it. and then if i start up in that dir, it will know to use those deps?
00:05emezeskegrizlo42: Yep!
00:06grizlo42ahhh
00:06emezeskegrizlo42: It will automatically download them if necessary
00:06grizlo42its starting to make sense now
00:08emezeskeLeiningen *is* one extra thing to learn, but it pays off pretty quickly
00:08emezeskeWithout 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.
00:09grizlo42emezeske: yeah this is true. im just being a baby. thanks for the pointers
00:13samfloresI'm back just to say midje + lazytest do a great job :)
00:13michaelr`good morning clojurianians!
00:14casiongood evening
00:31emezesketechnomancy: From the readme: "The lazytest.deftest namespace is a drop-in replacement for the clojure.test library"
00:31emezesketechnomancy: Or is that not what you mean?
00:31technomancyemezeske: oh, I didn't know that
00:31technomancyI've only heard of lazytest in the context of midje
00:32technomancywait, does that require code changes?
00:32emezeskeYou're such a midje hater ^_^
00:32technomancyI meant a drop-in replacement for lein test that has a filesystem watch loop
00:33emezeskeAh, I see
00:42arohneremezeske: midje has...problems
00:42technomancyI 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.
00:43technomancymidje lacks obviousness.
00:43casionthe name itself could bear some obviousness
00:44technomancyI always accidentally type midge and then have to go back and fix it.
00:50arohnerfor a while, I've been threatening my cofounder that I'll write a testing library
00:50emezeskearohner: I certainly don't think that midje is perfect, but I find there to be a lot to like
00:50arohneractually, about 3 testing libs
00:51technomancyI think the reason everyone wants to write testing libraries is that you can achieve metacircularity (which feels awesome) without writing an entire interpreter.
00:51technomancyerr--self-hostedness, rather
00:52friois clojure.test not preferred?
00:52arohnermeh. I'm already self-hosted: https://circleci.com/
00:52technomancyheh
00:52technomancyfrio: IMO clojure.test is the best
00:53arohnerI found clojure because I was researching writing my own lisp
00:53technomancybecause 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.
00:54friocool technomancy :)
00:54friois it decent/preferred for TDD? im starting a small project atm and would like to write some cursory tests first
00:56technomancysure, 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
00:56technomancyusually that's lein repl or editor integration like clojure-test-mode
00:59ScriptorI wonder if there's a paredit coffee mug
00:59frioyeah; ive got a decent emacs setup currently technomancy, so im not too worried about that :)
00:59brainproxyScriptor: thought would be cool!
00:59brainproxy*that
00:59frio(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)
01:00Scriptorbrainproxy: from the size of the cheatsheet...that'd be a lot of coffee
01:01brainproxyScriptor: 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
01:01brainproxyhttps://github.com/michaelsbradleyjr/prelude/raw/master/personal/cheatsheets/PareditCheatsheet-letter.pdf
01:02Scriptorbrainproxy: a little blurry here, but that might just be my computer
01:03brainproxyused 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
01:03brainproxyScriptor: it is a bit blurry, but less jagged than simply blowing up the .png
01:20technomancyfrio: there's always virtualbox =)
01:28Scriptorbrainproxy: true, although browsers are getting better with smoothing out enlarged images
01:28Scriptorhave you tried printing it out?
01:50technomancyswank clojure: officially deprecated. http://groups.google.com/group/swank-clojure/browse_thread/thread/c73bc8fe409a78d2
01:55amalloyall right! now i can stop telling people i think maybe you officially deprecated it
01:56tomojhuh, I just discovered nrepl.el yesterday :)
01:56wmealing_me too
01:56wmealing_it seems to start up a little slower than slime though
01:57Scriptorhow tightly is nrepl bound to clojure?
01:59tomojhttps://gist.github.com/d624bc7151cd2c789e58 - wonder if this is piggieback or cljs
01:59tomojI didn't even notice the extra nils until now
02:26cemericktomoj: sorry, are you using leiningen or nrepl.el?
02:34tomojcemerick: leiningen there, hadn't tried nrepl.el
02:36cemericktomoj: 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.
02:36cemerickBut, it does look like the extra nils are probably piggieback's fault.
02:37cemericktomoj: maybe file an issue?
02:38tomojwill do
02:41cemerickoh, I know why the nils are an issue. Also related to #queue not being available on the Clojure side. :-/
02:44arohnercemerick: thanks for the tweet!
02:44cemericktomoj: yeah, definitely file that issue. That's going to be a PITA, I'm afraid...
02:44cemerickarohner: Sure thing :-)
02:48tomojfwiw it doesn't really bother me one bit, I was just confirming the existence of #queue[]
02:59amalloythere's a reader literal for queues now, at last?
03:01tomojin cljs only it seems
03:01tomojsurprisingly..
03:02tomojamalloy: btw, you were right long ago, a tiny patch makes the defcurrieds work with reduce-kv
03:02amalloyi'm glad i was right, but i don't remember what you're talking about
03:03tomojwell, the defcurrieds don't work with reduce-kv :)
03:03amalloylike uh, r/take?
03:03tomoj"reducer combinators"?
03:03tomojyeah
03:03cemericktomoj: well, it'll happen for any literal that exists in cljs but not in clojure
03:04amalloycool. well, submit that patch!
03:04amalloyand one adding #queue for clojure too, so we can all stop doing this stupid c.l.PersistentQueue/EMPTY crap
03:05cemerickamalloy: http://dev.clojure.org/jira/browse/CLJ-976
03:06cemerick"#queue" :-(
03:06amalloy*shrug* #queue is fine
03:07amalloypersonally 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
03:09clgvamalloy: I would name ordering as reason, since the order in a queue matters to its basic operation whereas a vector is random access
03:09amalloyso? ordering matters in queues, vectors, and lists
03:10clgvI mean you choose a queue because you want to put elements to the end and take them from the front^^
03:11amalloyuhhh
03:11amalloywe're not talking about why you'd want to use a queue
03:11amalloyobviously there are algorithms where queues are useful. i'm just saying how i'd prefer it to print
03:11clgvI wanted to support you with a reason for the #queue (a b c) notation instead of #queue [a b c] ;)
03:11tomojisn't the atom reducer stuff like (swap! cnt dec) (if neg? @cnt ...) potentially buggy?
03:12amalloytomoj: yes
03:13amalloyalternatives 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?
03:13Scriptorclgv: but vectors are better than lists for placing an element at the end, so I think it still goes both ways
03:14tomojI mean the bug where something else swaps in between the swap! and the deref
03:14amalloyno, not a problem. only one thread ever has a handle on that atom
03:14tomojsure, with the core reducibles
03:15tomojcouldn't some other reducible do something different?
03:15amalloywith any of them ever, i think
03:15tomojoh, hmm
03:15amalloythat code is in take, right?
03:15tomojyeah
03:15amalloyand take isn't foldable, just reducible, iirc
03:15tomojyeah
03:16amalloyso any reducer "source" that fiddles with take's atom in multiple threads is in error
03:17SgeoHow good/bad is Clojure with modifying code at run-time
03:17tomojwell
03:17SgeoI think that's a thing people think of with Common Lisp and Smalltalk
03:17SgeoOr at least that's the sort of thing I'm aiming for.
03:17tomojI have one candidate for a reducer that might wind up using multiple threads
03:18tomoj..but I'm not sure if it makes sense as a reducer
03:19tomojif cljque had reducers integration, I would think the bug in take could be exposed
03:19amalloySgeo: people who think that about common lisp are not wrong implementation-wise - it can do that afaik - but are usually using a bad algorithm
03:19tomojCollFold doesn't make sense there (afaik) but CollReduce, uh, might
03:19Sgeoamalloy, I mean for purposes of developing while it's running
03:20SgeoRather than restarting on each change
03:20amalloySgeo: clojure is maybe not absolute-top-notch with that, but it's very good
03:20clgvSgeo: you dont have access to a functions code from the compiled functions without doing anything "special" but you can easily redefine functions
03:21Sgeoclgv, like CL and Scheme then, I guess. I can live with that.
03:22clgvSgeo: someone on #clojure told that he is doing "genetic programming" with clojure
03:22muhooit's an exciting time to be alive
03:23SgeoAre 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?
03:23SgeoBut I don't really remember it
03:24amalloy&`x
03:24lazybot⇒ clojure.core/x
03:24clgv,`x
03:24amalloyand macrolet doesn't have first-class compiler support, but is implemented in a library instead, so there are some quirks there
03:24clojurebotsandbox/x
03:25SgeoHow well/poorly does Clojure support code-walking? If for example some crazy person wanted to implement cl-cont in Clojure?
03:26SgeoIs it easier than CL? Because afaik CL has some quirks that make it difficult
03:26amalloypoorly afaik
03:27tomojhttps://github.com/swannodette/delimc
03:27amalloySgeo: but check out clojure.tools.macro/mexpand, which is a code-walker to include [symbol-]macrolet
03:28SgeoIn case I wanted to run something on a computer that didn't have it installed
03:30amalloyare you talking about gcj? throw it in the trash immediately; it is awful
03:30Sgeoamalloy, didn't have anything specific in mind
03:30SgeoJust a concept
03:31SgeoAs in, looking for something similar to Tcl's tclkits and most CL implementation's... compileness
03:31amalloydoesn't exist. you need the jvm
03:32clgvin leiningen 2 :hooks do not work when I specify them in a profile :my-profile and execute with lein2 with-profile my-profile uberjar?
03:33Sgeoamalloy, and the JVM can't just be bundled into a .exe alone with the bytecode of a Clojure project?
03:34amalloyprobably possible, but any sane person would murder you
03:35clgvSgeo: you want >100MB *.exe files? :P
03:38SgeoWhy do protocols exist if you have multimethods? Is it for efficiency and interop with Java?
03:38amalloyyes
03:38Sgeo:/
03:39SgeoTwo distinct features, one of which is theoretically usable in place of the other (discounting interop).
03:39amalloy*shrug* if you take out all the efficiency and java-interop features, you're left with something that's as popular as common lisp
03:39SgeoI'd use it over Common Lisp due to the immutable data structures, I think
03:40michaelr`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?
03:41amalloyneither would be wrong
03:58joneaveshey all - quick question about strings - i seem to be missing something fundamental
03:59joneaves(str "\\")
03:59joneavesexpected return?
03:59tomoj&(str "\\")
03:59lazybot⇒ "\\"
03:59joneavesthen how do i get a single backslash?
03:59tomoj&(println (str "\\"))
03:59lazybot⇒ \ nil
04:00amalloyjoneaves: "\\" is a one-character string, containing the single character backslash
04:00joneavesamalloy: thank you
04:00joneavesso - it's a visual representation thing
04:00amalloy&(count "\\")
04:00lazybot⇒ 1
04:00amalloyyes
04:00joneavesright
04:00joneavesthat is incredibly confusing
04:01amalloythat is how pretty much every language ever works
04:01noidi"\n" is a one character string as well, containing just the newline
04:01amalloy"\n" is different from "\\n"
04:01joneavesi'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
04:02joneavesand i'm examining this in the REPL
04:02amalloyyep
04:02joneavesso - i really should compare it to a debugger - which of course would have the \\
04:02joneavesbut.... that's not been my world - so hence my confusion
04:03joneavesthank you all very much
04:03amalloyyes, good insight in comparing it to the debugger
04:04clgvjoneaves: you can use `pr` instead of `print` - that way the excaping is printed as well ##(do (pr "\\") (print "\\"))
04:04lazybot⇒ "\\"\nil
04:05joneavesthanks 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
04:05joneavesbut the (println foo) is a great trick to force evaluation - these are the little idiomatic things i need to keep learning
04:05clgvjoneaves: I meant for examining on the repl ;)
04:06joneavesright
04:06amalloyjoneaves: yep, so long as you don't refer to it as forcing evaluation it's a good way to get what you want
04:07joneavesamalloy: can you give me a better expression to use - that's what it seems like it's doing
04:07noidijoneaves, 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>)
04:07amalloyinterpreting escapes? presenting a user-friendly string?
04:07noidithe repl does the former
04:07joneavesamalloy: interpreting escapes seems like the best phrase - cheers
04:08amalloybut 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
04:09noidiyeah
04:09joneavesamalloy: 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
04:10tomojif I want a reify that takes args like extend, am I doing it wrong?
04:11noidione 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
04:11amalloytomoj: not necessarily, i think, but you can't have it
04:12noidiwhat 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
04:12tomojamalloy: because of jvm impl specifics?
04:12joneavesnoidi: 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
04:13joneavesthe "REPL is the debugger" helps me quite a bit
04:13amalloymmmm, no, it should be technically feasible in the same way that it works for deftypes
04:13Cr8more so that things the repl prints out, you could reasonably copy-paste back in and get the same data again
04:13amalloybut 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
04:14amalloyplus, because you need to close over things in a reify, passing it extend-like args usually wouldn't be very helpful
04:15tomojfor shared impls you can just call a shared helper fn in the reify
04:16tomojthat was the only reason I knew to use extend
04:16tomojwell extend is still more flexible that way, ignoring lexical closures, but I probably don't need it anyway
04:20kralhola
04:36tomojSgeo: I think protocols are about more than just interop
04:37tomojI dunno
04:37tomojcould you somehow bake defmulti/defmethod into the language and use them to define everything else?
04:38SgeoAlthough writing macros for such has hit a bit of a snag
04:38Sgeodefmulti/defmethod is multiple-dispatch, which could be taken to be a more general case of protocol's single-dispatch
04:39tomojright
04:41tomojbut..
04:42tomojtake (defprotocol ISeq (-first [coll]) (-rest [coll]))
04:42tomoj(defmethod ISeq-first (comp type first)) ?
04:42tomojer
04:43tomoj(defmethod ISeq-first type) ?
04:44tomojhmm
04:45tomojI guess you'd just do (defmulti first type)
04:45tomojwith a (defmethod first :default) that calls seq
04:47tomojyou lose satisfies? ?
04:47tomojguess you could replace it, and modify reify/deftype?
04:55RaynesMan serpent.
04:55RaynesOops, wrong channel.
04:55RaynesWow, I bet that sounded great out of context.
04:56ejacksonspectacular.
04:57ejacksoncore.logic problem: figure out a context where that doesn't like like.... well, like it sounds.
06:56clgvI 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
06:57ro_stantares_: is there a cheatsheet for validateur? or do i have to spelunk in the tests? :-)
06:58antares_ro_st: docstrings
06:59antares_and http://clojurevalidations.info
07:09ro_stah, do you not have a marginalia doc for it?
07:10antares_ro_st: I can put codox reference up today
07:11ro_stthat'd be handy, i reckon
07:14ro_stantares_: do you have plans to put codoxen up for all the clojurewerkz projects?
07:14antares_ro_st: when all the guides are ready, probably
07:14antares_most projects have docstrings but they hardly offer much value over the guides
07:14antares_but I understand their purpose
07:15ro_stin val's case specifically i think it's valuable having a plain ole api ref available
07:16ro_stgreat little library
07:19kiloncan anyone link me to the well known clojure poll ?
07:20michaelr`try looking for "the clojure survey"
07:20kilonthe one that shows what people use and suck
07:20clgvkilon: chas emericks survey?
07:20kilonmichaelr`: thank you very much mate
07:20kilonclgv: yeap thats the one thanks
07:21kilonI want to recommend such a survey for Pharo
07:22kilonhttp://www.pharo-project.org/home
07:22kilonbecause i find that survey real eye opener and very useful
07:22kilonhttp://cemerick.com/2012/08/06/results-of-the-2012-state-of-clojure-survey/
07:39antares_ro_st: http://reference.clojurevalidations.info
07:40ro_stah awesome!!
07:40ro_stperfect :-)
07:40ro_stthanks antares_
08:04ro_stantares_: when presence-of gets a vector of symbols instead of a symbol, is that a way to combine multiple presence-of calls into one?
08:04antares_ro_st: just use presence-of multiple times
08:04antares_all it does is returning a function
08:04ro_stwhat does the vector do, then?
08:05antares_ro_st: nesting of attributes
08:05ro_stahhh
08:05ro_sthandy!
08:05antares_[:address :street] will validate presence of (get-in m [:address :street])
08:06ro_stthanks
08:06ro_stis it possible to nest validation sets?
08:07antares_ro_st: no. I cannot think of how that would work.
08:07ro_stcool
08:07antares_a validation set is a list of functions + a fancy way of reducing over the lsit, basically
08:08ro_stis there a way to use length-of to check for a minimum but no maximum?
08:08ro_stie, > 0
08:11ro_stah. length of is strings. i thought it was for checking the count in a sequence
08:15antares_ro_st: you can trivially write a function that will check for sequence length, too
08:18ro_stwhat about :at-least and :at-most variants for length-of?
08:18ro_stjust an idea :-) i'll make do with a fn of my own
08:18antares_ro_st: there are gt, gte, lt, lte
08:19ro_stah so use numericality-of, somehow?
08:19ro_sthow would i tell it to use that on the (count (f m attribute)) ?
08:21antares_ro_st: length-of works for strings only
08:26ro_strigt
08:27antares_ro_st: I would consider collecting good validators in validateur.seq/*, validateur.seq/length-of and so on
08:27antares_and similar namespaces
08:29SgeoOne 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?
08:30_fogus_Sgeo: In theory Clojure macros are unsafe, in practice they work wonderfully
08:32Sgeo...Clojure uses the typical try/catch rather than a CL-style condition system, doesn't it?
08:35_fogus_Yes
08:37Sgeo:(
08:38_fogus_Others have created condition-style systems as libraries however
08:38SgeoHmm, but I can't expect libraries to use them
08:39SgeoDo those libraries intercept traditional Java/Clojure exceptions somehow?
08:39_fogus_That's the nature of libraries
08:42ChousukeSgeo: 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)
08:43Chousukeso in practice it's very difficult to create hygiene issues with clojure macros if you explicitly don't attempt it.
08:56osenertechnomancy: I can't get nrepl-current-ns to return something other than "user", is that normal?
09:04osenernevermind, looks like it is dependent on the current buffer
09:09michaelr`can i do an outer join in korma?
09:15michaelr`hmpf
09:15michaelr`can i?
09:15michaelr`can i do an outer join in korma?
09:17ro_stmichaelr`: https://github.com/korma/Korma/blob/master/src/korma/core.clj#L217
09:18ro_stthe third example in that docstring gives you what you want i think
09:19michaelr`haha
09:19michaelr`thanks mate!
09:19michaelr`this has to be in the docs
09:19ro_stmay the source be with you *waves hand*
09:19michaelr`i actually searched the source for "outer"
09:19michaelr`heh
09:20michaelr`oops train is at the station gotta go
09:22cshellwish I could take a (short) train to work
09:23ro_stantares_: if you want it https://www.refheap.com/paste/4549
09:28S11001001,42
09:28clojurebot42
09:29duck11231so 42 is also the question?
09:29naegI'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
09:32igstannaeg: zipWith usually, if I understand what you're asking
09:33naegigstan: 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
09:33S11001001duck11231: in this case
09:35duck11231I could see Deep Thought using logic programming. Like it said, the hard part was asking the right question, after that, the answer came easy
09:36cshellmatrix product?
09:41edlothiolnaeg: componentwise product (or just "product" in contexts where it's unambiguous)
09:41naegmatrix multiplication seems to be what I looked for
09:47samrathow do I upgrade my nrepl package (its installed with emacs-starter-kit, using defvar my-packages)?
09:56clgvcan I define new public methods with `proxy`?
10:05clgvseems that I need an interface
10:06_fogus_,(doc definterface)
10:06clojurebot"([name & sigs]); "
10:07_fogus_Super helpful
10:12clgv_fogus_: what's better definterface + proxy or gen-class? I only want to implement an eventlistener that has an additional query method
10:12naegscriptor: 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:12AWizzArdThis one was probably already linked a few times, but anyway: http://sweaxis.org/stats/lang?src=hn10
10:13naegI'm focusing on comparing different implementations of conways game of life in clojure vs. python
10:13piranhanaeg: heh, interesting :-)
10:13_fogus_I don't know. But at least with definterface+proxy you can reuse the interface if needed.
10:13clgvgen-class requires aot. if I have definterface + proxy in the same namespace this should work without aot, right?
10:13scriptornaeg: can you paste some examples?
10:13_fogus_Ah yes! That too
10:13naeghttp://pastebin.com/AEmg7JLM
10:14clgvwell. then definterface + proxy seems better for that little task
10:15naegI was able to boil down most of the examples similar to this one
10:16naegsince python supports some FP you'll most likely find many ways to reproduce such simple examples
10:16naegbut I don't think that's what most python programmers do
10:16scriptornaeg: of course, but at the same time I don't think you see a lot of type() calls in idiomatic python code
10:16naegindeed, I haven't actually seen this before at all
10:17scriptornaeg: you should take some of the more challenging 4clojure problems and try to do the same
10:18naegscriptor: I'm currently reading that paragraph about conways game of life - i'll try to compare some implementations of this algorithm
10:18naeg(Clojure Programming)
10:19naegthe clojure solution in the book is very neat and general, can't wait to find out what python has to offer
10:19achenghello 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:20naegI'd always prefer a linux distro
10:20S11001001good way to start an os war in #clojure :)
10:20naeg:D
10:23wmealing_acheng: are you more productive in OSX or Linux ?
10:23achengyou 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:23wmealing_so linux it is
10:24achengfound my 20" iMac on the curb.
10:24wmealing_just laying around
10:24naegit also depends on your environment. I guess if the company you work for creates only products for mac...
10:24achengjust 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:25scriptora lot of companies these days develop on macs
10:25scriptorso it's useful to at least get familiar with the environment
10:25achengmy workplace is primarily windows. there's maybe 3 macs around
10:25naegI did so too for some time, it's not that bad afterall if you got used to it
10:30achengok. 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:31achengnext 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:31jake__good morning
10:32edwacheng: You use the cyanide capsule conveniently hidden in a molar.
10:33achengedw: that might explain the vague feeling i've been having
10:34jake__Can I use the 'tools.namespace' library to get a list of which files have changed?
10:35jake__I would like to use it to write an auto testing loop?
10:35achengjake__: did you check out lazytest?
10:37jake__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@rhickeyhttp://sweaxis.org/ - they only have 7 Clojure participants so far: http://sweaxis.org/stats/lang
10:40edwamalloy_: ping
10:41TimMcrhickey: What's the difference between those first two scatter charts?
10:43TimMcUgh, question #2 needs to be split.
10:43scriptorTimMc: x-axis has a different range
10:44estebannhas anyone had any luck using sqlite's ATTACH statement with java.jdbc
10:45chouserrhickey: clojure still doesn't seem to be an option in the survey. I wonder how it's in the chart at all.
10:45TimMcMeh, too many of those questions are weirdly stated and feel like trick questions. Not bothering.
10:46jolyit 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:46chouseroh, I see it now. Yeah, it wasn't there when I did the survey either.
10:47chouserI reject the premise anyhow.
10:47scriptorI hope nobody is going to actually take this survey seriously
10:47scriptorconsidering how biased the questions are
10:48chouserpretty charts though
10:48TimMcSure, 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:48hyPiRionoh, the Yegge case yet again
10:49dnolenI'm 100% liberal!
10:49TimMcSo am I a conservative whose favorite language is liberal? -.-
10:49TimMcI desire things that so far I have not found practical.
10:49Bronsai'm 54% liberal :(
10:49hyPiRionI believe this is a good representation of Yegge: http://abstrusegoose.com/483
10:50joly76% liberal here
10:50AWizzArdTimMc: optional type checking is the right thing. And the progress on Typed Clojure is also very nice.
10:51TimMcI should take a look at Typed Racket one of these days.
10:52edw84.72% liberal. That's what happens when HTTP becomes your ABI.
10:52`fogusThe survey sounds like fun
10:52edwAnd you're a Lisper.
10:52mattmossQuestion: if you have different namespaces/modules relying on maps, how do you prevent or deal with spelling/typos?
10:52@rhickeyYes, very broken in that the title of some questions if often contradicted or exceeded by the descriptive paragraph
10:52edwImagine if SOAP had won?
10:52@rhickeyThose problems were i nthe original essay
10:53mattmossExample: I pass a map from one namespace {:hint 3}, but a typo in the other namespace is expecting {:himt ...}
10:53`fogusAt least it retains the spirit of the original :p
10:53AWizzArdTimMc: Typed Racket is the parent of Typed Clojure so to speak.
10:53clgvlol clojure got younger in the past 10mins on that survey ;)
10:53mattmossIn many cases, no error is thrown or noticed, because (:himt m) will return nil.
10:53mattmossWhich isn't an error and, in some cases, is validd.
10:54@rhickeyclgv: yes, it will take a few of you to pull the age back from my having participated :)
10:54clgvrhickey: already done. ;)
10:54scriptordid my part
10:55`fogusClojure 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@rhickeyflawedas it is, I think the result will be interesting as Clojure devs assess Yegge's original criteria
10:55mattmossIn C++, I could (roughly) const char* kHint = "hint"; then the compiler would alert me to the typo.
10:55edwI'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:55mattmossIn 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"
11:00xeqimattmoss: I solve that with tests
11:00mattmossAnyone? 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:01mattmossoops, sorry
11:01hyPiRionmattmoss: find
11:01mattmossfind?
11:02`fogusmattmoss: You can add a precondition on a function that checks for the existence of important keys.
11:02hyPiRion,[(find {:hint 1} :hint) (find {:hint 1} :himt)]
11:02clojurebot[[:hint 1] nil]
11:02ejacksonoh dear, only 54% liberal... see you guys....
11:03hyPiRion,(if-let [[_ v] (find {:hint 1} :himt)] :key-exists! :key-not-there)
11:03clojurebot:key-not-there
11:03`fogus,((fn [m] {:pre [(contains? m :a)]} (:a m)) {:aa 42})
11:03clojurebot#<RuntimeException java.lang.RuntimeException: java.lang.AssertionError: Assert failed: (contains? m :a)>
11:04dnolenejackson: 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:05mattmossxeqi, `fogus, hyPiRion: So basically, I need to, in a test/precondition, name all fields just to say "Are you there?"
11:05dnolenejackson: in anycase, anyone crazy enough to use core.logic and to encourage others to do so can't possibly be very conservative ;)
11:06`fogusmattmoss: If those keys are important for correct calculation, then it's not so bad.
11:06jsabeaudryIs lein2 still being hold off because clojars is not ready?
11:06xcvI'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:06xcv the java GUI frameworks is kosher.
11:07TimMc`fogus: The trouble is typos in optional keys. :-/
11:07mattmoss`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`fogusOK
11:07scriptorxcv: what does the app need to do?
11:07mattmossSo I understand TDD and the like, but my mind doesn't quite work that way yet.
11:08TimMcmattmoss: You could make a little fn that checks a map's keys for anything outside of a known set.
11:08ejacksondnolen: thank heavens !
11:08scriptorit took me a while to realize I was doing a bastardized form of TDD for a while
11:08scriptorI always liked writing the code to use an interface first
11:08xeqimattmoss: 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:09ejacksonstatic ones !
11:09xcvscriptor: 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:09TimMc21. "Bag of crocodiles" sounds exciting. [Agree <-> Disagree]
11:09mattmossxeqi: 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:10mattmossA typo in the identifier will flag a compiler error
11:10rbxbxxcv there's always offline ClojureScript.
11:10mattmossA typo in a string literal won't.
11:10`fogusCan C++ type checking help against misspelled map keys?
11:11xeqimattmoss: you don't take it a step further and make objects for each string value so they can be type checked?
11:11xeqi* objects with a common parent interface
11:11`fogusmattmoss: Clojure supports that same pattern.
11:12mattmossMy use of const char* was just an illustration... more likely, yes, I'd use an object.
11:12xcvrbxbx: 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:12mattmossAnd I do realize I could do that in clojure do, with (def hint :hint)
11:12chouser`fogus: no, but you don't use maps in C++ because they're so painful :-)
11:12mattmosschouser: good one :)
11:12`foguschouser: zing!
11:13mattmossBut, 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:13rbxbxxcv 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:13hyPiRion,(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:13clojurebot#<RuntimeException java.lang.RuntimeException: java.lang.Exception: key not found>
11:13chouserI do miss static checking. I do not miss required static checking, nor munging everything that need to be checked into a type system.
11:14hyPiRionI don't know if there's an equivalent in core.
11:14xcvrbxbx: 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:14xeqiin general its not worried about
11:14mattmossA precondition looking for expected keys on each function seems the way to go.
11:15TimMcmattmoss: (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`foguschouser: 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:15chouser:-)
11:15xeqibut determining a typo in a key is definintly determinining intent
11:15mattmossIt'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:15rbxbxxcv 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:16mattmossTimMc: Yeah, something like that is what I'm thinking.
11:16ejacksonchouser: yeah, exactly ! Every now and then I want to put a line around stuff and say only let the following types through.
11:16TimMcThrow in a (set ...) around (keys m).
11:16xcvrbxbx: 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:17rbxbxxcv awesome. Please report back with your findings if you get a chance :)
11:17ejacksonchouser: I end up using :pre and :post, but it feels like compiler work.
11:17chouserejackson: It's sometimes worth using assert or pre/post conditions for that
11:17chouseryeah
11:17ejacksonhe !
11:19xcvrbxbx: I will :)
11:19mattmossThanks guys... gotta run for now.
11:20`fogusejackson: Are you limiting yourself to type checking?
11:20ejacksonfogus: in some cases - but I do use them for other sanity checking
11:26dnolenmattmoss: another approach would be explicit access protocol + defrecord. use pre / post everywhere for type checking always seemed yucky, at least to, to me.
11:32chouserI think an explicit access protocol to retrieve data is also yucky.
11:34hyPiRionIt's much work just to ensure you don't do typos.
11:34chouserit 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:34hyPiRionI think it would be better to just fix the typo.
11:34dnolenchouser: 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:34chouserwould have to be as fast as (:foo bar) and nearly as convenient.
11:35TimMchyPiRion: Even better would be to never make typos!
11:35TimMcBut that's now people work.
11:35TimMc*not
11:35hyPiRionTimMc: We are only humans, not machines.
11:35TimMc*not how <-- wow, that's an interesting one
11:36hyPiRionSpeaking of the devil, eh.
11:36jsabeaudryAnyone knows if crate works well with advanced compilation?
11:37`fogusTrammel has defconstrainedrecord, but it's far from speedy. But at least it can be turned off if the need arose.
11:37chouserthe 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:37chouser`fogus: interesting to consider the difference between associating the checking with the collection vs. the operation
11:38dnolenchouser: for me also just currently defining ILookup + case serves the same purpose over access protocols. keyword access syntax + immediate failure.
11:38`foguschouser: I went with the operation
11:38chouserdnolen: yes, that's an interesting option.
11:39chouser`fogus: oh, you use a different lookup fn to get checked vs non-checked, even when using a defconstrainedrecord?
11:39dnolenchouser: of course that won't work w/ defrecord.
11:39`foguschouser: but it could just as easily go with the record
11:40mkwhat's the reduce/fold that works for associative binary operations? And does it use multiple threads?
11:40`foguschouser: No. I modify assoc/etc. to look up the constraint checker in the record's metadata
11:41chouser`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`foguschouser: That is a nice idea. I might add that.
11:42chouserI don't know which is better; just pondering
11:42`fogusMe too
11:43`fogusThat might be a different library in any case since Trammel is meant as an all or nothing thing
11:56ostens+cnt
12:02jaleyhi! is there a way to implement a protocol for an array type? like [I, for example?
12:02chouserawesome question!
12:03jaleythe reader doesn't like [I, clearly
12:03chouserYou might try it in quotes, I don't know the answer.
12:04jaleymy 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:04jaleyif I'm already in crazy-person territory with that, reign me in :)
12:05jsabeaudryWell if type metadata is an indicator i specify that a variable is an array of bytes using: ^bytes
12:07jaleyobligatory microbenchmark from a colleague: https://gist.github.com/73878a2fec73a6a3dbb4
12:07jsabeaudryjaley, have you tried "ints"?
12:08jaleyjsabeaudry: on it now
12:08`fogus|eatsFor multimethods dispatching on (class foo) you need to put something like (Class/forName "[Ljava.lang.String;") in the method definition
12:08jaleyno, ints is not a class
12:08jaleyrelevance.engine.core> (class ints)
12:09jaleyclojure.core$ints
12:09`fogus|eatsMaybe this is something to explore
12:09dnolenjaley: http://dosync.posterous.com/51626638
12:10dnolenjaley: arrays are an open set so you have to do something dynamic. but it works and it's fast.
12:10jaleyfogus|eats: that works
12:11ostensI'm noobish to clojure, and I had a question regarding strategies for function definition.
12:11jaleydnolen: ok thanks
12:11jaley; (extend-type (Class/forName "[I") Sortable (sort [this] ... ))
12:11ostensI'm interested in writing a music library (notation), and have been writing functions for things like converting MIDI to frequency
12:12ejacksonostens: I'm pretty sure you'll find all of that in Overtone...
12:12ejacksonfwiw
12:13edwAnyone have advice for a poor sod stupid enough to type "(read)" into their Emacs *nrepl* buffer?
12:13ostensthanks, ejackson, but I'm specifically interested in notation, similar to PWGL (an algorithmic composition environment in common lisp)
12:13technomancyedw: are you on 0.1.3? I think it might have been fixed.
12:15ostensMy 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:15edwtechnomancy: An nrepl-version fn might be handy. :P
12:15technomancyedw: it shows when you connect
12:15edwYeah, 0.1.3
12:16technomancyhuh, ok... must be something else then
12:16edwC-c C-b doesn't do the trick.
12:16ejacksonostens: i'd go with the former, but thats IMHO.
12:16edwOh wait...
12:16technomancyyou could always try entering something in the *nrepl-server* buffer
12:16edwNo, that's _available_, I have 0.1.2 _installed_.
12:16ostensJust wondering what was idiomatic. Thanks!
12:19jkkramerwith nrepl.el, can arg lists be shown in the echo area when editing code in non-repl buffer?
12:19edwAh, much better, technomancy!
12:19technomancyjkkramer: I think turning on eldoc-mode should do the trick
12:20jkkramertechnomancy: that gives me arg lists for emacs lisp functions
12:20edwInterestingly, if an exception occurs while reading, and another READ is preformed, nrepl.el uses the existing (mini)buffer.
12:25technomancyany windows users want to debug what's going on here? https://github.com/technomancy/leiningen/issues/674
12:26jkkramertechnomancy: think the eldoc-mode thing this warrants creating an nrepl.el issue or am I doing something wrong?
12:28technomancyjkkramer: yeah, just confirmed it here. it used to work in an earlier version
12:28technomancyjkkramer: actually it looks like nrepl-eldoc-enable-in-current-buffer does it
12:28technomancyjkkramer: so you just need that in a clojure-mode hook
12:30jaleyso... would there be anything wrong with having clojure.core/sort use Arrays.sort() when passed a primitive array?
12:32chouserjaley: does that mutate the array? clojure.core/sort always returns a new sorted collection.
12:32edwamalloy_: ping
12:33jaleychouser: yeah... I guess it would need a copy? though Collections.sort() also mutates the collection i think?
12:33jaleychouser: both have void return type
12:33pepijndevosI remember several clojure projects getting a free yourkit thing, how does that work?
12:33jaleychouser: wait... it already uses Arrays.sort
12:34dnolen_pepijndevos: your project needs to be open source, email them - that's about it
12:34jaleychouser: but it uses to-array, so it will always box the ints
12:35pepijndevosdnolen_, does it need to be a well known and widly used?
12:36dnolen_pepijndevos: not as far I can tell.
12:36pepijndevoscool
12:57dansalmoinstead of (-> 1 comp (repeat 3 inc)) is there something like this that works? (-> 1 comp (repeat 3 inc))?
12:57dansalmoinstead of (-> 1 comp inc inc inc) is there something like this that works? (-> 1 comp (repeat 3 inc))?
12:58chouser(+ 3) ?
12:58clojurebot3
12:58jsabeaudryWhile in a clojure-jack-in session, what is the best way to search all files of the project for a specific string?
12:59chouserC-x RET git grep "your string" # :-)
13:00jsabeaudry"C-x RET g is undefined"
13:01technomancyM-x rgrep
13:01chouserOh. that just shells out so you can run git grep
13:01chouserMine does, I mean. I don't know what technomancy's does
13:01chouserProbably something better :-)
13:03technomancyhyperlinked grep <3
13:03jsabeaudrytechnomancy, That works
13:03jsabeaudryThanks
13:04technomancythere's a half-baked find-usages in swank-clojure, but I recommend rgrep
13:15jsabeaudryAs 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:16xeqiis there an elisp equivalent for (some #{'clojure-mode 'clojurescript-mode} major-mode) ?
13:18emezeskejsabeaudry: 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:19jsabeaudryemezeske, is it mature? lots of bugs left?
13:19emezeskejsabeaudry: No, it is definitely not mature
13:20emezeskejsabeaudry: Right now I have to run my own branch of crate that has bug fixes applied, etc
13:20jsabeaudryemezeske, I see, thank you very much for the input, I'll definitely hold off crate usage or now
13:21jsabeaudryI'm not too experienced with web development, is it very common for web servers to serve only javascript and no html at all?
13:22stuartsierraIt is not *very* common, but it is becoming more popular for some kinds of applications.
13:23stuartsierrahttp://en.wikipedia.org/wiki/Single-page_application
13:26jsabeaudrystuartsierra, Ah! Exactly what I had in mind! Thanks!
13:26mmitchellAnyone 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:27jsabeaudrymmitchell, I think drawbridge is aimed exactly at that purpose
13:27mmitchelljsabeaudry: interesting, i'll have a look
13:29technomancydrawbridge is something else
13:29technomancyyou might want environ
13:43the-kennylynaghk: 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:43lynaghkthe-kenny: the latest singult snapshot handles exploding seqs fine. I'm pushing out a new release later today.
13:43the-kennyAh, nice!
13:44lynaghkthe-kenny: also, singult is 20--100 times faster, since it's written in plain JavaScript.
13:44the-kennyAnother thing I always wanted is some syntactic sugar for events: [:input {:type :button, :onclick #(js/alert "ohai!")}]
13:44francisman grep
13:44francisof course, not in shel
13:45lynaghkthe-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:46lynaghkthe-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:47the-kennylynaghk: I haven't had a look at singult, I'll take a look later today :)
13:47lynaghkthe-kenny: (obligatory disclaimer: I'm the author, so take everything with a grain of salt).
13:47the-kennyI know :)
13:47the-kennyI'm back in about 20-30minutes, I'll have a look then
13:47lynaghkthe-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:48naegsomeone willing to give me some feedback on this explanation of conway's game of life: http://i.imgur.com/dP0Zf.png
13:50jsabeaudrynaeg, what sort of feedback? ("an initial state" vs "a initial state" ?)
13:51naegjsabeaudry: whether you basically understand what conways game of life is about after reading it
13:51naegand thanks for that, corrected. also removed the "Then" at "Then the same procedure [...]"
13:52casionnaeg: besides the copying from wikipedia, it's good
13:52naegcasion: I'm lazy :P does copying those four rules matter that much?
13:53casionand the images? and similar word choices
13:53casionit's no big deal, I'd have done the same thing… no use rewriting a good explanation more than is needed
13:53amalloyedw: what's up?
13:53casionbut at the same time, it's no more of an explanation than linking to wikipedia
13:54naegcasion: 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:54naegbut for a blog post, it's better to write such things myself then just say "read it up on wikipedia", isn't it?
13:55naegI tried to compress is to all the reader needs to know, and the wikipedia article is huge
13:55casionnaeg: when I wrote something similar I felt it important to explain the patterns a bit more
13:56chouserA lot of programmers know what Conway's Game of Life is. Does your audience need more than one sentence a link to wikipedia?
13:56naegcasion: for example how the glider moves along?
13:56casionnaeg: for example, yes
13:56casionchouser: I agree
13:56naegchouser: 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:57casionI did soemthing similar writing life in supercollider, and I figured anyone reading it would have a decent clue
13:57casionbut in my context, algorithmic composition, explaining the patterns more in depth than wiki was helpful
13:58naegthey will see the algorithm implemented in Clojure and Python and with further explanation
13:58casionat the very least, a paragraph on gliders probably would keep a mildly imformed reader interested
13:58casionsince they're the simplest interesting spaceship
13:59naegI'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:00naegbut thanks for your feedback, at least I know that people will most likely understand what the game is about
14:03firesofmayWhich is the recommended library in clojure for image manipulation/matching?
14:03casionfiresofmay: imageJ is very good if you don't mind plain java
14:05firesofmaycasion, I do mind plain java :p It would be better if there is something in plain clojure.
14:06firesofmaycasion, 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:06casionother thank using imagemagick or imagej, I don't know anything particularly useful
14:07casionnot 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:09firesofmaycasion, cool. I'll check them out. Anyway I have a very simple use-case.
14:09firesofmaycasion, thanks for your help :)
14:10casionsure, there maybe something whipped uf clojure that I don't know about
14:10casionbut imageJ is pretty standard
14:35dansalmo:chouser - thanks, but answer by clojurebot was more succinct.
14:36dansalmowhat is the correct way to do something like this: (-> 1 comp (repeat 3 inc))
14:36dansalmoso that is does this (-> 1 comp inc inc inc)
14:36amalloynot use an arrow
14:37amalloyand (-> 1 comp inc inc inc) is nonsense that will throw an exception
14:37drewr,(-> 1 inc inc inc)
14:37clojurebot4
14:38dnolendansalmo: you asked this earlier, it cannot be done. -> is not about composing functions, it's syntax transformation.
14:38dansalmosomething more general than 4?
14:38dansalmo\
14:38dansalmosorry, I am new to clojure
14:39drewr,((comp inc inc inc) 1)
14:39clojurebot4
14:39dansalmoI want to call a fn n times, feeding the results forward
14:39amalloy&(nth 4 (iterate inc 1))
14:39lazybotjava.lang.ClassCastException: clojure.lang.Cons cannot be cast to java.lang.Number
14:39amalloy&(nth (iterate inc 1) 4)
14:39lazybot⇒ 5
14:41dansalmo:amalloy - thanks, that's what I needed.
16:00stuartsierraHey y'all, when you're working at the REPL, and you want to switch namespaces, do you use 'in-ns' or just 'ns'?
16:01stuartsierra(This is for a class I teach)
16:01dnolenstuartsierra: in-ns, mostly 'cause Chouser said it was more idiomatic ;)
16:01chouserns is dangerous is the namespace you're switching to did some :refer-clojure stuff
16:01metajacki was under teh impression ns did seoms refers or something when you used it
16:01chousers/is/if/
16:01duck11232in-ns if I'm not using C-c M-p
16:02stuartsierraYes, `ns` automatically refers `clojure.core`
16:02chouserso, in-ns
16:02stuartsierraChouser's example is a good one.
16:02chouserstuartsierra: are you in the class now? Tell 'em hi for me!
16:02stuartsierrano, in a few weeks
16:03chouseroh, oh well.
16:03chouser:-)
16:03stuartsierraBut I'll tell them you said hi.
16:06jweissdoes 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:07stuartsierraJust define a function that refers/imports what you want. DON'T create new Vars.
16:07technomancyjweiss: nstools
16:09technomancystuartsierra: I usually do (doto 'my.ns require in-ns) because I enjoy feeling like a smartass
16:10stuartsierraha
16:10chouserstuartsierra: wow, that's a really good idea.
16:11jweissstuartsierra: 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:11steveols
16:11stuartsierrajweiss: yes
16:11technomancyit sucks that you have to resort to hacks to make it declarative inside the ns form like nstoos
16:11steveo*oops
16:11stuartsierraor just make bigger namespaces, which is the sane solution
16:12jweissbig namespaces have drawbacks too, harder to find stuff in them
16:12jweissespecially when it does break down logically into smaller ones
16:12stuartsierraSplit it across files with `load` if you want.
16:13technomancyugh; no
16:13jweissyeah i tried that too, don't like it
16:13edwamalloy: ping
16:13jweissnstools is not quite what i want, i don't want to totally clone the whole set. i'll try the function approach
16:14amalloypong again
16:14technomancynstools is egalitarian in that it allows you to get close to promoting your own namespace choices as default alongside clojure.core
16:15edwOh 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:16amalloyedw: in the vector used to keep ordering?
16:17edwIn e.g. "#ordered/map([:a 42] [:b true])" I'm referring to the inner brackets.
16:17amalloythat's just an artifact of the printing, not the internal representation
16:18amalloy([:a 42] [:b true]) is what (seq m) would look like; (:a 42 :b true) isn't what anything would look like
16:18edwBut your reader fn gets that nested datastructure from the reader, correct?
16:18amalloyyes.....?
16:19edwAs opposed to a flat list...
16:19Raynes............
16:19amalloyright. i could choose either format for serialization
16:19Raynes<3
16:19edw........
16:19amalloyi chose to wrap vectors because it looks like the seq of a map, which is familiar
16:19amalloyand helps you tell what pairs with what
16:19edwI was thinking that this may cause unnecessary memory allocations on reading.
16:19amalloy*shrug* sure
16:20amalloyclojure is an exercise in mostly-unnecessary allocations
16:20amalloythe 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:22edwIt'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:22amalloyi'd be calling partition 2 on the seq anyway
16:23amalloythe allocations just show up in the reader instead of in my literal-reader-function
16:24amalloyand 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:24edwamalloy: Fear not, I'm wasn't going to ask you to change it.
17:21naegwhat am I doing wrong when source can't find the code of my function?
17:23edwCould you provide us a bit more context? In SLIME?
17:23naegedw: clj
17:24edwRight. What source can't find what function?
17:24naegehm, not sure whether this was clear, but I'm talking about the (source) macro from clojure.repl
17:24naeg(source n)*
17:25edwDid you redefine it at the repl? Or in SLIME or nrepl?
17:26edwIf you did, there's no source file info associated with it.
17:26edwC-c C-k from Emacs will recompile the file, which will associate file and lineno info.
17:27edwFor nrepl; I've forgotten the SLIME binding.
17:27naegedw: I'm now in emacs or something, just clj, the clojure repl
17:27naegwhat I'm really trying to do is to see the actual code of a function that is returned by another funtion
17:27edwSo did you type in the func like ">(defn my-inc [n] (+ 1 n))"
17:27naegyes
17:29edwThat'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:30naegnope, just a "regular" HOF
17:30naegnvm then, will figure out without actually seeing it then
17:30llasramnaeg: 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:31llasramWhich I guess really is exactly what edw said in the first place. I think time to go home...
17:31edwThanks, 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:32amalloyyou can take a look at technomancy's serializable-fn, which creates functions (including closures) that print as their source code
17:32naegit's not that important actually, I was just wondering if and how it's possible
17:32naegthanks for the answers though
17:49mkwhat's the reduce/fold that works for associative binary operations? And does it use multiple threads?
17:59TimMcmk: You're thinking of the upcoming reducers library?
17:59TimMcIt uses Fork/Join.
18:00mkTimMc: I'm not sure at all, I thought it would already be in clojure
18:01TimMcIIRC it is in Clojure master, but not in an extant release.
18:01amalloythe 1.5 alphas
18:01TimMcOh hey, we have alphas?
18:02amalloyfour of them, i think
18:02mkwhat'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:03jkkramermk: https://github.com/clojure/clojure/blob/master/src/clj/clojure/core/reducers.clj
18:03amalloyfold
18:03amalloyit needs more information than reduce does
18:05mkTimMc jkkramer amalloy: thanks
18:19nathanmarztechnomancy: hey, have a leiningen question for you
18:20mknathanmarz: ask away
18:21nathanmarzi have a somewhat difficult build problem
18:21nathanmarzi'm trying to write a test for dependency isolation in storm
18:22nathanmarzwe have some code that does some funky classloader stuff to distinguish between user code and storm system code
18:22nathanmarzso i want to write a test that ensures that the right classes are loaded at the right times
18:22nathanmarzso i want to have a "subproject" in storm that defines a user topology
18:23nathanmarzit should build a jar (using lein jar), except use the classes from the parent project
18:23nathanmarzi tried doing something like this: http://pastie.org/4570814
18:23nathanmarzbut it looks like you can't override the classpath like that
18:24nathanmarzso the question is, how do you disable leiningen's auto-construction of the classpath and just specify it yourself?
18:26technomancynathanmarz: 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:27nathanmarzmmm
18:28nathanmarzwell, not really
18:28nathanmarzleiningen handles that case without issue
18:28nathanmarzthe way our custom classloader works
18:28technomancywhat'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:28nathanmarzis 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:29nathanmarzi want to test that our custom classloader works
18:29nathanmarzso i need to build a test topology in a separate jar
18:29nathanmarzbut i want to build that test topology against exactly what's in the Storm project at the moment
18:29nathanmarzso i have a subfolder
18:30nathanmarzstorm/test/test-topology
18:30nathanmarzwhich has its own project.clj (my attempt is in that pastie)
18:30nathanmarzand i want it to build against the classpath of storm, which i'm computing with (with-sh-dir "../.." (:out (sh "lein" "classpath")))
18:31nathanmarzthat way i can build my topology jar against the version of storm in the project, and write tests that test my custom classloader
18:31technomancyok, so you aren't really nesting it in that case?
18:31nathanmarzwhat do you mean by nesting?
18:31technomancyyou could link the top-level project into the checkouts/ dir of the test project
18:32nathanmarzoh
18:32nathanmarzlet me try that
18:32technomancyI mean if you want storm's classpath on the classpath of the project, then you're not isolating it
18:32nathanmarzit should be there on compile time, the isolation will happen at runtime
18:33technomancyok, 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:34technomancywell, try the checkouts approach; if I understand the problem that should take care of it
18:34nathanmarzyea, that sounds about right
18:34nathanmarzso with checkouts, i guess i can just put some fixed version of storm in :dependencies
18:35nathanmarzand then it will always compile against the latest?
18:35nathanmarzdoes that apply to "lein jar" too?
18:35technomancyno, checkouts are only a dev-time convenience
18:36technomancyyou'll want to bump the storm version in :dependencies if storm's dependencies change
18:36technomancysince checkouts aren't transitive
18:36nathanmarzso if i do "lein jar" it will ignore checkouts?
18:36technomancyyeah
18:36nathanmarzok
18:36nathanmarzyea, so i need this behavior during lein jar
18:37SegFaultAX|work2I'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:37nathanmarzi gotta run, i'll dig into this more later
18:37nathanmarzthanks for the help technomancy
18:37SegFaultAX|work2If it is, what if you have millions or tens-of-millions of facts? The network load would be immense, no?
18:42TimMcSegFaultAX|work2: I think the client only has a cache of the data. Not sure what that implies for full table scans, though...
18:42TimMc*partial cache
18:44SegFaultAX|work2TimMc: Still seems like each new applciation server spikes the hell out of your network traffic.
18:44SegFaultAX|work2TimMc: Even if it's just caching the working set for that node.
18:46SegFaultAX|work2nDuff: Example?
18:46nDuff...to be sure, workloads and needs differ, but then, datomic doesn't necessarily _try_ to be for everyone.
18:47nDuffSegFaultAX: 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:47holohi
18:48nDuffSegFaultAX: ...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:50SegFaultAX|work2nDuff: Who would do the load balancing?
18:50SegFaultAX|work2nDuff: Would you have to encode a portion of your application logic into nginx/apache/whatever?
18:50SegFaultAX|work2(The portion that selects the appropriate application server eg consistent hashing)
18:50nDuffSegFaultAX: I'm not a webapp.
18:51SegFaultAX|work2nDuff: Well generally then, where in the architecture do you route incoming requests to the appropriate application server?
18:51nDuffSegFaultAX: "requests"?
18:51SegFaultAX|work2nDuff: Inbound packets.
18:52nDuffSegFaultAX: Servers use AMQP topic queues to subscribe to the messages they're interested in handling.
18:52holois 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:52SegFaultAX|work2nDuff: Ah, cool. So it's kind of encoded into their subscription?
18:52holowhen i said it doesn't work, i really mean, the option configure -> convert o a leiningen project doesn't exist
18:53nDuffSegFaultAX: Right -- the subscription includes information on what they want to handle, and the queue only routes them things that match.
19:02TimMcnDuff: And each of your nodes is configured to ask for a different slice?
19:04nDuffTimMc: ...well -- I'm not using datomic, just pointing out that my use case could be conducive to it. :)
19:04nDuffTimMc: ...oh, you mean a different slice of the incoming stream? Yes.
20:25FrozenlockIf 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:28technomancyFrozenlock: you would have to declare pomegranate as a dependency and use that
20:28technomancymost people just restart
20:28FrozenlockRestart? The repl?
20:28technomancy=\
20:29lynaghkaperiodic: new c2 + reflex + singult releases out, just for you!
20:30xeqioh, 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:31lynaghkxeqi: yeah, I'm pretty much targeting webkit only.
20:31lynaghkxeqi: I'm happy to accept shims via pull requests, though, assuming they don't uglify the code too much.
20:32Frozenlocktechnomancy: Restart doesn't seem to do it either...
20:33xeqireflex looks neat, almost frpish
20:33xeqiare reflex/singult also webkit only?
20:33lynaghkxeqi: that's the primary testing platform
20:34lynaghkxeqi: 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:35xeqilynaghk: I was trying out the c2demo and it used it
20:35xeqiimtodo I think
20:35technomancyFrozenlock: you added a library to :dependencies and it didn't show up when you restarted your repl?
20:36lynaghkxeqi: ahhh, yes. I'll open up an issue about fixing that. Hopefully the newer goog closure abstracts that matchesSelector stuff away
20:36Frozenlocktechnomancy: No, I don't have the project.clj or anything, I just have lein in a folder with a particular jar
20:37technomancyoh, outside a project
20:37technomancyyou can do that with pomegranate
20:37FrozenlockYeah. Kind of "on-the-fly" if you will.
20:40xeqilynaghk: not that I meant to only complain about it, c2 looks neat
20:42xeqiFrozenlock: (cemerick.pomegranate/add-classpath "name.jar") I think
21:18Kowboyis there some good online documentation for the ns macro?
21:18KowboyI see so many different ways of use and require that I am confused as to what is idiomatic
21:18KowboyI'd like to have a nice reference
21:19mkKowboy: clojure.org/cheatsheet links to one
21:19Kowboyyou would think the "Namespaces" section on clojure.org would make it clear
21:20adamvhIf 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:20Kowboyah, clojuredocs.org
21:20Kowboyhttp://clojuredocs.org/clojure_core/clojure.core/ns
21:20adamvhLike say I clone the incanter github
21:20adamvhand want to add plotting functionality
21:21adamvhhow do I actually use my new-and-improved incanter?
21:21mkKowboy: 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:21Kowboyalso confusing is when to use vs require
21:21mkKowboy: do you understand namespaces, generally?
21:22Kowboygenerally, yes
21:22mkKowboy: ok. Here's how it works:
21:22KowboyI understand use pulls the public var from the "used" namespace into your namespace
21:22xeqiadamvh: change the version in your local incanter's project.clj; then lein install; then change the dependency for your other projects
21:22mkns 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:23xeqiadamvh: using the checkouts feature is another way
21:23adamvhxeqi: So I would edit incanter's project.clj, bumping the version number
21:23Kowboywhere require only makes the namespace accessible in your file, so you have to qualify access unless you use :as
21:23mkthere's a global map between names (basically symbols) and Namespaces. You need to create a namespace before you can use it.
21:23Kowboybut it would be nice if this was stated clearly somewhere
21:23adamvhxeqi: and then change my deps to point to the bumped version number
21:23Kowboymk: I got that
21:23adamvhxeqi: and then run lein install?
21:24xeqiadamvh: and possibly changing the group name, esp if you want to deploy them somewhere
21:24mk*ns* is used for symbol resolution
21:24KowboyI understand the concept, and I've been using them for awhile...
21:24KowboyI just always forget the particulars
21:24adamvhxeqi: ...group ... name?
21:24mkright. So in-ns will switch and do create-ns if the ns doesn't exist
21:24xeqiincanter/incater -> org.clojars.adamvh/incanter for example
21:25Kowboymk: I am more concerned with the details of :require and :use in the ns macro
21:25adamvhxeqi: Ah, I see
21:25adamvhThe Java ecosystem
21:25adamvhI don't fully understand it yet
21:25mkrequire loads the namespace from the classpath, and it might alias the namespace
21:25KowboyI think what I normally want to use is :require [something :as s] or whatever
21:26mkloading means that it just reads the file (there are other load functions)
21:26xeqino links to http://blog.8thlight.com/colin-jones/2010/12/05/clojure-libs-and-namespaces-require-use-import-and-ns.html yet?
21:26Kowboyright, so without :as, you have to fully qualify symbols from the required namespace
21:26Kowboycorrect?
21:27Kowboywhereas :use pulls the symbols into your namespace, possibly stomping on other symbols
21:27mkalias 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:28Kowboy:use is a little more lazy, so you don't have to prefix the symbols
21:28mkdoes that make sense?
21:28Kowboyyes
21:28mkit's basically a list (map) of replacements
21:29Kowboyunderneath it's all fully-qualified symbols
21:29mkrefer will unceremoniously dump all matching vars from the other namespace's ns-publics into this namespace
21:31Kowboyuse is like require + refer?
21:31KowboyI think I saw that in the docs
21:31mkns-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:31amalloythe is exactly what use is, yes
21:31KowboyI think 2 things are confusing to a newbie
21:32amalloyas of clojure 1.4, you never need use or refer, though: require supports a :refer option
21:32mkyep - requires (which loads, maybe aliases) and then refers (dumps publics into current)
21:32Kowboy1. 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:33KowboyI can see a lot of users doing (:require foo.bar) and expecting to have access to those symbols
21:33mkKowboy: 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:34Kowboy2. The difference between :use and :require
21:34Kowboyright, and I think that's what people initially assume require does
21:34Kowboyinstead, that is the refer part
21:35Kowboyrefer is a non-intuitive name, just my opinion
21:35Kowboyat least, it doesn't translate for me relative to other programming langauges (not just Java)
21:35mkKowboy: 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:36mksorry, that's wrong
21:37Kowboyrefer doesn't load
21:37mkI was thinking of require. Refer is called refer rather than import because import is reserved by clojure for referring to classes
21:38mkyes, it's probably confusing, but there's not much that can be done
21:39KowboyI think something can be done
21:39mkKowboy: what do you propose?
21:39Kowboythe documentation can be put in layman's terms a little more than it is today
21:39Kowboymaybe I'll take a shot at this in a blog post or something
21:40Kowboyif it can be turned into official documentation somewhere, great
21:40mkKowboy: you might ask who's responsible for the docs you have in mind, and then suggest your changes
21:41KowboyOK, I run into some of the core developers every now and then at the TriClojure meetups in Durham
21:44Kowboythanks mk and amalloy, this was really useful information
21:44mkKowboy: 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:45mkKowboy: np
21:46jrajavHas anyone used Clojure with Android recently?
21:47jrajavAnd 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:47close-parenI've been meaning to. working on a game, and can't stand writing Java
21:47close-parenat least not for entity scripts
21:53xeqijrajav: might try to get in touch with the person behind http://clojure-android.blogspot.com/
21:53xeqiwas/is a gsoc person working on clojure+android
21:54jrajavThanks
22:08Kowboyso, I have this in an ns macro: (:require [clj-webdriver.taxi :as taxi])
22:08Kowboythen (defn driver []
22:08Kowboy (taxi/start-driver! {:browser :firefox}))
22:08Kowboy No such var: taxi/start-driver!
22:09Kowboydid I miss something here?
22:13xeqiKowboy: (taxi/set-driver! ...) ?
22:13Kowboyset-driver! is a method in clj-webdriver.taxi namespace
22:14Iceland_jackWell is it set-driver! or start-driver!?
22:14xeqisorry, you pasted "start-driver", I was suggesting "set-driver"
22:15Kowboysorry, start-driver!
22:16Kowboywhoops.
22:16Kowboyset-driver!
22:16Iceland_jackhaha
22:16Kowboyit's getting late. I blame the clock. Stupid clock!
22:17Iceland_jackOr just blame Past-You, that person never does anything right
22:17adamvhis there a way for me to get leiningen to not use a checksum?
22:18KowboyI think you can add :checksum :warn or :checksum :ignore to your project.clj
22:19mmitchellis memoize thread safe?
22:19mmitchelli'm using delay to lazy load data from a db, just wondering if i should be using memoize instead
22:23KowboyI think it would be pretty terrible if Clojure, of all languages, had a non-thread-safe memoize
22:24Kowboyor you could look at the source code online
22:24KowboyI'm sure you will be able to tell at a quick glance whether it is using STM
22:26adamvhKowboy: Thanks, that did it.
22:27KowboyWoohoo! I helped someone
22:30dnolenKowboy: it doesn't use STM, it uses an atom.
22:55yankovcan anyone explain the difference between refs and atoms?
22:57casionyankov: my understanding is that atoms are uncoordinated, and refs are coordinated
22:58casionyou can have 2 threads operating on an atom at the same time, but you can with a ref
22:58casionI may however be limited in this understanding as I'm still new
22:59nkkarthikyankov: well, I am no expert either but, suppose we have two slots transaciton-no and balance
22:59yankovcasion: hm.. but what happens if two transactions are operating on an atom, which value get accepted
22:59nkkarthikwhen ever i have to change balance I have to change transaction-no, say
23:00nkkarthikthen balance and transaction-no should be coordinated... that's what casion means by coordinated
23:00nkkarthikwhen there is no such coordination needed then we can go with atoms
23:02yankovso, suppose I have two refs. I can have a transaction which will require to update both refs?
23:02nkkarthikyankov: yeah dosync
23:03aezopanybody know any good IDE's for linux?
23:03aezoplooking for something very lightweight
23:03yankovnkkarthik: gotcha. thanks!
23:03nkkarthikyankov: :)
23:03frioaezop: for what purpose?
23:03aezopuh, writing clojure?
23:03aezopjust simple stuff
23:03friothe canonical answer for clojure is always going to be emacs :)
23:04friobut if you're just looking for a simple text editor to get familiar with, sublime text 2 is nice
23:04RaynesEh
23:04RaynesSublime Text 2 is a furious mess for Clojure.
23:04aezophow so raynes?
23:04RaynesIt can't even indent things properly.
23:04yankovnkkarthik: you did a good job :)
23:04aezopoh ha
23:04RaynesYou'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:04Raynessad*
23:04frioshrug Raynes; my guess is aezop is new to Linux
23:04aezopI'm really looking for simple syntax highlighting and low memory footprint
23:05aezopI'm not new to linux
23:05frio(because the rest of us have a pretty good idea of what tools we use in linux; vim, emacs, etc.)
23:05aezopI was just asking the clojure community what they would recommend
23:05frioso ST2 would probably feel quite familiar
23:05cemerickfrio: There's nothing canonical about tools, and especially editors. Only personal preferences.
23:05friofair enough aezop :)
23:05cemerickPeople should use whatever they're used to already if they're just getting started with Clojure.
23:05davejacobswhat'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:05frioi agree cemerick :)
23:06RaynesExcept if it can't indent Clojure properly.
23:06friofor a learner Raynes, that's less of a stumbling block than figuring out emacs chords, or the fact vim is modal
23:07RaynesNobody helping you because your code is a mess and impossible to read is an even bugger stumbling block.
23:07yankovthere we go. editor wars :)
23:07RaynesBut really, once light table can save files properly, it'll probably be an excellent starting point.
23:07RaynesI do not care in the slightest what editor people use.
23:08frionot being able to write code because you don't know that you need to press "i", or "ctrl-x-s", is... um, big
23:08friobut!
23:08davejacobsi only care what editor people use when they try to convert me -- which is always a no go
23:08RaynesI just don't want to suggest something to someone that will make their code a mess if they're not careful.
23:08frioi do agree about light table
23:08frioim very excited about that :)
23:08RaynesYou can get working with Emacs pretty fast though.
23:08RaynesVim is another story.
23:08davejacobsvim is actually quite easy now
23:08davejacobsi finally figured out the perfect config
23:09davejacobslein2 + lein-tarsier + vimclojure + paredit = bliss
23:09frioalias vim="emacs" :p?
23:09davejacobsthe missing piece was lein-tarsier
23:09cgagyep
23:10jkdufairdoes anyone have slime-ritz working in aquamacs?
23:10cemerickRaynes: is there something about jiraph that answers the "why not neo4j?" question?
23:10Raynescemerick: I think it's pretty much revisions.
23:11RaynesBut for a more detailed answer, catch amalloy_ when he doesn't have the underscore.
23:11cemerickThat'll do for now, thanks :-)
23:11cemerickI know as much about one as the other at the moment.
23:12Frozenlo`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:12frioRaynes: 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:13Raynesfrio: I think ST2 is a great editor, but it has terrible Clojure support.
23:13jkdufairor does anyone recommend a setup on mac os for aquamacs or emacs?
23:13friofair enough :)
23:13RaynesIt probably wouldn't be hard to fix, but nobody wants to touch textmate bundles.
23:13yankovRaynes: just curious, what kind of things you are lacking in ST2 for clojure?
23:13Raynesjkdufair: nrepl.el is nice.
23:13frioyeah, that last part is true enough Raynes
23:13Raynesyankov: It can't indent Clojure properly.
23:14RaynesAnd the syntax highlighting is broken on regexes.
23:14jkdufairRaynes: thank you
23:18ivanfrio: would vanilla Windows Emacs work?
23:19ivanI gave up on "decent dev env on Windows" because of Emacs/git slowness and java opening jars without share mode FILE_SHARE_DELETE
23:20davejacobsall right so drying up ring handlers -- how do i do that?
23:20davejacobsby "drying up" i'm thinking of before filters in rails
23:21frioivan: 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:24cemerickdavejacobs: Not sure if there are any Rails people here; I presume you're referring to DRY?
23:25cemerick…and bizarrely conjugating it to a verb? ;-)
23:31samratare there any clojure libraries to convert numbers to base64?
23:33cemericksamrat: https://github.com/clojure/data.codec …or, there's 2 or 3 Java libs with reasonable APIs and good perf.
23:33cgagi used org.apache.commons.codec.binary.Base64
23:38samratcemerick: cgag thanks, I'll check both of those
23:39davejacobscemerick -- sorry, left the computer for a sec
23:39davejacobshaha yeah, that's fairly common in the Ruby community
23:39davejacobskindof like restful ;-)
23:40cemerickhrm, perhaps :-)
23:40davejacobsbasically -- 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:40brehautrestful won because apparently restafarian isnt cool
23:40davejacobsin rails and other frameworks, there are typically callbacks that are called at different points in a request lifecycle
23:40davejacobswhat about restalicious?
23:40TimMcdavejacobs: It helps if you say "DRYing".
23:41brehautdavejacobs: thats middleware / handlers in ring
23:41cemerickdavejacobs: 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:41davejacobssorry -- i didn't know that was ruby-only
23:41davejacobssure i can do that
23:42davejacobsre: 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:42jkdufairRaynes: thx for the nrepl tip. works really nicely
23:42cemerickThe Ring "request lifecycle" is approximately: request -> function -> response. Done. :-)
23:42davejacobscemerick: i thought about (comp), but am I going to have to do that to every handler?
23:42brehautdavejacobs: middleware is just a handler that might delegate to another handler
23:42jkdufairfunny think about clojure. you go away for 6 months and everything changes
23:42cemerickdavejacobs: sure, middleware is just a special case of composition
23:42davejacobsbut there is the understanding that middleware decides what's happening before it ever touches the app's business logic, no?
23:42davejacobsat least in mvc
23:43cemerickMiddleware can do whatever it wants; it's just a function.
23:43davejacobsmy view could be uber skewed by rails. ps, i'm not new to clojure, just clojure web dev
23:43brehautdavejacobs: have you read my rambling introduction?
23:43cemerickskewed?
23:43davejacobsright -- 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:44davejacobsbrehaut, i don't know that i have
23:44brehautdavejacobs: http://brehaut.net/blog/2011/ring_introduction
23:44cemerickWhat if middleware *is* your business?
23:44brehautdavejacobs: its worth taking some time to have a look at how compojure does things
23:44brehautyou'll learn a lot about what middleware can let you do
23:44davejacobsokay will do
23:44davejacobscemerick: touche
23:44adamvhDoes clojure have some equivalent to functionp?
23:45davejacobsi guess i always thought of middleware in the same way i think of libraries
23:45cemerickdavejacobs: don't mind me; yes, read brehaut's post (it's tops), and don't stress too much about "best practices"
23:45brehautdavejacobs: compojure is basically a bunch of utilities to make specific types of ring handlers
23:45xeqicemerick: hammer hammer
23:45davejacobsi see
23:45davejacobswell the thing i'm worried about is composability i guess -- not necessarily "best practices"
23:45brehautdavejacobs: in my article i say that i prefer moustache to compojure; thats changed. big fan of compojure now
23:46davejacobsbrehaut -- ah okay, i did skim this article this morning. will delve into it now
23:46davejacobsoh yeah? why is that?
23:46davejacobsmore opinionated/less a la carte decision making?
23:47brehautfirst up its more popular by a massive factor, and more actively developed as a result
23:47xeqiI haven't seen a db related middleware; but you could checkout friend for auth
23:47davejacobsi see
23:47cemerickxeqi: hammer-time?
23:47davejacobsis that friend-by-cemerick? haha
23:47brehautsecondly, 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:47jkkrameradamvh: fn? or ifn?
23:47davejacobswe should really be branding our OSS projects like they do with clothing
23:48davejacobsooh route destructuring. it did not have that abt a year ago when i looked into compojure
23:48brehautand compojure is a much more natural ring citizen
23:48davejacobsnice
23:48cemerickdavejacobs: also, a thought: http://cemerick.com/2011/01/13/how-should-clojure-applications-be-structured/
23:48davejacobsokay, excellent
23:48davejacobsthanks cemerick, i'll check it out
23:49samratI 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:49davejacobsah okay, yeah that's great advice. i'm already feeling that
23:49davejacobsany clojure expertise that i've built up transfers all the way -- which doesn't happen with Ruby/Rails
23:49davejacobsi'm happy with that
23:50davejacobsand what about noir? does it have a broader scope than compojure?
23:50brehautnarrower scope
23:50brehautits sort of opinionated compojure
23:50brehautplus sugar
23:50davejacobsgotcha
23:51brehaut(its built on top of compojue)
23:51davejacobswell, i don't like other people's opinions all up in my code, so compojure it is ;-)
23:51akhudekI also like straight compojure
23:51cemerickIt does seem to have pleasantly won the day.
23:52cemerickPerhaps mixed with certain specialized additions like bishop.
23:52davejacobsdoes noir take care of XSS, CRSF, etc.? i guess that's one thing i don't want to opine about on my own
23:54akhudekdavejacobs: the session stuff is handled by ring
23:54jkkramerthere's middleware for csrf. xss depends on how you render views
23:54cemerickdavejacobs: jkkramer is referring to https://github.com/weavejester/ring-anti-forgery, I presume
23:55davejacobsokay awesome
23:55davejacobsmiddleware saves the day huh
23:55jkkrameryeah, that
23:55jkkramerfunctions save the day
23:55brehautonce you drink the pure functional middleware kool-aid, there is no going back ;)
23:55jkkramerI still find compojure's (GET …) syntax a little too macro-y but one gets used to it
23:56akhudekalso, if you need html input sanitization, it is easy to use http://code.google.com/p/owasp-java-html-sanitizer/
23:56davejacobsyou don't have to tell me to like a pure functional request-response cycle
23:56davejacobshaha
23:56akhudeke.g. for rich text editor inputs
23:56davejacobsakhudek: awesome, thx
23:57akhudekspeaking of security/attack/web layers, I also wrote an updated in memory session library https://github.com/diligenceengine/aging-session
23:57davejacobsfinal question: any suggestions to auto-generate restful routes?
23:57akhudekhaven't gotten many comments on it yet
23:58davejacobsi.e., in rails, there's a macro resources that generates the five restful routes + routes for new and edit
23:58akhudekI don't think there is any synthesis for that
23:58casionyou web guys make my head spin lol
23:59akhudekIt's worth pointing out that the recent github hack was also due to unsafe defaults in the generated route handlers
23:59davejacobswhich hack? not the protected attributes hack