#clojure log - Mar 15 2016

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

0:08 mmercer: i was banned in #haskell but not in here. if that doesn't prove that clojure is superior I don't know what does

0:19 ben_vulpes: patience is next to godliness or what was it

0:23 tolstoy: Should it be possible to (using component) do something like (merge (system/map :some thing) {:other thing} {:still-other thing})?

0:26 Hm. Seems to return a SystemMap, so that's a yes, I guess.

1:19 pmbauer_: somebody please ban mmercer; those comments are inappropriate, sexist, unprofessional and do not represent the Clojure community

1:20 tolstoy: Doesn't seem to be an op.

1:20 rhg135: I'd hope not

1:21 I think they just don't idle as op

1:23 tolstoy: Plus it's late. I wonder how they'd get notified?

1:24 rhg135: PushX?

1:25 tolstoy: I think puredanger is one. amolloy another?

1:25 Or, amalloy.

1:26 rhg135: Yeah

1:26 I don't think amalloy sleeps anyway

1:44 whunix: Hi, what's a good tutorial for beginners?

1:44 I am going to read about Racket HTDP book and then move on to Clojure from that

1:44 what book would be appropriate to read after that?

1:45 in terms of Clojure

1:45 faxmodem: whunix: clojure from the ground up

1:45 its online from aphyr

1:45 tolstoy: Just listened to a podcast with the author of: http://www.braveclojure.com. He said he approached it as he learned it being a Ruby programmer.

1:45 faxmodem: then maybe clojure for the brave and true

1:46 whunix: faxmodem, where's the book? Can't find it :(

1:47 tolstoy: https://aphyr.com/posts/301-clojure-from-the-ground-up-welcome

1:48 whunix: tolstoy, is that all?

1:48 tolstoy: There's a link at the bottom to the next chapter.

1:49 Summary: https://aphyr.com/tags/Clojure-from-the-ground-up

1:51 whunix: isn't it better to just jump into Braveclojure?

1:52 tolstoy: Sure. I think it depends on your familiarity with functional programming, or Lisp, etc, etc, or your general programming experience. Might start with one of the books. Clojure Programming, or what have you.

2:49 irctc: In http-kit I want to defer the answer of http request, like return a future or something, what is the idiomatic way to do that?

3:04 Empperi: so you mean when using http-kit client and you make a request and want to get the response via defer?

3:04 it's built in http-kit client http://www.http-kit.org/client.html#sync

3:05 if you are talking about having http-kit as a server and calling it from browser with clojurescript then the short answer is "you don't"

3:05 the long answer is "use core.async" although that too won't be synchronous

3:05 clojurebot: Ik begrijp

3:06 Empperi: but close at least

3:06 and wtf clojurebot

3:06 you messing with me? lol

3:24 amalloy: ~the long answer

3:24 clojurebot: the long answer is "use core.async" although that too won't be synchronous

3:28 Empperi: lol

3:34 opqdonut: :D

5:15 CStorm: so anyone have a read/video for me who are looking to get insight in different database options?

5:15 reading "mongodb sucks" is getting old, so trying to get a more insight in alternatives.

5:16 or atleast to why mongodb sucks ;)

5:21 Empperi: mongodb doesn't have relations in any way and it doesn't have transactions and it doesn't have any support for schemas

5:21 that enough for you why mongodb sucks? :)

5:21 prohobo: mongodb sucks

5:21 Empperi: but in truth mongodb doesn't suck

5:22 but it sucks as a general purpose database

5:22 prohobo: its webscale

5:22 Empperi: for specific use case scenarios mongo is awesome

5:23 CStorm: what db should i read up on as a general purpose database?

5:23 specific for clojure

5:23 prohobo: CStorm: postgres prolly

5:23 ridcully_: CStorm: postgres

5:23 CStorm: haha

5:23 :D

5:23 prohobo: :|

5:23 CStorm: goodie, thanks guys.

5:24 Empperi: yeah, postgres is a great choice for a lot of stuff

5:24 CStorm: being at ios and osx for 6-7 years and shifting to clojure has it ups and downs :)

5:24 one of them being a mess to figure out the whole db mess.

5:25 Empperi: you've never used databases?

5:25 you're up for a rough ride my friend :)

5:25 CStorm: used coredata for ios

5:25 but else no

5:26 might be rough but looking forward to it :)

5:26 gotta start somewere right

5:26 prohobo: whats so rough about using dbs

5:27 Empperi: well for starters, you have learn a new language: SQL

5:27 and to understand how relational databases work

5:28 also there's transactions and transaction isolation levels

5:28 there is a reason why there are people whose sole purpose is to do stuff with relational databases :)

5:28 same thing goes for other types of databases

5:29 not that it won't be a truly enlightening journey to learn all that stuff but it's going to be a rough ride and there's tons of new stuff to learn

5:30 CStorm: well what kinda programmer would i be if i just would say "ugh im already behind the wagon i dont wanna learn it"

5:30 im looking forward to it, no matter how "rough" it will be :)

5:31 i-blis: CStorm: if you're looking for a good read on DBs, give "seven databases in seven weeks" a shot; it gives a nice overview on what you get with the different paradigms out there

5:31 CStorm: thank you i-blis, will look that up right away

5:32 Empperi: CStorm: indeed, that's the right attitude :)

5:35 prohobo: not a CS major?

5:36 ridcully_: knowing SQL and what comes with it is IMHO a valuabe skill for a developer. but maybe i am just old

5:37 also starting with it on most OS is just a `sqlite3` call away

5:49 CStorm: I bought the book now i-blis– looking forward to it.

5:53 i-blis: CStorm: hope you will enjoy it as I did (despite being a long time SQL user, I enjoyed even the chapter on PostgreSQL)

5:57 hyPiRion: I think sqlite3 is easier to get started with, but Postgres is really good once you've managed to get it up and running. That isn't always as straightforward as one would like though.

6:13 Empperi: ridcully_: no, you are not just old. You are correct

6:14 that's especially true with Clojure and other languages with powerful set operations

6:15 prohobo: but you are also old

6:18 Empperi: it's all relative :)

6:18 34 years old

6:18 I personally think I'm still young and in the beginning of my career

6:21 hyPiRion: Yeah, 34 is not much.

7:14 keksi_: I have a problem modifying my data so I can handle it. I want to modify the structure from the from.clj to to.clj kind of data: https://gist.github.com/Keksike/77477abf2bfcbd5754ee , what should I do?

7:14 I dont think cheshire had a proper function for this one

7:17 faxmodem: I'm playing with overtone/at-at

7:18 when I'm running a function using (at/every 10000 #(myfunc a b c)) it doesn't behave the same as if run as (myfunc a b c)

7:18 ridcully_: keksi_: pass true as second argument to parse-string. then you get keywords

7:19 keksi_: ridcully_: I tried that too, but it got rid of the [ & ]

7:19 faxmodem: e.g. the side effects of myfunc are not observed when running it inside an every block

7:20 keksi_: ridcully_: (and it put it in parantheses instead)

7:21 ridcully_: yes. its a list then instead of a vector.

7:22 keksi_: how do I convert it to a vector?

7:23 ridcully_: ,(vector '({:a :b}{:c :d}))

7:23 clojurebot: [({:a :b} {:c :d})]

7:24 ridcully_: DOH

7:24 s/vector/vec/

7:24 keksi_: wow, thanks :)

7:25 faxmodem: or into

7:25 keksi_: which is preferred?

7:25 faxmodem: good question :)

7:25 in terms of readability I'd vote for vec

7:26 ridcully_: in terms of me remembering vector and vec i vote into ;)

7:27 faxmodem: :-D

8:18 kungi: Is there a difference between (vec) and (into [])

8:31 hyPiRion: kungi: not semantically

8:32 But vec is likely more performant.

8:33 MJB47: iirc it isnt

8:33 but i might be remembering wrong

8:34 it was tested by someone here a few weeks back

8:37 Empperi: kinda surprised if vec isn't faster

8:37 it uses PersistentVector.create() under the hood

8:37 while into uses transducers and conj

8:44 MJB47: http://insideclojure.org/images/20150107/numbers.png

8:44 from http://insideclojure.org/2015/01/07/vec-perf/

10:22 digiorgi: Hi, i'm trying to use clojure with maven, to get a good integration with other ides clojure + java. But when i'm starting CIDER on emacs, connecting from maven i get errors.

10:22 WARNING: The following required nREPL ops are not supported:

10:22 apropos classpath complete eldoc format-code format-edn info inspect-pop inspect-push inspect-refresh macroexpand ns-list ns-vars ns-path refresh resource stacktrace toggle-trace-var toggle-trace-ns undef

10:22 Please, install (or update) cider-nrepl 0.12.0-SNAPSHOT and restart CIDER

10:22 but i have installed the required version

10:33 justin_smith: is the cider-nrepl middleware properly loaded? I thought that it wouldn't work without lein.

10:34 well I guess boot maybe uses it too somehow? anyway, you'll need to do something to make it run properly in maven, it won't be automatic.

10:52 X-warrior: how would you guys represent your own tree structure? a map of maps?

10:52 justin_smith: that or a deftype

10:54 X-warrior: I was doing an exercise for an interview and represented the tree as a deftype. Today I received their answer saying that my code is too much OO and they wanted more functional programming

10:54 justin_smith: interesting - did you use mutable fields?

10:55 X-warrior: justin_smith: yes I did

10:55 justin_smith: aha, yeah, I might use deftype, but I would not use mutable fields unless absolutely neccessary

10:56 X-warrior: well, you have 1 node with one child... you add a new node, how can you add it without using mutable fields?

10:57 justin_smith: the same way you do with any other immutable data type - you have an operation that returns a new instance containing the new node

10:57 X-warrior: I guess my problem was that I created some deftype methods to add new node/retrieve specific node and others

10:57 justin_smith: eg (cons 1 ()) returns '(1) but () is not altered

10:58 X-warrior: you can still have methods to insert and retrieve - it's just a different style when working with immutable data

10:59 where of course insert returns a new tree (that can implicitly share structure with the original, since they are immutable, depending on implementation), and the retrieval would work the same as before

11:04 X-warrior: justin_smith: do you mind to take a look at the code to point some improvements that I could do, so it became more functional instead of OO ?

11:04 besides the mutable fields

11:05 now that I already failed at the test and spent so much time doing it, I would like to get better at this

11:06 justin_smith: X-warrior: I can take a look later, but really the mutable fields thing is what will make the biggest difference (I say without even seeing the code)

11:07 Glenjamin: what was the exercise brief?

11:09 X-warrior: Glenjamin: I had to do a reward system where a customer wins points for invitee from invitee on a 0.5^k

11:10 so direct invitee will give me 1 points, 0.5, 0.25...

11:11 ystael: you had to implement a pyramid scheme kickback mechanic as an interview question? o_O

11:11 justin_smith: just watch, they'll use his code to implement uber but for amway

11:11 X-warrior: ystael: well, it wasn't an interview question... it was one part of the hiring process

11:12 Glenjamin: hrm, my instinct is to record the parent of each customer with something like {:parent <parent-id>}

11:12 and then when adding a new customer, traverse the graph and add points

11:12 X-warrior: https://bitbucket.org/matheusbrat/clojure/overview

11:13 Glenjamin: i guess something like {<id> { :parent <id>, :points n, :id <id> }, ...}

11:13 justin_smith: X-warrior: one issue with using a deftype with mutable fields, is that one assumes you will be using this structure in a webapp or some other process that handles concurrent clients, and mutable fields don't tend to handle concurrent update very well. This is kind of why we use immutable data structures with containers like atoms / agents / refs

11:14 otherwise you end up needing to mess with locking and such

11:14 X-warrior: Glenjamin: that seems as a nice approach

11:16 justin_smith: got it

11:16 * X-warrior going to lunch brb

11:27 ilevd: Hi, clojurebot

11:27 ,(print "Hi!")

11:28 clojurebot: Hi!

11:39 ilevd: Ask, please

11:41 cortexman_: what's the deal with paredit not allowing you to insert the parens that will fix the mismatch?

11:42 ilevd: I don't know

11:43 MJB47: speaking of paredit

11:44 (f| (f2 v)) -> (f2 v)

11:44 whats the command called?

11:44 | being point

11:44 luma: raise

11:44 MJB47: ty

11:56 justin_smith: cortexman_: I've found paredit handles missing ) that you insert by hand nicely, but not other kinds of closing delimiters, which makes me think it's a bug

11:56 cortexman_: the easiest thing is to turn off paredit, fix the matching, then turn it back on again.

11:57 cortexman_: but you can also use commands like kill and yank without being affected by paredit, so that's another approach

11:57 cortexman_: got some good tips from #lisp. i.e., to fix ((( ))) to ((( ])), stick the cursor in the space in the middle, M-z ) C-q ] M-z is zap-to-char and C-q is quoted-insert

11:58 justin_smith: ahh, nice

11:58 so yeah, zap-to-char and quoted-insert must also be outside paredit, like kill-region and yank are

11:58 cortexman_: yeah

11:59 i think it's fewer keystrokes this way, maybe.

11:59 justin_smith: also in evil mode, r is not effected by paredit, so you can insert spaces and use r to change each one to the right kind of delimiter

11:59 cortexman_: i have been thinking about switching to evil mode, but have not taken the dive

12:00 justin_smith: I switched, and I liked it so much that I eventually started using vim

12:00 haha

12:00 cortexman_: lol.

12:00 this is a good reason to use emacs: https://github.com/RallySoftware/rally-emacs

12:01 justin_smith: in terms of being able to extend it to make apps, emacs is at least as good as the browser (though not nearly as pervasively deployed)

12:05 wooh, this guy used my webapp to help write this article! http://www.vox.com/2016/3/15/11225128/donald-trump-gullible-internet

12:05 (webapp is full stack clojure/cljs)

12:06 direct link to the part that came from our app http://www.getlittlebird.com/blog/data-62-of-the-people-donald-trump-rted-this-week-follow-multiple-white-supremacist-accounts

12:27 TimMc: Fun!

12:31 justin_smith: As compared to what my prior work has been used for, it's definitely gratifying to see the product of my sweat used that way.

12:32 TimMc: To the extent to which I can get excited about anything with "social media" in the title, this is neat. :-P

12:32 justin_smith: heh, it's a fun app to work on

12:33 TimMc: (my social media strategy is the LeechBlock browser add-on)

12:59 sfz-: XD

13:43 tolstoy: I use Control-Q (quote) and Control-W (delete) to repair par-edit stuff.

14:09 ben_vulpes: does anyone know where the datomic provisioning clojure lives, if it's even available to the public?

14:13 amalloy: isn't life a lot easier if you just don't break paredit stuff? how does everyone end up with so many unbalanced expressions?

14:17 TimMc: amalloy: It sometimes happens. I have no idea how.

14:17 Paredit does have at least one bug around comments, though.

14:36 sdegutis: Welcome.

14:51 Welcome to #clojure.

14:53 TimMc: anything is possible at #clojure

14:53 the only limit is yourself

14:55 rcg: ,(/ 1 0)

14:55 clojurebot: #error {\n :cause "Divide by zero"\n :via\n [{:type java.lang.ArithmeticException\n :message "Divide by zero"\n :at [clojure.lang.Numbers divide "Numbers.java" 158]}]\n :trace\n [[clojure.lang.Numbers divide "Numbers.java" 158]\n [clojure.lang.Numbers divide "Numbers.java" 3808]\n [sandbox$eval25 invokeStatic "NO_SOURCE_FILE" 0]\n [sandbox$eval25 invoke "NO_SOURCE_FILE" -1]\n [clojure.lang...

14:55 rcg: or the laws of mathematics...

14:55 scnr

14:56 sdegutis: You can do /anything/ at #clojure.

14:57 TimMc: rcg: http://zombo.com/

14:57 sdegutis: Anything at all.

14:58 This is #clojure, and welcome, to you, who have come to #clojure!

14:59 The infinite is possible at #clojure. The unattainable is unknown at #clojure.

14:59 tolstoy: paredit rarely breaks for me, but sometimes I inadvertently cut/paste something wrong from a non-Emacs buffer.

14:59 sdegutis: Oh man. This site takes me back.

14:59 tolstoy: that's what undo-tree is for

14:59 tolstoy: Missing Plug-in?

14:59 sdegutis: because Emacs without undo-tree is literally just pure unadulterated insanity.

15:00 rcg: TimMc, sorry, due to lack of plugins, i cannot watch that, even got my linux box from the shelf to check. but according to the wikipedia article it sounds quite entertaining :)

15:02 mavbozo: you can get "anything" from infinity at #clojure

15:02 ,(get Double/POSITIVE_INFINITY get "anything")

15:02 clojurebot: "anything"

15:06 sdegutis: mavbozo: bravissimo

15:07 TIL you can intensify Italian words like "bravo" by adding "issim" after the final consonant

15:07 Also pianissimo means "very quiet"

15:07 er, very soft

15:17 mavbozo: sdegutis: grazie infinite!

15:22 sdegutis: Today my job is to normalize internal data using a sequence of regex-based migrations.

15:23 What can go wrong?

15:23 ystael: sdegutis: where are you located, roughly? i want to know whether i need to get a car and start driving

15:23 sdegutis: :D

15:37 X-warrior: justin_smith: I changed my solution to use a map as proposed. Did you have time to take a look on the previous version?

15:59 mavbozo: ,(:a.b.c/foo {:a.b.c/foo :bar})

15:59 clojurebot: :bar

16:00 mavbozo: is it okay to have keyword which has '.' in its namespace part?

16:01 but this http://clojure.org/reference/reader#_literals says keywords cannot contain '.'

16:02 hiredman: it is refering to the name part

16:03 keywords and symbols have name and namespace parts

16:05 the set of allowed characters for symbols and namespaces on th reader page don't match the characters the reader actually accepts, and are just for symbols and keywords created via the reader

16:06 mavbozo: got it. thanks hiredman

16:10 hiredman: ,:foo.bar

16:10 clojurebot: :foo.bar

16:10 hiredman: ,*clojure-version*

16:10 clojurebot: {:major 1, :minor 8, :incremental 0, :qualifier nil}

16:34 TimMc: ,(keyword ":")

16:34 clojurebot: ::

16:46 sdegutis: Does something like distinct-by make sense?

16:47 So that (distinct-by first [0 :a] [0 :b] [1 :c]) would -- oh wait

16:47 Hmm. Guess I need to transform my data.

17:29 Bye.

17:38 What's an agreeable way to tell if any item in a collection satisfies a given predicate?

17:38 Something like (any? coll f)

17:39 cfleming: sdegutis: (some f coll)

17:39 sdegutis: Hmm, strange name.

17:39 Thanks Colin.

17:39 I had a feeling that was the function, but it seemed like maybe I was going insane.

17:39 justin_smith: ,(some nil? [false nil true])

17:40 clojurebot: true

17:40 sdegutis: Thanks Justin.

17:40 justin_smith: heh, just reminding myself how it behaved

17:41 sdegutis: Hmm. Interesting.

17:42 Our data is just so... actually, no, there aren't words to describe it.

17:48 cfleming: so how's your IDE going?

17:49 cfleming: sdegutis: It's going really well.

17:49 Lots of free non-commercial licences gone out, but lots of people paying for it too.

17:50 So it's definitely looking sustainable at this point, assuming a reasonable number of people renew and some growth in the community.

17:50 sdegutis: cfleming: So has it become a full time gig now?

17:50 cfleming: Yeah, it has been for a while now.

17:50 sdegutis: Sweet.

17:50 I like your icons of companies who use it on your home page. That's a clever idea.

17:51 cfleming: I'm just getting back to development in the last couple of weeks after the support spike after releasing.

17:51 sdegutis: Yikes, that sounds like it was really boring.

17:51 cfleming: Thanks! I think a lot of companies do that for their products. Lots of companies don't allow use of their logo, sadly.

17:52 Yeah, that and licensing, EULAs, payment systems, etc etc - I haven't done much real work since October/November.

17:54 ben_vulpes: 'real work' heh

17:54 cfleming: Yeah, none of the rest feels like real work, it's all necessary though.

18:09 cortexman: i'm trying to figure out how to link my cljs buffer with my ClojureScript REPL in emacs

18:13 supposedly it's C-c M-J (capital J) but it doesn't seem to hook up correctly

18:15 sdegutis: cfleming: I hear ya, I'm only recently getting back into being really productive.

18:23 rhg135: productivity is a lie

19:19 Kamuela: rhg135: lol

20:02 sdegutis: So I guess ->> can't see on the inside of #() special forms.

20:02 ,((->> [1 2 3] (map inc) #(apply +)))

20:03 clojurebot: #error {\n :cause "Wrong number of args (1) passed to: core/apply"\n :via\n [{:type clojure.lang.ArityException\n :message "Wrong number of args (1) passed to: core/apply"\n :at [clojure.lang.AFn throwArity "AFn.java" 429]}]\n :trace\n [[clojure.lang.AFn throwArity "AFn.java" 429]\n [clojure.lang.RestFn invoke "RestFn.java" 412]\n [sandbox$eval25$fn__26 invoke "NO_SOURCE_FILE" 0]\n [sandbox...

20:04 sdegutis: Ever notice that?

20:07 justin_smith: ,(macroexpand '((->> [1 2 3] (map inc) #(apply +))))

20:07 clojurebot: ((->> [1 2 3] (map inc) (fn* [] (apply +))))

20:09 justin_smith: ,(macroexpand '(->> [1 2 3] (map inc) #(apply +))) ; sdegutis - this makes it pretty clear what happens

20:09 clojurebot: (fn* [] (apply +) (map inc [1 2 3]))

20:25 rhg135: ,'#()

20:25 clojurebot: (fn* [] ())

20:29 TimMc: ,(-> foo #(inc 5) ())

20:29 clojurebot: #error {\n :cause "Can't call nil, form: (nil (fn* foo [] (inc 5)))"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.IllegalArgumentException: Can't call nil, form: (nil (fn* foo [] (inc 5))), compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyzeSeq "Compiler.java" 6875]}\n {:type java.lang.IllegalArgumentException\n :message "Can't call nil, fo...

20:29 TimMc: mmm, right

20:29 also, interesting

20:30 ,(macroexpand-1 '(-> 4 ()))

20:30 clojurebot: (nil 4)

20:33 rhg135: What?

20:33 clojurebot: What is sampling a random integers betwen 2, 12 s..t. P(X = i) = (7-|i-7|)/36

20:34 rhg135: Right?

20:39 justin_smith: what a card

20:41 rhg135: I know. clojurebot is so funny and smart and cool

20:42 justin_smith: I just wish clojurebot would stop stealing my girl.

20:43 TimMc: rhg135: The macro sees a list and does (cons (first list-form) (cons inserted-form (rest list-form))) or something

20:43 which is (cons nil (cons 4 ())) in this case

20:43 rhg135: Ah

20:44 justin_smith: who is your girl?

20:44 TimMc: https://github.com/clojure/clojure/blob/clojure-1.7.0/src/clj/clojure/core.clj#L1564 yep, except it's using unquote-splicing

20:45 justin_smith: rhg135: sadly "my girl" is a rhetorical phrase used for comical effect

20:47 rhg135: Ah, those love triangles

23:48 sdegutis: Hi.

23:48 I forgot why I opened IRC, but here I am.

Logging service provided by n01se.net