#clojure logs

2016-05-09

00:13apricityanyone have advise for cider-jack-in taking like a minute to start up, I don't get errors and it finally brings up a lein repl but takes foreeever and I'm on a fast machine running arch linux. running lein repl only takes like 3 seconds.
00:35tolstoyapricity: I don't know, but you can try "lein repl :headless" and then cider-connect.
00:59dysfunhrm, there's a repl option i had to use for boot to make it start up faster, maybe there's something similar for lein
01:36justin_smithapricity: does your "lein repl" load up your main ns, or start up in the user ns?
02:02apricityjustin_smith: it starts in the user namespace
02:03apricityjustin_smith: but, when i use cider, it's just a test project created with lein new testing, I haven't edited anything in the project
02:07apricityshould I be using boot instead of lein? I'm just starting to learn clojure
02:08dysfunno. boot is the thing you should use when you're being clever and lein no longer solves your problem
02:08dysfunit's a fantastic tool, but it still confuses the hell out of me sometimes
02:10tolstoyDo you ever worry that a turing complete build system will lead to spaghetti on non-personal projects?
02:10dysfunnot really. you're still working with high level primitives and there just isn't that much that you might actually want to do in a build for the jvm
02:11dysfunplus i don't hack proprietary code any more, which helps
02:28tolstoyYeah. I've just seem some interesting projects (10+ years) with Ant extensions designed to introduce scripting, etc, etc, to the point where no one remaining understands the build anymore.
02:29dysfuna previous client used ant for deploying their php, and it was a total clusterfuck
02:29dysfunbut my answer there is what the hell were you thinking using ant for that?
02:29tolstoyI kinda liked Ant + check your jars into CVS, back in the day.
02:30dysfunthere is nothing about CVS I can say that is nice
02:30dysfunand i'm not terribly fond of ant to start with
02:31dysfunmuch as i get annoyed with git from time to time, i think back to using svn and cvs and suddenly it doesn't seem so bd
02:33dysfunwe're pretty spoiled today. i complain when i have to check out a mercurial or a darcs repo
02:37tolstoyAt that time, Ant and CVS were all there was, I think, and I don't miss that, but I do like the basic simplicity.
02:37tolstoyBut that might have just been my mind set.
02:37tolstoyBuild system for building the app.
02:38tolstoySome other project then knows what to do with the artifact.
02:38tolstoyA build system that does everything scares me a little. Too tempting under pressure to just add more "query this thing, get keys, deploy to that server, log a receipt over there," etc, etc. ;)
02:39tolstoyI like my complexity distributed around a bunch of simple projects, each one of which is isolated at the source level.
02:44dysfunmost of my stuff is deployed to clojars
04:31RovanionA function has [{:as ev-msg :keys [event uid ?data]}] as its arguments list. Can someone link a doc which explains what that actually means?
04:32opqdonuthttp://clojure.org/reference/special_forms#binding-forms
04:32opqdonutor actually, http://clojure.org/reference/special_forms#_map_binding_destructuring
04:35RovanionThank you opqdonut!
04:48hellofunki'm curious about core.async channels that are accessed from multiple threads. if i think of a channel as a queue, and values can be placed on this queue from any other channel/thread, then are these channels explicitly implemented with locking to avoid race conditions? are they not shared memory?
04:49dysfunthey're safe. don't worry too much about how they're implemented
04:49hellofunkdysfun: i'm not worried, i know they are awesome. but i'm studying multithreading in another language and it made me think of core.async and howt hey might be implemented.
04:50dysfunyes, it uses locks under the hood
04:50dysfuni saw a great presentation on youtube about it
04:50hellofunkdysfun: do you recall which one?
04:50dysfunnot in the slightest, sorry
04:50clojurebotTitim gan éirí ort.
04:50hellofunkclojurebot: perhaps you know which video?
04:50clojurebotNo entiendo
04:50hellofunkclojurebot: only speak spanish?
04:50clojurebotExcuse me?
04:51dysfunclojurebot picks a random "i don't understand" phrase from a list
04:51hellofunki know, just having fun
04:52dysfunhrm, it may have been this one
04:53dysfunhttps://www.youtube.com/watch?v=1bNOO3xxMc0
04:53dysfunif not, it's a good talk for your interests anyway
04:59hellofunkthanks
05:04dysfunyw
08:54shiranaihitoplease check this out: https://www.kickstarter.com/projects/141490519/support-a-100-people-funded-online-news-outlet-pha .. would you like to have a news media that actually does what it's supposed to?
10:29sdegutisIs it possible for a compile-time parsing of (format) strings using a Clojure macro similar to how Rust does this?
10:29sdegutisThanks, eh.
10:58djcoinHi all, i'm not very good with the JVM ecosystem, excuse me for asking a trivial question! I would like to install apache commons in .m2 so that leiningen can use it straight away, how can I do that?
10:59amoedjcoin: leiningen will automatically pull Maven dependencies from the central repository, so if you just specify the commons dependency in project.clj, lein will retrieve it when it builds your project
11:00amoedjcoin: like [commons-validator/commons-validator "1.5.0"]
11:02dysfunlein will automatically put things into ~/.m2/repository when it fetches them
11:03djcoindysfun: amoe ok thanks!
11:11RovanionCan I lein run any argumentless function in my code?
11:13RovanionI'm trying to run a function which can be found in src/clj/proj/file.clj, but lein complains that file.clj is not in the classpath. Meanwhile the same file is found when compiling normally.
11:19gandhiIf I'm running Datomic with a transactor does that mean my Clojure app will need 2 JVM instances?
11:24mavbozo_Rovanion, how do you run with leiningen? like this lein run -m proj.file.your-function ?
11:25mavbozo_Rovanion, "lein run -m proj.file/your-function" ?
11:25Rovanionmavbozo_: No, I was doing lein run -m database/migrate instead of lein run -m proj.database/migrate. Thank you!
11:26mavbozo_gandhi, yup! 1 for your clojure app and 1 for your datomic transoctor
11:27djcoindysfun: amoe , if I may bother you some more! from the repl I can do: (import org.apache.commons.compress.compressors.xz.XZCompressorInputStream)
11:28dysfunwith a quote in front of it, sure you can
11:28djcoinbut it will fail, when I try to run "lein node-webkit-build" ; clojure.lang.Compiler$CompilerException: java.lang.ClassNotFoundException: org.apache.commons.compress.compressors.xz.XZCompressorInputStream, compiling:(me/raynes/fs/compression.clj:1:1)
11:29djcoina quote does not seem to be necessary, but from the repl, it just works, I can use reflect on the class etc. seems correctly loaded
11:29dysfunokay
11:29dysfunwhat code is triggering that error? is it yours or in the plugin?
11:31djcoindysfun: i'm just running the lein node-webkit-build with a basic template. It somes to blow up in the mentionned library raynes/fs/compression.clj
11:31djcoineven though I have specified this lib in my dependencies and specified also the commons-compress that it is using (and then did "lein deps")
11:31dysfunand you've definitely got commons-compress in your deps?
11:31djcointo be sure to have the correct dependencies
11:32djcoinwell, as I said, if i do lein repl I can import it
11:32djcoinnot sure where to look
11:32dysfunyeah, sorry, i'm still half asleep
11:32djcoinno worries, if anyone has a clue... thanks
11:33dysfuni can only suggest looking at the node-webkit-build lein plugin github to see if anyone else has encountered it
11:34dysfunbut it sounds like one of these tedious build things that should be impossible but happen anyway and take ages to debug
11:36djcoinok thnks dysfun
11:36djcointhanks
11:36djcoin*
11:41amoedjcoin: can you paste the full output?
11:42djcoinamoe: THanks! Sure, here you go: http://paste.ofcode.org/75zZZq8FmXe9RdfZ9K8xqB
11:42amoedjcoin: what about if you remove the explicit commons-compress dependency -- same behaviour?
11:43amoedjcoin: also can you paste project.clj?
11:43djcoinamoe: yes :|
11:44djcoinamoe:
11:44djcoinhttp://paste.ofcode.org/X9mz6Uxfb7wKar3RyqbaR9
11:47djcoinamoe: I'm using a leiningen from nixos a not so common linux distro, maybe that's why. I would have to tweak some things so that leiningen uses the .m2 at start up. I don't know
11:49dysfunyou should really install the latest lein
11:49justin_smithyeah, it works best if you just put it in ~/bin
11:49dysfundistributions have been known to package quite elderly versions
11:51djcoinyep... here is the result of lein classpath, commons-compress is not here, would that be the reason? http://paste.ofcode.org/9GYCqbUKrbTjpnj56WQDPF
11:51djcoin(i'm using lein 2.6.1)
11:52dysfunoh. that's actually reasonably recent
11:52dysfunactually that's what i'm running
11:52dysfunwow. and that's a distribution package?
11:53djcoindysfun: yeah, but Nix (and nixos) seems pretty fast on this
11:53justin_smithdjcoin: the classpath is not determined by the contents of your .m2, it's determined by your project.clj
11:53dysfunyeah, i've noticed that freebsd is very quick with jvm updates
11:54justin_smithdjcoin: it just caches things in .m2
11:54dysfunand they also ship lein 2.6.1 heh
11:54djcoinjustin_smith: when I use a plugin (here the node-webkit-build - https://github.com/wilkerlucio/lein-node-webkit-build ), what librairies are accessible to my leiningen?
11:55amoedjcoin: the problem goes away if I remove the lein-cljsbuild plugin
11:55dysfundjcoin: whatever is in your dependencies in the project.clj
11:55djcoinThose librairies seems to be in .m2
11:55justin_smithdjcoin: lein starts two jvms
11:55justin_smithdjcoin: the jvm that runs plugins does not see your project deps
11:55justin_smithand the jvm that runs your project does not see lein/plugin deps
11:56justin_smiththat's a generalization, there are ways to make things accessible to plugins, but it isn't always intuitive
11:57justin_smithdjcoin: whether they are in m2 is just a caching question, what matters is what ends up in classpath during the apropriate java task
11:58djcoinjustin_smith: yes, I suppose, anyway to see this classpath?
11:58justin_smithdjcoin: it will show up in the command line args via ps x
11:58djcoinamoe: when I remove the plugin from project.clj, I can't use the lein task
11:59justin_smithif the task lasts long enough to capture that
11:59amoedjcoin: really? It seems to work for me, or at least it gets further before breaking
11:59ridcullywhat about `lein deps :plugin-tree` ?
11:59justin_smithridcully: ahh! that's the one -- djcoin ^
12:00amoethen I get to see log messages, "Reading node-webkit available versions" and then it chokes because I don't have 'package.json'
12:01djcoinhttp://paste.ofcode.org/dVkMgGZAJgMnDemhnuRYD3
12:02djcoinhttp://paste.ofcode.org/CbSi8GG9bHbhCfFaMJbYVN <= updated it , there are confusing dependencies found
12:02djcoinincluding some related to fs
12:03dysfunhrm, i seem to be perpetrating macro evil
12:03amoeI think you want to add commons-compress to the exclusion list for lein-cljsbuild
12:03djcoinThanks ridcully
12:04dysfuni have a bunch of functions of the form [state val] -> [newstate converted-val]
12:05dysfunit's getting to be an awfully repetitive pattern in my code and i just know there's some obvious way of factoring it out that hasn't occurred to me
12:05djcoinamoe: YES that's it !
12:05justin_smithsounds like a job for a monad
12:05djcoinNow I only have an error for the missing package.json
12:05djcoin:)
12:05clojurebotPardon?
12:05dysfunright, but monads suck in clojure, so how about something more practical?
12:05TimMcsounds like a job for Eclipse code templates!
12:05TimMcoh wait this isn't Java
12:06dysfuni think plumbing can do it if i turn the vecs into maps
12:06dysfunany other libraries that spring to mind?
12:06justin_smithdysfun: I bet there's a trick with fluokitten or cats
12:07dysfunwhen i said 'monads suck in clojure', i was specifically talking about my experience with cats
12:07justin_smith:)
12:07dysfun(to which i have contributed code, therefore i feel justified in slating it)
12:09amoedjcoin: actually probably just exclude fs
12:53idevis there any cljs gui library where: (1) all your gui state is in datomic/cljs, (2) view is just datomic->dom via react, and (3) all changes to ui is done via datomic queries
12:55idevhttp://tonsky.me/talks/ is a genius
12:58dysfuni think om.next is supposed to cover off a certain amount of that
12:59idevhttps://dl.dropboxusercontent.com/u/561580/conferences/2014.12%20clojure%20eXchange.pdf is brilliant
13:24justin_smithyeah, om.next is that plus "parsers" to handle the datomic results
13:50beakyom.next apparently has a query lang on steroids?
14:13idevin datomic, aRe the only valid ops (add e a v) and (remove e a v)
14:13idevso we can't remove an item unless swe know the e,a,v of the item we want to remove ?
14:20dysfunyou can't remove it unless you know the e and a of it
14:48jsselmanIs emacs+cider the most powerful development environment currently for clojure? Anyone know if any of other solutions (vim-fireplace, lighttable, cursive) are approximately as powerful?
14:49dysfuni think cider is still the most powerful, but some people prefer an IDE like experience
14:49jsselmanSetting up emacs+cider from scratch has been pretty painful for me, but I'm willing to endure it if the tooling is worth it
14:49dysfunhah, i have one of my friends learning emacs (with evil-mode) because he was unimpressed with vim-fireplace
14:52jsselmanHmm, I haven't tried evil-mode
14:52jsselmanI feel it would probably be frustrating though; like how vim-mode in IntelliJ mostly works until it doesn't
14:53dysfunwell the joy of emacs is that you really can just fix it
14:53dysfunbut it depends on your tolerance for frustration :)
14:53mavbozojsselman, what editor you use daily?
14:53jsselmanTrue but it's overwhelming for someone new to the entire ecosystem
14:53jsselmanI used IntelliJ for years, but lately have been using vim daily
14:53mavbozoi use emacs regularly, so I use cider
14:54jsselmanfor development that is, basically switched from java -> ruby development
14:54jsselmandoing clojure for personal stuff
14:57amalloyjsselman: i've heard good things about evil from at least a couple vim->emacs guys
15:03finishingmoveI am just starting out, but I decided to go with Cursive, because I generally find Jetbrains IDEs to be best in class
15:04finishingmovewith that said, I am considering NeoVim (have used Vim a bit in the past, but making it do all the things I want from an IDE makes it too slow)
15:07finishingmoveI know emacs is popular with FP languages, especially lisps, but it's like a world of its own which makes me question is it all worth it really
15:33dysfunwell it really depends on what you want
15:33dysfunthe cider environment is pretty much as powerful as it gets
15:34dysfunbut mostly i use it because my hands are hardwired to emacs and i value the productivity
16:56patham9_https://gist.github.com/patham9/789a459c1ba1113de7864dc0f337dbdc
16:56patham9_why would this shuffle-random always return the same shuffle?
16:56patham9_altough its incrementing this value
16:58justin_smithpatham9_: defn has an implicit do, you don't need to use it explcitly like that
16:58patham9_ah I see
16:58justin_smith(not your question, but just FYI)
16:58patham9_thank you :)
16:59justin_smithpatham9_: also, you should use commute instead of a deref / ref-set combo
16:59justin_smiththat removes the need for the extra deref at the end of the block too
17:00justin_smith,(def r (ref 0))
17:00clojurebot#'sandbox/r
17:00justin_smith,(dosync (commute r inc))
17:00clojurebot1
17:00justin_smith,(dosync (commute r inc))
17:00clojurebot2
17:01patham9_ithe incrementation seems to work yes. interestingly i still get the same shuffles altough its incremented
17:01justin_smithright, just saying commute does it more simply
17:01patham9_thanks a lot, changed to commute now
17:02justin_smithpatham9_: I thought I'd be able to help more but I have a meeting, I'll check in later if someone else doesn't sort it out
17:02patham9_thanks a lot :)
17:11amalloypatham9_: implementation looks fine. can you demonstrate a usage of it that defies your expectations?
17:12patham9_(shuffle-random '[1 2] ) => [1 2]
17:12patham9_no matter how often its called
17:12patham9_altough use-counter gets incremented in each usage
17:13patham9_its a bit frustrating to not have seed in Clojures shuffle, making it nearly a no-go for most scenarios where testcases etc. are involved.
17:13patham9_and this java-version for some reason has trouble accepting the seed
17:16patham9_also with manual setting seed it doesnt work so the reference part at least seems not to be the issue
17:16amalloysmall numbers are just bad seeds for j.u.Random
17:16amalloyyou are using very little of the randomness in it, just a single coinflip
17:17amalloyignore the whole reference part, and try just constructing some Random objects with seeds manually, and shuffling using them
17:17amalloywith a small seed and a two-element collection, you seem to always get no change
17:18patham9_ah I see, so collection seems to be too small
17:18patham9_maybe I should use seed*10 mod 1000 or something?
17:18amalloythose seeds are all way too small
17:18amalloythe range of an int goes up to 2 billion
17:19TEttingerjava.util.Random is a... pretty flawed RNG. it's a linear congruential generator, so it is in theory the fastest kind, but only 42 bits of randomness are possible IIRC
17:19TEttingermight be 48
17:19amalloy48 apparently
17:19TEttingerso nextLong won't produce all longs
17:19amalloythe good news is, to shuffle a 2-element array, you don't need a lot of entropy
17:19TEttingertrue
17:20patham9_ah i see :)
17:20ridcully,(frequencies (take 10000 (repeatedly #(shuffle [1 2]))))
17:20TEttingerjava 8's SplittableRandom class is nice
17:20clojurebot{[2 1] 5036, [1 2] 4964}
17:20patham9_with (* seed 10000) it seems to work now :)
17:22TEttingermight want unchecked-multiply instead of *, since I think * will eventually overflow and throw an exception
17:22TEttinger,(reduce * (range 10 1000))
17:22clojurebot#error {\n :cause "integer overflow"\n :via\n [{:type java.lang.ArithmeticException\n :message "integer overflow"\n :at [clojure.lang.Numbers throwIntOverflow "Numbers.java" 1501]}]\n :trace\n [[clojure.lang.Numbers throwIntOverflow "Numbers.java" 1501]\n [clojure.lang.Numbers multiply "Numbers.java" 1867]\n [clojure.lang.Numbers$LongOps multiply "Numbers.java" 467]\n [clojure.lang.Numbers ...
17:23TEttinger,(reduce unchecked-multiply (range 10 1000)) ; might need these to be longs
17:23clojurebot#error {\n :cause "integer overflow"\n :via\n [{:type java.lang.ArithmeticException\n :message "integer overflow"\n :at [clojure.lang.Numbers throwIntOverflow "Numbers.java" 1501]}]\n :trace\n [[clojure.lang.Numbers throwIntOverflow "Numbers.java" 1501]\n [clojure.lang.Numbers multiply "Numbers.java" 1867]\n [clojure.lang.Numbers$LongOps multiply "Numbers.java" 467]\n [clojure.lang.Numbers ...
17:23TEttinger,(reduce (comp unchecked-multiply long) (range 10 1000)) ; might need these to be longs
17:23clojurebot#error {\n :cause "Wrong number of args (2) passed to: core/long"\n :via\n [{:type clojure.lang.ArityException\n :message "Wrong number of args (2) passed to: core/long"\n :at [clojure.lang.AFn throwArity "AFn.java" 429]}]\n :trace\n [[clojure.lang.AFn throwArity "AFn.java" 429]\n [clojure.lang.AFn invoke "AFn.java" 36]\n [clojure.core$comp$fn__4727 invoke "core.clj" 2461]\n [clojure.lang.L...
17:23TEttingergah
17:27amoewhat's the most natural representation for byte streams in clojure?
17:51TimMcamoe: An InputStream or OutputStream, I suppose, but I've never really worked directly with bytes in Clojure.
17:51TimMcIf it doesn't need to be particularly performant, you can pass Bytes around in seqs or queues or whatever.
17:53TimMcAnything better than that is likely implemented as a Java lib, not Clojure-specific.
18:03patham9_(set/union (for [x (range 10)] 1)) => (1 1 1 1 1 1 1 1 1 1)
18:03patham9_wat ^^
18:04patham9_,(set/union (for [x (range 10)] 1))
18:04clojurebot#error {\n :cause "No such namespace: set"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: No such namespace: set, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6688]}\n {:type java.lang.RuntimeException\n :message "No such namespace: set"\n :at [clojure.lang.Util runtimeException "Util.java" 221]}]\n ...
18:04patham9_,(require '[clojure.set :as set])
18:04clojurebotnil
18:04patham9_,(set/union (for [x (range 10)] 1))
18:04clojurebot(1 1 1 1 1 ...)
18:04amalloydon't call set functions on things that aren't sets
18:04amalloyalso, set/union wants N arguments, not one
18:05patham9_how can i unfold these entries as a sort of arguments?
18:05amalloyapply
18:05amalloyand then you'll get the quite-reasonable arror that 1 is not a set
18:05patham9_makes sense :)
18:05patham9_,(apply set/union (for [x (range 10)] #{1}))
18:05clojurebot#{1}
18:05patham9_nice :)
18:06patham9_thanks a lot
19:33TEttingerinteresting stuff here, not sure how many of y'all web-dev-elopers are going to be scrambling to update: https://imagetragick.com/
22:25TimMcamalloy: Do you have something in useful that does max-n of a sequence?
22:26amalloyi don't think so
22:26amalloyit'd be in useful.seq if so
22:26TimMcThanks, I checked that one.
22:27justin_smithTimMc: if you google "max n ruby" you get a bunch of reference implementations
22:27justin_smiththat's not true, you get a bunch of kids videos
22:28TimMchaha
22:56namragreetings. i'm kinda confused. do i still need ring-core and ring-jetty-adapter as dependency when using the lein-ring plugin?
22:56namraor are they pulled through lein-ring?
22:56justin_smithnamra: you only need ring-jetty-adaptor if you plan on running jetty standalone in production (I'd consider using aleph or deploying to a container isntead)
22:57justin_smithlein-ring helps abstract between a dev time embedded server and whatever server you want (embedded or as a host/container) in production
22:58namrabecause lein-ring provides 'lein ring uberjar'
22:58justin_smithand lein ring uberwar
22:58justin_smithand lein ring server
22:59namrayes so what server will it use for uberjar? jetty?
22:59justin_smithI usually choose aleph
23:27TimMcaleph confuses and terrifies me
23:29TEttingerI'm having doubts here... I'm not sure if clojure will be the best choice for this project I'm starting.
23:30TEttingerI already know I'll be doing a small amount of inheritance or at least implementation of java interfaces, that shouldn't be a huge problem. I'm concerned about code verbosity on array-based things possibly being worse than with Java once type hints are factored in
23:31TEttingerlots of 2d and some 3d arrays
23:32TEttingerI looked at Kotlin for a middle ground but it currently doesn't handle non-1d arrays super well
23:33TEttingerwould it be possible to get macros in place that would simplify array handling code and if possible insert type hints?
23:34namraTEttinger: aren't macros for such purposes? to build the language you need?
23:35TEttingeryeah, I'm just not sure what the technical limitations are here. I know I can't use macros like fns as arguments
23:36TEttingeralso type hints are metadata, or are like it, so I don't know if that gets preserved with macros
23:37TEttingerI know array code performance drops like a rock without it
23:38justin_smithTEttinger: there's options like hiphip and core.matrix if you haven't checked them out
23:38TEttingerI've used hiphip
23:38TEttingerlong time ago
23:38justin_smithTEttinger: there's also the possibility of doing the shit that needs array performance in java, and the glue in clojure - best of both worlds
23:38TEttingermy stuff is an odd case and is unlikely to fit core.matrix
23:38TEttingeryeah, I am planning on as much of that as possible
23:41TEttingerI have about... 25-30K? lines of Java I've written in a lib that handles lots of game-related stuff that would be slow in clojure, I'm starting to have concerns about code using that lib that needs to do array handling. it won't be critical I hope in this section
23:41TEttingerother people have written more, total is about 41K Java SLoC but I won't use all of it
23:42TEttingerit might make sense to just make a small glue lib?
23:43TEttingerI wonder how hard it is to have java code take Clojure IFn values