I tend to prefer the functional version to threading because (1) honestly, like fluent interfaces, it seems overused (2) function application is damn easy to read and (3) as soon as you have as many nested operations, it can and should be refactored into meaningful auxiliary functions. The first line reads as:
Multiply all ... 4 copies of ... the length of ... the string "200". So, basically, the length of that string multiplied by itself 4 times? (exponent).
The other form is more like step-by-step instructions, which is nice. However results are implicitly being passed at the first or last argument (I don't always remember which), and most everyday functions don't fit in the first/last category.
(->> (range 10)
(map inc)
(filter even?)
(take 2)) ;=> '(2 4)
or (-> {:body {:some {:json :data}}}
(assoc-in [:body :some :more-json] :more-data)
(assoc :status 200)
(update :body json/generate-string))
;;=> {:body "{\"some\":{\"json\":\"data\",\"more-json\":\"more-data\"}}", :status 200}
It doesn't work all the time, obviously, and it can be easy to get carried away with 15 threaded map/filter/reduce calls that should be factored into separate functions, but most of the time I find it to be a nice idiom that substantially improves readability.[1]: http://lambda.jstolarek.com/2012/03/function-composition-and...
Would it not be possible to do something similar in another functional language to take a <pipe function> and apply it sequentially to a list of function calls?
An example is that I use Clojure Refactor Mode (with CIDER) for emacs. A trick (and treat) that a lot of Clojure code uses is the arrow macros: -> and ->>. Clojure Refactor Mode has thread-first, thread-first-all, thread-last, thread-last-all and unwind. Since I've committed those to my long term memory, I can just call thread-first-all on something like:
and get: This is so huge, because many times changing the levels of threading makes reasoning about the code so much easier.