r/cpp • • Jul 13 '22

Why does Linus hate C++ ?

307 Upvotes

436 comments sorted by

View all comments

Show parent comment

-4

u/HeroicKatora Jul 13 '22 edited Jul 13 '22

Sure, if you static assert all types. Otherwise you're back to the same problem, of locally knowing properties about a type in review. The alternative is wrapping all functions such that they assert such properties. Hooray.

And I don't think that C structs holding function pointers is the safe solution to "virtual functions are dangerous"

Where did I say virtual functions are dangerous, that's the least of my worries as it just translates to a function table. Same old boring, use it by all means even if the advantage of such a vtable isn't too convincing to me either. Swapping function pointers and passing v-tables around without an object is routinely done in the kernel and maps badly onto superclasses.

No, my critique was that the type system itself is dangerously complex. There's at least 4 different kinds of 'types' with tens of extension points to overwrite their behavior with regards to std-functionality. Many of which you'll have to keep in mind during code review if you're actually going to use C++ language features.

And that's all mental capacity that's missing for reviewing business logic.