#clojure logs

2015-12-16

00:00rhg135I finally got around to writing that irc defibrilator for lazybot
00:01rhg135https://www.refheap.com/112745 too bad the documentation, lack thereof, is bad.
00:08amalloyspeaking of which, i wrote a lazybot restart script
00:08amalloywhich works great when i run it by hand
00:08amalloybut when cron runs it, it just kills lazybot
00:14rhg135in theory it should whois 'lazybot' dvdry hour and restart it. additionally it should launch it at start
00:14rhg135I started in bash, but quoting is a mindf***
00:16princesojustin_smith: thanks. the problem is at compile time. i just want to know how the repl resolves the dependencies
00:19princesothen how to make all namespaces available in calls like (schema.core/validate ...) without the need of (require)
04:07owlbird,(update-in {:name "alice"} () #(str "%" % "%"))
04:07clojurebot{:name "alice", nil "%%"}
04:08owlbirdif the second parameter is empty, a new item with nil as key will be append to the result
04:08owlbirdwhy the 'update-in' was designed like this
04:34ghost_Hello, beautiful Clojuristas
05:29justin_smithprinceso is gone, but the repl makes those things available via require :P
05:31justin_smithowlbird: the alternative would be to throw an error
05:46TEttingerI wonder when justin_smith sleeps... there seems to be a helpful presence in #clojure, like that helpful kami in japanese folklore that cleans houses when you aren't looking
05:47justin_smithhaha
05:47MJB47its a bot
05:47justin_smith"when I sleep" is not often enough
05:54ghost_justin_smith is a rnn
05:55TEttingerradical neural network
05:56ghost_anyway, does someone of you guys know how to open my text app on windows?
05:56ghost_in cmd or somethin
05:56TEttingeris it made in clojure?
05:56TEttingeryou can make a runnable jar with lein uberjar
05:57justin_smithTEttinger: he wants it to launch inside a console
05:57TEttingeroh: java -jar mything.jar
05:57justin_smithTEttinger: but that won't launch inside a terminal when double clicked
05:57ghost_yes, it will "load" and then do nothing
05:57TEttingerjavaw is what is used when double-clicking and it suppresses the terminal by default
05:57Bronsa`justin_smith: doesn't sleep, he just naps between netsplits
05:58justin_smithheh
05:58poweredweren't runnable jars double-clickable in windows?
05:58ghost_TEttinger: so how to open it on windows? on linux, it works just fine
05:58TEttingerthey are, they just don't have a console, powered
05:58poweredah yes
06:00TEttingerghost_: one way that I can think of is to create a cmd window that runs the command 'java -jar whatever.jar'
06:00TEttingerand that is usually a bat file
06:00ghost_eww, that's awful
06:00ghost_thank you bill_gates
06:01TEttingerwell yes but the alternative is to create a cmd window and run your app again inside your existing clojure jar, adding on java startup twice
06:01TEttinger(which would work when double-clicking the jar)
06:02TEttingerthere's the different jar to exe things that are more comfortable for many end-users
06:02ghost_run my jar within a jar? in cmd?
06:02TEttingerand those can have a cmd window specified
06:02TEttingerI could explain that I just don't think it's the best approach tbh
06:03TEttinger(the -main method would dispatch differently based on when called with no args for the double click vs. some special arg that it gives when it calls its own jar)
06:03ghost_pff, I'll check clojueclr then
06:04TEttingernot ideal either since none of the libs you use will work
06:04TEttingerwell, none of the java libs
06:05TEttingermy personal recommendation is probably the launch4j or similar jar2exe program
06:05ghost_ /reads a blogpost about dotnet being awful
06:05ghost_uhm, I'll stay with java
06:05ghost_I'll check 'em, thanks
06:05ghost_and I use none of the libs :^)
06:07TEttingeryep, http://launch4j.sourceforge.net/index.html Supports GUI and console apps.
06:08ghost_soo, it creates an .exe?
06:09Glenjaminthere's also that capsule thing?
06:09schmirghost_: yes, .exe
06:09ghost_schmir: that rocks
06:10ghost_and it's the best IRC ever
06:10schmirghost_: and shell scripts on unix
06:10ghost_schmir: like these written in bash?
06:10owlbirdwrite a bat file for windows, and exec java -jar
06:11ghost_damn that's good
06:13TEttingerGlenjamin: I'll take a look
06:15TEttingerGlenjamin: interesting, but doesn't seem to solve this problem. good to know about though
06:22ghost_by the way, what is the difference between jars in uberjar and uberjar+uberjar dirs?
07:24justin_smithghost_: what is an uberjar+ubarjar dir?
07:28ghost_justin_smith: classes dir, stale dir, snapshot.jar
07:29justin_smithso you are asking about all the things in target/ ?
07:31ghost_yeah, basically
07:31justin_smiththe class files are created as part of producing the jar, and the jar is produced as part of creating the uberjar
07:32ghost_justin_smith: oh, okay
07:33ghost_and I *have* to have jre on my machine? I can't produce a "standalone" executable?
07:33justin_smithghost_: clojure generates jvm bytecode, it doesn't produce a regular executable
07:34justin_smiththe closest you can get is a special executable that contains its own jvms
07:34justin_smithand then it has to have a jvm inside for every OS that can run it
07:34justin_smithit's easier to just expect each user to have a jvm
07:36ghost_o-kay, thanks
07:46jweissin core.async/alts! if one of my operations puts nil on channel it seems to not be selected, which is nice, but i don't see that documented anywhere. is that intended behavior?
07:46justin_smithjweiss: doesn't putting nil on a channel close it?
07:47jweissjustin_smith: the docs for >! says "nil is not allowed", i don't know what that means exactly
07:47jweissit doesn't say what happens if you do it. undefined behavior?
07:48jweissif i try to take from that channel with <!! it just blocks, i think if it's closed it returns nil, doesn't it?
07:50justin_smithjweiss: so it looks like returning nil from a go block closes that go blocks channel, but you cannot generally close a channel by putting nil on it
07:51justin_smiththat was the source of my confusion
07:51jweiss(let [c (async/chan 1)] (async/go (async/>! c nil)) (async/<!! c))
07:51jweissthat blocks, so it acts as if putting nil is a no-op
07:51justin_smithjweiss: I was talking about (<!! (go nil))
07:51justin_smithwhich returns nil
07:52jweissok, my question is whether it's safe for code to sometimes put nil on a channel
07:52justin_smithbut nil from a go block does not generalize to putting nil on a channel
07:52justin_smithI'm not sure
07:55ghost_hey, justin_smith: what do people use clojure for? I've only heard of "web stuff", I haven't seen any killer web app yet though
07:55jweissjustin_smith: in this case i don't care about the result of the go block
07:55justin_smithjweiss: yeah, I only brought up go block values because that's the one case where putting nil on a channel simply closes it
07:56poweredhow about you put :nil on it and check for that?
07:56jweisswell,i guess i'll just proceed as if this is legal and see what happens :)
07:56justin_smithbut it's not a direct put, it's an incidental put done by go, which I guess behaves differently than an explcit one
07:56justin_smithpowered: ::done is a good convention for that
07:57justin_smithghost_: I use it to make a SaaS webapp with a distributed computation backend
07:57powered:: takes the current namespace?
07:57justin_smithghost_: I don't know about "killer" but it allows a small team to get a lot done quickly and not code ourselves into a corner
07:58jweisspowered: yes
07:58justin_smithpowered: it's a shorthand for :this-ns/foo
07:58justin_smith,::foo
07:58clojurebot:sandbox/foo
07:58justin_smithpowered: in general, for "magic values" it's better to use the namespaced version
07:59poweredbut wouldn't a check in a different namespace fail (= keyword ::foo) ?
07:59justin_smithpowered: right, but the point of ::done is that it is a magic sentinal value, that only your code in that specific place cares about
08:00poweredso it should only be used in that namespace, ok
08:00ghost_justin_smith: your job or open source?
08:01justin_smithpowered: I mean this is making a lot of assumptions - I'm just saying this is a common way of doing things - and yeah usually it would be a namespaced keyword since it's a magic value in that specific context
08:01justin_smithpowered: but you can make namespaced keywords from anywhere, if you know which one is being looked for
08:01justin_smith,:whatever/which
08:01clojurebot:whatever/which
08:02justin_smithghost_: if you know of paid work to do clojure on an open source repo let me know! but no, it is not - it's a software as a service so open source would kind of be counterproductive to getting a paycheck
08:03justin_smithwe release open source libs, but the app is closed
08:03ghost_can you link it?
08:05justin_smithghost_: the app? or the open source libs?
08:06ghost_justin_smith: both
08:06justin_smithour open source stuff is here https://github.com/littlebird our app is here http://www.getlittlebird.com/
08:07ghost_sweet name :D
08:07justin_smithghost_: that client list is partial - there's some big companies that won't let us say they use our app :P
08:07justin_smithhttp://www.getlittlebird.com/customers
08:07ghost_justin_smith: comcast? TIL you're evil
08:08justin_smithhaha
08:08justin_smithghost_: if only you could see the rest of our clients, hah
08:09justin_smithI mean it's an app for marketers, so it's damned from the start, right?
08:09ghost_justin_smith: satan, shkreli and church of scientology?
08:10justin_smithclose enough
08:10ghost_D:
08:11spaceplukis there a cleaner way to write this? https://gist.github.com/spacepluk/70a0e9fbd152073828ff
08:11spaceplukI've been checking cond-> and friends but I'm not sure they help readability
08:14justin_smithspacepluk: (as-> state s (action-events {:action "stop-session"}) s) (assoc s :session (session s (:params action))) (add-events s [(session-start s)]))
08:14justin_smithit looks better when it's not all on one line
08:15spaceplukjustin_smith: thanks! that's perfect
08:15justin_smithspacepluk: as-> literally expands to that kind of let block where you have the same symbol on the left hand side every time
08:57sdegutisAnyone know an ETA on Clojure 1.8?
08:58beakyjrllo
08:58beakyhow does parsing in clijure
08:58beakycompare to parsing in haskell
08:58beakyis it just as easy
08:58beakyor is it a nightmare
08:58beaky(like parsing in C is)
08:59puredangersdegutis: new rc should be coming soon
08:59sdegutisYay!
08:59sdegutisThanks puredanger :)
08:59sdegutispuredanger: I'm most of all looking forward to the built-in socket thing.
08:59beakywhats that
08:59sdegutisbeaky: parsing in Clojure is the same as in any other language
09:00justin_smithsdegutis: I'd say it's easier to use instaparse than it is to use a C parsing lib at least
09:01beakyah
09:01beakywhats instaparse
09:01beakyis ti like instagram but for parsers
09:01poweredit's a parsing library
09:01beakyoh
09:01justin_smithit's based on the popular haskell one iirc
09:02sdegutisjustin_smith: well along with the language you have to take into account the tools, e.g. lex & yacc &c.
09:02sdegutisbeaky: exactly. it's like instagram but for parsers.
09:02justin_smithsdegutis: have you actually used lex and yacc? I'd say instaparse is easier
09:02sdegutisjustin_smith: I have not.
09:03sdegutisjustin_smith: anyway I plan to write my own lua-like language in 2016, entirely in C (no yacc/lex etc) so I'm very excited about taht
09:17mpenetI second instaparse, it's a wonderful lib
09:21oraclehow to pass a vector to a parameter list?
09:21oracle
09:21oracle(j/execute! db ["update tab set a=? ,b=?,c=?", my-vector-for-a-b-d])
09:22oraclefor that code, it actually need three parameters.
09:22oraclebut I have the parameters stored in a vector. Must I unpack the vector? if so that ugly.
09:23poweredcan't you concat it?
09:24justin_smithoracle: apply
09:24justin_smithpowered: concat would be the opposite
09:24oraclecancat what? The expected code should be like ["my-sql-string", p1,p2,p3]
09:25justin_smithoracle: (apply j/execute! db ...)
09:25oraclebut I have a value of [p1,p2,p3]
09:25justin_smiththat way you don't need to unpack
09:25sdegutisHmm, org.clojure/clojurescript 1.7.189 may be broken, it fails to load because it can't find clojure/tools/reader/impl/ExceptionInfo.clj even when I have org.clojure/tools.reader in my deps.
09:25oraclelet me try
09:25oracleapply doesn't work here
09:25justin_smithoracle: why not?
09:26justin_smith,(apply + 1 2 [3 4 5])
09:26clojurebot15
09:26oraclebecause apply only work for the last parameter as vector
09:26oraclebut there it last paramter is ["sql", p1,p2,p3]
09:27oracle(j/execute! db ["update tab set a=? ,b=?,c=?", p1,p2,p3])
09:27poweredthen (concat ["sql"] args)
09:27justin_smithoracle: oh, the three params need to be inside the vector?
09:27oraclethat the correct code
09:27oracleOh, looks that works, let me try
09:28justin_smith(j/execute db (into ["update tab set a=?, b=?, c=?"] coll))
09:28justin_smithI guess concat works too
09:28oracleyeah... it works
09:28oraclethanks. clojure is so cool!!!
09:28poweredseqs vs vectors still scare me because sometimes it appends and sometimes it puts it at the start
09:29justin_smithpowered: vectors always conj to the end, seqs always conj at the start
09:29justin_smithsets conj everywhere
09:29justin_smith,(into #{} :a :b :c :d)
09:29clojurebot#error {\n :cause "Wrong number of args (5) passed to: core/into"\n :via\n [{:type clojure.lang.ArityException\n :message "Wrong number of args (5) passed to: core/into"\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" 48]\n [sandbox$eval49 invokeStatic "NO_SOURCE_FILE" 0]\n [sandbox$eval49 in...
09:29justin_smithergh
09:29poweredapply!
09:30justin_smith,(into #{} [:a :b :c :d])
09:30clojurebot#{:c :b :d :a}
09:30justin_smithpowered: you should use into instead of apply conj - because into uses transients
09:32poweredtransients are fast?
09:32justin_smithtypically they are faster, yeah
09:33oracleanybody using sql againt postgresql inside clojure?
09:33oracleIt throws the exception of Unhandled java.sql.BatchUpdateException
09:33oracle
09:34poweredoracle you could also ask at #postgresql
09:34oracleBut If I post sql in the message to run against postgreslq, it work
09:34justin_smithoracle: yes, I use it extensively
09:34poweredwhy name yourself oracle when you use postgresql
09:35oraclehehe, I previously use oracle,
09:35geirby`lol, my thoughts exactly :)
09:35oraclegood guess.
09:35oracleThe issue looks like in postresql command window, it could convert string to int or int to string automatically.
09:36oraclebut if using jdbc clojure, it just failed.
09:36poweredpostgresql doesn't do implicit casting unlike oracle
09:36oracleAnd it doesn't throw the right message.
09:36lumawhat is the error message?
09:37oracleI think it did casting in postgresql. I am using pgAdmin III. the sql works in that tool. but doesn't work in jdbc clojure
09:37powereddoes it fail before execution?
09:38oraclefailed in jdbc.
09:38lumawhat is the error message?
09:40oracleI am using (.getNextException e) to get the exception message
09:41oracle:No operator matches the given name and argument type(s). You might need to add explicit type casts.
09:41oracle
09:41lumayes, your data types are wrong
09:41oracleBut it didn't tell me which column name.
09:42oracleok, I don't ask future, since it doesn't related to clojure. thanks very much.
09:42lumawell, check the type of your input values and the types of the database tables and see which one doesn't match
09:42lumadatabase columns*
09:43oracleyes, I am doing it.
09:43poweredsounds like a postgresql error though
09:53oracleAnybody used clojure webdriver?
09:54oracleit set a thread level variable. So in each thead we don't need to specify the driver.
09:54oraclebut if use with core.async, looks like it will broken, right? since core.async does'nt bind to a sepcific thread.
09:58justin_smithoracle: core.async puts your code into a thread pool, so yes, thread bound things don't work nicely with that
09:59justin_smithoracle: though instead of (go ...) you can use (thread (binding [db my-driver] ...))
10:00justin_smithbecause thread is like go, but it doesn't use the thread pool- it uses a new thread
10:05oraclebut could I set the drive in function fun1, then call (go (fun1 (<! my-chan)))
10:05oraclewill that work?
10:05oraclewill fun1 be run on only one thread?
10:05justin_smithyes, of course
10:06justin_smithit's only the channel operations that get distributed in the thread pool
10:06oracleok, then that should work If I binding the variable at the start of fun1.
10:06oraclegot it.
12:33pdpiHey, I’m having issues with adding a :local-repository to my project, where I just get “java.io.FileNotFoundException: Could not locate clojure/data/json__init.class or clojure/data/json.clj on classpath.”
12:46justin_smithpdpi: adding the repository does not put any artifacts in that repository on your classpath
12:46pdpijustin_smith: sorry, clarification: the problem is that _everything else_ stops being available.
12:46justin_smithpdpi: you add repositories so it knows where to find jars, you declare dependencies so that it will have those jars on the classpath at runtime
12:46justin_smithpdpi: how did you declare the clojure.data.json dependency?
12:48pdpi:dependencies [[org.clojure/data.json "0.2.6"]]
12:49pdpiactually, I didn’t.
12:49pdpibut it built fine until I added the local repo
12:49pdpiI was reading that line off another project.clj
12:49pdpihuh.
12:50pdpinow that I added it works fine. Guess it was just grabbing it from the “normal” local repo without it being declared. Thanks!
12:57ghost__Have anyone here used launch4j?
14:48favetelinguisjust fond sente library but im to retarded to get the example project even running, anyone that uses sente and can give me some hints?
14:48justin_smithfavetelinguis: is this the first time you've used clojurescript?
14:54favetelinguisnot rly, been playing around with it before, the problem i have is what to do with the example project to get it running so i can view it in a browser and start playing with it, i have used figwheel and lumminus for this before but here there is cljx...
14:56justin_smithfavetelinguis: cljx is deprecated, but info on how to use it is here https://github.com/lynaghk/cljx
14:56justin_smithif you have the repo set up to use it, it should be straightforward
16:13jamesfordummieswhy does (spit FILE (doall (str/join "\n" (list (now) people (rotate chores)))) write clojure.lang.LazySeq@52bb721
16:16BRODUScan someone give me a hint a to why this code isn't evaluating correctly: http://pastebin.com/n2jvQ3iJ , i'm stumped
16:19amalloysymbols are different from vars
16:19amalloy'/ is not division
16:20BRODUSah
16:27justin_smithjamesfordummies: (doall (str/join ...)) doesn't do anything - doall is for forcing lazy seqs to realize, it doesn't do anything to strings (and even if you had doall around the lazy seq inside, it wouldn't change the type to not be lazy-seq or change how it is printed)
16:27jamesfordummiesjustin_smith: i see
16:27justin_smithjamesfordummies: the issue is that calling str on a lazy-seq does not show the contents
16:28jamesfordummieswhere is str being called? inside something i’m calling?
16:29justin_smithjamesfordummies: string/join calls .toString or str I forget which, and I should have specific .toString above (it's just that in clojure code that's how it's usually used so I get used to that shorthand)
16:29jamesfordummiesjustin_smith: so how can I force force strictness? and where?
16:29justin_smith,(str (rotate "abc"))
16:30clojurebot#error {\n :cause "Unable to resolve symbol: rotate in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: rotate in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6704]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: rotate in t...
16:30jamesfordummiesi defined rotate
16:30justin_smithjamesfordummies: it's not about the strictness, it's about the type
16:30jamesfordummiesah… ok
16:30justin_smitheven if it's fully realized, the .toString for lazy-seqs kind of sucks
16:31justin_smith,(str (map inc (range 10)))
16:31clojurebot"clojure.lang.LazySeq@c5d38b66"
16:31jamesfordummieswhich part of my code is a lazyseq?
16:31justin_smith,(pr-str (map inc (range 10)))
16:31clojurebot"(1 2 3 4 5 ...)"
16:32justin_smithjamesfordummies: either now, people, or rotate is giving you a lazy-seq - I can't tell you which with the info we have :)
16:32justin_smithnotice the difference between pr-str and str above
16:34jamesfordummiesjustin_smith: i see… ok one second
16:35jamesfordummiesjustin_smith: (defn rotate [chores] (concat (rest chores) (list (first chores))))
16:43justin_smith,(class (concat [1] [2]))
16:43clojurebotclojure.lang.LazySeq
16:43justin_smithjamesfordummies: there's your lazy seq
16:43jamesfordummies;_;
16:44justin_smithjamesfordummies: you could change it to (conj (vec (rest chores)) (first chores))
16:44justin_smith,(let [chores [1 2 3]] (conj (vec (rest chores)) (first chores)))
16:44clojurebot[2 3 1]
16:45justin_smith,(let [chores [1 2 3]] (conj (subvec chores 1) (first chores)))
16:45clojurebot[2 3 1]
16:45jamesfordummieshm ok
16:45justin_smith(the second one there is faster, but only works if chores is a vector)
16:46justin_smithjamesfordummies: alternatively you could replace (rotate chores) with (pr-str (rotate chores)) in the code that does the output
16:47jamesfordummiesjustin_smith: thanks so much dude
16:48justin_smithnp, glad I could help
17:02jabbis there an idiomatic way to do a loop over a range
17:02jabbthe one i wrote took 138 seconds compared to C's 3
17:03jabb(doseq [i (range 1000000)] (println i)) takes 138 seconds, for (int i = 0; i < 1000000; ++i) printf("%d\n", i); takes 3
17:03justin_smithjabb: for side effects or to build a result?
17:03jabbboth
17:04justin_smithyeah, doseq is as good as clojure will offer there, sadly. You might want to use some alternative to println that doesn't call flush after every call? might help
17:04justin_smith1/20th the speed of C sounds about right for that kind of operation
17:04jabba simple for loop?
17:04jabbhmm
17:05slesterare you timing the actual loop part or the printing too?
17:05justin_smithwith doseq the printing is the loop
17:05justin_smithit won't process the next line until the previous is flushed
17:06justin_smithI think C has something slightly more elegant
17:06slesterI guess just wondering if the hold-up is printing
17:06justin_smithI should say with c / println the printing is the loop
17:07jabbI believe C flushes on newlines
17:07jabbso printf("\n") flushes
17:07jabbpython's "for i in xrange(1000000): print i" takes 4.5 seconds
17:07justin_smithjabb: is this explicitly done by printf or is it just leaning on console adaptor behavior there?
17:08jabbmight be console adaptor
17:08ridcully_iirc stdout is not flushed?
17:09justin_smithjabb: btw that doseq takes 20 seconds on my machine
17:10justin_smithjabb: are you running inside emacs or something?
17:10jabblein repl
17:10justin_smithjabb: my 20 second time is inside java -jar clojure.jar
17:10jabbjustin_smith: try a C function
17:11justin_smithjabb: 31 seconds inside lein repl
17:12ridcully_java -cp clojure.main -e '(doseq [i (range 1000000)] (println i))' 3.68s user 0.76s system 71% cpu 6.239 total
17:12justin_smithjabb: a.out takes 3 seconds
17:13justin_smithridcully_: woah, why was yours so much faster?
17:13ridcully_3s is xterm rendering all that nonsesense ;)
17:14ridcully_justin_smith: i was using clojure 1.8.beta2 with jdk8
17:14jabbjustin_smith: echo 'int main(void){for(int i=0;i<1000000;++i)printf("%d\n",i);}' > /tmp/m.c && gcc /tmp/m.c -o /tmp/m && time /tmp/m
17:14justin_smithjabb: yes that is what I ran
17:14justin_smith3 seconds
17:15jabbwonder why mine is taking 138s
17:16justin_smithridcully_: ahh! when I run inside the repl, it's counting the time printing, when running java under the time command it's more forgiving about the time the terminal spends printing so it gives a lower reported number
17:21ridcully_jabb: are you printing this all out? with that 138s timing?
17:21justin_smithridcully_: in the shell (time (println (:out (clojure.java.shell/sh "./a.out")))) reports that it takes the same amount of time - about 20 seconds
17:21justin_smithjabb: ^
17:21ridcully_jabb: can you try with just redir to /dev/null?
17:21justin_smitherr, s/shell/repl of course
17:21justin_smithso it looks like the bottleneck is the jvm and/or clojure's stdout handling
17:21ridcully_i use an 100lines xterm with bitmap font. that reduces rendering times _alot_
17:22justin_smithahh, that would yeah
17:22justin_smithgood old bittymaps
17:22justin_smithridcully_: I use /dev/null - that prints even faster!
17:22justin_smithheh
17:23ridcully_dev/null is about 3s for clj and 0.06 for c
17:23justin_smithstill about 20x, funny
17:23justin_smithno, that's more like 40x
17:24ridcully_but utilizes 150% cpu
17:26justin_smithjabb: one thing to note here is that lein repl isn't just a process using a tty - it's a process sending output in a high level format on a TCP socket, another one parsing and consuming that format (with middleware etc. applied) and then finally printing to the tty
17:26justin_smithjabb: just switching from my clojure.jar to a lein repl took execution time from 20 secs to 30 secs
17:29ridcully_rlwrap vanilla repl: 17s, lein repl 49s
17:29justin_smithridcully_: sounds like you might have some heftier middleware than I
17:29justin_smith(in terms of raw io throughput at least)
17:30ridcully_pretty could be a culprit?
17:30justin_smithridcully_: ahh - I was running with -server
17:30justin_smithor that
17:30justin_smithyeah
17:30justin_smithby default lein turns off hotspot, which should kick in on a loop like that, but I override that to make sure hotspot is on in my repl
17:31justin_smithridcully_: so that could also be a difference
17:31ridcully_that was a rlwrapped clojure.main 1.7 and a no-project.clj lein repl 1.7 - both jdk8
17:32justin_smithoyeah, in a no-project lein you will have hotspot turned off
17:32ridcully_in my lein config is vinyasa, pretty, eastwood, cljfmt, cider, slamhound, cider
17:33ridcully_i guess pretty could be a candidate and maybe cider?
17:35justin_smithyup
17:36justin_smithbut I really think hotspot being turned off would be a big diff too
17:36ridcully_well... i dont plan to print millions of lines right now. so i rest my investigations now ;)
17:36justin_smithheh
17:40benjyz1hi. I'm working with sync sockets and trying to create a thread for each socket
17:40benjyz1I mean normal sockets, not NIO
17:41benjyz1https://www.refheap.com/112775
17:43justin_smithbenjyz1: does (handler socket) return a callable function?
17:43justin_smithbenjyz1: perhaps you want #(handler socket)
17:44benjyz1I'm not sure about the constructs I'm using
17:44justin_smithbenjyz1: what I suspect is happening now, is that (handler socket) is called in the current thread, the return value is passed to the Thread constructor, and it's not callable
17:44justin_smithso the new thread crashes, and everything is done in the thread of that while loop
17:45devtropeAdd an uncaught exception handler to find out? ;)
17:45justin_smithbenjyz1: normally handler is not a function taking a connection as an arg and returning another function - try changing (handler socket) to #(handler socket)
17:45justin_smithbecause Thread. definitely needs something runnable as its arg
17:45justin_smithand #() is runnable
17:45benjyz1one issue is I'm trying to store state about the connections as well
17:45justin_smithbenjyz1: sure, but that's not likely the bug here
17:46justin_smithif handler returns anything other than a function of 0 args, that code is broken
17:46benjyz1yes, "#" fixed this
17:46justin_smithcool, now you can worry about storing state :)
17:47benjyz1I've looked at aleph and netty
17:47justin_smithaleph is pretty cool
17:47benjyz1and zeromq, but I'm doing it the hard way now
17:47benjyz1because I'm not worried about performance at the moment
17:48justin_smithbenjyz1: I've really enjoyed working with kafka
17:49justin_smithit's got a nice flexible way of doing many->one one->may or one->one
17:50benjyz1wondering whether it would make sense to have a map for all connections
17:52justin_smithwhat would you do with that map?
17:53benjyz1the simple issue I have now is, if client sends a disconnect message, then I want to set run flag to false
17:54benjyz1so i have a run atom, but I need that for every connection
17:57justin_smithor a map in an atom, with a key for each handler that's been started?
17:57justin_smithyeah, makes sense
17:58benjyz1I'm trying to isolate a few patterns, as you say. request-reply, publish-subscribe
17:58justin_smithbenjyz1: an elegant option would be to create an agent instead of using Thread, and put the agent in a set or vector in an atom. Then the agent will end up holding the return value of the handler once it returns.
17:59justin_smithso first set the agent to ::pending, then send it the job of handler on the new connection, so its value will be ::pending until it returns some value
17:59justin_smith(until the handler returns its new value, that is)
18:00benjyz1there is several things I want to do with the duplex-stream. not quite sure
18:00justin_smithfair enough
18:00justin_smiththere are definitely options
22:00kenrestivohow would i swap columns and rows in a matrix in an idiomatic way?
22:00kenrestivoooh wait, i think i remember, apply map or something...
22:01kenrestivoapply map vector IIRC
22:03Seyleriuskenrestivo: Yep
22:04kenrestivothat's so slick.
22:31gfredericksokay this bug is quite a doozie
22:31gfredericksI get a ClassNotFoundException when running `lein test`
22:31gfrederickssounds vanilla so far
22:31gfredericksbut I only get it with lein 2.5.3, not 2.5.2
22:32gfredericksand I just checked and both versions give identical output to `lein classpath`
22:32gfredericksso there is something very spooky here
22:32gfredericksI think :eval-in :pprint is the next step
22:36kenrestivothat's a weird one
22:36kenrestivothis is probably the ugliest rube-goldberg device i've ever stacked together, but hey, it works: https://www.refheap.com/112781
22:37kenrestivo(that's to transform a calendar in one format to a different format for hiccup/html displaying... and there's more on the hiccup side)
23:07gfredericksokay apparently my problem is something like :resource-paths ["lib/*"]
23:08gfredericksin 2.5.3 leiningen sees that and decides to create a directory called lib/*
23:08gfredericksdoes anybody know if leiningen supports this pile-of-jars-classpath-entry in any other fashion?
23:10amalloydowngtade to lein 1.x of course
23:11gfredericks:)
23:11gfrederickswill probably just use 2.5.2 as the workaround for now and figure out how to get away from the pile of jars later
23:45hiredmangfredericks: well, you can use unquote to run code to list the jars in lib
23:46hiredman~(for [jar (.listFiles (io/file "lib/"))] (.getAbsolutePath jar))
23:46clojurebotNo entiendo
23:46hiredmanclojurebot: jerk
23:46clojurebotyou cut me deep, man.
23:54lambda-11235clojurebot: No habla español
23:54clojurebotHuh?
23:54lambda-11235clojurebot: No habla espanol
23:54clojurebotGabh mo leithscéal?