3 ms·
His example of C vs C++ doesn't take advantage of virtual functions/polymorphism at all, which is a much more significant part of the "syntactic sugar" that C++
by Miky 16y ago
His example of C vs C++ doesn't take advantage of virtual functions/polymorphism at all, which is a much more significant part of the "syntactic sugar" that C++ adds over C, and is what I would say makes it OO.
So what if it's "just" syntactic sugar anyway? Calling functions in C is just syntactic sugar on top of messing with the stack. You could make the claim that any feature of any programming language is just syntactic sugar on top of something lower-level, eventually getting down to the circuitry. But that's not a terribly useful criticism.
The definition of OO to me is a certain kind of polymorphism, which is fit by class hierarchies in Java, Ruby, etc., multimethods in CLOS, and typeclasses in Haskell (although Haskell in general isn't OO), although of course, that's not an authoritative definition either.
- loup-vaillant 16y agoFirst paragraph: you're right. That's why I explicitly said that subtype polymorphism isn't mere syntactic sugar. Second paragraph: that, is past the limit of what one could reasonably call "syntactic sugar". Now I only have an intuitive idea of which compilation process is syntactic sugar, and which is not. I feel however that we could find a nice mathematical definition that nearly everyone will agree with.