#clojure log - Jul 22 2015

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

1:29 crocket: How do I debug java code in cider?

1:29 Cider can debug clojure code.

1:31 justin_smith: crocket: you can run jdb with emacs GUD mode https://www.gnu.org/software/emacs/manual/html_node/emacs/Debuggers.html

1:32 someone should hook up clojure debugging to GUD too

1:39 crocket: justin_smith, Does that integrate clojure and java debugging into one session?

3:01 Is there a shortcut for if-not?

3:22 Oh, it is if-not.

3:43 How do I resolve a symbol concisely?

3:44 tgoossens: crocket, (eval symbol)

3:45 ,(let [a 2 s 'a] (eval s))

3:45 clojurebot: #error {\n :cause "Unable to resolve symbol: a in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: a in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6543]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: a in this context"\n ...

3:45 tgoossens: merde

3:46 dstockton: ,(let [a 2 s 'a] s)

3:46 clojurebot: a

3:46 dstockton: ,(let [a 2 s 'a] (resolve s))

3:46 clojurebot: nil

3:47 dstockton: ,(let [a 2 s 'a] ~s)

3:47 clojurebot: #error {\n :cause "Attempting to call unbound fn: #'clojure.core/unquote"\n :via\n [{:type java.lang.IllegalStateException\n :message "Attempting to call unbound fn: #'clojure.core/unquote"\n :at [clojure.lang.Var$Unbound throwArity "Var.java" 43]}]\n :trace\n [[clojure.lang.Var$Unbound throwArity "Var.java" 43]\n [clojure.lang.AFn invoke "AFn.java" 32]\n [sandbox$eval97 invoke "NO_SOURCE_FI...

3:47 amalloy: you can't do that. eval has no access to lexical scope

3:51 dstockton: ,(let [a 2 s 'a] (prn s))

3:51 clojurebot: a\n

3:52 dstockton: ,(binding [a 2 s 'a] (eval s))

3:52 clojurebot: #error {\n :cause "Unable to resolve var: a in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve var: a in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyzeSeq "Compiler.java" 6740]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve var: a in this context"\n :at ...

3:53 crocket: tgoossens, What about (resolv symbol?

3:54 eval somehow feels awkward.

3:56 How do I evaluate a symbol to a local binding concisely?

3:56 eval fails.

3:58 (let [abc 3] (eval 'abc)) fails

3:58 ,(let [abc 3] (eval 'abc))

3:58 clojurebot: #error {\n :cause "Unable to resolve symbol: abc in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: abc in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6543]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: abc in this conte...

3:59 crocket: How do I fix (let [abc 3] (eval 'abc)) ?

4:00 irctc_: Will there be a ClojureScript runtime on V8 anytime this year?

4:00 crocket: http://clojure.org/evaluation

4:01 irctc_, What is the current ClojureScript runtime?

4:01 Nashorn?

4:05 irctc_: It runs thru Closure and then after that it becomes javascript

4:07 ClojureScript is just a pre-compilation artifact that never gets to run anywhere

4:10 crocket: Why does https://www.refheap.com/106807 fail?

4:10 (format-policy 'rolling-policy) in https://www.refheap.com/106807 seems to fail.

4:11 irctc_: Nashorn is German for Rhino (literally horn nose). I wish ClojureScript ran on Nashorn/v8/etc but as far as i know it's trapped on the JVM

4:11 crocket: Nashorn is on JVM.

4:13 irctc_: Nashorn is on JVM but there is no JavaScript based runtime for clojure (only a java based one as far as i know)

4:13 crocket: Anyway..

4:13 How do I make a symbol evaluate to a local binding?

4:14 In a function, I want to retrieve the symbol and the value of an argument.

4:25 irctc_: i guess for the beginner it doesn't solve programmer hell, it just creates more, anyway all the best, bye

4:26 crocket: I may need a macro for that....

4:26 irctc_, The programmer hell is mostly scarcity in the real world and artificial scarcity in corporate environments.

4:31 irctc_: so to answer to crocket's question is there an arguments collection with names+values for a function?

4:33 crocket: If you have years of time to learn a platform, it is not hell.

4:35 irctc_: yup, i guess one has to choose one's hell wisely, since there's enough frustration there to fill MILLIONS of programmers lifetimes, less hot is still burining

4:36 fundamentally i'd reject the fact that it does take years to learn a platform, and that is still the case

4:57 kwladyka: i have function (defn f [[cols rows] [col row]] ... ) and i need lazy sequence from that function in recursive way. So f to count next iteration call themself. Which function should i need to create this lazy seq?

4:59 and perfect way will be to start from not zero, for example (f [8 8] [3 5]) and next iteration will be (f [8 8] [3 6]), so not start from (f [8 8] [1 1])

5:00 or there is no way to do that and i have to use "n" parameter for lazy-seq ?

5:01 oh... maybe it is iterate...

5:02 but how to pass there [cols rows] in way to not be return as a result

5:02 i can use ref-set but it will be good if i dont have to

5:11 crocket: Is there a debugger that can debug clojure and java code simultaneously?

5:32 r4vi: intellij + cursive

5:42 lambda-smith: Can CIDER does that?

5:56 crocket: lambda-smith, cider can debug clojure code.

5:56 I don't know if cider can debug java code.

5:56 lambda-smith: I see, thanks.

6:38 kwladyka: http://clojuredocs.org/clojure.core/recur show example of use recur for denf compute-across without loop, but for my example https://www.refheap.com/d6b0e12cc47d57b0b3b300bc6 i have error CompilerException java.lang.IllegalArgumentException: Mismatched argument count to recur, expected: 0 args, got: 2,

6:38 What am i doing wrong?

6:42 sveri: Hi, I am trying to use re-matches like this: (re-matcher #"id=\"([a-zA-Z]*)\"" "<input class=\"form-control\" id=\"male\" name=\"male\" type=\"checkbox\" />"). I checked that this regex works with an online regex tester and extracts the id part, however in clojure I just get nil returned. What am I doing wrong here?

6:43 fi3aiXoa: kwladyka: recur is for tail recursion

6:44 kwladyka: fi3aiXoa, so it doesn't work because it is nested?

6:45 fi3aiXoa: kwladyka: yes. You can use it only in tail call. Please refer to http://clojure.org/special_forms

6:45 kwladyka: error message could be better though

6:45 crocket: How do I make multimethods dispatch according to java classes?

6:46 fi3aiXoa: crocket: just use `class` or `type` as a dispatch function

6:46 kwladyka: fi3aiXoa, thx

6:46 Bronsa: crocket: or consider using a protocol instead

6:46 crocket: Does a protocol not require defrecord?

6:47 fi3aiXoa: Protocols is one thing, records is another.

6:47 crocket: hmm......

6:47 ah

6:47 fi3aiXoa: (should it be "are one thing"?)

6:47 crocket: ok

6:47 kwladyka: crocket, http://blog.find-method.de/index.php?/archives/209-Dependency-inversion-in-Clojure.html <- read it, it is very good

6:48 fi3aiXoa: sveri: I'm not sure... Do you have a typo? Is it re-matches or re-matcher?

6:48 Bronsa: crocket: you can extend a protocol to java classes

6:49 just like you defmethod on a dispatch value

6:49 and protocol functions will dispatch much faster than multimethods using `type` or `class` as dispatch function

6:50 sveri: fi3aiXoa: both don't work

6:51 I am afraid it interfers with the escaping of the string: \" in the online test tool I don't have them escaped

6:51 fi3aiXoa: sveri: well, re-matches returns non-nil if the *entire* string matches the regexp. It's clearly not the case. Please read the documentation to re-matches and re-find. Also, it's a terrible idea to use regexps on html code.

6:51 crocket: Bronsa, Does a protocol function not dispatch based on the first argument?

6:53 kwladyka: sveri, did you try without \ ? maybe it is a problem like in #"..." it is interpret in another way

6:54 sveri, but it doesn't make sense... but maybe worth to try with something simpler

6:54 fi3aiXoa: sveri: oh, and I actually meant http://clojuredocs.org/clojure.core/re-matches when I said "documentation". It has some examples which should make things clearer.

6:54 crocket: Does a protocol function deal with default?

6:55 fi3aiXoa: You can extend protocol to Object.

6:59 kwladyka: sveri, oh i see ;; The distinction is that re-find tries to find _any part_ of the string

6:59 ;; that matches the pattern, but re-matches only matches if the _entire_

6:59 ;; string matches the pattern.

7:20 tgoossens: Any tips on how to debug the following case: When I execute (... code ...) it works, but when it is in a defn: (defn test [a b] (... code ...) ) it doesn't work anymore. Some class (of my own making) gives an exception

7:21 are there good debugging tools you would recommend?

7:24 crocket: Boo

7:24 tgoossens, cider and cursive

7:24 cursive is more advanced while cider runs on a lightweight environment.

7:24 cursive runs on IntelliJ which is very heavy.

7:25 tgoossens: i use emacs

7:26 kwladyka: is function like "for" but will stop if nil? Only "loop"?

7:30 tgoossens: crocket, ty

7:31 snowell: kwladyka: Try the :while modifyer for for

7:31 *modifier

7:31 kwladyka: snowell, ahh... so obviously! thx

7:32 snowell: ,(for [x [1 2 3 nil 4 5] :when x] x)

7:32 clojurebot: (1 2 3 4 5)

7:32 snowell: Derp

7:32 ,(for [x [1 2 3 nil 4 5] :while x] x)

7:32 clojurebot: (1 2 3)

7:36 crocket: ok

7:49 Kneiva: (inc snowell)

7:49 lazybot: ⇒ 1

7:53 sveri: kwladyka: thank you, re-find does the trick

7:53 not sure how I missed this

8:09 tgoossens: crocket, cider is really great. thanks a lot!!

8:15 crocket: tgoossens, Did you already succeed in starting a cider debugging session?

8:15 How did you do it?

8:16 wasamasa: it's funny to see emacs described as "lightweight environment"

8:16 how did people edit code in the eighties?

8:16 snowell: I've always heard that emacs is a fantastic OS, all it needs is a good text editor :)

8:17 wasamasa: I bet this joke is older than you

8:17 snowell: It's possible

8:18 H4ns: when emacs was said to be an acronym for "eight megabytes and constantly swapping", eight megabytes were considered to be a massive amount of memory

8:19 hellofunk: H4ns: i thought "emacs" stood for "emacs makes all code super" ?

8:20 snowell: Esc-Meta-Atl-Ctrl-Shift

8:26 crocket: It's simple. Moore's law made emacs lightweight.

8:26 After 20 years, eclipse could be considered lightweight.

8:26 Probably in 10

8:28 Firedancer: That's pretty optimistic

8:32 crocket: Moore's law is optimistic.

8:34 Does a protocol always dispatch according to the first argument?

8:35 sobel: I have some confidence Eclipse will always grow (and/or suck) to consume all benefits of Moore's law

8:37 ...on return to java coding, i comment all the side-effecting or data-mutating functions, and it's eye-opening.

8:38 "how *could* you?"

8:38 wasamasa: moore's law no longer applies to increasing CPU clocks

8:38 H4ns: wasamasa: it never did.

8:38 wasamasa: and considering how tricky utilizing more than one core is, I don't have any hope for eclipse

8:39 sobel: performance has always been an aggregate figure of i/o and cpu compute speed

8:39 but i think we've been i/o bound a while

8:42 Bronsa: crocket: yes

8:42 crocket: Bronsa, yes?

8:42 Bronsa: 14:34:50 <crocket> Does a protocol always dispatch according to the first argument?

8:42 yes

8:44 H4ns: it is, but it is using the jvm's dispatch mechanism, not the one implemented by defmulti/defmethod.

10:47 timvisher: anyone familiar with how to launch a headless browser using clj-webdriver?

11:13 J_Arcane: https://twitter.com/J_Arcane/status/623873442123808768

11:15 justin_smith: this bot is the best use of autocomplete API ever https://twitter.com/autocompletejok

11:30 crocket: Nice....

11:30 I finally fixed unilog...

11:34 iwillig: whats the best way to strip a namespace off a keyword… I was thinking about doing this (keyword (name :user/name)) but that seems kind of hacky

11:34 justin_smith: ,(name :key/word)

11:34 clojurebot: "word"

11:35 justin_smith: iwillig: I think that's the trick - what's the usecase for un-namespacing anyway?

11:35 gfredericks`: I have this emacs package called align-cljlet and I kind of like it but I don't think it's available in the emacs package managers

11:36 does anybody use something similar or...something?

11:36 iwillig: i want to filter out all user/create-at and task/created-at attributes in a datomic attribute list and i did not want to enumerate all of the possible namespaces

11:36 but that works.. thanks justin_smith

11:37 justin_smith: iwillig: in that case, you don't even need the keyword call right?

11:37 iwillig: yeah.. we can just leave them a strings and compare the strings…

12:01 timvisher: is core.memoize thread local?

12:52 monsta: Good evening, could some explain me the value of immutability?

12:54 kwladyka: (f? {[1 1] [2 1] [2 3]} [[2 1] [3 3]]) - i am look (f a b) which return me false if any of b element is in a. Otherwise true. I am too tired today, but i am so close the final solution :)

12:55 monsta, in other langauge you can write function (x){x=3;print x} and get result 3. With immutable data you can't change value of x.

12:56 monsta, and when you creating new data from old data there are not redundant. It is tree with indicators to right places in memory.

12:56 something like tree

12:57 watch "Clojure inside out"

12:58 snowell: kwladyka: Are the args maps?

12:59 kwladyka: snowell, sorry my mistake, it is not map

13:00 ha i got it (some? (some #{[1 1] [2 1] [2 3]} [[2 1] [3 3]]))

13:00 snowell: Hahaha my answer was going to be much dirtier than that

13:00 Glad you won't be using it :D

13:01 kwladyka: ;)

13:01 day by day i am learning more and more )

13:03 snowell: It looks like it returns true when there's a match

13:03 Didn't you want the other way around?

13:04 In that case you'd want nil? instead of some?

13:04 kwladyka: snowell, this is just detail :)

13:05 snowell: Incorrect boolean values are probably fine

13:05 kwladyka: snowell, but you are right

13:10 monsta: nani nani

13:10 =?

13:13 If there is a place where I can play with Clojure repl online?

13:15 xemdetia: monsta, if it is not something super complex you can always irc message clojurebot

13:16 snowell: monsta: There's also tryclj.com

13:16 rarebreed: and for clojurescript there's https://himera.herokuapp.com/index.html

13:19 iamjarvo: so i am using http-kit and trying to figure out how to see logs for requests

13:35 kwladyka: (f boolean value) - is any function which return value if true or empty list if false?

13:36 scriptor: ,(or true [])

13:36 clojurebot: true

13:36 scriptor: ,(or false [])

13:36 clojurebot: []

13:37 scriptor: hmm, not quite what you need, since the value is separate

13:38 kwladyka: scriptor, since the value is separate?

13:38 scriptor: separate from the boolean

13:39 kwladyka: ,(or false {[1 2] :king [2 3] :queen})

13:39 clojurebot: {[1 2] :king, [2 3] :queen}

13:39 kwladyka: looks good

13:39 clojurebot: Excuse me?

13:39 justin_smith: scriptor: #(or % ())

13:40 kwladyka: it is still ok, i needed (f boolean value) so the f is or

13:40 justin_smith: kwladyka: or is not an f, but OK

13:40 kwladyka: justin_smith, ?

13:40 justin_smith: kwladyka: ##(map or [1 2 3])

13:40 lazybot: java.lang.RuntimeException: Can't take value of a macro: #'clojure.core/or

13:41 justin_smith: or is not a function

13:41 the request was a function

13:41 kwladyka: oh... i thought everything in Clojure is function, even or

13:41 but it should be ok

13:41 i will se

13:41 see

13:42 ah not... it is not what i want

13:42 (f boolean value) - is any function which return value if true or empty list if false?

13:42 ^it is not this condition

13:43 justin_smith: oh, sorry

13:43 #(if % %2 ())

13:43 that should work

13:43 kwladyka: oh it is ok about readable

13:44 but no function in clojure core like that?

13:44 or something where i don't have to use #()?

13:44 justin_smith: (defn or-empty [condition value] (if condition value ()))

13:44 you can always replace #() with a proper function

13:44 kwladyka: i know, but i am trying to optimise my code

13:45 and many times i discover there is something in http://clojure.org/cheatsheet

13:45 justin_smith: #() is not more optimized than defn

13:45 no, there is nothing that does that in clojure.core

13:45 kwladyka: ok thx

13:45 scriptor: don't worry about the function call overhead

13:46 it'll be miniscule compared to everything else, and the jvm already inlines a bunch of stuff

13:46 justin_smith: scriptor: but the version of some function in clojure.core will be more optimized than one's first try, typically

13:46 if that funciton exists

13:46 scriptor: true

13:46 justin_smith: so kwladyka wanted to make sure there was no built in function that did that

14:04 monsta: snowell: Thank you!

14:19 sdegutis: Does anyone else among you notice as well that using partial when possible seems inherently cleaner than short-form ad-hoc functions?

14:20 * rhg135 raises his hand

14:20 sdegutis: Very well.

14:22 kwladyka: How can i increase memory for lein test?

14:22 maybe also CPU

14:23 wink: kwladyka: https://github.com/technomancy/leiningen/blob/master/bin/lein#L141

14:23 i.e. you can probably add some Xms and Xmx there

14:23 err, sorry. https://github.com/technomancy/leiningen/blob/master/bin/lein#L223

14:23 I think it's this one

14:24 kwladyka: wink, is it possible to set this on "get as much as you want"?

14:24 wink: no clue, sorry. Not that big of a JVM expert :)

14:24 but if it's possible it should be a default JVM option

14:24 rhg135: kwladyka: not as far as I know

14:25 * wink proposes -XX:+OmNomNomRAM to Oracle

14:28 sobel: i could use a little support figuring out something that's probably simple... i want to write to an output stream using data/csv but what i _really_ need is an inputstream from the csv conversion that i can feed to java that wants to do the reading

14:28 (and writing)

14:29 shoulda written this as a transducer, but...too late for today

14:31 kwladyka: can i check is it work in some way in clojure? show me max memory by println?

14:36 because i see it works in REPL, but it looks like doesn't work with lein test

14:38 sdegutis: I will await more answers.

14:42 kwladyka: what to do if my algorithm is too slow, how to measure that and check lazy seq, what to do with that

14:42 it takes gb and give me out of memory

14:42 *4gb

14:42 something is wrong

14:47 justin_smith: sounds like you need to do some profiling

14:48 kwladyka: justin_smith, ?

14:49 justin_smith: kwladyka: there are profiling tools, like the tools.trace library, or criterion for microbenchmarking, or jvm based tools like jvisualvm or yourkit

14:52 kwladyka: oh it looks like a tons of work

14:54 hmm how to check if something is lazy? like (lazy? f)

14:55 gfredericks: oh man

14:56 I think cljs stops inlining arithmetic if you use qualified symbols

14:56 kwladyka: ?

14:56 gfredericks, ?

14:56 gfredericks: kwladyka: unrelated

14:57 kwladyka: oh ok

14:57 justin_smith: ,(type (map identity nil)) ; kwladyka

14:57 clojurebot: clojure.lang.LazySeq

14:57 kwladyka: justin_smith, thx

14:57 justin_smith: I guess you might see other types that are technically lazy like chunkedseqs...

14:58 ,(type (iterate inc 0))

14:58 clojurebot: clojure.lang.Iterate

14:58 justin_smith: oh yeah, you can't just test for LazySeq never mind

14:59 sdegutis: Thank you for your answers.

15:00 kwladyka: justin_smith, can i debug app after run something in REPL in intellij and check what consume so many memory and why?

15:00 if yes maybe do you know good video/article how to do that?

15:01 justin_smith: kwladyka: you can use jvisualvm while your repl is running

15:01 and see what is using the heap, usually

15:01 and what is using cpu, etc.

15:01 kwladyka: https://visualvm.java.net/profiler.html

15:02 kwladyka: when you start jvisualvm, you'll see a list of running java processes, you can double click your clojure app to open it, then find the tools mentioned in that article to see what your app is doing

15:02 kwladyka: justin_smith, thank you!

15:02 justin_smith: s/app/repl (though it works with apps too)

15:02 kwladyka: jvisualvm comes with the jdk

15:03 kwladyka: I hear yourkit is much better, but it is a bit more complicated to get ahold of I think

15:11 kwladyka: what do you think about hava mission control?

15:12 *java mission control

15:13 eh i dont have idea how to check what consume so much memory with this... i will try what you told

15:14 justin_smith: kwladyka: java mission control does part of what visualvm does (I think like literally the entire app is basically embedded into it)

15:30 kwladyka: i run https://www.refheap.com/1a2497a2260906e30eb26575a and (type all-possible-notations ...) is clojure.lang.LazySeq

15:31 How can i optimise this?

15:31 i see how memory consumption rising and rising

15:34 maybe i should use (nth ...) instead of loop?

15:35 amalloy: kwladyka: are you trying to enumerate all possible positions on a chessboard?

15:36 kwladyka: amalloy, this is not a problem it is fast, i also assign all permutation for pieces to this possitions

15:36 hellofunk: amalloy: is that even physically possible?

15:36 kwladyka: and it takes much more time

15:36 agarman: 51! possible positions AFAIK

15:36 that's a lot of memory

15:36 amalloy: there's nothing inefficient in that code, although you are just longhand-implementing a version of filter

15:36 hellofunk: oh i'm confusing positions with moves

15:36 kwladyka: it works fast for small amount of pieces

15:37 amalloy: yeah, of course it does

15:37 kwladyka: but i guess it is because it is trying to read all this seq at once

15:37 or something like that

15:37 amalloy: and for large numbers of pieces you will need like more seconds than there are atoms in the universe, or whatever

15:37 kwladyka: maybe because of loop

15:37 i dont know

15:37 agarman: 51! is games...positions fewer

15:38 kwladyka: amalloy, anyway i need to do this, i can only optimise a little number of this, but not too much

15:38 amalloy: agarman: wikipedia claims it's around 10^43

15:38 kwladyka: you can't optimize brute-forcing the game of chess

15:38 kwladyka: or it is some super extreme good algorithm for chess which i dont know

15:39 amalloy, i can a little

15:39 amalloy, for pieces like rook or queen

15:39 rook takes whole row and whole column

15:40 anyway i have something wrong and i dont know it is problem with my code or algorithm

15:40 but i guess it is problem with loading whole seq at once from lazyseq

15:40 but i am not sure what to do with that

15:49 mmm maybe i will try with nth, i see it is a problem with loop recur and lazy seq

15:49 they lose they power then

15:49 because they incrementally rising instead of iteration

16:25 is it possible when use (for ...) to jump to next iteration without returning value? only with :when?

16:29 justin_smith: kwladyka: it's because of the size of the problem. But amalloy is right, your code is just re-implementing filter. You can just use (filter (partial notation-pass? board-size) (all-possible-notations board-size pieces)) to get a lazy-seq of solutions

16:30 and then use (into #{} ...) if you really want to force it to not be lazy, and to put them all in a set.

16:30 kwladyka: justin_smith, i am doing this now with for and it looks very promising

16:30 no, i want it to be lazy

16:31 justin_smith: OK, but the filter version is simpler - yeah, don't put the result in a set.

16:31 kwladyka: how can i prevent REPL to print what function return?

16:32 just like (not-print f)

16:32 i guess something exist

16:32 justin_smith: that's where the memory usage was ending up - in the set. If the consumer of count-solutions doesn't need to hold all the results at once, and can go through them one at a time, that will help your memory usage

16:32 kwladyka: (do (f) nil)

16:32 that's how I do it at least

16:32 kwladyka: justin_smith, thx

16:33 justin_smith: or (def result (f)) then access whatever part of result I want (but not the whole thing)

16:33 kwladyka: justin_smith, need to, but passed results are in small number

16:34 slester: Anyone have experience with "ExceptionInfo No such namespace: cljsjs.react, could not locate cljsjs/react.cljs at line 1" kinds of errors in the REPL? Using weasel and om.

16:34 martinklepsch: slester: are you using most recent version of weasel?

16:35 slester: this has been a problem at some point when repl stuff changed but should be fixed in the most recent release

16:35 slester: also just FYI there is a #clojurescript channel on Freenode as well :)

16:35 slester: martinklepsch: whoops, sorry about that!

16:36 martinklepsch: slester: fine w/ me, just letting you know :)

16:37 numberten: any reason test.check doesn't have float generators?

16:42 hiredman: I dunno, but a suspect a summary of the reasons would be something like "ugh, floating point"

16:43 numberten: haha fair enough

16:51 (gen/fmap float gen/ratio) I think is probably a good alternative

17:04 dagda1: why does this not print each number on a new line (apply println [0 1 2 3])

17:04 kwladyka: ,(println 0 1 2)

17:04 clojurebot: 0 1 2\n

17:04 kwladyka: as you can see it still print in one line because prinln works in that way

17:05 dagda1: kwladyka how do I print each number on a new line

17:05 justin_smith: ,(doseq [i [0 1 2 3]] (prinln i))

17:05 clojurebot: #error {\n :cause "Unable to resolve symbol: prinln in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: prinln in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6543]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: prinln in t...

17:05 justin_smith: err

17:05 ,(doseq [i [0 1 2 3]] (println i))

17:05 clojurebot: 0\n1\n2\n3\n

17:06 justin_smith: or ##(run! println [0 1 2 3]) ;; 1.7+

17:06 lazybot: ⇒ 0 1 2 3 nil

17:06 justin_smith: wait

17:06 ,(run! println [0 1 2 3])

17:06 clojurebot: 0\n1\n2\n3\n

17:07 justin_smith: oh, that's just lazybot being silly, OK

17:11 gfredericks: dnolen: so the new RNG slows down the test suite by 30%-70%, and I'm running out of ideas for optimizing it (I've now started pondering more JS-oriented algorithms); are you interested in taking a look?

17:14 kwladyka: https://www.refheap.com/e36238616dcd57a13ac301d47 what am i doing wrong here? Why it is so slow... ?!

17:14 how to improve it?

17:16 justin_smith: kwladyka: if you take off the (into #{} ...) part at the end it will be lazy

17:16 kwladyka: justin_smith, i am showing the end on screen

17:16 justin_smith: the into #{} forces it to be strict, so count-solutions can't return until every possible solution is stored in the set

17:16 kwladyka: justin_smith, and the end has a really small number of sets

17:17 justin_smith: if you take that into call out, it can start printing the result immediately

17:17 kwladyka: mmm i will try without that, but still the number of solutions to print is 92

17:17 it is small number

17:18 the main problem is other place

17:18 but i dont know where

17:18 without into #{} it is still slow

17:18 as before

17:20 dnolen: gfredericks: I'm very skeptical that it's RNG, have you looked at profiler yet?

17:21 gfredericks: dnolen: oh like in a browser? I'd been running on node; I'll try the browser version

17:23 dnolen: gfredericks: I only really recommend profiling in Chrome, for profiling use these settings

17:23 :optimizations :simple, :static-fns true, :pretty-print true

17:23 gfredericks: dnolen: okay cool, thanks

17:24 dnolen: gfredericks: make sure in Chrome you click the little gear in the dev console and click Hi-resolution Profiling

17:24 this will give you sub-millisecond sampling

17:25 gfredericks: oh cool, got it

17:25 kwladyka: justin_smith, the main problem all-possible-notations takes too much time... maybe i have just rubbish algorithm and that the problem

17:25 maybe have to do in another way

17:25 gfredericks: glad I asked

17:26 justin_smith: kwladyka: you are dealing with a combinatorial explosion, I guess you could hyper-optimize with low level tricks, but it's inherently slow to get all the permutations of a group that large

17:27 kwladyka: justin_smith, low level tricks?

17:28 dnolen: gfredericks: you may want to pick a illustrative run, anything that runs longer than 10 seconds unless you have a desktop machine is likely to make profiling very painfully slow.

17:28 justin_smith: using an iterator instead of a lazy-seq, using mutation on a single data structure instead of using persistent data structures and lettign them get garbage collected

17:28 gfredericks: dnolen: what does "pick an illustrative run" mean?

17:28 justin_smith: kwladyka: it won't be especially fun or pretty, and can only speed things up so much...

17:28 dnolen: gfredericks: like don't run all the tests

17:29 gfredericks: okay just a single test for longer than normal?

17:29 justin_smith: kwladyka: and at that point you've lost most of the benefit of using clojure in the first place

17:29 dnolen: gfredericks: something like that, I don't know anything about RNG changes so I can't tell you what to try :)

17:29 kwladyka: justin_smith, oh so Clojure just works slower in cases like this?

17:30 gfredericks: dnolen: roger

17:30 justin_smith: kwladyka: it isn't the fastest language - it is up to you whether you want to do 10x more work, risk bigger errors in the code, and do the whole thing in java or C

17:30 *at least 10x more work, for ~10x speed improvement

17:31 kwladyka: how it looks vs scala?

17:31 justin_smith: scala isn't going to be much faster I don't think

17:31 but I don't know a lot about scala, better to find someone who uses both and ask for their comparison

17:33 seangrove: Trying to uberjar a realtively small project for the first time (for this project), and getting this: Uberjar aborting because jar failed: clojure.lang.MapEntry cannot be cast to clojure.lang.IPersistentMap

17:33 There's not really anything more to go off than that - anything obvious I should be looking at?

17:35 justin_smith: seangrove: one thing I like to do is have only one ns that gets aot-compiled. It uses require / resolve at runtime to load my actual app and start it

17:35 that way I can eliminate a lot of headaches caused by differences between aot-compiled namespaces and ones that are not

17:36 seangrove: in case that's unclear, that aot compiled namespace is only a stub, and at compile time it doesn't load any other namespaces (thus no other namespaces get compiled while creating the uberjar)

17:37 seangrove: justin_smith: How's that affect determinism/load-time/etc.?

17:38 justin_smith: seangrove: determinism stasy the same - the same libs are in the uberjar.

17:38 load time is worse, because compiling all happens when starting the jar

17:38 instead of pre-compiling

17:38 seangrove: so that's a tradeoff, I accept it for the added simplicity

17:38 seangrove: Yeah, that's fair

17:38 justin_smith: (simplicity as in, what happens in my repl is what happens in the jar)

17:39 kwladyka: justin_smith, hmm i found 3 apps in scala and try it

17:40 1 do only count solutions without list them.... 2 doesn't work :)... 3 count solutions and i think it is fast

17:41 so i should understand scala now :D

17:43 wow so fast, magic

17:43 of course not mine :)

19:17 amalloy: are you around, cfleming? i was trying to use cursive's debugger support for the first time, and it seems like my breakpoints are not doing anything. i put a breakpoint on the first line of -main and selected the Run|Debug action; but all i get is a console message saying it connected to the target VM, and then disconnected from the target VM

19:44 gfredericks: dnolen: I haven't tried a more focused run yet, but the total test suite slows down by a couple seconds, and the profiler shows over a second of time spent in goo.math.Long

19:45 dnolen: gfredericks: so top line self time item?

19:46

19:46 gfredericks: dnolen: there's GC, then ISeqable, then Long.multiply

19:47 it might be only 600ms, these numbers confuse me

19:47 if the top level self column is all disjoint, then it's >1sec

19:48 dnolen: You can sort self time column

19:48 gfredericks: right, it's sorted

19:48 dnolen: The numbers don't lie

19:49 gfredericks: need to invent a splittable algorithm that's better for 32-bit signed integers

19:51 looks like the other half of the slowdown is GC

19:51 which also makes sense

19:52 eriktjacobsen: Really bizzare problem: I’m getting this error <java.lang.NoClassDefFoundError: clojure/tools/logging/impl/LoggerFactory> , but the problem is that it just started today and the problem exists even 2 months back in our codebase (when its been compiling fine those 2 months). it seems to retroactively breaking builds, and it just occured today simultaniously on all our developer laptops / servers. Has anyone heard anything?

19:52 I’m totally lost.

19:52 dnolen: gfredericks: what % in Long.multiply though?

19:52 eriktjacobsen: We don’t have a centralized maven, so if there is a probem its should be with main public maven

19:52 gfredericks: dnolen: 3.68%

19:53 dnolen: gfredericks: and Seqable?

19:53 gfredericks: 6.7%

19:54 dnolen: So I don't think any change to Long will matter much then. I suspect you made related changes elsewhere for algorithm?

19:54 hiredman: eriktjacobsen: have you run `lein clean`? have your cleared your .m2?

19:55 eriktjacobsen: yes, lein clean before each attempt. will try clearing .m2…. didn’t think local since it hit multiple laptops same time I’m seeing the exact same error from code several hundred commits ago from january. Will try clearing now

19:55 gfredericks: dnolen: not very much; you're saying changes won't matter because 3.68% is relatively small?

19:56 hiredman: eriktjacobsen: are any of your deps AOT compiled?

19:57 dnolen: gfredericks: if twice as much time is spent seq'ing that's where I would spend my time.

19:57 gfredericks: oh gotcha

19:57 dnolen: I wonder how Erlang QC does this without seqs

19:58 gfredericks: the lazy tree part you mean?

19:59 dnolen: gfredericks: yes when I ported test.check the implementation seemed pretty naive wrt perf

19:59 hiredman: eriktjacobsen: it may be some kind of code loading order issue, e.g. the clojure.tools.logging.impl namespace defines LoggerFactory which is something that is backed by a class (protocol, deftype, defrecord, etc)

19:59 gfredericks: dnolen: yeah at first it was just copied from haskell

19:59 hiredman: eriktjacobsen: and something is trying to do stuff with that type before the namespace that defines it has been loaded

20:00 dnolen: gfredericks: I suspect a custom rose tree thing could buy you 10X what you have today

20:00 gfredericks: dnolen: replacing the seqs you mean?

20:00 I've been pondering how to do that today and it's a slippery problem

20:00 dnolen: Just writing a data structure for the problem period

20:00 hiredman: eriktjacobsen: so you can make sure you aren't doing that, if your code does anything with LoggerFactory, and if it isn't you, you'll need to check your dependencies

20:01 gfredericks: well it already *is* a data structure, it's just made of lazy seqs

20:01 eriktjacobsen: hiredman: /sigh I got it. We pushed out Ultra-Repl

20:01 hiredman: what the heck is that

20:01 gfredericks: an extremely large lazy data structure that basically represents the search space

20:01 dnolen: gfredericks: but not necessarily suited to the problem

20:02 Anyways that's what I would do since that would be a global win not a micro opt like Long

20:02 eriktjacobsen: hiredman: since it was pushed out to ~/.lein/profiles, it was conflicting regardless of code checkout. (its a colorized repl that also changes output from stacktraces and whatnot)… oddly the code was working fine with repl UNTIL a lein clean was run… so yeah

20:02 gfredericks: dnolen: okay I'll keep thinking along those lines, thanks

20:02 hiredman: right, because at somepoint you aot compiled the project and the classfile was sitting there

20:03 gfredericks: all the easy thoughts about *ducers don't seem to fit because it's not linear

20:03 eriktjacobsen: hiredman I should have realized, it was just that we happened to be running ultra for several days without a lein clean… totally forgot about the repl change (since they had been playing nice together for week)

20:03 amalloy: gfredericks: new band name: the starducers

20:04 hiredman: you should track down who ever is touching the class without loading the namespace that generates it and send them a strongly worded letter

20:07 eriktjacobsen: hiredman: ok. is there a way to exclude from lein plugins?

20:07 hiredman: don't put it in?

20:08 eriktjacobsen: from a project.clj? heh… yeah right now fix is toggling out lein profile based on dev workflow using repl vs compiling

20:08 hmm way to only load a lein plugin during repl and not during compile / install ?

20:09 hiredman: why bend over backwards to keep using something that is broken?

20:09 eriktjacobsen: the colors are pretty

20:11 hiredman: do you think that is a little crazy?

20:12 eriktjacobsen: not really the colors are pretty helpful, and a script to toggle them out of lein profile when building takes 30 seconds to write and add a hook for in build scripts =\

20:15 hiredman: it just seems like developers will bend over backwards to try to keep using broken stuff, and like, just kick it to the curb, you don't need it, you'll be fine, and you won't accrete more code on top of the broken stuff

20:18 eriktjacobsen: its just a repl plugin, not part of actual code I’m shipping… outside of disabling it during compile, no code is going to be written on top of it…. meh its an improvement over standard repl. it sucks it doesn’t play nice with rest of code but its still perfectly functional for the repl itself

20:22 aamar: CLJS newbie question... anyone know since when or & why String length is (.-length foo) instead of (.length foo)?

20:23 Related, I'm seeing the .length form in a few very important libraries, like ajax.core.

20:32 amalloy: aamar: .-length is a property lookup, like foo.length, and .length is a method call, like foo.length()

20:33 so presumably .-length is used for built in arrays, and .length is used for some other kind of thing like an object defined by ajax.core

20:35 aamar: amalloy: that makes sense. thanks.

20:35 hm... still looks like the cljs-ajax is trying to call it on a String. Maybe it's just a bug.

20:49 bostonaholic: aamar: length is a property on a String, not a function

21:16 justin_smith: bostonaholic: to be clear, it's a method on the String class

21:17 bostonaholic: justin_smith: you sure? https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/length

21:18 justin_smith: bostonaholic: oh, I thought you were talking jvm, don't mind me

21:18 oh, duh, cljs-ajax, right

21:18 bostonaholic: haha, yeah. the original question was CLJS

21:35 justin_smith: ,(defn make-name [] (->> (all-ns) (mapcat ns-publics) (mapcat #(clojure.string/split (name (key %)) #"[-*!?]")) shuffle (remove empty?) (take (+ 2 (rand-int 3))) (clojure.string/join "-") symbol))

21:35 clojurebot: #'sandbox/make-name

21:35 justin_smith: ,(repeatedly make-name)

21:35 clojurebot: (juxt-compile-special NODE-key-seq-history byte-repeatedly-as timestamp-clojure-triml-array ..-identical-fn ...)

21:35 justin_smith: ,(repeatedly make-name)

21:35 clojurebot: (unchecked-some-min distinct-root if-char-make-refer unchecked-all-pop re-list-int-sorted ...)

21:38 justin_smith: ,(repeatedly make-name)

21:38 clojurebot: (descendants-in writer-at bound-aset re-type ex-use-string ...)

21:38 justin_smith: ,(repeatedly make-name)

21:38 clojurebot: (delay-proxy-booleans declare-with-matches-struct let-method aliases-array zipmap-executor ...)

22:18 justin_smith: ,(defn make-name [] (let [namespaces (all-ns) namespace (->> namespaces (mapcat #(clojure.string/split (name (.name %)) #"[.-]")) shuffle (take (+ 2 (rand-int 4))) (clojure.string/join ".")) variable (->> namespaces (mapcat ns-publics) (mapcat #(clojure.string/split (name (key %)) #"[-*!?]")) shuffle (remove empty?) (take (+ 2 (rand-int 3))) (clojure.string/join "-"))] (symbol (str namespace \/ variable))))

22:18 clojurebot: #'sandbox/make-name

22:18 justin_smith: ,(repeatedly make-name)

22:18 clojurebot: (instant.repl.clojure.clojure/select-future-load java.string.clojure.core.uuid/find-subvec-method java.clojure/frequencies-zero-ex-clojure sandbox.clojure.core.user/test-unresolved-not string.core.clojure.clojure.user/while-unchecked-str-unmap ...)

Logging service provided by n01se.net