5 ms·
So much gold to mine in this talk. Even just this kind of throwaway line buried deep in the Q&A: > I prefer to write code in a verb-oriented way not an object-
by DavidPiper 1y ago
So much gold to mine in this talk. Even just this kind of throwaway line buried deep in the Q&A:
> 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)
- BoiledCabbage 1y agoMore info on "The Expression Problem" https://en.wikipedia.org/wiki/Expression_problem https://en.wikipedia.org/wiki/Expression_problem
- pjmlp 1y agoThere are OOP languages that use doThing(X, Y), though. Ada, Julia, Dylan, Common Lisp for example. Yet another example why people shouldn't put programming paradigms all into the same basket.
- virgilp 1y agoThere are a handful of (somewhat exotic) languages that support multiple dispatch - pretty much, all those listed by you. None of the mainstream ones (C++, Java, C# etc) do. (also Common Lisp is hardly a poster child of OOP, at best you can say it's multi-paradigm like Scala)
- pjmlp 1y agoI guess Julia and Clojure are exotic. Since when do OOP languages have to be single paradigm? By then point of view, people should stop complaining about C++ OOP then.
- virgilp 1y ago> Since when do OOP languages have to be single paradigm? 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.
- pjmlp 1y agoThe Art of Metaobject protocol was written and researched in Lisp. Provides an OOP programming model, that no mainstream language, other than Common Lisp fully supports. https://en.m.wikipedia.org/wiki/The_Art_of_the_Metaobject_Protocol https://en.m.wikipedia.org/wiki/The_Art_of_the_Metaobject_Pr... Dylan, Julia and Clojure only have subsets of it.
- igouy 1y agoMulti-methods do seem like a missed opportunity: "Visitor Pattern Versus Multimethods" https://nice.sourceforge.net/visitor.html https://nice.sourceforge.net/visitor.html
- pjmlp 1y agoAt least we have Julia and Clojure as more mainstream versions of them. Still it isn't CLOS.
- olvy0 1y agoC# does support a form of multiple dispatch, through the dynamic keyword. Used it myself for writing a parser. https://shawnhargreaves.com/blog/visitor-and-multiple-dispatch-via-c-dynamic.html https://shawnhargreaves.com/blog/visitor-and-multiple-dispat...
- saghm 1y agoYeah, the dot operator is not a particularly strong signal of whether something is OOP or not. You could change the syntax of method calls in OO languages to not use the object as a prefix without the underlying paradigm being affected.
- robertlagrant 1y ago> Suddenly clicked for me why some people/languages prefer doThing(X, Y) vs. X.doThing(Y) It's when you start writing ThingDoer.doThing(X, Y) that you begin questioning things.
- morkalork 1y agoBut if you make it thingService.doThing(x,y) you're all good.
- phlakaton 1y agoIn Go, of course, thingService would implement the interface Thinger.
- LearnYouALisp 1y agoExcuse me, you need a BeanShell.BeanThread.GeneratorStalk.VeggFactory to do that in this Environment®™
- shuaiboi 1y agobjarne (creator of c++) has a quote about this: 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/p1962r0.pdf https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p19...
- saghm 1y agoThe main benefit of x.f(y) IMO isn't emphasizing x as something special, but allowing a flat chain of operations rather than nesting them. I think the differences are more obvious if you take things a step further and compare x.f(y).g(z) and g(f(x, y), z). At the end of the day, the difference is just syntax, so the goals should be to aid the programmer in writing correct code and to aid anyone reading the code (including the original programmer at a later point in time!) in understanding the code. There are tradeoffs to using "method" syntax as well, but to me that mostly is an argument for having both options available.
- nickitolas 1y agoIf my memory isn't failing me, that was part of the reason rust went with a postfix notation for their async keyword ("thing().await") instead of the more common syntax ("await thing()")
- saghm 1y agoYep, and that itself was similar to the rationale for introducing `?` as a postfix operator where the `try!(...)` macro had previously been used. In retrospect, it's kind of funny to look back and see how controversial that was at the time, because despite there being plenty of criticism of the async ecosystem in once, the postfix `.await` might be the one thing that seems to consistently be praised by people needing to use it. People might not like using async, but when we do use it, it seems like we're pretty happy with the syntax for `.await`.
- ahonhn 1y agoThis mention of verbs reminds me of Steve Yegge's blog post "Execution in the Kingdom of Nouns" from 2006. https://steve-yegge.blogspot.com/2006/03/execution-in-kingdom-of-nouns.html https://steve-yegge.blogspot.com/2006/03/execution-in-kingdo...