5 ms·
This is bad advice on the c++ part. If you don't use RAII, then you could've just not done the c++ lib (and have just a c lib). Exceptions, raii and smart point
by jandeboevrie 7y ago
This is bad advice on the c++ part. If you don't use RAII, then you could've just not done the c++ lib (and have just a c lib). Exceptions, raii and smart pointers are what makes modern c++ so pleasant, next to templates.
- a_t48 7y agoFWIW I’ve never been at a job that allows exceptions...but smart pointers and RAII are great.
- jstanley 7y agoNo exceptions. No exceptions.
- je42 7y agoExceptions are being fixed. See https://www.youtube.com/watch?v=os7cqJ5qlzo https://www.youtube.com/watch?v=os7cqJ5qlzo
- deleted 7y ago[deleted]
- EliRivers 7y agoOn the other side of the coin, I don't think I've ever had a job in which anyone would have ever considered banning exceptions (although I have worked at some where people did know that some other companies did ban them). The world of programming is a very broad church indeed.
- snovv_crash 7y agoOften bare-metal embedded toolchains don't support stack unwinding. I've even worked on an embedded linux where the toolchain didn't support stack unwinding. It made porting certain code to the platform interesting, to say the least.
- greggman2 7y agoExamples of companies or projects that ban exceptions Google, and therefore Chromium https://google.github.io/styleguide/cppguide.html https://google.github.io/styleguide/cppguide.html Mozilla, and therefore Firefox https://firefox-source-docs.mozilla.org/tools/lint/coding-style/coding_style_cpp.html https://firefox-source-docs.mozilla.org/tools/lint/coding-st... I'm pretty sure WebKit also doesn't use exceptions. It's not listed in their style guide but searching the repo I don't find any instances and the repo history shows turning them off.
- a_t48 7y agoWhat kinds of work were you doing that allowed exceptions?
- EliRivers 7y agoOff the top of my head, just listing a handful of various projects; a commercial static analyser, various GUIs, a broadcast industry projectile tracking and information presenting system, a multiple networked radar (and similar) network data fusion project, broadcast automation software, various data processing and display software sets, software simulating mechanical movement for artificial test data generation, image processing and morphing. I could go on, but hopefully that gives a flavour. A whole big bag of things. From my perspective, banning exceptions is the exception (a ha ha); not the rule. I've worked on embedded software that (I expect) didn't support exceptions in the provided compiler, but I don't consider that an explicit ban on exceptions - they simply weren't possible.
- LessDmesg 7y ago> modern C++ > pleasant Nice joke. Hour-long compilations, type-unsafe templates with unreadable errors, and circular references are considered pleasant now?
- deleted 7y ago[deleted]
- je42 7y ago- reasonable organized code doesn't take hours. even template heavy code is quite fast these days - templates are type safe. it is just the error messages are not helpful a lot of times. C++20's concepts should help - circular references. that's a thing in C as well. as soon as you need interact with your libraries user to allocate/deallocate resources. C++ has a large surface to interact with. Yes you can shot yourself in your foot. However, the more you know you can use the features to your advantage instead of shotting yourself in the foot. At the point you gain more than you lose.
- eru 7y agoTemplates are duck typing at C++ compile time (which is their runtime). Yes, concepts should help. 'Modules via copy-and-paste' (= #include) is what I would hurl at C++ these days. Though they are working on that as well, I heard. Though https://vector-of-bool.github.io/2019/01/27/modules-doa.html https://vector-of-bool.github.io/2019/01/27/modules-doa.html doesn't sound hopeful.
- rumanator 7y ago> Templates are duck typing at C++ compile time (which is their runtime). That description only applies of you venture into the dark realm of template metaprogramming, and anyone who ventures into those lands is wise enough to understand that the tool is not the one to blame if one decides to abuse a feature to apply it in a way it was not (initially) designed to be used.
- 7y ago
- LucaSas 7y agoHi, I am the author of the article. Regarding RAII, what I mention in the article is that it is ok to provide RAII wrappers as long as you also provide C++ wrappers for the non-RAII plain structs and functions from C. I think this is the best way to satisfy everyone. When it comes to exceptions and rtti the sad reality is that about 50% of the C++ community doesn't use (for one reason or another), so if you do use them in a library it can have an impact.
- wokwokwok 7y ago> Exceptions, raii and smart pointers are what makes modern c++ so pleasant Point in case for lack of portability, UE4 doesn't support exceptions unless you do a custom build.