r/programming • • May 25 '17

Readable Clojure

http://tonsky.me/blog/readable-clojure/
42 Upvotes

35 comments sorted by

View all comments

11

u/maestro2005 May 25 '17

I disagree strongly with wrapping things in redundant some?/none? checks. (when thing ...) is entirely idiomatic and you should get used to reading it.

I agree that sometimes excessive comp/partial usage can be hard to read, but his example is bad:

(map (comp str/capitalize str/trim) strings)

Anyone who calls themselves competent in clojure should easily read this as "capitalize and trim the strings". This is actually a perfect use of comp. The benefit of comp/partial is that you avoid creating a new function, which creates a new reference frame and introduces a variable just to pass it along to another function.

Even as experienced Clojure programmer I haven’t developed a skill to parse such structures easily.

Then you're not really that experienced.

6

u/quicknir May 25 '17

Not a clojure programmer, just do some elisp, but reading the article and your comment I agree with your comments. I was rather shocked to see "Avoid higher-order functions" as a header in an article about clojure.

4

u/[deleted] May 25 '17

I've never seen that suggestion before in several years of Clojure dev fwiw. The "Don’t rely on implicit nil-to-false coercion" & the "Avoid higher-order functions" suggestions are pretty atypical.