Hacker News new | ask | show | jobs
by CyberDildonics 660 days ago
Where are the vtables coming from if you use no inheritance and no memory allocation?
1 comments

Why program in C++ if you don't use any of its features? You're just writing C in disguise.
A C in disguise with better strong typing, compile time programming that beats hands down the preprocessor, while having the preprocessor available if one insists in using it, being able to design abstractions with bounds checking, namespaces instead of 1960's prefixes,....
Template specialization means more generated code, which, again, must fit in 2kb.

On very old archs (16bits, 8bits), there was no OO, because the code could not be complex enough to warrant it. It could not be complex because there wasn't room enough.

That being said, there are templated libraries (like fmt...) which may result in zero overhead in code size, so if the thread OP is using C++, then surely he could also use that library...

> Template specialization means more generated code, which, again, must fit in 2kb.

modern compilers are way better about de-duplicating "different types but same instruction" template specializations so it's less of an issue than you may expect , especially if you're coming with template specialization generation from the mid/late 2000's.

No different from copy-paste hard to debug preprocessor code.
This is not my claim.
It actually is, as it is voiced in a way as if preprocessor was better than using templates.
I don't write anything new and use inheritance anyway.

Even in an embedded context you have classes and destructors, operator overloading and templates. You can still make data structures that exist in flat constrained memory.

Sure, but 2kb code space? What sort of class hierarchy can you possibly use in so little space?
C++ has namespaces, C does not. That one singular feature makes C++ worthy of being used over C.
What class hierarchy?

Even demo scene people use C++ and windows binaries can start at 1KB. Classes, operator overloading and destructors are all still useful. There is no reason there has to be more overhead than C.

Right, they also tend to use special tools to crunch their binaries down to acceptable size, afaik.

That said, that's a very good point. Maybe they'd even use that fmt library?

What point are you even trying to make now? Every time you've been wrong about something and corrected you don't acknowledge it and just move on to something barely related.

https://en.wikipedia.org/wiki/Gish_gallop

You said this:

I'm pretty sure you wouldn't use C++ in that situation anyway, so I don't really see your point.

People have pointed out to you why you both can and would use C++, especially in place of C.