3 ms·
It depends on how much knowledge you need to read each line. The other factor is how much work the code does. When it comes to Clojure or any kind of functiona
by Cthulhu_ 5y ago
It depends on how much knowledge you need to read each line. The other factor is how much work the code does.
When it comes to Clojure or any kind of functional language or construct, those describe the "what"; what is the author trying to do, what should the code do.
If you go for imperative code, it quickly becomes more about the "how". Loops are a great example; in functional languages and constructs, you say "filter, then map, then reduce". In an iterative language, you say "Create a variable I, then start a loop, check if it's below length of list, increment, get element I from list X", etc, you get the idea.
The functional approach has a definite advantage here because - as long as you understand the language and constructs - it hides the implementation details and the exact approach to execution. A functional approach under water can transparently parallelize the request, even going as far as it becoming a distributed hadoop map/reduce job. Can't do that with a for loop.
Anyway, I forgot where I was going with this. The 20 lines can be fine if the one-liner is complicated.