Skip to content

Loops vs Array Methods? #14

@r002

Description

@r002

Hi! Thank you for writing this book! 🙏 I consider myself an intermediate programmer but there's always so much to learn! Am glad to stumble across your writings! (Someone I follow starred your repo! 😀).

I've been reading:
https://github.com/sapegin/washingcode-book/blob/master/manuscript/Avoid_loops.md

and see that you're a big fan for map and filter. I remember when I first learned about these functions, they seemed incredibly spiffy too. 🚀

But this past year I've been recently diving into other languages though and there are other well-known/famous programmers like Guido in Python who discourage/strongly dislike map/filter/reduce (famous article) as well as Rob Pike (co-creator of Go) who really hates map/filter/reduce.


Quoting Rob Pike:

image


From your article, I see you dislike reduce (Guido does too!) but with Python, we at least have list comprehensions so I can understand Guido's reasoning. But with Go-- Pike, et al, really went out of their way to completely banish array methods from the entire language (including map and filter).

Is your book only for JavaScript? I guess I'm just confused bc I'm currently learning Go and the language outright bans array methods and ternary operators (which I see you also use a lot).

(Though in the Preface, you say you can apply your ideas to any language though?)

Also: Do you recommend array methods in JS specifically only for JS frontend because the nature of the domain is a good match for it? (Like, if someone is programming in node.js, doing backend work, would you also recommend array methods?)

I guess I'm just trying to get to the root of the reason why different really smart people have such vastly different (and strong!) opinions re functional programming (and constructs/idioms like array methods). Is it simply because their domains are so different? (Ie. Go is for massively distributed, concurrent programming, monolithic industrial-strength/professional grade/unglamorous use cases and JS is for ...more artisanal/beautiful/built-by-the-TC39-committee-and-needs-to-appease-many-stakeholders use cases?)

Or is there more to it? Thank you for sharing your thoughts! 🙏🙏🙏

PS. Btw, if you don't want to clog up your Issues trackers, GitHub now has a Discussions tab that you can enable! 🙂

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions