by DavidPiper · 1y ago · 0 comments
> I prefer to write code in a verb-oriented way not an object-oriented way. ... It also has to do with what type of system you're making: whether people are going to be adding types to the system more frequently or whether they're going to be adding actions. I tend to find that people add actions more frequently.
Suddenly clicked for me why some people/languages prefer doThing(X, Y) vs. X.doThing(Y)
Unified function call: The notational distinction between x.f(y) and f(x,y) comes from the flawed OO notion that there always is a single most important object for an operation. I made a mistake adopting that. It was a shallow understanding at the time (but extremely fashionable). Even then, I pointed to sqrt(2) and x+y as examples of problems caused by that view.
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p19...
Ocaml example:
let increment x = x + 1
let square x = x \* x
let to_string x = string_of_int x
let result = 5 |> increment |> square |> to_string
(\* result will be "36" \*)But he still has a preference for f(x,y). With x.f(y) gives you have chaining but it also gets rid of multiple dispatch / multimethods that are more natural with f(x,y). Bjarne has been trying to add this back into C++ for quite some time now.
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n44...
It's when you start writing ThingDoer.doThing(X, Y) that you begin questioning things.
https://steve-yegge.blogspot.com/2006/03/execution-in-kingdo...
Ada, Julia, Dylan, Common Lisp for example.
Yet another example why people shouldn't put programming paradigms all into the same basket.
(also Common Lisp is hardly a poster child of OOP, at best you can say it's multi-paradigm like Scala)
https://shawnhargreaves.com/blog/visitor-and-multiple-dispat...
Since when do OOP languages have to be single paradigm?
By then point of view, people should stop complaining about C++ OOP then.
What I really meant to say with that was that it's lisp at its core -i.e. if one wants to place it squarely in one single paradigm, imo that one should be "Functional".
I was just surprised to see it listed as an example of OOP language, because it's not the most representative one at that.