this post was submitted on 15 Sep 2026
34 points (100.0% liked)
Programming
28522 readers
828 users here now
Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!
Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.
Hope you enjoy the instance!
Rules
Rules
- Follow the programming.dev instance rules
- Keep content related to programming in some way
- If you're posting long videos try to add in some form of tldr for those who don't want to watch videos
Wormhole
Follow the wormhole through a path of communities !webdev@programming.dev
founded 3 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Reduce is harder to read. Maps and filters are deeply simple. The problem space a reduce can solve is, I'm pretty sure, strictly larger than both of them. Its generality is its downfall.
I'll happily use a reduce, but it has to be either as a well named function or immediately stored in a well named variable. If the reduce is complex enough that you can't name it, that's a smell to me, reach for a different tool.
Absolutely. I've used many reduces that I later regretted. It's powerful, but also too cryptic.
And reduce has hidden performance risks. I've seen reduce used where the collector was assembled with a spread operator. But that's a loop within a loop, and can get very expensive. A simple forEach loop and just appending the new value in old fashioned ugly pedestrian imperative code, does not carry that risk.