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.
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.
But comparing modern Javascript to ancient PHP would be even more unreasonable.
When I write these sometimes-overly-simplified-articles I'm terrified of explaining something wrong, or that my knowledge may be incorrect on a very specific point.
I really like the way you express "everything is a first class 'thing'", I never thought of it that way.
"As I read articles and tried stuff out (and broke my server config more than once) I started to grasp the system, to get glimpses into how it all worked, until eventually it “clicked” and I felt comfortable working with it."
Have you written about your mental models for DNS? Color me interested!
Out of all the questions my students ask me, there's always confusion about the way servers talk to each other, or what they even are.
I'll definitely write about this now haha. Thank you for the idea :)
However, there is the concept of a pure function (one that is unaffected by and causes no side effects) which I think can be argued is fundamentally different.
But either way it works fine. Everything is a first class 'thing' that has properties that can be parameterised. If the 'thing' is an object the properties are alive and can be mutated (if mutable) for the lifetime of the object. If the 'thing' is a function the properties (arguments and local vars) are alive for the duration of the call.
When first class functions became mainstream though, 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)