9 ms·
I'm fine with implementing another static Object-Oriented language, but please learn from some of the best non-static Object Oriented languages out there like R
by fouc 6y ago
I'm fine with implementing another static Object-Oriented language, but please learn from some of the best non-static Object Oriented languages out there like Ruby and to a lesser extent Erlang/Elixir.
- hedora 6y agoAlso, C++ has solved many of the issues mentioned in the article (especially post C++11). It has not solved the “minimum set of primitives that make OO tenable” problem.
- Kranar 6y agoWhich problems from the article are you referring to? C++ is likely the worst OO language in common usage and C++ developers rightfully avoid using its native OO functionality as much as possible. They will literally jump through hoops and write tons of additional boilerplate code to avoid exposing the language's OO functionality (doing what C++ developers call type-erasure). C++11 didn't improve OO in C++, it gave programmers many features to avoid having to use it altogether.
- AnimalMuppet 6y agoI have literally never seen someone program C++ that way. I mean, it's probably true that some people somewhere are doing that. But saying "C++ developers rightfully avoid using its OO functionality as much as possible" seems like a complete distortion of the actual situation.
- Kranar 6y agoThose some people would be the authors of the standard library who use type erasure for std::function, std::string_view, std::span, std::any, std::ranges, std::fmt, the new class of pmr memory allocators use type erasure, the upcoming coroutines are built on type erasure. Common C++ libraries like boost have an entire library dedicated to type erasure: https://www.boost.org/doc/libs/1_75_0/doc/html/boost_typeerasure.html https://www.boost.org/doc/libs/1_75_0/doc/html/boost_typeera... Facebook's Folly library also provides type erasure functionality: https://github.com/facebook/folly/blob/master/folly/docs/Poly.md https://github.com/facebook/folly/blob/master/folly/docs/Pol... Google's Abseil is full of type erasure: https://abseil.io/ https://abseil.io/ Here is Adobe's C++ library for type erasure: https://stlab.adobe.com/group__poly__related.html https://stlab.adobe.com/group__poly__related.html And here's a talk by Sean Parent about how Adobe uses type erasure to emulate runtime polymorphism without using C++'s native OO features: https://www.youtube.com/watch?v=QGcVXgEVMJg https://www.youtube.com/watch?v=QGcVXgEVMJg I suppose these are just some people somewhere...
- pjmlp 6y agoAnd all of them use some kind of OOP ideas, while trying to sell themselves as not being OOP. classes, polymorphism, some level of inheritance, delegation, composition, builders, method dispatch, ....
- Kranar 6y agoNone of them are selling themselves as not being OOP. What they are doing is implementing an ad-hoc version of OOP that forgoes using C++'s native OO feature-set. Native C++ OO clashes with modern C++, often creating a dialect that does not play well with resource management and common C++ idioms. The type erasure libraries provide many of the traditional benefits of OO but allow you to retain value semantics (which native C++ OO does not). My argument was never about OO as a general concept, it was strictly that C++'s native OO feature set is very poor and modern C++ allows developers to move away from that feature set.
- AnimalMuppet 6y agoHow does native C++ OO not allow you to retain value semantics? Doesn't the Rule of 3 exactly give you value semantics? And it's quite standard to do that with what you're calling "native" C++ OO.
- Kranar 6y agoThe rule of 3 doesn't apply to C++ native polymorphic types and your statement is so far out of left field I'm guessing you don't do much C++ development. To humor you... if I have a base class of type Animal and a derived class of type Cat, then making a copy of a Cat through a pointer or reference to an Animal results in object slicing which is not what you expect when you make a copy of a polymorphic object. Basically you only end up copying the Animal instead of the entire Cat. https://en.wikipedia.org/wiki/Object_slicing https://en.wikipedia.org/wiki/Object_slicing One of the motivating reasons to use type erasure is precisely to solve this issue, so that one can copy an Animal or assign Animals and treat an Animal as a value and copies work as expected. When one copies a std::function or any of the type erased classes provided by the standard library, it just works as expected, without needing to consider lifetime issues, object slicing, C++'s complex rules about inheritance vs. virtual inheritance, and a host of other problems that don't mix well with other parts of the language. The cost of type erasure is that it requires a lot more work on the part of the author. The libraries I linked to help alleviate most of the boilerplate, but as the examples demonstrate, there's still a lot of work that needs to be done to get it right.
- AnimalMuppet 6y agoA Turing Machine is the minimum (probably) set of primitives that make computation possible. That doesn't mean we want to program that way. I'm not sure we want to do OO programming in the minimum set of primitives that make OO possible, either.
- hedora 6y agoMinimizing the number of OO primitives the language provides is one of the goals of the article. It’s not a goal of C++. I think there’s room for kitchen sink languages and also opinionated, minimalist languages.
- pkulak 6y agoErlang/Elixir are two of the least OO languages I can think of. Point still taken though. Elixir is an absolute joy, and the more new languages take examples from it, the better.
- andrewflnr 6y agoOn the contrary, at least if we talk about Alan Kay's vision then Erlang/Elixir are as close as we have today. Hint: the processes are objects.
- zokier 6y ago> at least if we talk about Alan Kay's vision Big if there. Most people do not mean Kays OO when they say OO.
- klibertp 6y agoWhich is why they should be educated, given a chance. No?
- xbar 6y agoI read "eradicated." But sure, let's educate them first.
- AnimalMuppet 6y agoKay was a visionary, but not every vision of his was the final word on reality. It's possible that the "mainstream" version of OO is better than Kay's.
- zokier 6y agoIt doesn't really matter if its better or worse. As a term OO means what people understand it to mean. Human languages (unlike programming ones) are descriptive, not prescriptive.
- chillfox 6y agoSo basically be like Crystal [1]? [1] https://crystal-lang.org/ https://crystal-lang.org/