4 ms·
The lesson for me is that this particular problem is exceptionally well suited for imperative code, and makes functional code look terrible in comparison. It's
by OskarS 6y ago
The lesson for me is that this particular problem is exceptionally well suited for imperative code, and makes functional code look terrible in comparison. It's not just the "Python-likes" that do well: both the C and C++ code (C++ in particular) are very straightforward, simple and very readable, but any functional language solution that uses reduce or whatever looks terrible in comparison.
The striking example is the JavaScript one: the simple imperative solution (for_of.js) is perfectly fine and lovely, but the other ones (map_with_state.js in particular) are total nightmares. Most of them are (almost certainly) significantly less performant than the simple imperative ones.
Not all problems are like this, of course, there are many examples where functional style code shines. But certainly there are many problems like this one, where imperative code is just the superior paradigm.
- Scarbutt 6y agoThe lesson for me is that this particular problem is exceptionally well suited for imperative code, and makes functional code look terrible in comparison. This is the case for 80% of real world code in IME.
- higerordermap 6y agoAs long as there aren't too many variables keeping state, imperative should be fine.