#clojure logs

2012-07-11

00:48noidisjl, save the worst error messages along with what they _should've_ said. that would make a great reference for when someone(tm) decides to do something about them :)
00:49noidi(re: https://twitter.com/stevelosh/status/222910504987926529)
00:50sjlnoidi: heh, {#"No single method: .* of interface: .* found for function .*" (rand-nth ["You called a protocol method with the wrong arity" "Clojure/Lein fucked up the AOT compilation; run lein clean."])}
00:51noidiI don't think you should be AOT compiling anything unless you're doing interop
00:52noidiat least then you can just restart your REPL when things get weird, and everything gets recompiled
00:52sjlnoidi: no, this problem persists across repl restarts
00:52sjlnoidi: lein thinks the AOT compiled stuff is done even though I've changed a protocol
00:53sjlso it doesn't recompile it, and when I try to use the changed version it's still using the old one
00:53dnolensjl: but what triggers AOT in the first place?
00:53sjlwhich certainly isn't going to work
00:53sjldnolen: that's a wonderful question
00:53dnolensjl: certainly not Clojure
00:53sjldnolen: https://github.com/sjl/caves
00:54sjlgrep -R aot . returns nothing
00:54dnolensjl: are you re-compiling some namespaces interactively and not others?
00:54noidiI generally prefer multimethods to protocols, because they're slightly easier to deal with because of things like this
00:56sjldnolen: okay I can consistently repro it, one sec
00:57noididefmulti has defonce semantics, which is surprising and annoying, but once you know that you can redefine things (using ns-unmap) without restarting the repl
00:57noidi(well, surprising = annoying when it comes to programming)
01:03sjldnolen: noidi: https://gist.github.com/3088120
01:05dnolensjl: so that only occurs under lein repl, not interactive dev?
01:06sjldnolen: if by interactive dev you mean lein swank then oh no, it definitely appears there too
01:06dnolensjl: so this is a bug that exists in your code right now? what's at line 39?
01:06sjldnolen: it's not a bug in my code. if you run 'lein clean; lein repl' the repl works again
01:08sjldnolen: that sed call changes the name of the method in the protocol, and updates the places where it's used. The problem is that Clojure thinks the protocol method still has the old name
01:08noidiyeah, I can reproduce it
01:08sjlso when I try to use the updated name, it explodes
01:08noidiwhen I run "lein repl", it tells "All namespaces already :aot compiled."
01:08dnolensjl: only lein2? or lein1 as well?
01:08sjland by "Clojure thinks" I mean "something in the Clojure/leiningen chain thinks"
01:09dnolensjl: Clojure doesn't AOT by default.
01:09noidisjl, you have caves.core marked as containing the main class for the project
01:09sjldnolen: hm, no idea. I can try it with lein1 if it's not much work to backport the project file I guess...
01:09noidiwhich means caves.core needs to be AOT compiled
01:09noidiAOT compilation is transitive
01:09noidiwhich triggers the compilation of the protocols
01:10sjlnoidi: Okay, so that explains the AOT compilation, but not the failure to notice updates to the files and recompile.
01:10noidilein only knows that caves.core is AOT'd -- it doesn't know that it should check the other namespaces for modifications and recompile them
01:11dnolennoidi: I'm confused as to why lein repl should trigger AOT
01:11sjlIt know it needs to AOT them the first time...
01:11dnolennoidi: regardless of project settings
01:12noididnolen, that's probably to make lein repl nicer to use with gen-class
01:12noidiI used to do a lot of lein compile, repl before I noticed that lein does that by default
01:13noidisjl, the transitive compilation bit is done by the Clojure compiler. lein just asks it to compile clojure.core.
01:13noidiso I think this could be considered a bug in lein
01:13akhudekI guess you could ask to to AOT the whole project as a not so nice work around...
01:14akhudekof course beware of core.match if you do that, it doesn't work with AOT
01:14sjllol
01:14sjlalias lein='lein2 clean; lein2'
01:14sjlproblem solved.
01:15akhudekthat works too :D
01:15dnolenakhudek: heh, yes - the warnings has since been added to the repo.
01:16akhudekdnolen: I discovered that the hard way :-(
01:16dnolenakhudek: sadly no patches yet.
01:17dnolenakhudek: finding AOT bug are a PITA.
01:17dnolenbugs
01:17akhudekI was pretty surprised that such a thing could even happen!
01:17dnolenakhudek: it easier than you think.
01:17akhudekI'll take your word for it. :-)
01:18dnolenakhudek: with enough dynamism your code can easily only make sense only at runtime.
01:18noidiI'd work around sjl's issue by adding (ns caves.core.Main (:gen-class :impl-ns caves.core)), and in project.clj set :main caves.core.Main
01:18noidi(or whatever, I never get the ns syntax right, but maybe you got the idea)
01:19noidiimpl-ns does _not_ get transitively AOT'd so its requirements aren't either
01:19seawordI'm diving into my first clojure program using ring and can't get the wrap-reload syntax quite right. http://pastie.org/4235725
01:19noidibut yes, the AOT stuff is quite a trainwreck at the moment
01:19seawordI get this error: IllegalArgumentException Parameter declaration wrap-reload should be a vector
01:19sjlnoidi: okay it's late, what exactly does that do?
01:19seawordWould be grateful for a nudge in the right direction, cheers.
01:19noidisjl, do you have o'reilly's clojure book?
01:20noidisjl, the impl-ns trick is mentioned somewhere in it
01:20sjlnoidi: is that programming clojure?
01:20noidiwait a sec, I'll check the book right now
01:20sjlor clojure programming?
01:20sjllol naming
01:20ssutchis there any difference between (defn a->b [x] x) and (defn a [x] x)
01:20dnolenakhudek: (def foo (partial bar baz)) was one bad pattern I used.
01:21sjlssutch: ... one is named 'a' and one is named 'a->b'?
01:21ssutchthat's what i figured
01:21ssutchjust wanted to make sure, what is the convention for using a->b?
01:21dnolenakhudek: extend-type was also a problem.
01:21noidisjl, check the note on page 338 of Clojure Programming if you have it
01:23sjlnoidi: the thing about the modification dates?
01:23xumingmingvhey guys, any comments on this? http://martinsprogrammingblog.blogspot.de/2012/02/why-is-clojure-so-slow.html
01:23sjlI'm quite sure the mtime is getting set when I save the file with Vim...
01:24sjlxumingmingv: My thoughts: "Get an SSD and don't use Clojure for shell scripts."
01:24ivanyou can use -Xbootclasspath to reduce the startup time
01:25ivanthat is, -Xbootclasspath/a:clojure.jar
01:25noidisjl, nope, the note about gen-class and transitive dependencies. I'm talking about the o'reilly book with the bird on the cover... :P
01:25noidiby emerick, carper and grand
01:25sjlnoidi: oh I have the rough cuts version -- I think the note you're talking about is on a different page for me
01:26sjlnoidi: this thing? http://i.imgur.com/UgQLM.png
01:26noidithat's it
01:27dnolenxumingmingv: do you have some specific concern?
01:27noidiof course, if you don't really need to be able to run "java -jar caves.jar", just drop the :main from project.clj and be done with it >(
01:27noidi:)
01:27sjlnoidi: so the solution is to make a special ns that uses some special ns voodoo to only generate one AOTed class
01:27sjland then let the rest of the project be unAOTed
01:27sjlwhich means protocol definitions will be loaded from the clojure sources
01:28sjlroughly?
01:28xumingmingvdnolen: just feel not good when a language I like marked *slow*
01:28akhudekdnolen: why was the partial pattern bad for AOT?
01:28dnolenxumingmingv: what languages do you use that are *fast*?
01:28noidisjl, instead of AOT'ing a class _containing_ functions that need stuff in other namespaces (which then get transitively AOT'd), you AOT a class that will, at runtime, load up the impl-ns and call functions in it
01:29noidisjl, at least that's my understanding
01:29dnolenakhudek: partial combined with instance? I think specifically.
01:29sjlah
01:30akhudekah, interesting. I'll remember to try to avoid that in the project I'm using a lot of AOT in
01:30sjlOkay I think that's my limit of JVM bullshit for the night. Time to go to bed.
01:30xumingmingvdnolen: I use java at work
01:30sjlnoidi: btw "Programming Clojure" and "Clojure Programming" both have birds on the covers :P
01:30dnolenxumingmingv: apologies I misread what you wrote. Martin (the writer) is actually a Clojure fan, certainly some of what he's says is true - idiomatic Clojure is often slower.
01:31noidisjl, argh :D
01:31dnolenxumingmingv: and the community hasn't been proactive about updating the Alioth benchmarks to leverage 1.3 enhancements. We've got 3 more benchmarks to go before we have the full suite competitive w/ Java (and of course Scala)
01:37xumingmingvdnolen: thanks for the information
01:38dnolenxumingmingv: http://github.com/clojure/test.benchmark
01:38aduhey
01:39aduis anyone here in the DC area?
01:39xumingmingvI found a stackoverflow question talking about this: http://stackoverflow.com/questions/4148382/why-does-clojure-do-worse-than-scala-in-the-alioth-benchmarks
01:39xumingmingvbut i dont quite agree with the accepted answer
01:39dnolenxumingmingv: yes, old question. run test.benchmark for yourself and see.
01:40dnolenxumingmingv: better yet submit one of the 3 remaining benchmarks, then Alioth will be update to date and people can go back to complaining about too many parens ;)
01:41xumingmingvdnolen: haha
01:46brainproxydnolen: in your study of prolog/datalog, did you spend any time with DES, "datalog educational system"?
01:46brainproxyhttp://www.fdi.ucm.es/profesor/fernan/des/
01:46dnolenbrainproxy: I've seen it but I've never played around with it.
01:47brainproxyokay.. seems a bit harder to find datalog "stuff" vs. prolog books, articles, etc.
01:47dnolenbrainproxy: to be honest I don't really understand Datalog that well - in fact I'm not even aware of any good explanations of how to implement it that aren't disk oriented.
01:47brainproxyi see
01:47dnolenbrainproxy: I picked Stuart Halloway's brain about this at the last Conj (I'm assuming he was working on Datomic already) and he said the same.
01:48dnolenbrainproxy: but clearly they figured something out that works well enough for real queries as well as data structures.
01:48brainproxyis datomic a kind of datalog?
01:48dnolenbrainproxy: it supports datalog style queries yes.
01:48brainproxyi mean that's my impression
01:49brainproxyI'm interested to understand the crossover between something like datomic w/ datalog style queries and a project like orientdb
01:49brainproxywhich also has a relational query engine
01:49akhudekif you are interested in query compilation/datalog specifically
01:49brainproxybut isn't SQL to be sure
01:49akhudekI guess I could recommend my collegues recent book on using FOL proof systems for this
01:50brainproxyakhudek: link, ISBN?
01:50akhudekhttp://www.amazon.ca/Fundamentals-Physical-Design-Query-Compilation/dp/1608452786
01:50brainproxyakhudek: thanks
01:50akhudekif you do a google search, parts are available online as part of a class material
01:52brainproxyakhudek: cool.. I'm still just getting my little toe wet w/ prolog, but I've saved it for future reference
01:52akhudekbrainproxy: if you have any questions on the topic, feel free to message me
01:52brainproxythanks!
01:53akhudekbrainproxy: I'm actively working on an implementation of what is discussed in that book (in clojure no less)
01:53gerunddevIs there a channel specifically for core.logic?
01:54dnolengerunddev: here
01:54brainproxydnolen: btw, I found another prolog primer.. http://www.ida.liu.se/~ulfni/lpp/
01:54brainproxyit has a much more mathematical approach
01:54dnolenakhudek: curious, are you actually building a in memory Datalog?
01:55akhudekdnolen: it's a first order logic theorem prover, all in memory
01:55gerunddevdnolen: Thanks. Know of any good primers on defne, defna, etc?
01:55dnolenbrainproxy: you can avoid buying books but the Bratko one and the Sterling Shapiro one are excellent :)
01:56dnolenbrainproxy: Bratko 4th ed now covers CLP which is just around the corner for core.logic.
01:56brainproxydnolen: I defeinitely am interested in the Bratko one
01:56dnolenakhudek: very cool :) open source one day?
01:56brainproxybut a number of comments suggested it's not a good first book
01:56brainproxyso I started looking for a "first book"
01:56akhudekdnolen: that's the idea :-)
01:56dnolenakhudek: sweet
01:57noidisjl, btw. lein has a :skip-aot option to prevent AOT compilation of :main https://github.com/technomancy/leiningen/blob/master/sample.project.clj#L97
01:57brainproxythe "Art of.." is supposed to be good for that purpose, but I like reading on ipad and mac, so opted for the book from springer.com, as I could pay and download it
01:57dnolenbrainproxy: huh, not sure why people said that.
01:57dnolenbrainproxy: a lot of my understanding of how to actually use core.logic came from Bratko.
01:57dnolenbrainproxy: it's actually why I added the DB functionality right way.
01:57dnolenbrainproxy: so I could try the examples :)
01:57noidisjl, I created a bug report for lein about this https://github.com/technomancy/leiningen/issues/679
01:58brainproxyinteresting... okay, well maybe it would be fine for me to start with, but I'll get to it; also reading a proper Java book now, rather than just absorbing through clojure interop
02:00brainproxyas DES is built entirely w/ prolog, i.e. it rides on top of your prolog runtime of choice, i hope to study it as well, to see how a datalog system can emerge from prolog
02:03gerunddevEvery core.logic demo shows that you can query goals in both directions. But I can't quite figure how to share code to do that.
02:03dnolengerunddev: what do you mean?
02:06gerunddev(run* [q] (membero q '(1 2 3))) & (run* [q] (membero 2 q)), but I'd like to be able to use the same relationship with [item coll] then pass a value for one and bind the other to an lvar.
02:07gerunddevI thought something like (defne [item coll] (memero item coll)), but apparently I don't grok defne.
02:07dnolengerunddev: defne/a/u are just for pattern matching sugar
02:08dnolengerunddev: just make a regular function. (defn my-rel [item coll] (membero item coll))
02:10gerunddevdnolen: I had gotten the impression that mixing functions and their logic cousins was a bad idea… now I can't even remember where I got that idea.
02:11dnolengerunddev: yeah not true, the whole point of core.logic (really miniKanren) is that the two approaches can coexist.
02:12amalloybtw dnolen, what do the -a/e/o suffixes mean? i've been just putting an o at the end of my relation-based function names, but it feels cargo-cult because i don't know why
02:13RaynesI wish I had a condo.
02:13madsyCan I somehow set "lein trampoline cljsbuild repl-listen" to inferior-lisp-program in emacs?
02:14madsyWhen I do I get "Wrong type argument: stringp, nil"
02:14dnolenamalloy: I guess o generally mean the goal is pure, inputs and outputs don't matter.
02:15dnolenamalloy: -a means soft cut, other branches will not be looked at (unlike conde)
02:15Raynesdnolen: I'll learn core.logic if you find something in refheap that could make use of it. :D
02:16dnolenamalloy: -u mean committed choice. not only with other branches not be looked at, all the goals after the first goal of a clause will only be run once.
02:16dnolen"not only will"
02:16dnolenRaynes: ha! kibit service?
02:16gerunddevdnolen: I can't even find what I read that made me think that now.
02:17amalloyhe's surely missing some chances to use core.match to simplify his dispatch
02:17Raynesamalloy: There is so much I could use core.match for.
02:17Raynesamalloy: My problem is that I purposely avoid it because if I had it, I'd use it for everything.
02:17dnolenamalloy: to be more specific, conde lines looks like this:
02:17dnolen[(head) ... bunch of other goals ...]
02:17Raynesdnolen: That's a damn good idea.
02:18RaynesI'm honestly going to open an issue for that.
02:18gerunddevAs a famous author once said, "Contradictions do not exist. Whenever you think you are facing a contradiction, check your premises. You will find that one of them is wrong."
02:19dnolenamalloy: with conda, if a head succeeds, other [...] [...] are ignored. the remaining goals of the succeeding line can succeed many times (produce many answers)
02:19dnolenamalloy: with condu, if a head succeeds those remaining goals can only produce one answer
02:19Raynesdnolen: If I wanted to get the mention of cake out of the core.logic readme, how would I go about that? Open a jira ticket? Ask you to do it for me? My CA is under a non-legal name and I haven't sent in a new one yet, so I can't just give you a patch.
02:19Raynes:(
02:19amalloyi've at least figured out how conde/conda behave (still not 100% sure about condu), but i'm wondering what the dang letters mean
02:20dnolenRaynes: where do I meantion cake?
02:20Raynesdnolen: 'Usage'
02:21Raynesdnolen: core.match, sorry.
02:21RaynesI get your core.things mixed up all the time.
02:21dnolenamalloy: condu can be use to implement (onceo g). conda can't. condu can guarantee that g will only produce one solution.
02:22dnolenRaynes: done
02:22RaynesCool.
02:24dnolenamalloy: both are used for pruning search so should be used care - they both disable in many instances the ability to run programs "backwards".
02:26amalloyokay. i'll plan on continuing to have a great new usage for conda and then eventually rewrite it when i realize i was wrong
02:28gerunddevI'm hoping to use logic programming in a schema on read no-sql environment.
02:28dnolenamalloy: I believe their inclusion in miniKanren was to show they could get nearly all the functional of "real" Prolog as it's used in practice.
02:28ssutchif i just want to return a body as-is from an if exp, what would i do?
02:28gerunddevWe currently have problems where document structures evolve over time, and writing migration scripts seems to defeat the purpose of using a no-sql datastore.
02:29dnolenamalloy: I've found them useful in making it easy to port Prolog. then it's fun to see if cuts can be eliminated w/o slowing things down too much.
02:29ssutcheg (if ((a) (b)) c) i want to get ((a) (b))
02:29gerunddevWhat if you could use rules to say, can this be interpreted as something valid?
02:29amalloy(or)
02:29amalloyspecifically, (or ((a) (b)) c)
02:30ssutchsorry, i didn't quite explain well enough