4 ms·
I think you missed Tim's point. A better analogy might be duplicating code vs writing a function once and reusing it. Hand-written recursion with the operation
by barrkel 16y ago
I think you missed Tim's point. A better analogy might be duplicating code vs writing a function once and reusing it. Hand-written recursion with the operation inlined is not usually very reusable (i.e. composable); however, if you factor out the recursive traversal and parameterize it by the operation to be performed, it composes much better. But at that point you're writing a library routine, rather than logic specific to the task at hand.
(As an aside: in my way of thinking about software design, generic library code is "free" - it doesn't count towards the number of lines of code for the actual task being solved. I try to make as much of the software that I design library-like, and the core of the app not a lot more than composing these pre-fabricated bits, as possible, potentially even to my detriment in short-term productivity. But this approach handles scale much better, in my experience.)
- deleted 16y ago[deleted]