This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-11-09
Channels
- # aleph (3)
- # beginners (327)
- # calva (3)
- # cider (20)
- # cljdoc (59)
- # cljs-dev (40)
- # clojure (104)
- # clojure-dev (30)
- # clojure-italy (8)
- # clojure-nl (36)
- # clojure-russia (3)
- # clojure-spec (3)
- # clojure-uk (79)
- # clojurescript (54)
- # community-development (5)
- # cursive (28)
- # data-science (21)
- # datomic (35)
- # emacs (14)
- # expound (1)
- # figwheel (2)
- # figwheel-main (82)
- # fulcro (18)
- # graphql (13)
- # jobs (12)
- # jobs-discuss (38)
- # kaocha (8)
- # lambdaisland (1)
- # lumo (12)
- # off-topic (20)
- # onyx (4)
- # re-frame (51)
- # reagent (12)
- # reitit (8)
- # ring-swagger (1)
- # shadow-cljs (22)
- # slack-help (2)
- # spacemacs (6)
- # specter (16)
- # testing (3)
morning
morning!
I’ve noticed something weird in my clojure code
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?
i often use merge
@alex.lynham rather than update
- in some circumstances i find the intent clearer
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... 🙂
@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.
i've never used kibit!
well i have now... i ran it on yapster's cassandra module, and it wasn't too bad
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…
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
that’s interesting. If anything I probably over-use ->
and ->>
because they make almost anything easier to read
even a noddy thing like (replace (trim "my &string ") #"&" "")
(think that’s the right arg order 😛)
i'm not sure a macro which makes everything easier to read can be over-used @alex.lynham
reads better as
(-> "my &string"
trim
(replace #"&" ""))
@alex.lynham I think you need a Java shiv for that 🙂 `String newString = s.trim().replace(“&”, “”); 😉
haha yeah good point
like, to use an actual example in my current emacs buffer
(->> @remaining-coll
(drop 1))
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))))
uberkey?
sounds next level
like a key, but…
the uberkey is the most-primary primary-key from a group of cql tables around one entity
there can be only one
there can be only one per entity
whence?
I'm using it to help tidy up a code base
> 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.
yeah that’s very true
like I say, I suspect I rationalise it after the fact
maybe I did pick it up from your code! haha
i quite like the (merge old-map (when X {:foo :bar}) (when Y {:baz :quux})))
pattern - it makes conditional updates very clear
Yeah I’ve been quite partial to that one too :thumbsup:
I think I quite often do if-let
then merge
or let
cond
merge
(if there are multiple cases that is)
(medley.core/assoc-some
would my tool of choice
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
🐍 🥫 I appear to have opened quite the can
i'm always up for a good idiom battle
and the coding part of my brain seems to have given up the ghost today
I’m trying (in vain) to track down one last buglet
https://twitter.com/bodil/status/1060935752857591808?s=21 How error messages could be reported
Also, useful if you want to save some money: https://twitter.com/manningbooks/status/1060551265367846912?s=21
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
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?
So we didn’t get to see the guts of the libraries, but rather the process of putting something together
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)
(where “doing something” means the individual numerical calculation, like adding three integers or whatnot)