Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Better title: "Why I should have written ZeroMQ in C++, not C++ without exceptions."


The entire first half of the article is dedicated to why "C++ with exceptions" is not acceptable for software that strives to have zero undefined behavior. Your proposed "better title" doesn't make sense given the article content.


He doesn't really make a case for not using exceptions though. He misuses the term "undefined behaviour", doesn't discuss RAII and doesn't give any concrete examples.


Writing C++ properly requires an entirely different mind-set to writing in "fancy C" using a C++ compiler. Bitching about exceptions is a sign you don't know what you're talking about, or your expectations are culturally incompatible with the language you're using. When you call a method, you must be aware of what exceptions it could throw and handle those you're interested in from. Ignore this at your own peril.

Return codes in C are easily ignored even if they're serious. In C++ you are compelled to deal with error conditions even if your action is to ignore them. This is a fundamental philosophical difference.

Better title: "Why I should've learned C++ thoroughly before writing ZeroMQ".


What about the author's complaints about exponentially increasing code complexity when introducing new features or new exception types? I feel like the author made an attempt to write c++ the "correct" way and found it unsuitable for the software's goals (zero undefined behavior).


There's been several extended discussions on this, some involving the author, and in virtually every case he's been berating the language for doing things a particular way but often because it's just one way of many and he's ignorant of the other ways of doing it.

There was some bitching about allocators, for example, as if he didn't know about the C++ allocator override feature which isn't even hard to implement. Then there was more confusion about template objects for things like `vector` where he was using them as you might a C linked list library, then complaining that you had to allocate twice as many objects.

I think the author is dimly aware of what C++ really is, and just refuses to play along because they'd rather be writing C code anyway.

John Carmack could probably tear apart every single one of those complaints in ten minutes and have time left over to talk about his new CTO position. That's because Carmack spends the time to learn his tools inside and out and doesn't simply bitch about things being not to his liking.


My way or the highway? In C++? what was that about cutural incompatibility again? ;)

C++ is a broad church, and there is room for all sorts!


There's several "design patterns" in C++ that are used, but you need to conform to at least one of them to have any hope of success.

For instance, do you prefer cheap copies? References? Reference counted pointers with auto-destructors? There's many ways of doing it, you're not necessarily forced to pick any particular one, but not making use of these facilities and instead doing it C-style is making your life harder than it should be.

Between the Standard Library and Boost, there's a lot to pick from. There's no reason to go and roll your own vector just because you don't like or understand the way the standard one works.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: