3 ms·
Most non-functional languages will implement map/filter/reduce as loops under the hood, but realizing that there is an abstraction for general sequence processi
by yomly 8y ago
Most non-functional languages will implement map/filter/reduce as loops under the hood, but realizing that there is an abstraction for general sequence processing frees you up to focus more on the core business logic at hand and reduces the surface area of your code for bugs.
Sure, handrolling a loop is a trivial activity that novice programmers can figure out, so you should _never_ get it wrong because you _never_ ever program tired or hurriedly under deadlines or make typos or input off by ones...
- AnimalMuppet 8y agoI don't recall exactly how many handrolled loops I've messed up in the last 10 years, but the number is either 1 or 2. Could I mess up one or two map/filter/reduces in 10 years? Is it impossible to mess them up? What about the cases they don't cover, so you use your own recursion?
- jodrellblank 8y agoOK you can write a handrolled loop almost perfectly. /Why/ are you writing ten years worth of loops - something a computer can do for you?
- AnimalMuppet 8y agoCan it? I'm working on embedded systems, in C++, with C++11-or-earlier compilers. Sometimes I need control of the exact order things happen in. Sometimes I need an action to occur either zero or one times, on the first available entry. Always I need to write code that my coworkers can read. How much of that can a C++11 compiler do for me?