#clojure log - Jan 13 2013

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

0:07 TimMc: bbloom: Dammit, I've now spent an hour learning about Aaron Swartz. I think it's some kind of paying-of-respects thing.

0:07 bbloom: TimMc: it upset me too. i've written more than my fair share of spiders in my day, so it kinda hit home

0:07 TimMc: Yeah, that too.

0:11 muhoo: yep. scary.

0:12 TimMc: It's also a good reminder to use really good OpSec when being Robin Hood. :-/

0:13 ibdknox: The whole thing is just ridiculous

0:13 muhoo: or, when doing civil disobedience, retain a lawyer first. mlk didn't end up in a brimingham jail by surprise

0:15 rosa parks also didn't act alone. and when i've been to anti-war protests, some of us were deliberately planning to get arrested

0:15 so sad though. heartbreaking

0:15 bbloom: technomancy: what is responsible for putting pprint into scope when i run `lein nrepl`?

0:15 seangrove: Hrm, does ohpauleez not hang out here much?

0:16 bbloom: seangrove: i think he was in here just yesterday

0:16 xeqi: $seen ohpauleez

0:16 lazybot: ohpauleez was last seen quitting 12 hours and 37 minutes ago.

0:16 seangrove: Ah nice

0:16 Would like to see a new release of shoreleave

0:17 ibdknox: FWIW: re the discussion about consistency earlier - I agree that there needs to be some. Even if the approach is compose these libs, there's almost always a standard set

0:17 bbloom: technomancy: nvmd, found it: REPL-y

0:18 yogthos: ibdknox: the templates can definitely do that, but until one catches on it's wild west ;)

0:20 ibdknox: yogthos: I don't disagree :)

0:20 yogthos: hehe

0:20 at least standard libs situation is starting to crystalize

0:25 tomoj: rails etc seem to have worse consistency problems to me

0:25 sure, if they're all rails apps and you know rails, you probably have a good idea about the basic project structure

0:26 if you're looking at a project written with some random awesome framework, the fact that you need to look in some file is probably only encoded in the framework's docs and/or source

0:26 ibdknox: tomoj: more importantly, you know that if you want to build a website, you use rails

0:26 Naty: hello

0:26 ...

0:26 anyone there?

0:26 ibdknox: tomoj: what do you use if you come to clojure?

0:27 tomoj: almost all clojure apps use a single consistent mechanism for encoding where the code is

0:27 sure, if that's a "consistency" problem then I call equivocation

0:28 not that it isn't a problem

0:29 muhoo: i'll go for comprehensibility and flexibility over consistency

0:29 headshot: ^^

0:29 python/flask, scala/lift

0:30 Naty: what?

0:30 clojurebot: what is short for ,(doc ...)

0:31 muhoo: botsnack!

0:33 Naty: i feel lost

0:33 sorry

0:33 i better left this room.

0:33 tmciver: Naty: if you have a Clojure question, just go ahead and ask.

0:36 nightfly: I'm afraid I already know the answer; but is there a relatively simple way to estimate the memory usage of a complexly nested clojure data structure?

0:39 muhoo: hmm, syme looks interesting.

0:41 nightfly: maybe one of the java instrumentation tools?

0:43 yogthos: headshot: well technically now scala has play/lift

0:47 Deece_: Some very naive benchmarking seems to indicate that, for small amounts of data, lists are much faster when using the 'stack' abstraction (peek & pop) than vectors. is this accepted behaviour?

0:53 muhoo: i dunno about accepted, but it seems unsurprising to me. lists are cons cells, linked lists, IIRC

0:56 devn: yogthos: I don't think there's an easy way to get people to agree either, but if we find some minor version of common ground I think everyone will be bette roff

0:56 better off*

1:00 Raynes: devn: Where do you live?

1:00 Not because I plan to murder you in your sleep or anything, but because I'm curious.

1:10 bbloom: devn: don't do it. it's a trap!

1:14 yogthos: rofl

1:15 devn: yeah I agree it would be nice to agree on some basic stuff that's idiomatic, I'm trying with the luminus thing :)

1:16 devn: my hope is that if I make it easy enough to use it'll catch on, and then everybody will have the same base template with the same layout

1:16 devn: it worked with noir I think

1:46 tomoj: from java, how might you implement reduce for PHS in terms of PHM's kvreduce?

1:59 amalloy: in java, tomoj? why would you do it in java rather than clojure?

2:00 tomoj: the map impl of a set is not public

2:00 amalloy: i guess because the backing map isn't exposed

2:01 tomoj: I think I figured it out by just creating an anonymous AFn subclass, but a problem is that PHM's kvreduce requires an initial value

2:02 amalloy: as should every reduce implementation in clojure.lang, i would think

2:02 it's the job of clojure.core/reduce to find an initial value for it if none is supplied

2:03 tomoj: reduce just calls coll-reduce

2:03 it seems you could extend CollReduce to PHS

2:04 but e.g. PHM and PV seem to CollReduce over chunked seqs

2:05 ah, and seq-reduce does a first/next if necessary

2:06 &(reduce (fn [ret v]) [])

2:07 lazybot: clojure.lang.ArityException: Wrong number of args (0) passed to: sandbox8277$eval30159$fn

2:07 tomoj: never noticed that

2:09 actually PHM's seq is not chunked

2:16 wow, ~4x speedup on (reduce + (into #{} (range 1e7)))

2:17 bbloom: tomoj: by doing what?

2:17 tomoj: using the backing map's kvreduce instead of an unchunked seq reduce

2:18 bbloom: which line are you comparing that against?

2:19 tomoj: which line in clojure's existing code?

2:19 bbloom: tomoj: oh, you're mucking with the implementation. i misunderstood

2:20 tomoj: I'm not exactly sure where PH{M,S} get reduced, actually

2:20 I'm guessing it's the Iterable CollReduce impl

2:23 so with this patch reducing over a PHS is faster than reducing over its backing map

4:23 Seba51: Having a chain of functions like split message into parts, calculate something, store the parts, send a message to a broker, should I use multiple agents to pass the processing from process step to process step or is just one agent fine. The agent do not have state (I set it to nil).

4:31 pepijndevos: Seba51: why are you using an agent without state?

4:32 It seems to me that what you want is maybe a queue?

4:32 Raynes: $dict overengineering

4:32 lazybot: Raynes: verb: present participle of overengineer.

4:32 Raynes: $dict overengineer

4:32 lazybot: Raynes: verb: To make something more complicated than necessary; often implies that the complexity was added intentionally.

4:34 pepijndevos: Raynes: overengineer can also be a noun. It like an overlord of engineers… maybe

4:34 Seba51: The agent is having an action queue, isn't it? The idea is to have a chain of agent which pass around the data. If a step fail the error handler tries to find a way out. When the system crashes and reboots, the unprocessed steps are identified and send to the related agent

4:35 correction: the related function is send with the data to the agent

4:35 hyPiRion: Raynes: I didn't think that overengineering was that. I thought it was to create an unneccesary good solution to a problem.

4:35 This changes everything.

4:36 pepijndevos: hyPiRion: I thought AbstractSingletonProxyFactoryBean was overengineering

4:36 Raynes: AbstractSingletonProxySuperUtilFactoryFactoryBeanFactory

4:37 pepijndevos: Seba51: I don't know your project, but I'd say an agent is to manage state. I fyou are using it as a wekr queue, use a work queue. Have you looked at java.util.concurrent queues?

4:38 hyPiRion: pepijndevos: I thought that only was ridiculous.

4:39 pepijndevos: hyPiRion: it's actually used: http://static.springsource.org/spring/docs/2.5.x/api/org/springframework/transaction/interceptor/TransactionProxyFactoryBean.html

4:40 Seba51: I haven't considered them yet. But I still will have to manage threads because, I want to process the queue between each step with multiple instances.

4:40 pepijndevos: Raynes: wait, what timezone are you in?

4:41 Raynes: pepijndevos: Central at the moment.

4:41 Yes, it's 3:29AM.

4:41 hyPiRion: pepijndevos: I know, I know. I'm just saying I thought overengineering was a very good solution to a problem, not a complex solution.

4:41 pepijndevos: ok

4:41 hyPiRion: pepijndevos: Raynes is like that.

4:41 Raynes: For now, anyways. I'm moving to LA in February. I'll actually have to sleep then.

4:42 ejackson: Raynes has overengineered his metabolism...

4:42 pepijndevos: ejackson: you're confusing me. Did he makt it too good, ro too complex?

4:42 hyPiRion: I'm like that when I can work whenever I want to as well Raynes.

4:43 ejackson: its certainly complex...

4:43 hyPiRion: But that's more because I synchronize with the american people, and because other people at home bothers me at normal hours.

4:43 ejackson: i'm naturally that way, but it hurts me after a while

4:44 or maybe that's just the coffee that goes along with it...

7:51 clj_newb: Hi, should lein repl write a target/lein-port file? My installation won't create that file. Leiningen 2.0.0-RC2 on Java 1.6.0_37 Java HotSpot(TM) 64-Bit Server VM, OS X 10.8.2

7:52 nevermind, after upgrading is working again, sorry

10:29 tmciver: Any recommendations of docs/blogs on how to get started deploying clojure/java web apps via apache server? I have little to no experience with Java servlet containers.

11:25 yogthos: tmciver: you mean deploying on tomcat?

12:04 technomancy: tmciver: supposedly if you just make a war file with lein-ring it's a lot like using jetty

12:12 yogthos: tmciver: tmciver: basically yeah, if you do lein ring uberwar then you just drop it in the webapps directory under tomcat and it will pick it up, the name of the app is whatever the name of the war was

12:13 if you want to run it as root, then you remove ROOT directory from webapps and rename your war to ROOT.war

12:30 tmciver: I'm trying to deploy to my own local server machine that's running apache. My question concerns how to get an app server like tomcat running within apache.

12:31 magnars: Seems like all examples I can find for Midje are with Leiningen 1, which makes them seem outdated to me. Is it just wrong of me to think so, or do people use other test frameworks these days? Or is Rich's anti-tdd-talk getting to the community? ^^

12:33 thorwil: magnars: i don't know what the market share for midje is, but i doubt it went down. maybe you are looking for examples in the wrong places

12:34 rodnaph_: magnars: what's this "anti-tdd" talk?

12:35 magnars: thorwil: may be - I'm using my google-fu, but it might not be sufficient. All I'm trying to figure out is some best practices, and how to set it up properly.

12:37 thorwil: what's the name of the site that lists dependencies of various clojure projects?

12:37 hiredman: magnars: most people use clojure.test which ships with clojure

12:39 thorwil: found it: http://clojuresphere.herokuapp.com/

12:43 unfortunately, i can't find an entry for clojure.test there. but for midje, it reports "used by" 571

12:44 magnars: it's likely a good idea to only chose midje over clojure.test, if you know it does somethng you want/need that the later doesn't offer

12:44 magnars: thorwil: thanks, that link is pretty nice

12:46 thorwil: magnars: regarding best practices, you might want to consider that tests can serve as (addition to) documentation. in this aspect, it makes sense to write them even after manual testing on the repl

12:47 magnars: thorwil: that's good input. I do enjoy using the repl to drive out implementation, so adding tests after seems like a nice workflow

12:48 thorwil: i found myself being more rigorous when writing tests oer tyring things on the repl. that is i found issues after initial repl testing, because my tests included more cases

12:51 magnars: Naming of test files: test/project-name/test/file.clj or test/project-name/file_test.clj ?

12:51 just a matter of taste?

12:52 muhoo: Raynes: you forgot Helper !

12:53 AbstractSingletonProxySuperUtilFactoryFactoryBeanHelper

12:53 * muhoo is just about ready to defenestrate the Android API

12:54 thorwil: magnars: i like test/foo/t_baz.clj for src/foo/baz.clj

12:55 magnars: it works well with filename completion

13:05 jonasen: Is it a known cljs bug that one can not create a function named the same as the root namespace?

13:08 erikwr: jonasen, don't you just get a warning?

13:08 jonasen: erikwr: https://www.refheap.com/paste/8494

13:10 Bodil: magnars: Re: Midje vs clojure.test, Midje is specifically tailored for a TDD workflow. If you use TDD then Midje is probably what you want. If you don't, it gets in your way, imo.

13:11 erikwr: jonasen, i guess i'm having trouble doing something similar. I tried to override set. nm

13:18 Bodil: jonasen: It's a named function, so it overrides the foo namespace with itself inside its closure. More of a known JS issue, I guess.

13:19 jonasen: Bodil: shouldn't cljs be able to fix it with name munging?

13:20 Bodil: jonasen: Yeah, should be easy enough to work around. It's certainly something Cljs should deal with.

13:32 djwonk: hi everybody. I'm looking for guiding principles or idiomatic Clojure ways to name functions and how to namespace them… at what point is a function name too verbose?

13:33 i've thought about grouping namespaces in logical ways -- such as functions that update a particular kind of thing -- together. it makes it feel like i'm grouping things in similar ways that I would with OO … don't know if that is idiomatic

13:38 Bodil: djwonk: Just group things together in a way that makes sense to you. And you'll notice when a function name is too long when you start getting annoyed while typing it.

13:39 djwonk: Bodil: thanks. I'm writing a Clojure version of this complicated German board game with all kinds of stuff happening. It is fitting together slowly

13:42 jonasen: how do I format code on JIRA?

13:45 tomoj: {{code}}foo bar baz{{code}} iirc

13:45 jonasen: tomoj: I'll try that. Thanks!

13:58 palango: a question to the osx people: is the preferred jvm the bundle from apple or the one from oracle?

14:00 osaut: the one from apple is not updated anymore

14:00 so the one from Oracle is probably a better choice

14:00 palango: osaut: ok, thanks

14:47 Sgeo: Oh god clojure.tools.macro/macrolet uses a recursive macroexpander

14:47 It's going to be horribly broken, isn't it

14:51 tomoj: is it not enough to (binding [clojure.lang.Compiler/LOCAL_ENV &env] (macroexpand ...)) ?

14:52 Sgeo: tomoj, .... hmm.

14:52 hmm?

14:52 tomoj: the &env is the problem, at least, yeah?

14:52 Sgeo: Yes, iirc (and according to my tumblr post from way back when)

14:53 Hm

14:55 tomoj: where's your tumblr?

14:55 oh, duh

15:01 guess you can't modify &env

15:02 Sgeo: What needs to happen is, I think, upon expansion of let*, fn*, and loop*, determine what the &env will be and pass that in to the single form macroexpander

15:02 marcellus123: I really loved the web scraper implementation in the Clojure Programming book that used agents as FSMs, seen here: http://goo.gl/aAMDi does anyone know of resources online that use that style or describe it in further detail? I'm trying to restructure some code to more closely match that style but I'm having trouble figuring out how to expand it beyond the toy-ish example

15:02 Sgeo: It is possible to, given a defmacro-defined macro, pass in your own &env

15:02 tomoj: no, that's what my "guess you can't modify &env" meant

15:02 the values of &env must be LocalBindings

15:02 which.. I dunno, maybe you can make those

15:02 Sgeo: Oh

15:03 Fake a let, grab the &env from there, use that?

15:04 tomoj: why not just expand to a let* or whatever and let the compiler take care of it?

15:09 Sgeo: hm?

15:09 clojurebot: benchmarking is https://github.com/hugoduncan/criterium

15:10 Sgeo: Fun fact: macrolet allows for hygienic macros

15:10 I'm not entirely sure on the details of how it works though

15:11 augustl: I have a list that I need to find an item on by predicate, and procude a new list with that item removed. What's a good way to do that?

15:11 so, I need two references - the item that was removed, and the new shorter list

15:11 gfredericks: augustl: just the first one?

15:12 augustl: gfredericks: yes, just the first one

15:12 gfredericks: augustl: and if it's not found?

15:12 augustl: do nothing

15:12 gfredericks: but return what?

15:13 augustl: if it's not found I don't need the shorter version of the original list

15:13 gfredericks: well we're returning [x ys] where x is the thing we found

15:14 if it's not found we can return [nil ys], or just nil

15:14 in any case you can definitely do this with loop; maybe with reduce

15:14 Sgeo: augustl, filter on the complement of the predicate?

15:14 augustl: making a refheap

15:14 gfredericks: Sgeo: he just wants to remove one

15:14 Sgeo: oh

15:15 augustl: something like this https://www.refheap.com/paste/8499

15:15 would be nice to avoid two iterations though, not that it really matters since the lists are short ;)

15:16 gfredericks: something like that sounds nice, yeah. [x ys] and [nil ys] that is

15:16 I'll write me a function :)

15:17 gfredericks: augustl: it might well have to be a loop; I can't think of another way to do it

15:17 a pretty simple one though

15:18 augustl: gfredericks: I'm thinking "filter" and then somehow later remove the found item from the list

15:18 not sure if there's a function for the latter thoug

15:18 h

15:19 gfredericks: augustl: that involves 2 passes though, like you said

15:19 augustl: one sec I'll write it up

15:20 augustl: ah, I see why you suggested a loop :)

15:21 gfredericks: https://www.refheap.com/paste/8500

15:21 augustl: ^ there's my untested first try

15:21 oh switch line 7 no [nil ys] :)

15:21 augustl: very haskelly :)

15:21 with the xs' and all

15:22 gfredericks: yay haskell

15:22 augustl: ..in which I pretend to know haskell

15:23 brehaut: augustl: btw, remove p xs = filter (complement p) xs

15:23 gfredericks: oh no haskell!

15:23 augustl: brehaut: :D

15:28 thanks folks, btw!

15:29 I should finish learn you some haskell, then I'll be able to do this low level stuff too!

15:29 gfredericks: yes, you can't use loop until you know monad transformers

15:31 muhoo: "learn you some haskell"? what is that, the chicken-fried version? or do you mean learn this http://learnyouahaskell.com/ ?

15:32 gfredericks: the erlang book used the word 'some' I think

15:33 muhoo: that book is cute, the illustrations are like the sesame street version of haskell.

15:35 * muhoo bookmarks

15:47 tomoj: I've wasted so much of my life doing `M-p C-M-b M-( try C-M-f C-j (catch Exception e (pst e RET`

15:47 ..instead of `(pst) RET`

15:48 gfredericks: tomoj: best to sit there in pained regret for a while

15:57 mae: how does one access the 'this' instance when using gen-class

15:57 (from inside gen class definitions)

15:58 gfredericks: when inside in instance method I think it'd be the first argument?

15:58 I thought they were instance methods by default but -main always ends up static... :/

15:58 * gfredericks is confused

16:00 mae: me too

16:00 lol

16:00 let me try that

16:00 oh snap

16:00 that actually worked

16:00 you rock

16:01 gfredericks: mae: so they are instance methods by default? except for -main presumably?

16:01 mae: gfredericks: nah just mean inside the instance method i omitted the first argument

16:23 ivan: tomoj: maybe you can make the REPL preserve the last form in some weird *_1 and then use a macro

16:24 I haven't yet run into the case where I have to try/catch in the REPL like that; what's going on?

16:25 oh, hah, I see what you mean

16:25 that sure is doing it the hard way

16:32 rbxbx: Are there any particularly good resources for getting up to speed with Storm other than the website & wiki?

16:32 tomoj: better way to write (fn compare [x y] (cond (and (= x foo) (not= y foo)) -1 (and (not= x foo) (= y foo)) 1 :else (compare x y))) ?

16:34 mae: ok this is driving me crazy, what does the - prefix do in a method definition

16:34 vs no -

16:35 tmciver: mae: do you mean (defn- ...) ?

16:35 mae: or (defn -main ...)?

16:36 I've only seen it used on a 'main' defn. I believe it's just a convention.

16:37 hiredman: defn- makes a function marked as private in the metadata

16:38 the gen-class stuff maps methods to function implementations by taking the method name and prepending a -

16:38 hence -main being the static main init method the jvm looks for in the main class

16:52 mae: tmciver: i mean (defn -main ...)

16:52 so in my case

16:52 i want to have a method which is exported to java land in AOT mode

16:53 i have the :methods declaration in gen-class

16:53 gfredericks: mae: what do you need this class generated for?

16:54 mae: gfredericks: to feel to voltcompiler

16:54 ; )

16:54 err

16:54 feed

16:54 *

16:54 gfredericks: what does it require?

16:54 mae: it only needs to extend a class 'VoltProcedure' and then export a public method 'run'

16:55 i have VoltProcedure in the classpath

16:55 (the jar file)

16:55 it is not complaining about that anymore, it was earlier

16:55 so this is the error i get now

16:55 gfredericks: might be one of the simpler classgen utilities can handle that

16:55 mae: Exception in thread "main" java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Keyword

16:55 gfredericks: I can't remember if any of them can do superclasses

16:56 mae: hmm

16:56 well i know there is proxy

16:56 but i have to generate the static class files

16:56 in this case

16:56 gfredericks: oh cemerick says gen-class; nevermind.

16:57 mae: so what's going wrong?

16:59 mae: gfredericks: well i think its just a matter of java not being happy with the interface i exported

16:59 or maybe my failure to convert something correctly on the clojure side

16:59 1 sec let me pastebin

17:08 gfredericks: http://hpaste.org/80714

17:12 tomoj: hmmm https://www.refheap.com/paste/2d485033427839cafeed7236b

17:12 mae: gfredericks: i would like to also state that i have got it to compile a class, but after adding the methods annotation to export to javaland it gives me the stack trace ipasted

17:18 amalloy: tomoj: your particular compare function must stackoverflow a lot

17:18 tomoj: heh

17:18 amalloy: anyway, you can clean it up a bit by using (= (= x foo) (= y foo)) somewhere in there

17:18 tomoj: I added the name for clarity without thinking about it

17:19 amalloy: (cond (= (= x foo) (= y foo)) (compare x y), (= x foo) 1 :else -1)

17:20 tomoj: that's somewhat better

17:22 I was thinking about (l/assoc compare (l/comparing foo) -1) but that seems pretty rarely useful

17:23 amalloy: what is l/?

17:24 tomoj: mostly hypothetical

17:24 augustl: any suggestions for how to better write this? :) https://www.refheap.com/paste/8505

17:24 i.e. remove the duplication

17:24 or whatever you measure of better might be ;)

17:25 amalloy: your loop/recur should be a reduce

17:25 also, conjing a map onto a map is gross. use into instead

17:26 augustl: ah, result is a vector

17:26 amalloy: in that case you've elided way too much code to get useful feedback

17:27 augustl: it was the map part I was curious about

17:27 amalloy: *shrug* use a let to avoid duplicating the common stuff, then

17:27 augustl: heh

17:28 amalloy: or, i suppose, (conj result (into {self-key (get-change-attr-value change) :attr attr-pubid} (when opposite {opposite-key (get-change-attr-value opposite)})))

17:30 hyPiRion: (conj result (merge {...} (if opposite {opposite-key ...}))) ?

17:31 augustl: seems more readable to just duplicate it

17:31 hyPiRion: I thought merge was more idiomatic than into when doing it on maps.

17:32 cemerick: gfredericks: what did I say about gen-class?

17:33 augustl: ah, merge takes nil, nice

17:34 amalloy: meh. i never use merge

17:34 well, that's not quite true

17:34 i haven't really thought about it before, but i think i use merge when i intend for entries to be overwritten, and into when i intend only to create new entries

17:58 gfredericks: cemerick: your flow-chart said it was needed

18:04 tomoj: how bad would it have been (not proposing a change - ignore the cost of changing existing code) if (= (seq {1 2 3 4}) [2 4]) ?

18:04 gfredericks: tomoj: so there'd be a clojure.core/entries function for iterating over the entries?

18:05 tomoj: was just about to say that

18:05 :)

18:05 s/bad/much worse/

18:05 gfredericks: (into m1 m2) wouldn't work

18:06 I can't think of anything serious

18:07 tomoj: I'd replace that with (into-kv m1 m2)

18:08 I guess when you iterate through a map, you more often want the entries

18:08 but when you map over a map...

18:23 gfredericks: tomoj: one thought is that the current definition is more general

18:24 i.e., I can get (vals m) from (seq m) but not the other way around

18:24 so the current version doesn't _require_ an extra function, while yours does

18:26 tomoj: it would also feel weird for (seq m) to lose so much information

18:26 devn: i didn't know you could do: [name [& fields] & opts+specs]

18:27 namely the + in the name

18:27 gfredericks: ,'foo+bar

18:27 clojurebot: foo+bar

18:27 gfredericks: ,'[+++ +-* foo*bar]

18:27 clojurebot: [+++ +-* foo*bar]

18:31 tomoj: it does seem weird for seq to lose the keys

18:36 technomancy: whoa; I actually had a use for c.c/next

18:40 prsn: Does anyone have a rough idea of how many downloads/installs clojure has? Or know where I can find out?

18:41 headshot: http://cemerick.com/2012/08/06/results-of-the-2012-state-of-clojure-survey/

18:42 might not be exactly what you're looking for

18:42 bbloom: prsn: i thought maybe teh sonatype maven server would have download stats, but apparently they are not enabled

18:43 talios: you should be able to get that information from Jason van Zyl tho, or someone else at Sonatype

18:43 they've posted central stats before

18:44 prsn: headshot: that's helpful, but yeah, it's hard to estimate what the response rate was

18:44 talios: do you know where they've posted them?

18:44 talios: http://www.sonatype.com/people/2010/12/now-available-central-download-statistics-for-oss-projects/

18:45 mae: how can i access the 'this' instance inside a gen-class instance method

18:45 talios: ahh thats on a per-project basis

18:45 and only for projects you control

18:46 bbloom: then i guess you'd need to email the clojure mailing list and ask for that info

18:46 this, of course, assumes lein downloads clojure from there

18:56 i really like the this streaming/serialization idea that i stumbled upon for fipp... i wonder if it would make sense to do a variant of it for html/xml/sgml...

18:57 i guess data.xml is "lazy"

18:58 ah data.xml already does this

18:58 start-element, end-element etc

19:06 TimMc_: Oh weird, Knuth's tree traversal section refers to preorder, postorder, and endorder instead of preorder, inorder, and postorder.

19:07 I've *never* heard of symmetric traversal being called postorder before.

19:07 (This is in TAOCP.)

19:08 bbloom: TimMc_: yeah, i ran across something like that confusing in a paper the other day. they said "post order" but they really meant "in order", at least as i understood the terms

19:08 i thought it was a typo or something

19:09 TimMc_: Knuth claims it makes sense because binary trees often encode trees, and the left subtree is therefore special -- but it's just insane for pre- to not be the opposite of post-.

19:10 And it doesn't help that "inorder" sounds like "endorder".

19:10 bbloom: i've always learned it as pre/in/post and that just seemed clear to me

19:11 for whatever little it counts for, wikipedia agrees: http://en.wikipedia.org/wiki/Tree_traversal#Depth-first_2

19:11 TimMc: I'm going to send Knuth an angry fax. :-P

19:11 bbloom: lol

19:13 amalloy: is he still paying for every error? "dear knuth, these terms are rubbish"

19:14 bbloom: i suspect this is unworthy of a hexidollar

19:15 TimMc: There's a lot of good stuff in here, but I'm not enamored with the general style.

19:16 Everything is so low-level as to obscure the actual algorithms.

19:18 bbloom: TimMc: apparently it was first published in 1968

19:18 TimMc: holy cats

19:19 bbloom: at least volume 1

19:19 TimMc: ...but that still doesn't excuse the lack of abstract descriptions.

19:19 bbloom: i havent seen it, much less read it

19:19 TimMc: Some of this stuff is like uncommented code.

19:20 bbloom: I nabbed a pirated copy to look something up (faster than going to the library), and now I'm trying to decide whether to buy it.

19:20 I probably will.

19:22 headshot: heh, re knuth

19:28 seancorfield: hmm, a friend was asking whether reading old/outdated comp sci books was worthwhile

19:29 i'd say "yes" for knuth and a handful of others

19:29 i was going back over some stuff for a C++ journal in the early/mid-90's... found a review i'd done of the gang of four book when it came out

19:30 and the journal had been publishing for over a year by then and i'd been doing c++ for a few years... interesting to look back even that far (two decades!)

19:31 i have a bunch of books from the late 70's / early 80's from when i was at university... and some of those are still good...

19:34 TimMc: Yeah, anything not language- or machine-specific has a good chance of remaining relevant.

19:37 Circa 2001 I picked up a book called the "Dictionary of Computing" for free outside a bookshop. The book was from the 80s or so but maybe 2/3 of the entries were still completely relevant.

19:38 technomancy: I found a book in Powell's called Travels in Computerland about a Theatre professor trying to build a database of all the performances in London from 1665-1700 and it was fascinating.

19:38 brainproxy: I have a dependency that's pulling in an older version of data.json and causing a problem w/ a more recent dep that's using the newer API for data.json

19:39 but ... having trouble figuring out which dep is the culprit

19:39 technomancy: kind of this double unfamiliarity of seeing tech that's completely ancient, but at the same time seeing it from the humanities perspective

19:39 brainproxy: try `lein deps :tree`

19:39 brainproxy: technomancy: thanks

19:40 bbloom: i really wish github let me make private notes about repositories

19:40 Raynes: bbloom: Evernote does.

19:40 ;)

19:40 bbloom: Raynes: it recognizes github?

19:41 Raynes: No, I mean you can make notes.

19:41 I was being a smartass.

19:41 Can you not detect smartassery?

19:41 brainproxy: technomancy: okay, found it ... it's datomic-free :-/

19:41 bbloom: Raynes: i can, but when it comes to evernote, i wouldn't be surprised if there was like plugins for sites & github was on the list

19:41 Raynes: true.

19:41 bbloom: Raynes: smartass.

19:41 brainproxy: since I can't fork that one, what are my options to have it not screw up the other library? if any

19:42 TimMc: brainproxy: exclusions?

19:42 Oh, wait... you said it's an API mismatch.

19:42 brainproxy: TimMc: yeah

19:43 TimMc: Can classlojure help? :-/

19:43 ugh

19:43 brainproxy: so another lib is using the api that's 0.2.1+ for data.json

19:43 seancorfield: brainproxy: there's a newer version of data.json that supports both old and new APIs

19:43 hmm, 0.2.1 should have both APIs

19:43 brainproxy: seancorfield: yeah, but the upstream lib is using the newer api

19:44 seancorfield: exclude data.json from both libs and add 0.2.1 as a direct dependency

19:44 both libs should be able to use 0.2.1 - it has both old and new APIs in it

19:44 brainproxy: seancorfield: can I exclude it purely from project.clj?

19:44 i mean w/o hacking source for datomic-free?

19:45 sorry, guess my lein fu is a bit weaker than I'd like

19:45 seancorfield: yes, where you specify each dependency exclude data.json

19:45 for example: [clj-webdriver "0.6.0-beta2" :exclusions [org.clojure/core.cache]]

19:46 clj-webdriver uses an older version of core.cache and my code needs a newer version

19:48 ecmendenhall: Hi everyone, I'm back…still working through SICP in Clojure.

19:48 I'm up to chapter 2, which builds up rational number arithmetic using cons, car, and cdr.

19:49 What are the most idiomatic equivalents in Clojure?

19:49 TimMc: car = first, cdr = rest

19:49 ecmendenhall: first and second for car and cdr, I assume...

19:49 amalloy: vectors, maps, lists, whatever

19:50 ecmendenhall: (vector a b) for cons?

19:50 hyPiRion: conj for cons.

19:51 amalloy: hyPiRion: wat. that doesn't work at all

19:51 TimMc: ecmendenhall: It really depends on what they're being used for.

19:51 hyPiRion: ,[(conj '(2 3) 1) (conj [2 3] 1)]

19:51 amalloy: (conj 1 2) ;; not a good thing

19:51 clojurebot: [(1 2 3) [2 3 1]]

19:51 seancorfield: if it's using pairs of numbers, vector with first and second might be better?

19:51 hyPiRion: amalloy: oh right, I was thinking without dotted lists.

19:52 ecmendenhall: TimMc: seancorfield: Yeah, in this case it's using pairs of numbers to do rational number arithmetic.

19:52 TimMc: ecmendenhall: If you want to stick precisely to the semantics of cons cells: cons, first, & next.

19:52 Oh, just pairs? Use vectors, first, and second.

19:52 &(first [5 6])

19:52 lazybot: ⇒ 5

19:52 seangrove: $seen ohpauleez

19:52 lazybot: ohpauleez was last seen quitting 1 day and 8 hours ago.

19:53 TimMc: amalloy: Good point about dotted pairs, if that's what you were getting at.

19:53 seancorfield: (vector num denom), (first rational), (second rational)

19:53 brainproxy: seancorfield: thanks so much, working now :D

19:54 seancorfield: brainproxy: cool...

19:54 ecmendenhall: Cool, thanks. I'll stick to vectors for pairs for now. When I need sequences I'll switch to cons, first, and next.

19:54 seancorfield: ecmendenhall: although i guess you could use clojure's native ratio types... but that's kinda cheating :)

19:55 &22/7

19:55 lazybot: ⇒ 22/7

19:55 seancorfield: (ratio? 22/7)

19:55 amalloy: if you want to avoid any possibility of confusion with clojure's builtin sequences, you could create a new Cons type that doesn't participate in any of clojure protocols

19:55 seancorfield: &(ratio? 22/7)

19:55 lazybot: ⇒ true

19:56 ecmendenhall: seancorfield: haha, yeah. I'm trying not to cheat too much and learn a thing or two.

19:56 seancorfield: &(Ratio. 22 7) ;; does this work?

19:56 lazybot: java.lang.IllegalArgumentException: Unable to resolve classname: Ratio

19:56 seancorfield: &(clojure.lang.Ratio. 22 7) ;; ??

19:56 lazybot: seancorfield: What are you, crazy? Of course not!

19:56 java.lang.ClassCastException: java.lang.Long cannot be cast to java.math.BigInteger

19:57 seancorfield: &(clojure.lang.Ratio. 22M 7M)

19:57 lazybot: java.lang.ClassCastException: java.math.BigDecimal cannot be cast to java.math.BigInteger

19:57 seancorfield: bah...

19:57 &(clojure.lang.Ratio. 22N 7N)

19:57 lazybot: java.lang.ClassCastException: clojure.lang.BigInt cannot be cast to java.math.BigInteger

19:57 seancorfield: oh.. duh.. of course..

19:58 TimMc: &(class (inc' Long/MAX_VALUE))

19:58 lazybot: ⇒ clojure.lang.BigInt

19:59 ecmendenhall: The first chapter also had a section introducing orders of growth, with exercises like "double the input on this O(n^2) algorithm and see how much longer it takes."

20:00 loliveira: how to make it work? (let [f (fn [x] (dec x))] (eval (read-string "(f 42)")))

20:00 ecmendenhall: I get orders of growth conceptually, but the results were always inconsistent using core/time to time functions

20:00 I suspect some of this has to do with on-the-fly compilation in the REPL?

20:01 loliveira: &(let [f (fn [x] (dec x))] (eval (read-string "(f 42)")))

20:01 lazybot: java.lang.SecurityException: You tripped the alarm! eval is bad!

20:01 ecmendenhall: The first evaluation always takes a lot longer using time. Am I on the right track with this?

20:06 TimMc: ecmendenhall: If you want to get a better timer, I recommend hugod's "criterium".

20:06 let's see...

20:06 $latest hugod/criterium

20:06 lazybot: No project by this name exists on clojars.

20:06 TimMc: Worth a try.

20:07 ecmendenhall: TimMc: Thanks, I'll check it out.

20:08 amalloy: it's probably pallet

20:08 $latest criterium

20:08 lazybot: [criterium "0.3.1"] -- https://clojars.org/criterium

20:13 arohner: amalloy: do I remember correctly that you had a library that has Sets that maintain insertion order?

20:16 aha, https://github.com/flatland/ordered

20:31 Rich_Morin: Hmmm - http://clojurewest.org/ is down.

20:31 bbloom: Rich_Morin: works for me

20:32 Rich_Morin: back now - hiccup, I guess

20:38 idlecool: hi guys. i am struggling to include a library into my project.clj by adding (require 'clojure.contrib.io)

20:39 but `lein run` throws out "Error loading project.clj"

20:39 i am using leiningen 2.

20:39 is there by anyway, i can get more discriptive errors?

20:40 gtrak: clojure.contrib is no longer a thing

20:40 idlecool: oh.

20:40 gtrak: what are you trying to do? there's probably a more appropriate library now.

20:40 idlecool: then where do i find io module?

20:40 brehaut: also, you dont use require in project.clj

20:40 technomancy: idlecool: clojure.java.io

20:41 idlecool: technomancy: works like a charm. thanks :)

20:42 gtrak: i am trying to add -javaagent to jvm-opts, and i need to know the current working directory (pwd)

20:43 brehaut ^

20:43 brehaut: what would be the optimal way to do this, if i not use require in project.clj

20:43 using*

20:44 gtrak: idlecool: you can eval in project.clj

20:44 for lack of a better way

20:45 brehaut: idlecool: i had assumed you were getting confused between dependancy/packages and namespace/requires

20:45 idlecool: brehaut: oh.

20:46 gtrak: eval, i am not sure how will i use eval find the current working directory

20:46 technomancy: idlecool: pwd is always the project root

20:46 gtrak: idlecool: here's an example: http://stackoverflow.com/a/12599890/244235

20:46 listen to technomancy :-)

20:51 tmarsh: This might be me miss-reading the docs, but I can't get a JTextArea to obey a margin using Seesaw

20:52 (defn make-item [] (text :multi-line? true :wrap-lines? true :margin [5 5 5 5] :border (line-border)))

20:56 idlecool: technomancy: gtrak: relative paths works just fine. :)

21:01 amalloy: arohner: yep, that's the one. enjoy, or let me know if there are problems

21:14 gfredericks: it is surprising that = does not bother comparing hashes

21:16 TimMc: &(->> :a :b :c #'+)

21:16 lazybot: ⇒ #'clojure.core/+

21:17 TimMc: I'd forgotten that var can "soak up" extra arguments. I'm sure I can do something heinous with that.

21:17 gfredericks: &(var first these symbols don't compile)

21:17 lazybot: ⇒ #'clojure.core/first

21:17 TimMc: &(->> 1 2 3 #'+)

21:17 lazybot: ⇒ #'clojure.core/+

21:17 gfredericks: &(var first eval System/exit)

21:17 lazybot: java.lang.SecurityException: You tripped the alarm! eval is bad!

21:18 TimMc: heh

21:18 gfredericks: &(resolve (symbol "eval"))

21:18 lazybot: java.lang.SecurityException: You tripped the alarm! resolve is bad!

21:19 gfredericks: &((ns-publics 'clojure.core) (symbol "eval"))

21:19 lazybot: java.lang.SecurityException: You tripped the alarm! ns-publics is bad!

21:19 TimMc: &(#((var + %3) 5 6) 'need 'more 'args)

21:19 lazybot: ⇒ 11

21:19 gfredericks: &(first (ns-map 'clojure.core))

21:19 lazybot: java.lang.SecurityException: You tripped the alarm! ns-map is bad!

21:20 gfredericks: &*ns*

21:20 lazybot: ⇒ #<Namespace sandbox8277>

21:20 gfredericks: &(the-ns 'clojure.core)

21:20 lazybot: java.lang.SecurityException: You tripped the alarm! the-ns is bad!

21:22 TimMc: ,(s/join \ (for [[k v] (ns-publics 'clojure.core) :let [added (:added (meta v))] :when (= added "1.4")] k))

21:22 clojurebot: "mapv *data-readers* filterv default-data-readers ex-info ex-data"

21:22 amalloy: gfredericks: it's nice if (= some-huge-vector other-huge-vector) can short-circuit on the first difference instead of having to hash them

21:22 is one reason that might have been done

21:23 gfredericks: amalloy: yeah, it's a complicated thing; you could only check if the hashes are already computed, but I can see why maybe that wasn't done

21:25 technomancy: so I think this is ready: https://github.com/technomancy/syme

21:26 ^ if you do remote work you might be interested in that

21:42 TimMc: How do I go about calling a constructor that expects a primitive int?

21:43 gfredericks: &(Integer. ^int 7)

21:43 lazybot: java.lang.IllegalArgumentException: Metadata can only be applied to IMetas

21:43 gfredericks: haha of course

21:43 TimMc: mmm, I think my problem is elsewhere

21:43 gfredericks: &(let [^int x 7] (Integer. x))

21:43 lazybot: java.lang.UnsupportedOperationException: Can't type hint a local with a primitive initializer

21:43 tomoj: I want metadata for numbers in cljs

21:43 gfredericks: man I don't know anything about primitives in clojure :(

21:43 TimMc: Eh, I had the wrong signature anyway.

21:43 gfredericks: tomoj: that's impossible right?

21:43 tomoj: I think I have the .cljs side done, but the clojure reader won't accept it, of course :(

21:44 TimMc: Passing 0 worked fine.

21:44 gfredericks: tomoj: how do you represent it at runtime in JS?

21:44 tomoj: as a Number object

21:44 gfredericks: man how do I not know about this

21:45 tomoj: but really, I probably don't want to put metadata on numbers anyway

21:45 I was thinking about units ("dimensional analysis"?)

21:45 gfredericks: tomoj: is there some magic method that a JS object can have such that it works with +?

21:46 tomoj: I think it's .valueOf

21:46 gfredericks: oh but that has to return a number

21:46 rather than giving + arbitrary meaning

21:46 goright

21:46 right*

21:46 tomoj: ({valueOf: function() { return 3; }}) + 4

21:47 #u/ms 1000 ?

21:47 mae: oh boy

21:47 how do i do varargs

21:48 gfredericks: java varargs?

21:48 mae: i.e. call a varargs function in java with an empty arg list

21:48 tomoj: then a set of custom arithmetic operators :(

21:48 gfredericks: mae: I think on the jvm it's just an array argument

21:48 mae: i try into-array

21:48 gfredericks: tomoj: let's team up on a generic arithmetic lib

21:48 mae: but getting null pointer exception

21:48 lol

21:48 tomoj: you can implement Number by returning a value in the standard units for that dimension but then you just get a normal number at the end..

21:48 just like valueOf

21:48 mae: anyways, ill keep hackin at it

21:49 gfredericks: mae: you need to make sure the type of the array is correct?

21:49 mae: ah i gotta use annotation?

21:49 gfredericks: mae: into-array can take a type as its first arg

21:50 mae: make-array might be slightly more natural

21:50 &(make-array Integer 0)

21:50 lazybot: ⇒ #<Integer[] [Ljava.lang.Integer;@5def14>

21:55 mae: hmm

21:55 what does the & do

21:55 is that the lazybot command

21:55 heh

21:55 gfredericks: yes

21:55 amalloy: gfredericks: "of course", but it's actually wrong: metadata can only be applied to IObj, not IMeta

21:56 gfredericks: amalloy: oh the error msg you mean?

21:56 amalloy: yeah

21:56 gfredericks: what is IMeta?

21:58 amalloy: &(clojure.reflect/reflect clojure.lang.IMeta)

21:58 lazybot: ⇒ {:bases nil, :flags #{:public :interface :abstract}, :members #{#clojure.reflect.Method{:name meta, :return-type clojure.lang.IPersistentMap, :declaring-class clojure.lang.IMeta, :parameter-types [], :exception-types [], :flags #{:public :abstract}}}}

21:59 gfredericks: &(clojure.reflect/reflect clojure.lang.IObj)

21:59 lazybot: ⇒ {:bases #{clojure.lang.IMeta}, :flags #{:public :interface :abstract}, :members #{#clojure.reflect.Method{:name withMeta, :return-type clojure.lang.IObj, :declaring-class clojure.lang.IObj, :parameter-types [clojure.lang.IPersistentMap], :exception-types [], :flags #{:public :abstract}}}}

21:59 gfredericks: so IObj can take meta and IMeta can return it

22:07 amalloy: right, except that of course IObj can do both, since it extends IMeta

22:08 gfredericks: oh so it does

22:08 amalloy: wouldn't be very useful to put metadata on something without being able to get it out, anyway

22:56 yedi: gawd i hate frameworks

22:57 Raynes: Don't use them.

22:57 That's what I do.

22:59 gtrak: I hate libraries

23:00 well, anything with dependencies

23:01 TimMc: From clojure.lang.Compiler: static Symbol dummyThis = Symbol.intern(null,"dummy_this_dlskjsdfower");

23:04 gtrak: I kinda just want includes

23:04 TimMc: ,(apropos 'load)

23:04 clojurebot: (with-loading-context *use-context-classloader* load-reader load load-string ...)

23:04 TimMc: ,(doc load)

23:04 clojurebot: "([& paths]); Loads Clojure code from resources in classpath. A path is interpreted as classpath-relative if it begins with a slash or relative to the root directory for the current namespace otherwise."

23:05 gtrak: and each function should have its own dependency graph, that's easy to separate.

23:07 yunfan: hi, just found avian http://oss.readytalk.com/avian/status.html , i was wonder if it could run clojure

23:08 gtrak: yunfan: does it have reflection and classloaders?

23:09 yunfan: gtrak: it do has java.lang support , i am not a java programmer you could check http://oss.readytalk.com/avian/javadoc/index.html

23:09 gtrak: "a useful subset of Java's features," doesn't sound promising

23:09 yunfan: tried the paint sample app, its really cool

23:10 technomancy: yunfan: I tried it a while back. I think it can run a raw Clojure repl but it can't run Leiningen

23:10 I think that was due to some of the aether dependencies rather than leiningen itself though

23:11 yunfan: technomancy: so it means you could build a independ clojure executable app?

23:12 technomancy: yunfan: for some subset of Clojure

23:12 gtrak: might have better luck with clojurescript

23:12 yunfan: :]

23:25 technomancy: one of the maintainer guys was pretty responsive when I was emailing him

Logging service provided by n01se.net