This is a mix of great advice, things that are hopefully obvious, and a few terrible ideas just to spice things up. In particular the example of (comp str/capitalize str/trim) being labeled as “hard to read” compared to the lambda version is just bizarre, and the convention of marking reference types with * “because it resembles C/C++ pointers” would be a huge red flag if I saw it during code review. Adding in extra newlines sounds like a great idea if you always work plugged into an external display or two but shows a disregard for your colleagues who may prefer to work from a laptop.
(comp str/capitalize str/trim)
I thought the * prefix was interesting in that it offers up a solution to naming references. I find it difficult to name references something other than the thing they point to.
I think you could make a case for a special naming convention for top-level def reference types, but it’s not helpful when it’s a local, which hopefully is the more common case.
I had similar thoughts. It seems peculiar to offer a recommendation “Avoid higher-order functions” in a functional language.
The article did put me in mind of Stuart Sierra’s series of posts Clojure Dos and Don’ts. I also like How to Name Clojure Functions.
Regarding the recommendation to replace the threading macro with a let: an advantage (for me) of the threading macro, is that it’s immediately clear that the result of a function is not used again. It’s a temporary value that doesn’t matter after the next function in line has been called. In a let you have to scan the surrounding code to see how the value is used.
As an aside: I quite dislike that the code examples are images without alt text.
Also, avoiding the threading operator just to obscure the computation going on with some (probably badly) named steps (remember, naming is hard) is not the best.
At work we used ->> a lot, because it both frees you from giving strange names to intermediate computation results and allows you to plug in whatever function you want to intercept the computation without having to rewrite your code.
If we’re going to keep using the lisp tag for Cloure posts can we switch to using the Fortran tag for all other languages?
Remember the tags are a means to an end. How many people are interested in Clojure articles and not interested in other articles with the lisp tag? How many people want to hide one and not the other? Whereas e.g. I hide articles about go becasue they annoy me, but wouldn’t want to hide articles about other algol-family languages.
At least two.
Clojure is different enough from the other lisps that I usually don’t waste time reading articles about it.