5 ms·
What got me to stop using reduce was when I and another sr. held a theoretical "gun" to a jr devs head and asked him what a block of code involving reduce did a
by virtue3 3y ago
What got me to stop using reduce was when I and another sr. held a theoretical "gun" to a jr devs head and asked him what a block of code involving reduce did and they didn't have a clue. They were pretty bright; so I just threw it the towel at it being useful to the health of a large codebase after that.
Still love map. But reduce can feel very "code golf" real quick.
- yakshaving_jgt 3y agoI’m confused. Do you not think that would have been a good opportunity to teach that person what folds are for? Fold/reduce is fundamental. It’s weird to me that its use would be discouraged or outlawed somewhere.
- jrockway 3y agoIf your language has a `for` keyword, I would just say use the `for` keyword.
- yakshaving_jgt 3y agoBut why? The language I use has various flavours of `for`. It also has various flavours of map and fold. It also has recursion. They each do different things. Those differences are meaningful and useful. Why would you limit yourself to just using `for`?
- izietto 3y agoIt depends. It isn't the case for Ruby, for example.
- thesnide 3y agoSo. That. https://blog.pwkf.org/2022/09/18/always-optimize-for-dummies.html https://blog.pwkf.org/2022/09/18/always-optimize-for-dummies... "Easy to read" means "easy for others". Current efficiency is usually borrowed on future one.
- tacitusarc 3y agoWhich junior devs?