3 ms·
I believe rust would be a better example here, with zero-overhead being a primary design goal. For C++, it's more of a mixed bag. As long as all the abstractio
by arghwhat 9y ago
I believe rust would be a better example here, with zero-overhead being a primary design goal. For C++, it's more of a mixed bag.
As long as all the abstractions and language features are compile-time evaluated to what people may consider to be "C-like code", then it's all the same.
I don't like the term "C-like code", though. It's not C's fault that fast code looks like that, and it is certainly possible to write "prettier" C code than what people have in mind.
- klmr 9y ago> I believe rust would be a better example here From what I’ve heard you’re almost certainly right. I just don’t know enough about Rust to comment on it (unlike C++).
- xfer 9y agozero-overhead abstraction is also C++'s primary goal. In what way it's mixed bag that is not the same in rust? Rust is basically C++ with lifetimes and a cleaner type-system.
- MaxBarraclough 9y ago> zero-overhead abstraction is also C++'s primary goal But it's not completely 'pure' on that front. LLVM's coding standards prohibit RTTI and exceptions precisely because they aren't zero-overhead. https://llvm.org/docs/CodingStandards.html#do-not-use-rtti-or-exceptions https://llvm.org/docs/CodingStandards.html#do-not-use-rtti-o...
- arghwhat 9y agoThose features are much worse than not just zero-overhead. Not only do they have a very clear overhead, the overhead applies to all code by default. You have to explicitly disable those features at compile-time to avoid the bloat.
- MaxBarraclough 9y agoTough to work without exceptions in particular, as the C++ standard library uses them.
- zlynx 9y agoBecause Rust knows about lifetimes and C++ doesn't. What C++ needs is a way to specialize types so that they automatically know if they need heap or stack storage without the programmer having to be explicit.