2 ms·
I had the same thought: he's doing OOP without using the "class" keyword. Well-written C code is actually very object-oriented this way, it just doesn't take a
by commandlinefan 6y ago
I had the same thought: he's doing OOP without using the "class" keyword. Well-written C code is actually very object-oriented this way, it just doesn't take advantage of the syntactic sugar of C++.
- Jtsummers 6y agoThis is only one thing that OO languages provide. My point, though, was that global state is not inherent to procedural languages as you claimed. And if all you're getting from an OO language is a bit of sugar and single dispatch, you're not getting much.
- mypalmike 6y agoThis is a common misunderstanding. Structural programming like this is clearly similar to what we think of as OO. But it existed before OO and is still heavily practiced in non-OO languages such as C. The main feature that OO added to this was dynamic function dispatch via inheritance. The specific function that gets called at runtime depends on the type of the struct. Inheritance has proven powerful but often results in confusing code. The development of interface-based (non-inheritance) dynamic dispatch in COM and Java, and later embraced by Go and Rust, shows that we can get what is arguably the primary benefit of OO with a flat structural approach.
- commandlinefan 6y ago... and this inevitable pedantry is why I thought twice about replying to OP.
- mypalmike 6y agoIt's not pedantic. If you're not doing dynamic dispatch, you aren't doing OO. https://blog.cleancoder.com/uncle-bob/2018/04/13/FPvsOO.html https://blog.cleancoder.com/uncle-bob/2018/04/13/FPvsOO.html