#clojure logs

2012-06-30

02:11xumingmingvI'am stuck with how to a gen-class and java array related problem
02:11xumingmingvhttps://gist.github.com/3022563
02:11xumingmingvis the :constructor part correct?
02:12xumingmingvto use "[java.net.URL;" to represent a java.net.URL class?
03:25SrPxHey guys. Is there a lein command to run a .clj file?
03:30antares_SrPx: there is no, you run namespaces
03:30antares_lein run -m my.namespace.to.run
03:31antares_namespaces that you want to run need to have (:gen-class) in the (ns …) definition and the -main function that takes & args
03:31antares_that's it
04:04SrPxantares_: o.o
05:04RaynesWell guys, the Heroku outage isn't effecting refheap anymore. Unfortunately, the database service I use was also effected by the storm that hit the AWS data center. My database is down and until it comes back up, refheap wont be working. Heroku will be trying to restart refheap every 10 minutes for the rest of the night until the database comes back online.
05:05RaynesI'm going to bed, sirs and madams.
05:06borkdudeoops
05:06borkdudeI read about the storm on the news now… good luck and sleep well
05:28alexyakushevHello, I'm a new to protocols but is it possible to extend some protocol for an arbitrary object to support destructuring?
05:29alexyakushevI guess if such a protocol exists it should implement `get` function or something
05:34borkdudealexyakushev maybe this? https://groups.google.com/forum/?fromgroups#!topic/clojure/K5HyK7GDnUE
05:35borkdudealexyakushev destructuring uses nth
05:37alexyakushevborkdude: Thanks! I'll take a look
05:37alexyakushevborkdude: I'm looking for associative destructuring, like for maps
05:37borkdudealexyakushev example?
05:38alexyakushevborkdude: You know, {:keys [foo bar]}
05:38borkdudeah
05:38alexyakushevYes, I found how to do that using `proxy` under the link you provided, thank you again
05:39alexyakushevThough I hoped it is possible to do this without wrapping of any kind. But that's too much:)
05:40borkdudealexyakushev I don't know what is used for associative destructuring, maybe the Associative interface?
05:41alexyakushevFrom the source code it calls simple `get`, as far as I can tell
05:41alexyakushevAnd `get` is redirected to clojure.lang.RT
05:41alexyakushevI haven't looked inside yet, but I guess protocols are not available that deep, am I wrong?
05:42borkdudealexyakushev I think you are right, clojurescript has that better solved I think
05:42borkdudealexyakushev one day maybe protocols will make it into this more fundamental level
05:42alexyakushevWell, hail to the Clojure in Clojure while we're waiting for it:)
05:43borkdudealexyakushev just apply a patch ;)
06:07borkdudeis there any clojurescript game similar to tictactoe on github?
08:28N8Dawgis anyone else having trouble connecting to www.datomic.com ?
08:56kmicuN8Dwag: no, it works
09:01kmicuN8Dawg: but some Heroku and AWS US based servers was down earlier, maybe this is the reason
10:36gfredericksI'm using Raphael with cljs and wanted to try out advanced compilation. Obviously I need to declare 'var Raphael' in an externs file, but what about all the methods on the raphael objects? how do I declare those?
10:38cemerickgfredericks: I'm right behind you. Please do post or gist about it when you have that riddled out.
10:38gfrederickshaha
10:38gfrederickswell I guess I'll try it the naive way and make sure it breaks first
10:46gfredericksis clojars on EC2?
10:53gfrederickswell apparently justing setting :optimizations to :advanced in the cljsbuild config doesn't do it
10:53tomojgfredericks: looking at the ip and https://forums.aws.amazon.com/ann.jspa?annID=1528 , I'm guessing no
10:53gfrederickstomoj: ok thx; thought I might have connectivity trouble, but I think it's working fine
11:02gfredericksstrangely the cljsbuild docs don't seem to mention advanced compilation at all o_O
11:27gfredericksoh nevermind it did do advanced
11:54Scriptoryep, makes a good deal of difference
11:54Scriptor18k lines to about 5k
11:54Scriptorandn that 18 is already minimzied
11:54Scriptor*minimized
12:58wingyfirst i thought why not goto-ns instead of in-ns .. is the answer that clojure tries to stay declarative?
13:09gfrederickswingy: if nothing else, goto-ns confusingly evokes goto
13:14gfredericks$mail cemerick I believe the externs section of http://lukevanderhart.com/2011/09/30/using-javascript-and-clojurescript.html describes the correct way
13:14lazybotMessage saved.
13:21gfrederickswhat are the implications of naming protocol methods with -foo instead of foo?
13:21gfredericks(in cljs)
13:23Bronsait's just a convention i guess
13:24wingyheh .. i was confused why they only showed vars and not functions :) but functions are first class and can be assigned to any var
13:24Bronsato tell that a protocol method is intended for internal use only
13:25gfredericksBronsa: you know that? I originally assumed it was mandatory since it seemed to mirror the .-foo attribute access syntax
13:25gfredericksbut only recently discovered you don't need it
13:25gfredericksand want to be sure there's not some crazy performance implication
13:26Bronsai am not 100% sure, for that ask dnolen, but i'm pretty confident that's the only meaning to the - prefix
13:27gfredericksokay thanks
13:28Bronsaalso gfredericks the .-foo syntax was introduced after those protocols were made so i dont think it's related in anyway
13:28Bronsaany way*
13:29gfredericksah ha. good to know.
13:50noko33why (meta ^String 'sym) is nil but (meta ^String []) resolves to {:tag java.lang.String} ?
13:51Bronsai'm guessing you are applying the metadata to the (quote sym) list
13:54dreishYes, you would need to do (meta '^String sym)
13:54dreish'^String sym is a tagged, quoted symbol.
13:56dreishIt looks more sensible if you write out the quote instead of using a quote mark: (meta (quote ^String sym)) ; yes ... (meta ^String (quote sym)) ; no
14:04noko33Bronsa, dreish: thanks, I understand now
14:11dnolengfredericks: - is just a convention. first the fn vs. the -first as implemented by a particular type.
14:16gfredericksdnolen: okay cool, thanks
14:31bagelzis there a clojurebot repl I can pm?
14:31gfredericksyou can pm clojurebot
14:32gfredericks,(+ 1 2)
14:32clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Wrong number of args (3) passed to: sandbox$eval-in-box>
14:32gfredericksclojurebot seems to be ill
14:32gfredericksbut you can also pm lazybot
14:32bagelzvery cool
14:32bagelzI pmed him and he did it fine
14:32bagelzthat is fantastic.
14:47gfredericksisn't there a constant-time way to find the highest bit set in a number?
14:48gfrederickswithout using logarithms :(
14:55wingywhats the point of:
14:55wingy(require 'clojure.set)
14:55wingy(clojure.set/union #{1 2 3} #{4 5 6})
14:55wingythe first line .. the second seems to work without the 1st
14:56gfredericksthe require ensures that clojure.set has been loaded. If it got loaded somewhere else already I suppose the second line would still work, but you shouldn't count on it
14:57dnolenwingy: some REPLs (lein) may have loaded clojure.set, but that won't always be the case.
14:58wingybut in the 2nd line im using a namespace qualified symbol
14:58wingycant still get why i would need the first one
14:59dnolenwingy: libs are not automatically loaded.
14:59wingythis works: (clojure.string/blank? "")
14:59wingywithout loading it
14:59tmciverwingy: in general you need the require. For me, lein repl loads it automatically, swank clojure does not.
14:59wingyblank? doesnt work
14:59dnolenwingy: what REPL are you using?
14:59wingylein
14:59dnolenwingy: lein loads a bunch of things
15:00dnolenwingy: if you use the standard Clojure REPL (which is not as nice), you have to require first.
15:00wingydnolen: no it didnt load string namespace since blank? wont work
15:00wingybut having (clojure.string/blank? "") worked
15:00dnolenwingy: blank? won't work because you didn't "use"" it, unrelated.
15:00wingyso unless it is doing some magic underneath when i use the full qualified name i still dont get why i have to require
15:00gfrederickswingy: first look up require vs use
15:00dnolenwingy: because automatically loading libs is a terrible idea.
15:01dnolenwingy: refer to the section on namespaces in your favorite Clojure book, should clarify things.
15:03wingydnolen: the example was from the book
15:09wingyok one last try: so i fire up "clj" version 1.4 .. i run (blank? "") it couldnt resolve symbol .. i run (clojure.string/blank? "") it worked .. i didn't require it .. so i run (require 'clojure.string) and it required it .. i do (blank? "") it didnt work .. i do (clojure.string/blank? "") it worked .. i dont get the purpose of require
15:10wingywhat did it help me with without me being able to do before i required it
15:10gfrederickswingy: (blank? "") will never work until you do (use 'clojure.string)
15:10wingyyeah i know .. im trying to get require
15:10gfredericksthat's a separate issue
15:10wingyi get use .. i dont get require .. whats the purpose
15:10gfredericksokay so don't infer anything from whether or not blank? works
15:11gfredericksthe purpose of require is to ensure that the namespace has been loaded. the reason you're seeing the behavior you are is that it was loaded already before you required it, which should be considered a coincidence
15:14wingyby loaded you mean the source files are read into memory .. and i can use them but have to specify the namespace qualified symbol
15:14wingymakes more sense now
15:14gfredericksno you do have to specify the namespace qualified symbol
15:14gfredericksoh yes you said that
15:14gfrederickssorry I read an extra negative
15:14wingyyou inverted my expression
15:14gfredericksyes I think you have it
15:15SrPxhey guys what is again that clojure library to write html clojure-like and then convert?
15:15gfrederickshiccup
15:15gfredericksor crate in cljs
15:15wingyseems that i always want to use (use)
15:15gfrederickswingy: it's deprecated
15:16wingyuse is deprecated?
15:16gfredericksrequire now has the use functionality as part of its options, and you're encouraged not to blindly use everything from a namespace so that it's easier to track where each symbol comes from
15:16gfredericksbut I still use use sometimes :)
15:17gfredericksdon't tell anybody
15:17wingylol
15:17wingygfredericks: use will be removed? where is the deprecation info
15:17gfredericksI don't know about either of those
15:17gfredericksthe changelog for 1.4 might mention it
15:18wingyhow did you know its deprecated then
15:18gfredericksI hang out in #clojure a lot
15:18wingythe book isnt mentioning it
15:18wingyok
15:18gfredericks1.4 is pretty recent
15:18gfredericksprobably recenter than any book
15:19SrPxgfredericks: ty
15:22wingyok require over use and refer
15:22wingyso many options are creating incidental complexity
15:23gfredericksthe ns macro has a long and sordid history
15:23bagelzunavoidable if it's supposed to be useful, right?
15:35wingyclojure is as unix as it can get
15:35brainproxydefend your statement
15:36wingysmall pieces doing one thing good one thing only
15:36wingythen macros come to help you
15:36brainproxy:)
15:36wingythis and that to require .. but dont use them! they will make your code messy
15:36wingyuse "ns" macro
15:36wingykinda wtf
15:37wingyyou first confuse me .. then you help me out .. while in node.js you just use require()
15:37brainproxyoh, your coming from nodejs also?
15:37brainproxy*you're
15:37wingyyeah .. explaining my confusions a lot huh? :)
15:37brainproxyme too
15:37brainproxyI started w/ nodejs in jan 2010
15:38wingya little bit later for me .. are you still using it?
15:38brainproxystill really like it, sure
15:38brainproxysome things are easy to reach for
15:38brainproxysuch as sockjs, socket.io
15:38wingyyeah their npm is really neat
15:38brainproxyyeah, npm is really slick
15:39wingyso simple .. also node.js itself is so simple and powerful .. but js is bleeh
15:39wingyused a lot of coffeescript before livescript
15:39brainproxyjs can be nice, and I like coffeescript a lot
15:39wingyhave a look at LiveScript
15:39wingyits Coffee with FP style
15:39brainproxybut ultimately, once you get a sense of what immutable collections and STM bring to the table, it's hard to want to prog in plain old js
15:40wingyyeah
15:40wingyfor how long have you been using clojure?
15:40brainproxygoing on two months now
15:40brainproxynot very long
15:40tomojSTM == atoms in this case?
15:40brainproxyread the O'Reilly book on Clojure as a crash course
15:40brainproxytomoj: i meant STM in general
15:41brainproxyas opposed to having to think about splitting work out to different processes
15:41tomojprocesses? thought you were talking about js
15:41brainproxynodejs has a notion of processes
15:41brainproxye.g. the child_process module
15:41brainproxywhich is actually really cool
15:41tomojdon't see how that is relevant
15:42brainproxywell, um, with a single thread, if you have anything cpu bound then you'll get eaten alive
15:42brainproxyso you need to split out work and coordinate among processes
15:42wingyfor blocking operations
15:42brainproxyeven with the cluster sugar, it's still kind of hairy
15:43wingyif you don't want to chunk the long living operations in pieces and have everything in one process .. but that is an ugly hack in my ears
15:43tomojI don't see how cljs helps at all there
15:43brainproxywe're not talking cljs
15:44brainproxyif I accidentally said cljs i meant straight up clojure
15:44tomojoh, clj-jvm vs js?
15:44brainproxyyes
15:44brainproxywell, vs nodejs considered in toto, not just js the language
15:44wingyclj/jvm vs js/node.js
15:45wingyi feel it doesn't add much value to use cljs on node.js
15:45tomojI disagree strongly
15:47tomojunless you mean it doesn't add much value to use cljs/node.js instead of clj/jvm, then I only disagree weakly :)
15:47brainproxyi think cljs on top of nodejs is pretty attractive actually
15:47wingyyeah that was my point
15:48brainproxybecause of the things cljs gives you
15:48wingyi would rather wanna use clj/jvm than cljs/node.js
15:48brainproxyi'm just saying that when I bump up against anything that dips into mvcc territory
15:48brainproxythen I am going to go with clojure/jvm
15:48brainproxyhands down
15:49brainproxythe reality is that a lot of web facing stuff, e.g. collaborative web apps, that kind of thing
15:49wingybrainproxy: what db are you using?
15:49brainproxyeasily start to deal with mvcc related concerns, and in my experience trying to work that out with node is kind of difficult
15:49tomojI would almost say that it is impossible
15:50brainproxywingy: some couch stuff, i am experimenting with orientdb also
15:59wingythougt about using datomic .. anyone having experience with that one?
16:18antares_folks who have been asking for an alternative insert function in Monger: 1.1.0-beta1 now has it, see https://github.com/michaelklishin/monger/blob/master/ChangeLog.md
16:32augustlare there any books out there that describes the details of the inner workings of the persistent data structures in clojure?
16:35arohneraugustl: http://blog.higher-order.net/2009/02/01/understanding-clojures-persistentvector-implementation/
16:35arohnerhttp://blog.higher-order.net/2009/09/08/understanding-clojures-persistenthashmap-deftwice/
16:42augustlarohner: cool, thanks :)
16:42augustlwould be interesting to try to implement it on top of Node.js buffers
16:42augustlwhich are just raw out-of-vm (but still garbage collected) allocated bytes
16:47wingylein is like npm but for the whole project cycle
16:47wingypretty cool
16:48augustlthere are so many things that are solved problems on the JVM platform.. Makes you wonder why people bother to make new ones.
16:48augustlI've heard Oracle is implementing Node.js on the JVM, for example
16:49antares_with a complete JS implementation based on invokedynamic, yes
16:49wingywhat?
16:49clojurebotwhat is 2d6
16:49augustlV8 is cool, but is it worth having to write all the libraries from scratch again? :)
16:49antares_it will be part of JDK 8, called Nashorn
16:49augustla fork of Rhino?
16:49antares_no, a green field design
16:49antares_invokedynamic from the ground up
16:50augustlinteresting naming, Nashorn = rhino (ish) in many european languages
16:50antares_yes, absolutely, that's the pun
16:51antares_http://www.google.com/url?sa=t&amp;rct=j&amp;q=&amp;esrc=s&amp;source=web&amp;cd=1&amp;ved=0CFEQFjAA&amp;url=http%3A%2F%2Fwiki.jvmlangsummit.com%2Fimages%2Fc%2Fce%2FNashorn.pdf&amp;ei=imbvT5npNYLU-gariJmvAw&amp;usg=AFQjCNFyPrV5etR8ikgrNn5-5wZCZUWyGA&amp;sig2=ywfL2opN9UPUq0gVayfTEg
16:52augustlgreat, thanks
16:52wingyso js would be yet another jvm lang
16:52antares_right
16:52wingyusing a new engine
16:53wingybut that wouldn't affect clojure programmers who only wants to use clojure
16:53augustlRhino is kind of black magic, seems like a welcome addition
16:53wingyi can understand the need for javascript for java coders since java is not dynamic
16:54antares_wingy: it has no relation to Clojure, just saying that Oracle indeed works on a JS implementation and there are at least two projects that are "polyglot Node.js-like environments"
16:54wingyyeah
16:54antares_and it is just one more proof that they care about JVM being polyglot
16:54wingypretty cool initiative
16:54wingyyeah just like heroku
16:54wingyi like polyglotism
16:58wingyseems that jvm is of higher value, than the java lang itself
16:58wingyi dont think they thought it would play out like this in the late 90s?
16:58wingythe goal was to make Java the lang popular right
16:59pipelineas far as i understand it
17:00pipelinethey expected the jvm to be very valuable also
17:00augustlnot sure if this is off topic, does clojurescript implement persistent data structures? The presentation by Rich Hickey on blip.tv is a year old or so
17:00antares_augustl: it does
17:00augustlwith the same performance characteristics of cloure?
17:01augustlthat is, a vector with 1000 items won't perform a full cow when creating a copy with one more item added to it, etc
17:03tomojif it did that, it wouldn't be persistent, would it?
17:03antares_augustl: more or less, they are doing some interesting things to get as close as possible to JVM Clojure performance where JS VMs can optimize things well
17:04tomojactually if you always do a full copy, then 'old versions' are not penalized, so maybe that does count as persistent.. just always slow?
17:05augustlantares_: cool
17:05technomancytomoj: I'm not sure the whole "old versions don't degrade in perf" is necessarily technically part of persistence. I think it depends on who you ask.
17:05augustltomoj: no idea.. I'd guess the performance characteristics of making copies with alterations is part of the whole "persistent" thing
17:05tomojtechnomancy: naturally
17:06tomojin effect I was asking you :)
17:06augustlcurrently investigating why everyone is using backbone and jQuery and nobody is using google closure for building JS apps, google closure seems insanely powerful
17:06augustl(meta-related to clojurescript)
17:11tomojwith backbone you just download one small file, drop in a jquery cdn link, write 10 lines of code and you have a stupid todo list
17:12tomojfor many it would take longer just to understand what the hell closure is I think
17:12augustlyeah, people seem to like tools that are easy to use the first days and weeks while writing an app
17:12augustlindeed, I'm currently having to make a big effort to figure out how to use closure. Seems like it's worth it, but the docs by Google are kind of meta
17:14akhudeksadly, I think there is probably a need for some sort of easy bootstrap for the clojure stack, even though that sort of "easy" is against the general philosophy of the language
17:14akhudeksome of the noir + lein newnew templates are a good start
17:15akhudekI shouldn't say against the philosophy, rather, not the most important kind of "easy"
17:18augustlI've had enough of tools that optimize for being easy to get started with ;) The "getting started" chunk is quite a lot smaller than the "being a competent user of" chunk.
17:19antares_akhudek: it is not against, it is just not the #1 priority for the core team. I think the community in general is all for making all kinds of things easier on newcomers.
17:23SrPx...
17:26SrPxI'm trying to create a project using leiningen: C-x shell, lein new myproj... the problem its being created on emacs/bin
17:38wingyi feel disabled in clojure world
17:38wingyhow do i run a .clj script?
17:40kovasbwingy: theres a number of tools for that
17:40kovasbwingy: 3rd party stuff on github
17:40wingywow .. sounds hard to do a such simple things .. is it because it has to be compiled etc?
17:40kovasbor you can just write a shell script
17:41kovasbi don't think it needs to be compiled
17:41wingyis there no equivalent to someething as simple as: "node.js ./script.js" ?
17:41kovasbbut it does need to be run through the jvm
17:41wingy"node ./script" i meant
17:41kovasbyes, there are such things
17:41kovasbprobably many , on github
17:42Chousukewingy: the biggest problem with running clojure programs as scripts is the jvm startup time.
17:42kovasbwingy: most stuff tends to be automated through lein
17:42wingykovasb: could lein run a simple script like that?
17:42kovasbwingy: that automates a huge number of things
17:42aperiodicwingy: if you're using lein, then the easiest way is probably `lein run -m my.ns`, if my.ns has a -main fn
17:43kovasbusually i do "lein run"
17:43kovasbfrom inside my project folder
17:43kovasband it runs
17:43augustlI don't think the java platform is commonly used for command line scripts
17:43kovasbwingy: https://github.com/technomancy/leiningen/blob/master/doc/TUTORIAL.md
17:43augustlor CLIs in general
17:44augustlbecause of the slow startup time that was already mentioned
17:44wingyi see .. explains why its so difficult
17:44kovasbhow to run a script is an example in the middle
17:44augustlso since few people do it, that's probably why it's hard to do :)
17:44wingyhmm a big -
17:44wingyscripts are making dev faster
17:44kovasbyeah, its more like "i wanna run my program" rather than "i wanna run my script"
17:44kovasbbut nb there are solutions for jam startup time
17:45augustldoesn't `java -jar path/to/clojure.jar path/to/the-script.clj` work?
17:45augustlit will execute the -main of the-script.clj
17:45augustl(afaik)
17:46kovasbi think you put the namespace instead of a file path
17:46aperiodicwhat about the classpath?
17:46kovasbif you are calling java directly ilke that you need to use the options of java
17:47kovasb(the executable)
17:47wingyok lein run -m app.core worked great .. ill stick to that one for now til im not a noob anymore :)
17:47kovasbsweet!
17:47wingyhate the first month of noobishness .. you are so disabled
17:47kovasbyeah learning about lein is great
17:47kovasbthats what its all about
17:48wingy"For those of you new to the JVM who have never touched Ant or Maven in anger: don't panic. Leiningen is designed with you in mind."
17:49wingyhe read my mind
17:50wingyisnt there a way to make jvm startup time faster for testing things out?
17:50wingyeg. having it up all the time .. then there would be no need for start up?
17:53augustlwingy: there are many ways to reload stuff in a jvm as it runs yeah
17:54wingyaugustl: i mean for running simple .clj scripts .. it takes like 5 secs for jvm to start .. is there a way to have it as fast as node?
17:54aperiodicno
17:54wingyok
17:55aperiodicyou can mitigate things somewhat by AOT-compiling, but jvm startup is always gonna be a second or two for the foreseeable future
17:56augustlwingy: well there are other JVMs out there than HotSpot, perhaps there are some with focus on startup speed
17:56augustlbut now I'm just guessing, for all I know, long startup time is an effect of the bytecode formats or whatever
17:56wingybut why does it start and stop start and stop all the time .. cant it just be started?
17:57wingyif you want a clean state for some reason you could just run a command for it .. but it would always be started .. kinda makes sense
17:58augustltechnically speaking it can, afaik
17:58aperiodicthat is the usual strategy for development. run a repl or swank server, restart it only when you have to, and run tests in a persistent autotest mode so you don't have to wait on jvm startup
18:00wingyyeah i have to find my dev flow for clojure/java
18:01wingyit sure won't be like the one for node
18:01wingyand perhaps it shouldn't
18:01aperiodicdo you use vim/emacs?
18:01wingyno
18:01wingysublime text as a interim editor
18:08anierowingy: vim or emacs gets you in-editor code evaluation with varying levels of hackery involved in making it work
18:08anierorecommend lein-tarsier + vimclojure, if you do vim. emacs, you're on your own
18:09aniero... or most people in here can help with that, i assume :D
18:09wingy:)
18:10anierowingy: have a project you're working on?
18:10wingyyeah
18:11wingyi hope 2 weeks will get me up to speed with clojure
18:11anieroit'll probably take longer than that... heh
18:12wingywhy i hope
18:12anierothink i'm getting the hang of things, though
18:18SrPx2 days trying to learn clojure and I can't even get a hello world because I can't do anything with emacs, clojure repl won't work with sublime, not good with notepad++, don't know eclipse
18:18SrPxsigh : /
18:19hyPiRionTried clojure-box?
18:20hyPiRionhttp://clojure.bighugh.com/
18:20amalloySrPx: just use your favorite editor, and don't bother with editor integration. paste it into a command-line repl
18:21ivaraasenSrPx: had some problems with the repl in Sublime myself. worked once i fixed the keymapping
18:21SrPxhmm
18:22SrPxamalloy: but everything uses leiningen
18:22amalloyyes, and i advocate using leiningen
18:22wingyjust use the command line instead
18:22SrPxivaraasen: you are using sublime?
18:22amalloyfrom the command line
18:22wingySrPx: i am .. but just for editing text
18:22amalloyyou don't need any editor support to use clojure productively
18:22SrPxivaraasen: how did you fix the repl?
18:22ivaraasenSrPx: yeah
18:22ivaraaseni have leiningen installed though
18:23wingywow cool .. lein repl includes clojuredocs examples
18:24wingybut bad that i have to run (doc *ns*) and then (cdoc *ns*(
18:24wingybut bad that i have to run (doc *ns*) and then (cdoc *ns*)
18:24SrPxivaraasen: how did you do it
18:46wingyprogramming is like a game in which you want to escalate to the next level
18:49ivaraasenwingy: i prefer trying to glitch the games
18:51augustlspeaking of games, have anyone ever created games with Clojure? I suppose interfacing with LWJGL from clojure isn't too hard.
18:51antares_augustl: people typically use clojurescript for games
18:52augustlfor browser based games, you mean?
18:52aperiodicaugustl: there are implementations of tetris & asteroids in penumbra's examples folder (https://github.com/ztellman/penumbra/tree/master/test/example/game)
18:52ivaraasenaugustl: i've seen a guy do Minecraft mods in Clojure
18:53aperiodic(this seems to be a really popular question here in the past few days)
18:53augustlivaraasen: ah, interesting, I'll look that up
18:54ivaraasenaugustl: it's named conjcraft if I remember correctly
18:54augustlyeah just found it, that's correct
19:21recurHi, I'm a clojure n00b. I want to repeatedly apply a function a set number of times passing in the output as the input. Is there a simple way to do that (I'm trying not to create loops :) )?
19:24jjidorecur: you want a fold it seems
19:25recuroh cool, looks perfect
19:25recurthanks jjido, didn't know that existed :)
19:28jjidorecur: it is called reduce
19:28jjido,doc reduce
19:28clojurebot#<CompilerException java.lang.RuntimeException: Can't take value of a macro: #'clojure.repl/doc, compiling:(NO_SOURCE_PATH:0)>
19:28recuroh haha, i was looking at the actual clojure 'fold' function
19:28recurwow, clojurebot failed
19:28jjidoI failed
19:29recur,doc fold
19:29clojurebot#<CompilerException java.lang.RuntimeException: Can't take value of a macro: #'clojure.repl/doc, compiling:(NO_SOURCE_PATH:0)>
19:29recurat least it doesn't crash :D
19:29recuran egg drop hitting an exception on the other hand… :P
19:30hyPiRion,(doc reduce)
19:30clojurebot"([f coll] [f val coll]); f should be a function of 2 arguments. If val is not supplied, returns the result of applying f to the first 2 items in coll, then applying f to that result and the 3rd item, etc. If coll contains no items, f must accept no arguments as well, and reduce returns the result of calling f with no arguments. If coll has only 1 item, it is returned and f is not called. If val i...
19:30hyPiRionIt didn't fail, it returned exactly what you would expect it to return.
19:31aperiodic,(take 10 (iterate inc 0))
19:31clojurebot(0 1 2 3 4 ...)
19:31aperiodicrecur: i think iterate is what you want
19:31aperiodic,(doc iterate)
19:31clojurebot"([f x]); Returns a lazy sequence of x, (f x), (f (f x)) etc. f must be free of side-effects"
19:31recurahh, awesome
19:32recur,(rest '(3 4 5))
19:32clojurebot(4 5)
19:32recursweet bot :)
19:32aperiodic~botsnack
19:32clojurebotThanks! Can I have chocolate next time
19:34recur,(clojure.repl/doc first)
19:34clojurebot"([coll]); Returns the first item in the collection. Calls seq on its argument. If coll is nil, returns nil."
19:35recursweet, learned how to use namespaces at the same time. Pretty useful 5 mins :)
19:35recurthanks for the info!
19:36recurhehe, with light table and doc, I now have my own personal dynamic reference page :)
19:58wingylein is the defacto for clojure i guess. no need to look at maven at all?
19:59gfredericksnot unless you're already using it or have some organizational incentive like that
19:59ivaraaseni really need to try Overtone
20:01wingylooks really cool
20:01wingymusic in code
20:03SrPxCan I use java libs on clojurescript? (guess not =S )
20:03wingySrPx: yes
20:03SrPxwingy: o.o
20:03wingyfull java interop
20:03gfredericksno
20:03SrPx...
20:04wingyoh ...
20:04wingyO_o
20:04gfredericksunless maybe you run it on rhino I suppose
20:04gfredericksbut if you're doing that there's no reason to use cljs
20:04wingyoh clojurescript :P
20:04gfredericksthere are easier ways to slow your code down
20:04gfredericksI recommend Thread/sleep
20:05wingy:)
20:06wingyovertone looks neat!
20:06wingyfinally no more software pianos!
20:06SrPxõo
20:06SrPxlol.
20:18kovasbthis 1424 build of cljs is killing me
20:18kovasbanyone know how satisfies? has changed?
20:19ivaraasenwingy: also, OSC integration is quite nice. i've done a few small live sessions using my Android phone to control Renoise.
20:20gfredericksI'm not sure how lein cljsbuild tests are supposed to work
20:21kovasbclojure needs the sponsorship of some internet billionare
20:21kovasbso many lose ends
20:23gfredericksa lot of ends have been tightened so far
20:23kovasbyes, but the surface area is speeding :)
20:23kovasbspreading
20:25kovasbfml. i can't event ind where satisfies? is implemented in the source
20:27kovasbah there we go.
20:42gfrederickswith the cljsbuild browser repl, is there any way to update code without restarting everything involved?
20:45kovasbupdate code?
20:45wingyseems that you really don't need to install clojure at all
20:45gfrederickslike change my source code
20:45gfredericksand have the repl reflect that.
20:45kovasbyou can reload the application without rebooting the repl
20:45wingyyour install jvm then lein .. and it will fire up clojure using "lein repl"
20:45kovasbthe repl state will remember what namespace you are in
20:46kovasbbut the state in the browser will be wiped out
20:46gfredericksso refresh the page and reconnect?
20:46wingycould someone confirm
20:46kovasbthe connect should happen automatically
20:46kovasbwingy: yes
20:47wingykovasb: yay
20:47gfrederickskovasb: mine is manual
20:47kovasboften i just move to the namespace at the repl and paste the new code in
20:47kovasbhmm
20:47gfrederickswhich is how I set it up
20:47gfredericksjust to aggravate myself apparently
20:48kovasbcool YMMV but it works "most" of the time for me
21:08wingywhy do i have to quite 1: (def a ^{:created (System/currentTimeMillis)} 1)
21:08wingythat wont work, this do: (def a ^{:created (System/currentTimeMillis)} '1)
21:08wingyi dont get why
21:09wingysince (def a 1) without quoting works
21:10gfredericksoh you can't put metadata on numbers
21:10gfredericksit works the second way but not really
21:10gfredericksit just doesn't crash
21:11gfrederickswhen you add the quote you're essentially writing (quote 1)
21:11Iceland_jackgfredericks: Doesn't it apply the metadata to the quote?
21:11Iceland_jackRight
21:11gfredericksso the metadata gets added to that list
21:11gfrederickswhich gets lost at compile time
21:11gfredericksso there's no effect
21:11gfredericksyou can put the metadata on the var though
21:12arohner_wingy: metadata can only be added to clojure objects (vars, symbols, datastructures)
21:12wingyi thought that was what i did
21:12arohner_java ints and strings are final, so clojure can't extend them
21:12gfrederickswingy: move it to before the a
21:12wingythis works: (def a ^{:created (System/currentTimeMillis)}
21:12wingy[1 2 3])
21:12wingyah .. i think i get it
21:12gfrederickswingy: yeah vectors can have metadata
21:13wingyright
21:13gfredericks,(with-meta {:foo 2} #{1 2 3})
21:13clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.PersistentHashSet cannot be cast to clojure.lang.IPersistentMap>
21:13gfredericks,(with-meta #{1 2 3} {:foo 2})
21:13clojurebot#{1 2 3}
21:16wingyis ^ a sugar syntax for with-meta?
21:16gfredericksnot quite
21:16gfredericks^ is read-time metadata attached to the code itself
21:16gfrederickswhereas with-meta is a runtime function call
21:17wingybut in the end the meta data that is created is no different?
21:17wingyjust different ways to create it?
21:18gfrederickswell you have to be careful with the difference. In a lot of cases read-time metadata only has any effect if a macro or an element of the compiler is expecting it
21:18gfredericksif not it may not make it through to runtime
21:19gfredericksI could say (if foo ^{:haha true} bar baz) in my code
21:19gfredericksand the metadata would be meaningless
21:19wingyi see
21:20gfredericksbecause the compiler isn't expecting metadata there
21:21gfredericks,(meta (with-meta {} {:my :meta}))
21:21clojurebot{:my :meta}
21:21gfredericks,(let [x {}] (meta ^{:my :Meta} x))
21:21clojurebotnil
21:22gfredericks^ that's the difference I'm talking about
21:22gfredericks,(meta ^{:my :Meta} {})
21:22clojurebot{:my :Meta}
21:22gfredericks^ however that also
21:25wingydidnt know the last one worked
21:25gfredericksit's because the map {} compiles to itself
21:25gfredericksso it carries the metadata with it to runtime
21:25wingyso ^ isnt counted as a arg
21:25gfrederickscorrect
21:26gfredericksthe reader immediately places the metadata on the map it creates
21:26gfredericksthe compiler sees a list of two elements
21:26gfredericksa symbol meta and an empty map
21:26gfredericksit resolves the symbol meta to clojure.core/meta, and compiles to code that will call that var with the map as its argument
21:26wingyi see
21:27gfredericksit's the same map that the reader attached the metadata to, so it's still there
21:27gfredericksbut in the middle case the reader attached the metadata to the symbol x
21:27wingygood thing to do is to know how clojure works exactly under the hood
21:27gfrederickswhich is not what the clojure.core/meta function is receiving as its argument
21:27wingyright
21:28gfredericksit took me a while to get the readtime/runtime distinction
21:28wingyi understood parse time and run time pretty quick in js .. have to get the clojure internals more in details
21:29gfredericksmacros are a lot easier once you understand read vs compile vs run
21:29wingyrun is eval?
21:29gfredericksno I just meant runtime
21:30wingyok so 3 phases
21:30gfredericksyeah, at least abstractly
21:30gfredericksI'm not actually familiar with the internals too muchu
21:31wingyread time: source code to code structure, compile time: code structure to byte code, run time: run byte code
21:31wingyis that correct?
21:31gfredericksyep
21:31gfredericksmacros run at compile time
21:32wingyyeah they manipulate the data structure at compile time
21:32gfredericksexactly
21:34wingyso the reader is for the first part, the compiler for the next .. is there a "runner" or is the compiler running it once it has the byte code?
21:34gfredericksI think that's just the jvm running it
21:34wingyok
21:35wingysomeone here said that parse-string is the reader
21:35gfredericksread-string?
21:35clojurebotread-string |is| as unsafe as eval unless *read-eval* is bound to false.
21:35wingyyeah
21:35gfredericksyeah that's basically it
21:35wingyand if you pass the returned data structure to eval it will be compiled and run
21:35gfredericksyep
21:36gfredericksread-string is good for figuring out what the reader macros do
21:36wingyso one can say from a higher perspective that eval is compiler/runner ?
21:36gfredericksI think it wraps the expr in a function, compiles that, and calls the function
21:36gfredericksso sorta
21:36wingyok
21:37mindbenderhow do I install a plugin in lein2?
21:40wingygfredericks: for how long have you been using cljure?
21:40gfredericksthree or four years or something
21:40wingywow
21:40wingyyou must be very productive in it
21:41gfredericksit just makes me grumpy about other languages
21:41wingyyeah
21:41wingyit already has that affect on me
22:45wingyisnt there a good way to browse https://clojars.org/
22:54mindbenderdoes the :extra-classpath-dirs option still work with lein2 cos I just got an error when trying to swank into a project that uses that option to specify the file the jvm was complaining of not finding?
22:55mindbendertechnomancy: ^^
22:55technomancymindbender: it was removed in 2.x; try :resource-paths
23:18frozenlo`I'm using org-mode to write a text. In it I link to some images (with [[./folder/img.jpg]]). I want to use the exported as an input for Noir. So I do this `(slurp "my-html.html") and it works perfectly... except for the images. The "." appears in the images path, messing evertyhing up. Any workaround?
23:30mindbendertechnomancy: :resouce-paths got me up to having swank server started. I'm using :plugin [lein-swank "1.4.0"] then I get similar issue to https://github.com/technomancy/swank-clojure/issues/92. I on cygwin emacs 23.4.1
23:32technomancyhm; I don't know what causes that
23:32mindbendereven slime-connect says connected but doesn't create slime-repl buffer
23:35mindbendercould it be a plugin conflict?
23:35technomancyunlikely; it's probably on the elisp side
23:38frozenlo`Solved my problem. If anyone is interested, here is a little function to export org document to an html usable by Noir. https://gist.github.com/3026701
23:54michaelr525good morning
23:58wingygood morning