#clojure log - Jun 10 2015

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

2:04 Guest34113: Help needed on our new genuinevBulletin forum software (it is not nulled) please visit https://www.criosphinx.net for more information (we're able to install vBulletin 5 Connect

3:10 benhuda: hello

3:29 dsapoetra: hi guys, can somebody help me with clojurescript and domina library?

3:31 so i've got a code ( https://gist.github.com/dsapoetra/10a61354b4151c528ba7 ), as you can see, in (defn ^:export init ..) i have 3 click event from 3 different link, each link change same html content, problem with my code is that only first event that worked, any suggestion?

3:45 J_A_Work: Is there seriously not a way to properly restart a Cider REPL without entirely closing and restarting the buffer?

3:46 I’m doing a lot of work with reader conditionals in some .cljc files, and there’s a bug in the reload there on clojure side. Which, OK, not much to do about that, but from a UI level in Emacs it’s a pain in the arse.

3:46 The restarted Cider buffer doesn’t even pop up in the same place.

4:04 acron^: morning

4:05 i want to pass a boolean to a fn but it doesn't feel idiomatic: (fetch-data location path true/false)

4:06 what's the idiomatic way to do this? keys?

4:07 (fetch-data location path :returnEmpty) ?

4:07 zot: acron^: context? why does passing a bool feel non-idiomatic? it's still data, even if its the simplest form

4:08 acron^: in this example, the boolean might indicate that an empty string should be returned, rather than throw

4:08 amalloy: i think acron^'s concern is that a function call like (foo true false false true) doesn't really have any apparent meaning

4:08 acron^: exactly amalloy

4:09 zot: would 2 versions of the func make more sense, where one includes a default (a la 'get'), so you can pass "", and throw if no default is given?

4:09 amalloy: acron^: in clojure, usually you do this by passing a single map parameter, with keys for all the optional stuff: (foo {:cheat? true, :ai :dumb})

4:10 acron^: zot: yeah, i considered a 'fetch-data-no-throw' or something

4:10 amalloy: then at the call site there's evidence of what each arg is supposed to mean

4:10 acron^: amalloy: i think that's a good plan

4:11 amalloy: some clever bugger will tell you that (foo :cheat? true, :ai dumb) is way cooler, but don't believe them

4:11 zot: agreed. that sounds better than my idea. (for clarity — i meant same function name, just variable arity.)

4:13 acron^: is there shorthand for if a map key exists use the value, else use something else ?

4:14 amalloy: acron^: are you familiar with destructuring, or are you just using get?

4:15 acron^: i'm vaguely familiar with destructing....not really

4:15 yes, using get atm

4:15 well, i would

4:15 amalloy: acron^: then it's just (get m k default)

4:15 acron^: ahh

4:15 :D

4:15 thanks

4:16 TEttinger: (inc amalloy)

4:16 lazybot: ⇒ 278

4:18 zot: amalloy: do you mind elaborating on the dislike of (foo :kw1 arg1 :kw2) mechanism? I've seen it a few times, and been curious why it's lightly used.

4:19 amalloy: zot: because the convenience it provides at the call-site when typed in manually by a human is saving two characters, and the inconvenience it adds when calling it programmatically is quite substantial

4:20 zot: amalloy: makes total sense. i've never actually used it (or had to try to build up an apply-able arg set). thanks!

4:20 acron^: amalloy: works a treat: https://www.refheap.com/102375

4:21 is the override necessary?

4:21 overload*

4:21 amalloy: no, but it's polite

4:21 you can do it if you want, or not

4:21 acron^: i shall strive to be polite :)

4:22 amalloy: acron^: now are you ready for destructuring cheat-mode?

4:22 * hellofunk has his interest peaked

4:22 zot: lol

4:22 amalloy: (defn opts-test ([name] (opts-test name {})) ([name {:keys [include] :or {include false}}]) (str name " " include)))

4:23 * hellofunk understands cheat mode now

4:23 amalloy: so that you can put all the option names and all the default arguments in one place, instead of individually at each place where you happen to need them

4:24 whomp: what's the difference between concat and a bunch of conj calls?

4:24 hellofunk: whomp: for starters, concat is lazy

4:26 whomp: also: concat accepts collections, whereas conj accepts one collection and then individual elements

4:26 whomp: hellofunk, ok, so it's just lazy and with a slightly different way of dealing with arguments

4:27 hellofunk: whomp: conceptually they are quite different. conj builds a collection and concat builds a sequence

4:27 whomp: also, concat builds the seq the same way always, but conj uses the collection type's efficiency to determine where the addition is performed (front or end of the collection) while concat respects arg order always

4:28 TEttinger: ,(conj [1 2 3] :a)

4:28 oddcully: ,(conj (conj (conj '(0) 3) 2) 1)

4:29 clojurebot: [1 2 3 :a]

4:29 oddcully: ,(concat '(0) [3 2 1])

4:29 clojurebot: (1 2 3 0)

4:29 (0 3 2 1)

4:29 TEttinger: ,(conj '(1 2 3) :a)

4:29 clojurebot: (:a 1 2 3)

4:29 acron^: amalloy: awesome cheat, thanks

4:30 TEttinger: important thing to note, conj-ing onto a vector produces a vector (and appends to end), conjing onto a seq (aka list) produces a seq and prepends to beginning

4:30 whomp: hellofunk, thx, very interesting

4:31 TEttinger: I don't actually know how conj works with maps

4:31 ,(conj {} :a)

4:31 clojurebot: #error {\n :cause "Don't know how to create ISeq from: clojure.lang.Keyword"\n :via\n [{:type java.lang.IllegalArgumentException\n :message "Don't know how to create ISeq from: clojure.lang.Keyword"\n :at [clojure.lang.RT seqFrom "RT.java" 528]}]\n :trace\n [[clojure.lang.RT seqFrom "RT.java" 528]\n [clojure.lang.RT seq "RT.java" 509]\n [clojure.lang.APersistentMap cons "APersistentMap.java"...

4:31 TEttinger: ,(conj {} [:a 1])

4:31 clojurebot: {:a 1}

4:31 TEttinger: ah!

4:31 it just needs pairs

4:31 hellofunk: TEttinger: specifically, it needs a vector

4:32 ,(conj {} '(1 2))

4:32 clojurebot: #error {\n :cause "java.lang.Long cannot be cast to java.util.Map$Entry"\n :via\n [{:type java.lang.ClassCastException\n :message "java.lang.Long cannot be cast to java.util.Map$Entry"\n :at [clojure.lang.APersistentMap cons "APersistentMap.java" 42]}]\n :trace\n [[clojure.lang.APersistentMap cons "APersistentMap.java" 42]\n [clojure.lang.RT conj "RT.java" 638]\n [clojure.core$conj__4114 inv...

4:32 TEttinger: I've noticed that before, any idea why that is?

4:32 hellofunk: TEttinger: the vector is the seq part of a map. hence why mapping over a map uses vectors for each pair

4:32 TEttinger: yep

4:32 there's a non-seq part?

4:33 hellofunk: TEttinger: well the map itself is not a seq

4:33 TEttinger: ahhhh

4:33 right

4:34 whomp: what's the difference between a sequence and a collection? i see that ISeq extends from IPersistentCollection

4:34 hellofunk: ,(= (seq? {:a 1}) (seq? (seq {:a 1})))

4:34 clojurebot: false

4:35 hellofunk: whomp: some collectsions are not seqs, for example, as my last snippet shows

4:35 TEttinger: I think Collection refers to the parent of all generic Java collections and Clojure collections, except maaaaaaybe Maps

4:36 hellofunk: whomp: and many seqs are not collections; a lazy-seq for example

4:36 TEttinger: ,collection?

4:36 clojurebot: #error {\n :cause "Unable to resolve symbol: collection? in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: collection? 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: c...

4:36 TEttinger: hm

4:36 hellofunk: ,(doc coll?)

4:36 clojurebot: "([x]); Returns true if x implements IPersistentCollection"

4:36 whomp: hellofunk, but ISeq extends from IPersistentCollection

4:36 TEttinger: no, more interested in seeing if java.util.HashMap is actually a Collection

4:37 hellofunk: whomp: personally, i recommend caring less about implementation details and more about the high-level concepts. for example, a map collection can have more than one implementation depending on its size and other factors

4:37 TEttinger: yep

4:38 yeah, it tends not to matter too often what interfaces clojure's data structures implement

4:38 whomp: ok, so collections are just structures where you know how many elements it has, and it doesn't need to be ordered, and sequences are where it needs to be ordered but you don't know necessarily how many things it has?

4:38 hellofunk: whomp: sets and maps are important collections, but neither is a sequence. however a vector is also a collection, and it *is* ordered

4:38 whomp: right, so is what i said a good summary?

4:39 TEttinger: so typically, most clojure functions that operate on data structures internally operate on seqs. if you look at the source for, say, frequencies, it probably calls seq on its collection argument to turn it to a sequence (or return nil if it is not a sequence, which is critical)

4:39 hellofunk: whomp: you are right that a collection is a concrete, finite entity full of stuff. a sequence is an ordered entity, sometimes infinite. most importantly, a proper sequence enjoys the sequence api for all types of stuff. and, all collections can be made into sequences by calling seq on them

4:40 TEttinger: ,(seq "hey!")

4:40 clojurebot: (\h \e \y \!)

4:40 TEttinger: and some non-collections too

4:40 whomp: ok, so a collection can always make up an order, even if there's not always a good way of determining what comes before what, e.g. for a map

4:40 TEttinger: strings are a bit of a special case

4:41 right

4:41 you can call seq on a Map or Set just fine

4:41 ,(seq {:a 1 :b 2})

4:41 clojurebot: ([:a 1] [:b 2])

4:41 hellofunk: whomp yes all collections can be made into sequences, which is why you can map over a map. but if the collection is un-ordered, you cannot guarantee what order that seq will be in

4:41 ,(map identity #{1 2 3})

4:41 clojurebot: (1 3 2)

4:42 whomp: ok awesome, thanks guys it makes a lot of sense :)

4:42 TEttinger: clojure's a great language, my favorite by far

4:42 hellofunk: ,(into #{} "hello!")

4:42 clojurebot: #{\! \e \h \l \o}

4:42 TEttinger: haha wow

4:43 (inc hellofunk)

4:43 lazybot: ⇒ 2

4:43 jonathanj: should i use data.json or cheshire?

4:43 hellofunk: ,(map int "what's up?")

4:43 clojurebot: (119 104 97 116 39 ...)

4:44 amalloy: jonathanj: probably cheshire. there's nothing *wrong* with data.json as far as i know, but cheshire is better

4:45 jonathanj: amalloy: better in what way?

4:46 amalloy: i don't really remember, honestly. it's been a while since i looked. more configurable, probably better performance, probably also using a better underlying java library

4:46 kungi: Question to all the native english speakers here. Would you use "salutation" as a database field name or something else?

4:46 jonathanj: it's certainly more popular

4:47 amalloy: a more active maintainer who doesn't have to go through jira

4:47 kungi: i think salutation is recognizable

4:47 "title" is maybe fine too, but i've certainly seen it called salutation

4:47 puredanger: cheshire does keyword keys and data.json does not

4:47 jonathanj: kungi: sure, why not, you might find people using "greeting" more commonly though

4:47 puredanger: and cheshire is faster

4:47 amalloy: jonathanj: well uh, salutation also means a different thing, i believe

4:48 like one meaning is greeting, yes

4:48 $dict salutation

4:48 lazybot: amalloy: noun: A polite expression of greeting or goodwill.

4:48 kungi: jonathanj: greeting sounds perfect thank you :-)

4:48 jonathanj: amalloy: yes, that's true, i hadn't thought of using it as title

4:48 my interpretation was a greeting though

4:48 kungi: title is reserved for Dr. or Prof. or Rittmeister :-)

4:49 dsapoetra: Hi everyone, sorry to interrupt, please help me in this issue : http://stackoverflow.com/questions/30751038/clojure-event-listener-on-domina-library , will appreciate any help. Have a good day

4:49 jonathanj: so if i had a file of json objects separated by newlines, i guess i can combine line-seq to achieve what i want?

4:49 (map cheshire/parse-string (line-seq rdr))?

4:50 and both map and line-seq are lazy... *checks docs*

4:51 when is Clojure 1.7.0 final likely to be released? anyone have any guesses or insider information?

4:51 puredanger: unknown (and that is the most official info you'll find)

4:51 we release when we're done

4:51 zot: kungi: sure, or 'greeting', if i understand what you want, and you want something less formal

4:52 puredanger: I am hoping to get an RC2 out this week

4:52 zot: whoops, didn't realize i was in scrollback :/

4:52 amalloy: jonathanj: well, beware that valid json objects can have newlines in them

4:52 (as i recall)

4:52 jonathanj: puredanger: i was going to say, i saw RC1 a little while ago

4:52 amalloy: the thing outputting this JSON has a strict output

4:53 puredanger: generally when we get an RC that doesn't have any major objections, that becomes the final release

4:53 that is, it really is a candidate for release

4:54 oddcully: puredanger: "when it's done OR later" (always keep your options)

4:54 jonathanj: are there any things i can tune to improve start up time of clojure (or java in general, i guess) software?

4:57 oddcully: jonathanj: what exactly are you talking about?

4:58 there is always the option to moar ghz, moar ram, moar ssd (at least to some degree)

4:58 TEttinger: jonathanj, it's uh an open problem. ssd would be the best help I think

4:59 Timothy Baldridge started work on a clojure-like language called Pixie that avoids the JVM to improve startup time

4:59 but if you need to use java, there are plenty of wacky opts

5:00 running the java.exe or javaw.exe (or other platform specific java program) with args like:

5:00 java.exe -server -XX:+TieredCompilation -Xms512m -Xmx512m -jar MY_THING.jar

5:00 jonathanj: i have an SSD, i'm running a high-end 15" rMBP

5:00 (and OS X)

5:01 TEttinger: would have a definite improvement if the machine can handle -server, which not all windows machines have enabled

5:01 if you can increase -Xms and -Xmx higher, do it. they are starting memory and max memory, respectively

5:02 jonathanj: the reason i ask is on a friend's machine (running Debian Sid) running lein does not seem to take as long to get going

5:02 maybe OpenJDK is faster than Oracle's JDK?

5:02 (the hardware is not significantly different)

5:02 TEttinger: OpenJDK does always have -server available, Oracle not always, but Oracle should have -server on any mac you try it on...

5:02 amalloy: TEttinger: that is bad advice. setting Xms and Xmx too high will just lead to really long GC pauses, with roughly the same average performance unless your program is actually memory-starved

5:03 TEttinger: hm, didn't know that, but I did often hit max memory with usually using less

5:03 interesting

5:03 amalloy: well sure, the jvm will use all the memory you give it

5:03 but it uses it as a dumpster, to let trash pile up

5:03 TEttinger: ah

5:04 amalloy: like lazybot runs on 60MB, and 4clojure.com is on i think 80MB?

5:04 TEttinger: nice

5:04 amalloy: it used to be 40MB, and still could be except that there is a problem with startup that i never got around to fixing

5:04 acron^: omg...how do i merge two vecs??

5:04 lazybot: acron^: Uh, no. Why would you even ask?

5:04 TEttinger: acron^: concat?

5:04 acron^: thanks

5:05 tip of my tongue/brain

5:05 TEttinger: ,(concat [1 2 3] [10 20 30])

5:05 crocket: Does java 8 use an aggressive garbage collector by default?

5:05 clojurebot: (1 2 3 10 20 ...)

5:05 TEttinger: will produce a seq

5:05 ,(vec (concat [1 2 3] [10 20 30]))

5:05 clojurebot: [1 2 3 10 20 ...]

5:05 crocket: GC is lazy....

5:05 My clojure REPL sits on top of 1.5GB of RAM.

5:05 TEttinger: crocket, heh ask amalloy!

5:06 crocket: Why

5:06 jonathanj: hrm, i read this recently: http://stuartsierra.com/2015/04/26/clojure-donts-concat

5:06 TEttinger: amalloy was just saying that lazybot runs on 60MB of RAM

5:06 amalloy: jonathanj: indeed, concat is the wrong answer

5:06 you want into

5:06 crocket: Probably, his lazybot was launched with -Xmx 60M

5:07 amalloy, How did you conclude immediately that 'if-let-all' didn't fit your 'useful' project?

5:08 amalloy: crocket: because i've participated in many discussions about that function before, with different names, and i don't want it

5:08 jonathanj: what are the correct circumstances for using lazy sequences in Clojure?

5:08 crocket: amalloy, Why not?

5:08 jonathanj: i seem to read about a lot of people who advise against using them

5:08 crocket: I was not in the discussion

5:09 jonathanj, If you want to process 16GB of data with 2GB of ram, use a lazy seq.

5:09 It's good for streaming large data with a little amount of RAM.

5:10 amalloy: i don't really want to get into it, crocket. you can probably find it in the google groups archives, ,or the irc log archives somewhere. these days i stay out of the big design discussions, which tend to tread the same ground over and over, and just answer small questions to help people with specific problems

5:10 crocket: It seems you were burnt out.

5:10 TEttinger: ,(into [] [1 2 3] [10 20 30])

5:10 clojurebot: #error {\n :cause "Key must be integer"\n :via\n [{:type java.lang.IllegalArgumentException\n :message "Key must be integer"\n :at [clojure.lang.APersistentVector invoke "APersistentVector.java" 284]}]\n :trace\n [[clojure.lang.APersistentVector invoke "APersistentVector.java" 284]\n [clojure.core$transduce invoke "core.clj" 6583]\n [clojure.core$into invoke "core.clj" 6600]\n [sandbox$eval...

5:10 TEttinger: ...what

5:11 ,(into [1 2 3] [10 20 30])

5:11 clojurebot: [1 2 3 10 20 ...]

5:11 TEttinger: ok phew

5:11 amalloy: crocket: yes, on those types of things

5:12 TEttinger: into just takes one coll. the extra optional argument, as of 1.7, is a transducer

5:12 TEttinger: ahhh

5:12 whodidthis: how do i get C-j back to auto indent with emacs 24.4

5:14 jonathanj: should i use (reader) within a (with-open)?

5:14 the examples on clojuredocs seem to suggest it, so i guess so

5:16 hellofunk: acron^: TEttinger: just be aware that into uses conj, so unlike concat, preservation of order will dependon the collection type, while concat always preserves order.

5:17 whodidthis: oh electric-indent-mode -1

5:22 WickedShell: Apparently (.setProperty System "awt.useSystemAAFontSettings" "lcd") isn't valid as setProperty couldn't be found as a matching method but I can see it here https://docs.oracle.com/javase/8/docs/api/java/lang/System.html#setProperty-java.lang.String-java.lang.String- any reason that this might be happening?

5:24 TEttinger: which exception of those 3 do you get, WickedShell? or a different one?

5:24 oh!

5:24 static

5:25 (System/setProperty "awt.useSystemAAFontSettings" "lcd")

5:26 WickedShell: well that definetly fixed it. So if it's static I always need to address it in that manner?

5:26 TEttinger: I think there's a way with the dot syntax , but slash is definitely the way I usually see it with static methods

5:27 $google clojure.org java interop

5:27 lazybot: [Clojure - java_interop] http://clojure.org/java_interop

5:27 WickedShell: ... yup it was right there and I read right passed it. (Forgot that it was a static method)

5:27 Thanks!

5:29 TEttinger: (. System setProperty "" "") is what the / effectively compiles down to, but / is much more readable, since the paren dot space args special form has lots of different orders that mean different things for its arguments

5:30 no prob, WickedShell

5:31 I think it's about damn time for me to start implementing macroexpansion for my clojuresque language... wish me luck...

5:33 Guest34113: vBulletin vbShout for versions 5.x download the attachment without signning up! http://bit.ly/1FIwtND - More vBulletin products/plugins for any version will be added in due course.

5:33 kungi: What is the equivalent of select * in datomic?

5:33 Guest34113: vBulletin vbShout for versions 5.x download the attachment without signning up! http://bit.ly/1FIwtND - More vBulletin products/plugins for any version will be added in due course.

5:53 jonathanj: is there something like Python's defaultdict() in Clojure?

5:55 hellofunk: jonathanj: what does that fn do?

5:56 jonathanj: i want to use (get-in) without first having to worry about creating nonexistent elements in a nested map structure

5:56 hellofunk: creates nonexistent keys with the provided callable before setting them

5:57 Duke-: you can use (get-in m [keys] default-value) with a normal map

5:57 hellofunk: jonathanj: you mean you want to generate a map that already has a bunch of default keys, but just nil as their values?

5:57 jonathanj: sorry, i have to deal with real life, i'll try explain better in a moment

5:58 hellofunk: ,(into {} (for [k [:a :b :c]] [k :default-val]))

5:58 clojurebot: {:a :default-val, :b :default-val, :c :default-val}

5:58 oddcully: defauldict() gets a fn and getting key, that are not there, return (fn key) instead iirc

5:59 .withDefault if you know groovy

6:03 hellofunk: just came across this, lol: http://i.imgur.com/NsMbRKD.png

6:09 jonathanj: what i'm actually trying to do is create a lopsided tree structure, which was originally modelled in Python with dicts, perhaps there is a better choice in Clojure

6:11 maybe tree-seq can help me

6:24 J_A_Work: Can anyone suggest a painless tool for quickly testing a Compojure API?

6:25 Empperi: https://github.com/ring-clojure/ring-mock

6:25 should do it

6:40 isaac_rks: why is clojures build tool named after a racist story

6:40 this is problematic and i will be advising everyone i know to stop using clojure as it promotes racist attitudes

6:41 p_l: ... damn, Poe's Law strikes again

6:45 wasamasa: I just had an idea why this particular short story was picked

6:45 isaac_rks: because it's a story which denigrates native americans

6:45 ?

6:45 wasamasa: the tool to manage java packages before maven was ant

6:46 it's simple as that

6:47 isaac_rks: as simple as that eh

6:47 Empperi: isaac_rks: I'd say you can pick almost any word in any language and find it offensing in some culture somewhere around the world

6:47 isaac_rks: as simple as mindlessly accepting western patriarchal culture's racist attitudes

6:47 Empperi: for instance, I had zero knowledge Leiningen is considered offensive by native americans

6:48 isaac_rks: thats because you have white privilege

6:48 wasamasa: Empperi: like the pidora linux distro

6:48 Empperi: or the master/slave terminology in databases and whatnot

6:48 Empperi: I'm pretty damn sure that's just a sad coincidence considering technomancy and that he actually moved to Thailand to do charity work

6:48 stopped doing programming

6:48 mostly

6:48 wasamasa: yeah

6:49 Empperi: so I'm pretty damn sure he isn't a racist asshole

6:49 wasamasa: he's currently working on minor projects to teach his kids

6:49 isaac_rks: im bored and pretending to be a sjw

6:50 he sounds like an interesting character

6:50 Empperi: trolling level 1 achieved

6:50 and yeah, he is

6:50 really nice guy

6:50 haven't met him in person

6:50 but been chatting with him

6:51 Bronsa: isaac_rks: trolling is not welcome in this channel

6:51 isaac_rks: ok i will desist

6:51 wasamasa: fun, reminds me of the futile troll attempts on #haskell or #emacs

6:51 isaac_rks: irc is just such a tempting trolling medium

6:51 J_A_Work: leave that for your subreddit please,

6:52 isaac_rks: instant gratification

6:52 Empperi: isaac_rks: the problem here is, irc is a minority chatting medium and most of the guys here are above average in intelligence

6:52 especially on channels like this

6:52 you'll find it really hard to do successfull trolling

6:52 I was 110% certain you were trolling but I was bored

6:53 jonathanj: hrm, is there a function to map over values of a map but produce a map again?

6:54 i'm trying to sort the results of (group-by)

6:54 wasamasa: Empperi: here's said game: https://github.com/technomancy/calandria

6:54 isaac_rks: johnathanj idk about clojure but in racket i would use a fold

6:55 wasamasa: jonathanj: so you're looking of the map equivalent of mapv

6:55 jonathanj: you could alternatively use into and {}

6:55 http://clojuredocs.org/clojure.core/into

6:56 jonathanj: (into {} (map (fn [[k v]] [k (f v)]) some-map))?

6:56 Bronsa: that's one way to write map-vals, yes

6:57 another is (zipmap (keys map) (map f (vals map)))

6:57 (reduce-kv (fn [m k v] (assoc m k (f v))) {} map) is a little more verbose but probably the most efficient version

7:01 TEttinger: Bronsa, that last one looks weird

7:01 what is f there?

7:02 Bronsa: TEttinger the same f in the previous 3 esamples :)

7:02 TEttinger: ah

7:02 ,(let [f str] (reduce-kv (fn [m k v] (assoc m k (f v))) {} map) )

7:03 clojurebot: #error {\n :cause "No implementation of method: :kv-reduce of protocol: #'clojure.core.protocols/IKVReduce found for class: clojure.core$map"\n :via\n [{:type java.lang.IllegalArgumentException\n :message "No implementation of method: :kv-reduce of protocol: #'clojure.core.protocols/IKVReduce found for class: clojure.core$map"\n :at [clojure.core$_cache_protocol_fn invoke "core_deftype.clj" 55...

7:03 TEttinger: the map at the end was also weird

7:03 ,(let [f str] (reduce-kv (fn [m k v] (assoc m k (f v))) {}) )

7:03 clojurebot: #error {\n :cause "Wrong number of args (2) passed to: core/reduce-kv"\n :via\n [{:type clojure.lang.ArityException\n :message "Wrong number of args (2) passed to: core/reduce-kv"\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 [sandbox$eval51 invoke "NO_SOURCE_FILE" 0]\n [clojure.lang....

7:03 TEttinger: hm

7:03 Bronsa: `map` is a map, not c.c/map

7:04 TEttinger: ,(let [f str] (reduce-kv (fn [m k v] (assoc m k (f v))) {} {:a 1 :b 2}) )

7:04 clojurebot: {:a "1", :b "2"}

7:04 TEttinger: ah, nice

7:05 it's much more fun to figure out clojure code than C# code, especially while less capable due to sleeping pills

7:05 I've tried both

7:05 and #clojure tends to be more helpful :)

7:06 wasamasa: there's a c# channel?

7:08 jonathanj: hmm

7:08 i have a POSIX timestamp represented in milliseconds

7:08 (in JSON data)

7:09 when i parse the timestamp (which is a float) with cheshire i end up with a value like 1.425356936278875E9 in the repl

7:10 i'm wondering about losing precision

7:11 the number as it appears in the JSON is 1425356936.278875

7:12 why does it end up with the exponent notation representation?

7:12 Empperi: I wonder why on earth your timestamp is a float if it is in milliseconds?

7:12 and it gets parsed to floating point number which is by definition an inaccurate number format

7:13 but I'm still finding it hard to grasp why floating point?

7:13 ,(System/currentTimeMillis)

7:13 clojurebot: 1433934806288

7:13 Empperi: that returns a long

7:13 oddcully: 1970-01-17? really?

7:14 jonathanj: Empperi: maybe it's not in milliseconds then

7:14 i just assumed it was but i guess it's obviously not

7:14 Empperi: it's something very wierd

7:14 :)

7:14 jonathanj: it's just the result of time.time() in Python, i'm guessing

7:15 Empperi: but anyway, I'd try to handle it myself and read it as BigDecimal

7:15 oddcully: seconds

7:15 Empperi: "The method time() returns the time as a floating point number expressed in seconds since the epoch, in UTC."

7:15 TEttinger: JSON only has one kind of number

7:15 Empperi: geesh, who thought it was a good idea to use seconds?

7:15 oddcully: ,(java.util.Date. (long (* 1425356936.278875 1000)))

7:15 clojurebot: #inst "2015-03-03T04:28:56.278-00:00"

7:15 TEttinger: what clojure calls a double, IIRC

7:16 wasamasa: floaty floats

7:16 Empperi: well, actually there's both float and double in java

7:16 TEttinger: I mean in JavaSCRIPT

7:16 JSON standard...

7:16 $google json.org

7:16 lazybot: [JSON] http://json.org/

7:17 isaac_rks: you don't need any java knwoledge for clojure, aye

7:17 Empperi: anyway, if the data given to you is in seconds with decimal part then doing it like oddcully suggests should work

7:17 isaac_rks: looking for a more practical alternative to racket

7:17 Empperi: but you need to read it in as BigDecimal to keep it accurate

7:17 wasamasa: isaac_rks: even more practical?

7:17 TEttinger: isaac_rks, you don't need it but it sure helps

7:17 Empperi: yeah

7:17 you'll face java sooner or later when doing clojure

7:17 wasamasa: isaac_rks: and sure, you'll need it once you make use of anything java

7:17 isaac_rks: wasamasa: by practical i mean "more libraries"

7:17 TEttinger: yep

7:18 wasamasa: like, when doing file IO :D

7:18 isaac_rks: hmm

7:18 TEttinger: clojure has a ton of clojure libraries and easy access to even more in java-land

7:18 isaac_rks: face what parts of java?

7:18 TEttinger: first things first:

7:19 the guy who designed Java's Generic Collections stuff for java 2.4 was...

7:19 the same guy who invented Scheme

7:19 one of the same guys *

7:19 wasamasa: guy steele?

7:19 TEttinger: yes

7:19 wasamasa: oh well

7:19 p_l: TEttinger: he was one of the designers of java in general

7:19 TEttinger: $google guy steele java generics

7:19 lazybot: [Code Reads #10: Guy Steele, “Growing a Language” — Wordyard] http://www.wordyard.com/2007/06/12/steele-growing/

7:19 p_l: and iirc also did aspectj

7:20 isaac_rks: oh yeah, interesting

7:20 wasamasa: maybe I should bring that up next time our android hacker at work rants about james gosling being the reason for all the sucky decisions

7:20 TEttinger: yep, so there's just more in common than you'd think

7:20 p_l: leading to infamous quote about how at java conferences "this would be the moment people give an ovation" when he finished his AspectJ prelection at ILC, iirc

7:21 TEttinger: Java was originally called Oak. Oak was a language designed "for average programmers," not bad ones but not particularly good ones either

7:22 isaac_rks: TEttinger: this is a good article

7:22 TEttinger: if you can learn clojure, learning the basics of java should be a cinch

7:22 Empperi: but the intricacies of JVM on the other hand...

7:22 :)

7:23 isaac_rks: thats what scares me

7:23 Empperi: but JVM is still the best virtual machine out there

7:23 p_l: Empperi: not really

7:24 Empperi: oh, which is better these days?

7:24 isaac_rks: there arent any perfect languages :( i find this very frustrating

7:24 haha

7:24 Empperi: try haskell if you want a perfect language

7:24 :P

7:24 but forget about pragmatism

7:24 (ok, now I'm trolling)

7:25 isaac_rks: nah i need s expressions

7:25 p_l: Empperi: JVM got a bunch of stuff working because of huge amounts of money poured to make it work (indeed, HotSpot has to "deoptimize" code to optimize it etc.)

7:25 Empperi: well, I don't really care how it's done when the end result is excellent

7:25 isaac_rks: s expressions are fkn amazing, all i had used was python, then when i started doing scheme

7:25 it makes programs so much easier to read imo

7:26 p_l: Empperi: also, JVM is IMO extremely hurt by the fact that most people know only Oracle's (openjvm being afaik pretty much the same)

7:26 dysfun: lisp is lisp is lisp. i've stopped caring which lisp i'm writing for

7:26 isaac_rks: feels like writing an actual language instead of flipping switches on a machine

7:26 TEttinger: downsides to an amazing JIT compiler: the core standard lib that java needs to load with every new run of a program is 32 MB, loaded from disk to RAM before it can do anything

7:26 Bronsa: dysfun: really? that doesn't make much sense to me

7:27 TEttinger: then you load more libs, and if your HDD is not good... it's slow

7:27 Empperi: TEttinger: yeah and Clojure makes it even worse

7:27 p_l: TEttinger: it's unrelated to the JIT compiler, it's an issue with Oracle/Sun JVM

7:27 Bronsa: there are *huge* differences between lisps

7:27 p_l: TEttinger: I am very happy about using J9 as main JRE because of that :D

7:27 TEttinger: p_l, well where is the hotspot implementation?

7:27 dysfun: Bronsa: i spent long enough bending my brain to read s-expressions that they're much of a muchness

7:27 TEttinger: oh?

7:27 what does J9 do, p_l

7:27 dysfun: Bronsa: sure, i've got slightly different techniques for doing stuff in different lisps and i've got different standard libraries

7:27 p_l: TEttinger: among other things, it can do code-sharing between multiple JVM processes for other than the stdlib cache

7:28 TEttinger: nice!

7:28 is this an OpenJDK?

7:28 dysfun: Bronsa: but mostly i pick which lisp to use based on boring stuff like "$platform has $library i want to use"

7:28 e.g. there are immutable datastructure libraries for common lisp, and the standard library there definitely is not geared to immutability

7:28 p_l: TEttinger: OpenJDK pretty much is Oracle

7:29 J9 is IBM's stuff

7:29 TEttinger: except redistribution, openjdk is much more permissive

7:29 how's startup time with J9, and is it open source?

7:29 p_l: TEttinger: the difference boils down to few libs that Sun didn't have apropriate rights to

7:30 and no, not open source - but it shows that there *is* some work other than HotSpot

7:31 Unfortunately, HotSpot has to work uphill, both ways, to get the performance, and due to its design can only get it when in long-running process

7:31 dysfun: p_l: there are many java distributions. especially if you include proprietary ones

7:32 p_l: dysfun: yes. Unfortunately, it appears general public only knows of one (I don't really consider OpenJDK separate except for bugs from having slightly different few libs)

7:32 dysfun: e.g. azul systems have one, oracle has several and most of the big companies involved in java have their own variants

7:33 but for open source java, we're pretty much looking at openjdk

7:33 TEttinger: azul has zing and zulu, but zulu is OpenJDK patched up nice

7:33 dysfun: yeah, but zing definitely isn't

7:33 TEttinger: yeah zing is pricey

7:34 dysfun: however, i was speaking to one of the azul guys the other day, and they will give you it for free for open source projects that meet their requirements

7:34 TEttinger: waiting on 32-bit zulu before I start distributing clojure apps with zulu's jdk 8

7:34 dysfun: you're deploying to old hardware or the windows desktop?

7:34 TEttinger: apparently it works great when you need to bundle JREs on Mac today

7:35 windows

7:35 (Macs all being able to run 64-bit apps)

7:35 (zulu is currently 64-bit only last I checked)

7:36 dysfun: probably because the client backend was shit so hotspot became the only one people bothered to maintain because servers are where the money is

7:40 TEttinger: there may be a 32-bit -server profile

7:41 dysfun: maybe. i shouldn't expect azul will make money off it though. even the new raspi is 64-bit capable, isn't it?

7:45 TEttinger: yeah, they don't make money off zulu anyway I guess

7:45 really it's just another thing to be able to test on for stuff like automated builds, that would find it useful

8:01 ro_st: has anyone used core.memoize with memcached as a backend before? i'm struggling and i'm not finding any decent reference examples to follow

8:05 dysfun: that's ambiguous. could you explain specifically what you want from it?

8:05 are you expecting core.cache to talk to memcached?

8:06 ro_st: trying to use this

8:06 https://github.com/clojurewerkz/spyglass/blob/master/src/clojure/clojurewerkz/spyglass/cache.clj

8:06 with this http://clojure.github.io/core.memoize/#clojure.core.memoize/PluggableMemoization

8:06 bilus: I haven't used it this way but this may be helpful: https://github.com/clojurewerkz/spyglass/issues/10

8:06 ro_st: in a core.memoize/ttl memoizer

8:08 thanks bilus

8:10 damn. on first inspection, it seemed that i could simply (hah) plug memcached into core.memoize. looks like it's not that easy

8:12 seems like memoize's ttl uses (delay)s and memcached can't store that

8:15 bilus: Perhaps rolling your own memoize would be the easiest way?

8:16 I mean the built-in memoize has like what? 5 lines of code?

8:19 ro_st: core.memoize, the library, not clojure.core/memoize

8:19 but i take your point :-)

8:19 bilus: ok :)

8:35 kwladyka: it is noob quesion but... what is the best pratice to read nested value from map, in my example from RING+compojure, sended form by POST: (render-file "register-2.html" {:name "step 2" :email (get-in req [:form-params "email"])})

8:35 is it ok or i should do this without get-in?

8:38 hellofunk: kwladyka: you could also destructure your req in the compojure route, but get-in is pretty standard too

8:40 Bronsa: I find multi-level destructuring really hard to parse

8:40 get-in is perfectly fine

10:07 jonathanj: do Clojure maps preserve their insertion order?

10:09 kungi: jonathanj: no

10:09 jonathanj: there are no guarantees for any map order in clojure

10:10 jonathanj: except you use a sorted-map

10:10 J_Arcane: http://blog.circleci.com/its-the-future/

10:13 noncom: i have a edn {}, and say that X can be either a key of it or a sub-{}, or it can be a member of a [] in any of the values in the {} or sub-{}. how do I remove the kvs were k==X and also free all the []s from being X present in them?

10:14 i am trying to use clojure.walk/postwalk for that, but still my results are not too good

10:15 Bronsa: noncom: an example? it's not really clear

10:15 noncom: ok, wait a sec

10:17 https://www.refheap.com/102385

10:17 i am trying to walk the datastructure and act accordingly to the situation on each step, but i don't have a big success with that

10:18 i remove "X" from a [] by first turning it into a set and then disj and then back (into []) - that's ok i think...

10:18 but otherwise..

10:18 idk..

10:19 oddcully: sets are unordered

10:19 kwladyka: Who use https://github.com/juxt/bidi ?

10:19 noncom: order is not important here, right

10:19 here is my current state: https://www.refheap.com/102386

10:19 it just keeps going in circles

10:19 on first {}

10:19 kwladyka: i just want confirm is it good as routing library for fornt and back side and there is no other alternative :)

10:20 *better alternative

10:20 noncom: kwladyka: seeing it for the first time, but looks good to me

10:23 kwladyka: thx for your opinion

10:27 andyf: jonathanj: The Clojure cheat sheet here lists several forms of sorted maps and sorted sets, including some that preserve insertion order: http://jafingerhut.github.io

10:28 Some operations on maps return unsorted maps, though, so depending on what you are doing with maps, sorting them just before you need them sorted might be more maintainable.

10:29 kwladyka: what Pedesal can by default whan Ring cant?

10:29 *expect routing

10:32 andyf: jonathanj: update-in creates maps if necessary when they do not exist. I've not seen anything exactly like Python's defaultdict, but the function fnil can help you achieve something similar. See the second group of examples here http://clojuredocs.org/clojure.core/fnil

10:42 noncom: Bronsa: did it: https://www.refheap.com/102388

11:15 kwladyka: What is the best partice in clojure to for create handler for create-user? (defn create-user [user] ... ) and pass the map when calling function or (defn create-user [name surname email ....] ...) or ?

11:25 justin_smith: kwladyka: if it's more than 4 distinct pieces of data, I prefer a map

11:25 kwladyka: justin_smith, "prefer a map" - i will be glad if you can write me example of code to be more precise

11:26 justin_smith: (defn create-user [{:keys [name surname email password-hash phone prefs]}] ...)

11:27 kwladyka: oh in that way, thx

11:27 justin_smith: because the caller is actually readable as code if they use a map with named keys

11:27 calling a function with more than four positional args isn't often readable (unless all the args are used identically)

11:28 kwladyka: and call that (create-user {:phone "12321"}) ?

11:28 justin_smith: swap! / update-in / etc. excluded as a special case

11:28 kwladyka: exactly, though I assume you would provide the other keys too

11:28 kwladyka: yes, but it is good to know it is possibility to not do that

11:28 justin_smith: ,((fn [{:keys [a b]}] (+ a b)) {:a 22 :c "OK" :b 20})

11:28 clojurebot: 42

11:30 kwladyka: is there a way to force to put all map keys? like name, surname, email, password,phoen,prefs not only phone?

11:30 justin_smith: kwladyka: you could use a precondition or assert so you would throw an AssertionError if keys are missing

11:31 kwladyka: also there is prismatic/schema which has extensive tools for making assertions about data

11:35 kwladyka: so... if i will use assert i have to write (assert :phone) (assert :sruname) etc.?

11:35 hmm but i guess it is data validation from that moment

11:36 and it is another topic

11:36 topic for some additional library

11:36 justin_smith: kwladyka: (assert (empty? (remove (set (keys input)) [:phone :email ...]))

11:36 it will fail if any of the keys in that final vector are missing from the input

11:37 kwladyka: mmm but i have to rewrite all keys from function parameters in that way, so it is not exatly what i expected

11:38 justin_smith: kwladyka: that's a fair point, yeah

11:39 oddcully: are those really all mandatory?

11:39 justin_smith: I guess a macro that expands to do the keys destructuring and also outputs the assert that all keys were provided could be done

11:40 oh, yeah, if not all keys are required you need to describe the required separate from accepted anyway, so no big loss there

11:41 kwladyka: :form-params in ring+compojure gives "email" instead of :email as the name of input fields. I thing to use "keyword" function to convert that in some way. Is any better way?

11:42 or it is not necessary and i should care about that?

11:42 *shouldnt

11:42 justin_smith: kwladyka: there is wrap-keyword-params - but really unless the data is entered as a literal, why not let the key be a string?

11:43 I am trying to remember if it was bbloom who had a rant about wasting so many CPU cycles turning strings into keywords when there were no data literals actually making the keywords useful

11:43 kwladyka: justin_smith, on the and i want have handler which will get :keys as function what we created and i want have handler for website which will call that handler

11:43 justin_smith: kwladyka: :strs works

11:43 kwladyka: but website handler will get data as "email", handler for uers will get data as :email

11:44 justin_smith: ,((fn [{:strs [a b]}] (+ a b)) {"a" 10 "b" 32})

11:44 clojurebot: 42

11:44 kwladyka: or maybe my idea of doing handlers like that is not wise?

11:45 justin_smith: wait, what are "website handler" and "handler for users" ?

11:46 kwladyka: ok, so user handler is the part of independend architecture. on this stage software don't know anything about website, it is just core of system with business model

11:47 handler website - function for GUI which will call core function

11:47 justin_smith: kwladyka: if you have a standard representation for the data inside the app, I'd make a converter that takes the data as provided by the http request and returns the other representation

11:48 kwladyka: I wouldn't try to manipulate the http server / middleware / etc. so that what you get is identical to your internal representation

11:48 kwladyka: so convert {"email" "bla@bla.com" "password" "secret"} into {:email "bla@bla.com" :password "secret}?

11:49 justin_smith: kwladyka: yeah, inside your http handler

11:49 kwladyka: oh using middleware...mmm it can be good idea

11:49 justin_smith: well, I wouldn't do it as middleware, because I think that's logically the job of the request handler, to create the data you would use internally

11:50 I mean yeah, I have used wrap-keyword-params so that the data is more usable straight off the request, but this also can lead to a mess I think, as opposed to having one piece of code (the handler) that has the job of taking the data from http and creating the data for your app

11:51 in the long run I think that's a more flexible way to do things

11:51 kwladyka: so something like (def web-handler (core-handler (change-data :form-params))) ?

11:51 justin_smith: kwladyka: yeah, and you could consider change-data a sort of middleware

11:52 but a middleware that is dedicated to a specific data format

11:52 kwladyka: so... any hints which function i can use to convert {"email" "bla@bla.com" "password" "secret"} into {:email "bla@bla.com" :password "secret}?

11:53 i guess keyword?

11:53 but maybe there is something better

11:53 justin_smith: ,(reduce-kv (fn [m k v] (assoc m (keyword k) v)) {} {"a" 0 "b" 1 "c" 2})

11:53 clojurebot: {:a 0, :b 1, :c 2}

11:54 kwladyka: http://stackoverflow.com/questions/9406156/clojure-convert-hash-maps-key-strings-to-keywords - oh i think i found something

11:54 justin_smith: but if that is the extent of the conversion you need, wrap-keyword-params does that - just remember you have the choice of doing something more specific

11:54 kwladyka: haha, that top answer is a slightly worse version of my example above

11:56 kwladyka: lol i didint know about wrap-keyword-params :/

11:57 oh not... i misslead

11:58 i just discover :params has keys, but :form-params has strings

12:06 hmm strage, it doesn't change anythink:

12:06 (def app

12:06 (-> app-routes

12:06 wrap-keyword-params

12:06 wrap-params

12:06 (wrap-defaults site-defaults)))

12:06 oh... sorry for multilines

12:07 still i have :params as keys and :form-params as strings

12:08 anyway with your hints i am able to solve that

12:08 thank you again!

12:23 klebervirgilio: What's up guys!! Who are working with clojure???

12:23 lazybot: klebervirgilio: Yes, 100% for sure.

12:23 justin_smith: lazybot: are you a dumbass???

12:23 lazybot: justin_smith: Yes, 100% for sure.

12:25 hellofunk: lazybot: (*&@#(*$%???$#&$^*()#$

12:26 oh, so *now* you get quiet

13:12 justin_smith: lazybot: *@#$&*#$&**??

13:12 lazybot: justin_smith: Definitely not.

13:18 xemdetia: is this lazybot magic 8 ball day

13:20 justin_smith: is it lazybot magic 8 ball day???

13:20 lazybot: justin_smith: Oh, absolutely.

13:24 xemdetia: oh my fault

13:45 code-ape: Hey, I'm looking at an IDE to use and am considering either Cursive or LightTable. Does anyone have any recommendations?

13:50 justin_smith: code-ape: cursive is the better choice

13:51 tcrayford____: code-ape: I've used bolth. Light table (when I used it, maybe 6 months ago or so) had pretty gnarly perf issues if you had a file over like 100 lines or so

13:51 hellofunk: code-ape: yes definitely cursive

13:52 code-ape: tcrayford____: hunh, good to know!

13:52 hellofunk: code-ape: i gave lighttable a try about a year ago and all the bugs were a real buzzkill (i used it on mac)

13:52 code-ape: And thanks justin_smith and hellofunk, I'll definitely get Cursive then!

13:53 tcrayford____: code-ape: documentation was also relatively bad, and customizing it seemed pretty hard. Saw a bunch of bugs as well. It has a lot of promise, but it's riddled by implementation issues imo

13:53 hellofunk: code-ape: be sure to check out Colin's videos on ClojureTV youtube video, including a new one from the clojure west conference a couple months ago.

13:54 code-ape: hellofunk: "Debugging Clojure with Cursive"?

13:54 hellofunk: code-ape: yes, and there is at least 1 more from about a year ago that is a great intro to how cursive works with clojure

13:55 code-ape: basically look at anything Colin has done, and also join his mailing list, lots of helpful people on there

13:56 code-ape: hellofunk: will do! Thanks for the help, I always love the clojure community :)

13:58 hellofunk: (inc #clojure)

13:58 lazybot: ⇒ 10

14:10 jonathanj: is there function that can give me the length of the common prefix between two vecs?

14:10 or rather, the length of the longest prefix match

14:12 justin_smith: hmm, something like ##(count (take-while (partial apply =) (map list [1 2 3 4] [1 2 3 7 8])))

14:12 lazybot: ⇒ 3

14:13 jonathanj: ah yeah, i guess take-while is what i was after

14:13 i was also wondering if that operation had a more common name

14:14 justin_smith: ,(count (take-while true? (map = [1 2 3 4] [1 2 3 7 8])))

14:14 clojurebot: 3

14:14 justin_smith: if you just want the count, at least

15:12 noncom: what's the most iniomatic way to see if a [] contains something?

15:12 seangrov`: (seq [])

15:13 Bronsa: I'd say empty?

15:13 noncom: oh, sorry, i have misworded my query

15:13 Bronsa: I've never liked using seq in place of empty?

15:13 noncom: i meant if a [] contains a particular element

15:13 i can only think of (some p [])

15:14 seangrov`: (some #{item} []), perhaps

15:14 I often bring in a ffilter function, which is (first (filter ...))

15:14 noncom: won't that be much slower than (some #(= % item) [] )?

15:14 Bronsa: (some #{el} vec) or (not (neg? (.indexOf vec el)))

15:14 noncom: so the #{} solution seems nice

15:17 ok what's the best way to remove an item from a []?

15:17 i think of composing (.indexOf) with take and drop

15:31 Cust0dian: noncom, removing random elements doesn't seem like a good idea when dealing with vectors: they are more like stacks, rather than arrays. Any chance you can use a map instead? Then you can remove just by key – clean and simple.

15:32 noncom, if you really need to though, something like this might work: (defn vec-remove [vector position] (vec (concat (subvec vector 0 position) (subvec vector (inc position)))))

15:33 andyf_: With RRB-vectors, removing an arbitrary element should be possible in something like O((log n)^2) time, rather than linear time.

15:34 https://github.com/clojure/core.rrb-vector

15:36 noncom: yeah, well, this concern is there... but in my case this cost will be very small, so i can afford it...

16:08 rs0: hey all, i'm hoping to get some feedback on a project I'm developing: https://github.com/rschmitt/collider

16:08 the goal is to bring Clojure's immutable persistent collections to Java development

16:08 (I'm aware of clj-ds, this is a different approach with different trade-offs)

16:20 TEttinger: good plan, rs0. is there any way to get uh syntax support in any way?

16:20 rs0: TEttinger: what do you mean?

16:20 TEttinger: collection literals?

16:20 TEttinger: I guess java doesn't have it for its own collections

16:21 rs0: TEttinger: the most recent plan i've seen is to keep working on value types and specialization, see what impact that has on collections, and then figure out how to retrofit collection literals into the language

16:21 TEttinger: that stream work is nice!

16:21 rs0: TEttinger: they are reluctant to special-case HashSet and ArrayList and friends, they may end up doing something more extensible like C++11 did

16:22 TEttinger: oh thanks. i'm irrationally proud of the convenience methods, personally

16:23 TEttinger: I have a lot of experience doing Java 8 development. i absolutely love streams, but if i never have to write .stream().map().collect(Collectors.toList()) again it'll be too soon. which is fine--i'm glad they built something simple that i can then make more ergonomic

16:23 TEttinger: that actually looks like it makes functional, immutable stuff usable in Java (!)

16:23 rs0: TEttinger: i see this project as a complement to dynamic-object https://github.com/rschmitt/dynamic-object

16:23 TEttinger: which I see as solving much harder problems

16:23 TEttinger: too bad Android won't get lambdas... ever

16:24 rs0: gee, i wonder why i have no desire to work in "mobile"

16:25 is the javadoc for maven projects hosted anywhere?

16:26 can I just link to it? it's probably easier than "read the unit tests"

16:27 ely-se: TEttinger: you can use Go on Android and Go has lambdas :P

16:27 rs0: ely-se: is that only true as of Go 1.5? (the android part, not the anonymous functions)

16:27 ely-se: 1.4 IIRC.

16:28 rs0: TEttinger: anyway, collection literals aren't the biggest problem, Java's type system is

16:29 TEttinger: Dynamic Object looks nice, rs0

16:29 rs0: TEttinger: Java's type system isn't really able to support abstract type-safe persistent collections

16:29 TEttinger: DynamicObject has served me extremely well in production; it's a fairly mature library

16:31 TEttinger: I need to listen to some more Meshuggah. all I know about them is that the album Ziltoid the Omniscient by Devin Townsend (and ONLY Devin Townsend, the entire band is him) used samples of Meshuggah's heavy drumming instead of him learning the drums, like he did for every other instrument

16:31 rs0: you mean they used the DfH samples?

16:31 TEttinger: yes, probably

16:31 clojurebot: No entiendo

16:34 TEttinger: (that approach is pretty amazing when it works... I've been doing all the art and code for my games myself, but also doing the fonts. I can't totally do a full-stack game because I have pretty much 0 musical skill)

16:35 aztak: /whois TEttinger

16:35 TEttinger: hehe

16:35 oddcully: :*)

16:36 rs0: TEttinger: anyway, java 8's return type inference makes java pretty tolerable, despite the lack of true collection literals. you can say say something like: List<Integer> list = clojureList(1, 2, 3);

16:36 maps are a bit more limited, but i did what i could there as well

16:36 TEttinger: yeah, DynamicObject looks like a good solution

16:38 rs0: i think it strikes a really good balance between static typing and the inherent dynamism of serialization/deserialization. i also think that the implementation strikes a really good balance between minimizing boilerplate and minimizing magic, since Java is very *very* limited when it comes to metaprogramming

16:39 DynamicObject used to be implemented purely as an ordinary InvocationHandler, but more recently i switched to invokedynamic-proxy which has allowed a lot of improvements (e.g. i can implement IPersistentMap etc without actually advertising those interfaces on the Java side)

17:20 lvh: Does ISeqable imply immutable?

17:20 gfredericks: prolly not

17:21 lvh: I'm trying to figure out if FileList (a browser thing) should be iseqable

17:21 gfredericks: not sure if there's a counterexample in clojure though

17:21 a quasi-counterexample are arrays

17:21 might be an actual counterexample in CLJS

17:21 amalloy: lvh: the problem is that if you create a seq wrapping a mutable object, it tends to break when you modify the underlying object

17:22 lvh: ok, that makes sense

17:22 amalloy: like for example, transient vectors aren't seqable in clj-jvm

17:22 gfredericks: but arrays are, and have that weakness

17:22 lvh: Is there a better option than (into [] my-thing)?

17:22 amalloy: gfredericks: yes. it's not super consistent

17:22 lvh: If I can promise that it won't mutate

17:22 gfredericks: ~clojure is not super consistent

17:22 clojurebot: In Ordnung

17:22 lvh: well, hey, maybe it does

17:22 rs0: arrays have many weaknesses =\

17:23 amalloy: but i sorta guess that seqing arrays is something that was deemed necessary for convenient interop, whereas seqing transient vectors is a thing you can just tell people not to do

17:23 gfredericks: totes

17:27 jeffcarp: can a project.clj file reference values in itself?

17:40 rs0: does anyone here have experience using RRB vectors?

17:40 from https://github.com/clojure/core.rrb-vector ?

17:41 oh my god. this is a ton of clojure code

17:41 https://github.com/clojure/core.rrb-vector/blob/master/src/main/clojure/clojure/core/rrb_vector/rrbt.clj

17:45 creese: For Stuart Sierra's component lib: Can a key in the system map point to a list?

17:46 amalloy: creese: why not? it points to any old object afaik

17:48 creese: can you instantiate an object inside 'map'?

17:49 amalloy: it is pretty hard not to

17:50 creese: I thought you couldn't have side effects

17:51 arohner: creese: you *can* have side effects, it's just not recommended

17:51 because laziness, and chunking

17:51 besides, object creation isn't really a side effect

17:52 amalloy: if creating objects counted as a side effect, you could never get anything done

18:28 cfleming: i restarted idea recently, and a clojure project that looked fine last time i touched it now has every symbol highlighted with "can't resolve symbol ____"

18:28 cfleming: amalloy: Does File->Invalidate caches and restart fix it?

18:42 amalloy: cfleming: a restart yields this error message: https://gist.github.com/amalloy/1660138e310101fc7881 - running gpg from the command-line, or lein deploy clojars or whatever, successfully decrypts my credentials (using the stuff in my keychain, i think)

18:43 and java -version prints 1.8.0_45, so i am a little confused as to why it is looking for tools.jar:1.7 inside a directory named 1.6.0.jdk

18:44 justin_smith: is taonsso on here by some other nick?

18:52 cfleming: amalloy: That is a very confusing message. I think the main fix would be to configure your gpg executable path (Settings->Other->Clojure->Leiningen).

18:52 amalloy: I'm not sure what that tools error means - normally it gives that error when lein can't download a dep for some reason.

18:53 amalloy: Re: 1.6 - I'm assuming you're on OSX here. By default IntelliJ runs under 1.6 on OSX due to a tragic series of bugs on later versions.

18:55 amalloy: It's so bad that JetBrains are actually developing and bundling a custom JDK now - see https://cursiveclojure.com/archive/1189.html#1193

18:56 amalloy: However I disagree with his conclusion - 1.6 is still a better solution unless you happen to hit bugs with it (which can happen under Yosemite)

18:56 amalloy: cfleming: i've set my gpg to an absolute path and am restarting it again

18:57 cfleming: amalloy: Oh, sorry, you don't have to restart, just refresh lein from the lein toolwindow - but restarting should work too :-)

18:57 amalloy: well, i don't get the gpg error anymore, but still this tools.jar stuff and all symbols are unrecognized: https://gist.github.com/amalloy/9f06027734734a91b348

18:57 cfleming: The JDK thing is really a pain, and can affect lein since Cursive runs lein in-process, so sometimes there are subtle differences.

18:58 amalloy: That's bizarre. Are you able to share your project.clj - is it a public project?

18:59 amalloy: cfleming: it's not public, but i can probably anonymize out the com.factual non-public dependencies

18:59 TEttinger: amalloy: cfleming: I know at least one person had issues with certain OpenJDK builds on mac, but they were fixed by using the Zulu builds

18:59 http://www.azulsystems.com/products/zulu

18:59 not sure if applicable to IDEA

19:00 cfleming: TEttinger: I haven't tried Zulu but the serious bugs relating to IntelliJ are all AWT/Swing bugs, which I'm assuming are not a priority for Azul

19:00 TEttinger: actually this was related to X not being installed with OpenJDK 7 by default

19:00 cfleming: amalloy: If you do a deps-tree on the command line, I'm assuming there's nothing tools related in there?

19:01 TEttinger: so I think they did fix some of it, since X is not a mess with zulu, similarly to Oracle JDK

19:01 cfleming: TEttinger: Thanks, I'll take a look and give it a go

19:01 clojurebot: No entiendo

19:02 TEttinger: it makes a lot of sense for Mac in particular since they only do 64-bit builds right now, but Mac always can run 64-bit

19:02 (well recent OSX anyway)

19:02 amalloy: cfleming: there's one, maybe: [org.apache.hbase/hbase-annotations "1.0.0-cdh5.4.0"] [jdk.tools "1.7" :scope "system"]

19:02 TEttinger: jdk.tools ?

19:02 what is that?

19:03 amalloy: beats me. apparently hbase-annotations depends on it

19:03 cfleming: amalloy: Ok, I bet that's it. I don't know what that :scope "system" means but I bet you it tries to get it from the current JDK, and that doesn't work under 1.6.

19:03 amalloy: probably so

19:04 cfleming: tools.jar contains things like the JDI classes.

19:04 TEttinger: http://stackoverflow.com/a/3080695

19:04 cfleming: amalloy: Can you exclude that dependency?

19:05 TEttinger: that stack overflow problem: The problem is that the path is not correct for Mac Os X (however it is correct for Windows and Linux).

19:05 cfleming: I'm actually not sure how that dep is supposed to work since tools.jar doesn't exist on OSX anyway

19:05 Right

19:06 TEttinger: it's called classes.jar

19:06 ${java.home}/../Classes/classes.jar.

19:06 cfleming: Yeah, the contents of tools.jar are in with all the other classes.

19:06 TEttinger: interesting

19:06 cfleming: I'm not sure whether that still applies to non-Apple JDKs

19:06 TEttinger: I'll download a zip of mac zulu, see what it has

19:07 cfleming: I just checked on my machine, later JDKs do have it.

19:07 amalloy: cfleming: i can't figure out how to exclude it, no. it comes in like five levels removed transitively

19:09 cfleming: amalloy: Can you use this? https://github.com/technomancy/leiningen/blob/master/sample.project.clj#L65

19:09 TEttinger: zulu has a tools.jar in {root of JDK}/lib/

19:09 amalloy: no, that is the one thing i tried

19:09 but it is still in deps :tree

19:09 cfleming: amalloy: sorry, I realise it's not ideal to have to do this to placate your editor, but the JDK story is a mess.

19:09 amalloy: i think because the "system" scope does weird stuff

19:09 cfleming: Ok

19:10 I'm going to ask in #leiningen

19:10 TEttinger: I'd maybe submit that as an issue to the hbase lib

19:10 amalloy: i imagine the answer would be, it works with maven

19:12 TEttinger: but I think maven on Mac may still be borked with that

19:12 cfleming: Only on Mac running 1.6

19:12 Which basically no-one but IntelliJ users does these days.

19:13 amalloy: One solution is to run IntelliJ with the bundled JDK, but it can be flakey.

19:13 amalloy: Unfortunately on OSX you end up choosing the JDK which annoys you the least

19:14 JDK6 will get more and more buggy with future OSX releases, I'm pretty sure.

19:15 amalloy: i mean, i don't even want very badly to use cursive to edit clojure code. it's ust weird that it used to work, and stopped working only when i restarted my machine. i wonder what changes i made in the month between restarts

19:15 cfleming: Yeah, that is strange. Is it possible that dep was added recently?

19:16 I can't see how that dep would ever have worked under 1.6

19:19 I actually can't find anything in the lein doc about :scope system at all - I suspect it gets passed right through to Aether.

19:19 TEttinger: oh maybe because it's "scope"

19:20 (makes me think you're right, it's java-like because it isn't a keyword)

19:20 cfleming: amalloy: If you're not using Cursive as your main editor but just for debugging or something, the simplest solution is to use a later JDK for IntelliJ. Otherwise the only thing I can think of would be to exclude the hbase annotations and hope they're not required by whatever you're doing.

19:21 Sorry I don't have a better solution.

19:21 amalloy: how would i use a later jdk?

19:22 cfleming: Probably the best solution is to download IntelliJ with the bundled custom JDK. Are you on Community or Ultimate?

19:24 Use https://download.jetbrains.com/idea/ideaIC-14.1.3-custom-jdk-bundled.dmg, and swap IC for IU if you're on Ultimate.

22:05 nf7: Is Clojure a good Lisp to start with?

22:06 Fare: sure

22:06 to start what?

22:06 people here are unlikely to strongly dislike clojure

22:06 nf7: To start learning about programming in Lisp, from the perspective of someone who's only experience of Lisp is Emacs Lisp.

22:07 Fare: Depends what you call "Lisp", but Clojure is an overall very nice language.

22:07 and definitely a Lisp.

22:07 but not a traditional one — for the better and worse

22:07 nf7: Hmmm.

22:12 Fare: its data structure story is more modern than traditional lisps

22:13 its control structures are stunted by direct mapping to tehe JVM

22:15 so I'd say it's a wash here.

22:16 if you like the JVM ecosystem or are stuck on it, Clojure is a great choice.

22:16 if you yearn for speed, not so much.

22:17 clojure is GREAT for concurrency, too.

22:17 although admittedly, Racket is quite good at that, too

22:19 in other words, there is no perfect Lisp, but Clojure is one of the good ones, and in many circumstances, a great recommendation.

22:20 if you like modernity, concurrency, data structures, conciseness, the JVM, purity-by-default, Clojure is just great.

22:21 if you like tradition, raw speed, control structures, macro-defining-macros, anything-but-the-jvm, or side-effects-by-default, Clojure is not so great.

22:31 Niac: is it possible to work without java libs in clojure?

22:32 I find it hard to remember all the java libs

23:03 echo-area: I have updated in project.clj the dependency to org.clojure/tools.nrepl 0.2.10, but lein deps :tree still shows a dependency to nrepl 0.2.6. Does anyone know a possible reason?

23:09 http://www.codedisqus.com/CSVVPVqXgk/how-to-upgrade-nrepl-version-of-leiningen.html

23:09 I found this

23:09 And :replace worked. I need to look into it though

23:15 http://stackoverflow.com/questions/28688721/how-to-upgrade-nrepl-version-of-leiningen (for a better source of info)

23:17 justin_smith: Niac: clojure is a java lib

23:18 Niac: especially with cljs becoming more popular it's viable to mostly use stuff that is 100% clojure on the api level, but clojure's better if you go ahead and use the platform where apropriate

23:22 Fare: Niac: yes, you can work without Java libs in clojure, though you lose one of the strong points of Clojure, doing it

23:22 When I debug clojure code in emacs, I don't get inspectable stack frames like I have with common lisp code.

23:22 is there a way to debug clojure code with stack information?

23:32 cfleming: Fare: Cursive contains a full debugger implementation

23:32 Fare: Contains inspectable stack frames, and much more

23:33 Fare: (full disclosure - I develop Cursive)

23:35 Fare: nice

23:35 is it working yet?

23:37 how do I get on the EAP?

23:37 cfleming: Fare: Yup - https://cursiveclojure.com/userguide/

23:38 Fare: I spoke at Clojure/West this year about the debugger if you're keen to check it out: https://www.youtube.com/watch?v=ql77RwhcCK0

23:38 Fare: Talks about the functionality and some of the limitations

23:39 gko: Will Cursive become a standalone product like RubyMine or PyCharm?

23:39 Fare: thanks

23:39 I'll put that on my todo list

23:39 cfleming: gko: That's my plan, yes, as well as being a plugin

23:40 gko: cfleming: nice. I'm on Ultimate, so I guess the plugin would work as the current EAP?

23:40 cfleming: gko: Right

23:41 gko: The same licence will work for both, in case you want to switch for whatever reason.

23:42 gko: cfleming: what do you mean?

23:42 seangrove: What's a good way to read-string an entire clojure source file?

23:43 If I (read-string (slurp ...)) I (of course) only get the first form

23:43 cfleming: gko: If you pay for Cursive and start using the standalone version, then decide you want to buy IntelliJ Ultimate and keep using Cursive, your previous licence will continue to work for the plugin in IntelliJ

23:43 gko: You could also switch the other way, although I'm not sure why you'd want to if you have Ultimate

23:44 seangrove: Nevermind, found http://stackoverflow.com/questions/6840425/with-clojure-read-read-string-function-how-do-i-read-in-a-clj-file-to-a-list-o

23:46 gko: cfleming: you mean the plugin in Ultimate will have its own licence?

23:47 cfleming: gko: Yes, I don't work for JetBrains so it won't come with Ultimate like the Python or Ruby plugins do.

23:48 * Fare wonders about ways to debug code in monadic style.

23:51 gko: cfleming: I see... But if there's a global Cursive licence, it means I could run just Cursive standalone instead of full blown IDEA, which can be slow...

23:53 cfleming: gko: Yes, that's true, although if you disable all the plugins in Ultimate it's pretty much the same thing.

23:57 gko: cfleming: yes... so, it will be like RubyMine/PyCharm but for Clojure? Will the licence be cross-platform? etc...

23:57 cfleming: gko: Yes and yes. The only difference is that it won't include JetBrains web technologies, unless I can come to an agreement with them.

23:59 gko: cfleming: great. what do JetBrains web technologies bring? HTML/CSS/JS...-related stuff?

Logging service provided by n01se.net