5 ms·
Whenever I read "modern" javascript code, I'm irritated by the prolifiration of map/filter/reduce. It makes code harder to read and modify. A straight for loo
by hsn915 5y ago
Whenever I read "modern" javascript code, I'm irritated by the prolifiration of map/filter/reduce.
It makes code harder to read and modify.
A straight for loop is infinitely better in every way.
- hiptobecubic 5y agoThis debate is basically just "I learned C first" vs "I learned a higher level language first."
- konart 5y agoMy learning path was Logo->Basic->Pascal\Delphi->PHP->Python->Ruby and then Go. With some of js here and there. I don't really think it has much to do with you language path but rather with the field you are working most of the time. People who are building Rails startups for sale will have opinion different from people who build some sort of integration systems.
- silisili 5y agoDisagree. I used Python heavily before Go, and Go is much, much easier to read. I've never seen Go code in any codebase I couldn't immediately follow. I can't say the same about Python, and that's supposedly an easier HLL. Then again, I learned BASIC first technically, so my brain probably isn't quite right :).
- hiptobecubic 5y agoNeither Go nor Python are languages that encourage composing functionality out of higher order functions, so I think the point stands.
- pjmlp 5y agoC is high level, many just think it isn't. DDJ had quite a few articles on how to do Lisp-in-C kind of thing.
- laumars 5y agoYou’re a bit quick to comment there because the GP said “highER”. ie another language that is a highER level than C. So technically their post is correct
- pjmlp 5y agoC provides the tooling to implement many of the necessary abstractions as libraries, hence why I pointed to the DDJ articles. You can even plug a conservative GC for the full Lisp like experience.
- hsn915 5y agoI learned C first but then I rode the functional bandwagon (and dynamic languages) and spent many many years in Python and Javascript. I thought map/filter was much better than imperative for a long time. I rediscovered imperative programming later and found it to be such a breath of fresh air.
- BurningFrog 5y agoIt's a bit messy in JS. In Ruby the map/filter/reduce handling is very smooth, readable and useful!
- dragonwriter 5y ago> It's a bit messy in JS. Mainly, IME, because of the combination of JS map, etc., passing extra, infrequently used parameters, and functions you might want to use often accepting optional less-frequently-used parameters, which can end up interacting horribly wrong when you do: arr.map(func) instead of: arr.map(v => func(v)) when you want a “simple” map application.
- dragonwriter 5y agoI find map/filter/reduce much easier to read if it is being used for a functional map, filter, or reduce operation or something not too distant from it. > A straight for loop is infinitely better in every way. A straight for, for-of, or for-in loop, as appropriate, is finitely better for imperative operations that don't naturally fit map/filter/reduce but need to be performed over some set of values.