3 ms·
I lean towards closures having primacy. FTR, I learned OOP way before I'd ever heard of functional programming. My reasoning is based on two things: Firstly, o
by Quekid5 6y ago
I lean towards closures having primacy. FTR, I learned OOP way before I'd ever heard of functional programming.
My reasoning is based on two things: Firstly, objects have identity and this is a superfluous notion for most cases. Functions just "do things" to their inputs and return the result. Secondly, OOP is fundamentally predicated on the notion of mutation[0], but I think that is totally antithetical to local reasoning (chunking). The latter may just be a preference, but IME it seems to bear out. Mutation seems to be a consequence of the focus on identity, now that I think about it after writing that footnote.
> I couldn't really understand the idea that they were fundamentally new compared to objects (in fairness this was only put forth by a few people)
Just a historical note: First-class functions were invented waaaaay before OOP was a gleam in somebody's eye.
[0] The only non-mutating OOP system I know of is O'Camls version of OOP, but it's not very popular because it's just... unnecessary. It also does away with "identity", now that I think about it.
- 7786655 6y agoIn Javascript, closures both have identity and are mutable, which is a huge pain when using React.
- Quekid5 6y agoI realize I was quite off-putting in my original reply, but "have identity" in what way, exactly? A memory address?
- Quekid5 6y agoJS... the "winner" of the Accidental Complexity game. (It was made in a couple of weeks, so it's excusable, but... it just hurts so much that this was the language that conquered the web :| )
- eitland 6y agoYes, and realizing there is probably a larhe subset of people who'd say they love JS but hate PHP can make a man who know both too well confused. Or at least aware of the hypocrisy ;-)
- jchw 6y agoTo be fair, PHP5 really was quite a nightmare for honestly a lot of reasons that JS was never. I think most people remember PHP5 and compare it to fairly modern JS, but I must say, modern PHP is a lot better than older PHP (i still prefer just about anything else.)
- eitland 6y agoTotally agree. But comparing modern Javascript to ancient PHP would be even more unreasonable.
- jchw 6y agoYes, to be clear, I agree. I think most people just don’t realize PHP actually did improve. I’ll admit until digging into a modern PHP library I didn’t even believe it could be meaningfully better.
- ss3000 6y agoI would say the biggest JavaScript inflicted pain when working with React is the lack of a notion of value equality in the default mutable collections. Coming from a ClojureScript background, it pains me to have to deal with all the idioms in React that hack around this fundamental impedance mismatch by forcing users to carefully maintain reference equality for collections between renders for perf optimizations, and more recently for correctness in hooks like useEffect.