News for hackers. Stuff that matters.
Re:Clojure Don’ts: Lazy Effects (2015) by djtango on Saturday March 03, 2018 @09:39AM (#16509419)
This is a sound article - Clojure's laziness is often a source of common gotchas for new users of the language.

It's often not clear what is lazy and what isn't - concat is lazy for instance. It isn't externally obvious which of the very common operations are lazy, filter being lazy has bitten me in CLJS a few times too.

Adding to the source of the confusion is that the REPL will often realize your side-effects which then won't get evaluated in your runtime environment.

One of the errors I used to make earlier on was:

    (map insert-into-db table-rows)
Re:Clojure Don’ts: Lazy Effects (2015) by serpix on Saturday March 03, 2018 @05:19PM (#16511996)
always mapv when doing I/O on the backend and always extra vec when returning sequences in the frontend
Re:Clojure Don’ts: Lazy Effects (2015) by joncampbelldev on Saturday March 03, 2018 @05:52PM (#16512182)
run! and doseq are for IO on each element of a sequence. Functions like mapv are intended for data transformation, not side-effects. This is why run! and doseq return nil
Re:Clojure Don’ts: Lazy Effects (2015) by djtango on Monday March 05, 2018 @05:22PM (#16525090)
I don't often find myself doing sequential side effects so often anymore, but when I do doseq has been my go to, though I will confess I didn't know about run! until this thread.