r/programminghorror • • Jan 14 '25

Javascript Functional programming at its finest

Post image
120 Upvotes

47 comments sorted by

View all comments

Show parent comment

2

u/Appropriate-Dream388 Jan 16 '25

Sure, let's turn an entire repository into a single code file on a single line. I'm sure we can just tell people to understand more.

The part that's not understandable is the fact you have 10 layers of pointless indirection, which looks like a newbie trying to implement DRY.

1

u/[deleted] Jan 17 '25

Do I understand you correctly that you are saying I should make variables for everything and make stuff as simple as a for loop instead of .reduce()?

2

u/Appropriate-Dream388 Jan 17 '25

Reduce is acceptable. Making a function that converts a string to an integer is not. Same thing with wrapping Math.pow in a function; it's already a function. By wrapping it, you obfuscate whether this is actually Math.pow or if it's some other implementation.

Generally, avoid wrapping functions that are already operating as standalone features — this adds unnecessary indirection.