5 ms·
"...rather than re-inventing the wheel with structs full of function pointers." I think you got that backwards. Structs full of function pointers predate c++.
by jmj42 15y ago
"...rather than re-inventing the wheel with structs full of function pointers."
I think you got that backwards. Structs full of function pointers predate c++. Going for the ad absurdum, why bother inventing C++, it's just a re-inventing of the structs full of function pointers wheel?
- strags 15y agoYou're right - "re-inventing the wheel" is probably the wrong phrase - I used it because it conveys a sense of needless effort when there is a better alternative. Basically, those who don't have access to basic object-orientation are doomed to implement it themselves in a messier, more verbose form.
- jmj42 15y agoI think the argument that Torvalds was making here is that that's exactly what C++ is. Messy and unnecessary. You can write C++, but if you do so without the mess, you're so close to C that there's no point in using C++. I, on the other hand, would argue that C's lack of object-orientation somehow dooms one to implement it. OOP is _not_ the pinacle of software development. Further, I would argue that "structs full of function pointers" neither, necessarily, represents a desire for object-orientation nor is it messy.
- strags 15y agoWhen your source code is full of structs that look like this: struct obj { struct obj_functions* functions; ... } struct obj_functions { void (*do_something_with_object)(struct object* obj,...); ... } ... I'd say it's hard to argue that you're not implementing C++ style OOP, and that it wouldn't be cleaner to use C++. Now, if you're just going to stick to the basics of C++ (ie. avoid templates, operator overloading, etc...), then there's a fair argument as to whether it's worthwhile. Certainly it's not worth rewriting the Linux kernel at this point. But, I don't think Linus's comment that "C++ is a horrible language" is fair. (I'm sure most of that is just Linus being Linus).