![]() This is basically the same approach Rust and Go use with panic(), and in both languages this facility by default causes the runtime to unwind the stack, as with C++ exceptions. One thing I think most people largely misunderstood is exceptions they're actually totally fine if used in _exceptional_ circumstances, as if they were some kind of softer assertion, when you expect some kind of contract to be always true, but calling abort is just too unreasonable. ![]() Almost every single C project I've seen (including some of mine, I've to admit) end up involuntarily reimplementing some basic algorithm or container, and most often than not it ends up being less efficient, or unnecessarily using the heap. It doesn't hurt that the STL is extremely optimized, and often provides you tools that accomplish what you cared about without lots of the gotchas and pitfalls you're almost certainly doomed to fall for if you're not aware of their existence. It can even be faster than C in the hands of a skilled developer that knows where and how use the right features. This is somewhat exaggerated, especially because while there are several poorly designed areas in C++ and the STL, it's not all that bad and it can lead to safer, less fragile code than the C equivalent with less effort (but arguably, more skill is required in order to learn and proficiently use C++). ![]() Įdit Correction: It's called Clean C not Clean C++ I believe this is still supported, but is officially deprecated, for what that's worth. > Don't use C++ runtime wrapper for C runtime includes (,, etc.), use C runtime instead (,, etc.) I believe that if you enable RTTI you pay for it even if you don't use it, which is why it's banned in the LLVM codebase. ![]() > Exception handling is the only C++ language feature which requires significant support from a complex runtime system, and it's the only C++ feature that has a runtime cost even if you don't use it There's a vaguely similar effort with a similarly poor choice of name, Clean C, which is guaranteed to compile as both C and C++ with the same behaviour (provided there's no undefined behaviour or platform-specific behaviour).
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |