Fork me on GitHub
#clojure-uk
<
2018-11-09
>
mccraigmccraig07:11:54

måningyåls

😄 4
dominicm07:11:16

Morning 🙂

thomas08:11:57

morning! TGIF!!!

🙌 8
folcon10:11:58

Morning 😃

alexlynham12:11:54

I’ve noticed something weird in my clojure code

alexlynham12:11:14

I seem to almost always use merge rather than update-in… an after the fact rationalisation being maybe that it’s super obvious you get a new thing back, but… well, duh it’s clj. on a scale of 1-very dumb:tm: how bad is this habit?

mccraigmccraig12:11:10

i often use merge @alex.lynham rather than update - in some circumstances i find the intent clearer

👍 4
maleghast12:11:36

X-Posted from #jobs : Hello Community! As well as the Front End focused job that we still have open - https://s3-eu-west-1.amazonaws.com/cervest-public/Cervest-JobDescription%E2%80%93SeniorFrontEndEngineer.pdf - we also now have a Back End, more Senior role open; basically someone to come in and work with me on the Infrastructure / Platform side of things. Here's the Job Description -> https://s3-eu-west-1.amazonaws.com/cervest-public/Cervest-JobDescription-SeniorSoftwareEngineer-Clojure.pdf Please take a look at our new website -> https://cervest.earth <- and have a think about how great it would be to program in Clojure / Clojurescript all the time AND make the world a better place... 🙂

maleghast12:11:09

Please poke people, particularly people from less well represented communities 🙂

folcon13:11:57

@alex.lynham @mccraigmccraig Actually how often do you use things like kibit? I generally optimise for readability, but I do wonder whether I should try taking some of the more sluggish apps that I’ve written and do a deep dive and swap out parts of it for performance.

folcon13:11:12

sorry the merge vs update got me thinking…

mccraigmccraig13:11:24

i've never used kibit!

mccraigmccraig13:11:03

well i have now... i ran it on yapster's cassandra module, and it wasn't too bad

folcon13:11:46

Yea, I’ve been wondering there’s a use-case for submitting performance based suggestions as well… X is known to be faster than Y sort of thing…

mccraigmccraig13:11:55

dunno - a lot of the suggestions were things like prefer (into {} (for [x y] (f x))) over (->> (for [x y] (f x)) (into {})) and while i can see the point i don't agree with it, 'cos the latter pattern stays the same when the processing pipeline gets longer and i do even find the threaded version easier to parse, so i'm a bit meh on kibit now

minimal13:11:19

yeah kibit is a bit meh because you can’t configure its opinions

folcon13:11:34

So profiles?

alexlynham14:11:28

that’s interesting. If anything I probably over-use -> and ->> because they make almost anything easier to read

alexlynham14:11:51

even a noddy thing like (replace (trim "my &string ") #"&" "")

alexlynham14:11:12

(think that’s the right arg order 😛)

mccraigmccraig14:11:58

i'm not sure a macro which makes everything easier to read can be over-used @alex.lynham

👍 8
alexlynham14:11:06

reads better as

(-> "my &string"
    trim
    (replace #"&" ""))

jasonbell14:11:11

@alex.lynham I think you need a Java shiv for that 🙂 `String newString = s.trim().replace(“&”, “”); 😉

alexlynham14:11:19

haha yeah good point

alexlynham14:11:13

like, to use an actual example in my current emacs buffer

(->> @remaining-coll
     (drop 1))

mccraigmccraig14:11:15

playing the "from my current emacs buffer" game:

(defn export-analytics-tables
  [cassandra filename-prefix fmt org]
  (let [[org-id] (t/extract-uber-key-value org.ents/Orgs org)]
    (->> (for [tx tables-to-export]
           (export-org-table cassandra
                             filename-prefix
                             (str "." (name fmt))
                             org-id
                             (assoc tx :fmt fmt)))
         (apply d/zip))))

alexlynham14:11:51

sounds next level

alexlynham14:11:45

like a key, but…

mccraigmccraig14:11:25

the uberkey is the most-primary primary-key from a group of cql tables around one entity

alexlynham14:11:22

there can be only one

mccraigmccraig14:11:19

there can be only one per entity

otfrom14:11:02

I'm loving lein var-graph

otfrom14:11:21

I'm using it to help tidy up a code base

otfrom14:11:29

I like kibit, eastwood, and joker

otfrom14:11:38

but I don't necessarily always follow the advice

otfrom14:11:21
replied to a thread:I'm loving lein var-graph

I'm using it to help tidy up a code base

rickmoynihan16:11:18

> I seem to almost always use merge rather than update-in @alex.lynham update was “recently” added in 1.7… so that would be more equivalent to update. I’m probably guilty of using merge for this in the past, though I’d say use merge when you’re updating multiple values (or doing so across more than 2 maps)…. so perhaps it’s a bad habit of mine you picked up? 🙂 What I normally find myself doing is (assoc old-map :foo :bar), where :foo is expected to exist, and I’m stomping it, with a value that is actually derived from the old :bar. When I see that I tend to try and use update; as the intent is arguably clearer, even if there’s sometimes a bit more syntax with it involving a function… i.e. assoc for new values, update for “changing” existing/derived ones.

alexlynham16:11:15

yeah that’s very true

alexlynham16:11:31

like I say, I suspect I rationalise it after the fact

alexlynham16:11:39

maybe I did pick it up from your code! haha

mccraigmccraig16:11:58

i quite like the (merge old-map (when X {:foo :bar}) (when Y {:baz :quux}))) pattern - it makes conditional updates very clear

rickmoynihan22:11:34

Yeah I’ve been quite partial to that one too :thumbsup:

alexlynham16:11:31

I think I quite often do if-let then merge

alexlynham16:11:42

or let cond merge

alexlynham16:11:56

(if there are multiple cases that is)

Ben Hammond16:11:11

(medley.core/assoc-some would my tool of choice

mccraigmccraig16:11:08

plumbing had assoc-when which was the same thing... i kinda slowly stopped using it though - i find the merge clearer, the condition is more general (than just some? value) and priority is clearly defined

alexlynham16:11:02

🐍 🥫 I appear to have opened quite the can

jasonbell16:11:54

It’s a Friday…. you’re forgiven, well by me but I can’t speak for everyone else 🙂

mccraigmccraig16:11:58

i'm always up for a good idiom battle

mccraigmccraig16:11:33

and the coding part of my brain seems to have given up the ghost today

alexlynham17:11:43

I’m trying (in vain) to track down one last buglet

3Jane17:11:54

https://twitter.com/bodil/status/1060935752857591808?s=21 How error messages could be reported

❤️ 8
😆 8
jasonbell17:11:49

I’ll stick with (.printStackTrace e) so I can see line numbers 🙂

3Jane17:11:59

(Sorry for the drive by linking, I’m running out of battery ‘:)

3Jane19:11:50

I’m alive… just XD And pulled together all the funny pics from the conference in here; it’s barely on-topic since we had one Clojure talk! (the one on ClojureCUDA/Neanderthal/Bayadera kit) https://twitter.com/i/moments/1060980969195347969

👍 8
danm20:11:41

Clojure on the GPU, nice

danm20:11:14

Presumably that compiles down to something else then? Or is it just using clj to manage the CUDA (C?) that's actually running on the GPU?

3Jane20:11:38

So we didn’t get to see the guts of the libraries, but rather the process of putting something together

3Jane20:11:03

For ClojureCUDA, the bits that actually do something (called kernels) are still written in C (apparently because what you’d put in there looks very much the same in C as in Clojure, so you wouldn’t get any Clojure-specific benefits and translating from Clojure to C would just introduce an opportunity for bugs to creep in)

3Jane20:11:08

(where “doing something” means the individual numerical calculation, like adding three integers or whatnot)

3Jane20:11:16

and the library itself provides a convenient wrapper. The same for OpenCL I think.

3Jane20:11:32

And then Neanderthal and Bayadera provide increasing levels of computational complexity using the previous ones as a base. (Neanderthal being your BLAS/LAPACK equivalent, and Bayadera for Bayesian data analysis)

3Jane20:11:57

so it’s a very logically built up stack, which I can appreciate even though it’s totally not my specialty right now 😉 (and I dearly hope I didn’t misrepresent anything XD )