digitalmars.D - Creator of ZeroMQ and AMQP comments on error handling
- =?ISO-8859-1?Q?Jos=E9_Armando_Garc=EDa_Sancio?= (12/12) Jul 15 2012 Hey everyone,
- Tobias Pankrath (2/3) Jul 15 2012 All his arguments about C++ exceptions hold for plain return
- =?ISO-8859-1?Q?Jos=E9_Armando_Garc=EDa_Sancio?= (9/11) Jul 15 2012 Yes but he would said that is not the point of his article. I think
- Paulo Pinto (12/32) Jul 16 2012 He is completely wrong.
- Tobias Pankrath (20/29) Jul 16 2012 I read the article like this:
- Jonathan M Davis (29/42) Jul 15 2012 wrote:
- David Nadlinger (8/11) Jul 16 2012 In many C++ projects, exceptions are disabled at compile time.
Hey everyone, Apologies for sending this to the D mailing list but I just read a very interesting article on error handling and was interested in your opinion. I just read an article by Martin S=FAstrik, one of the creators of AMQP and ZeroMQ, on using C++ for writing infrastructure/system software. At first glance most of his objects seem to apply to D. What do you all think? Why should I have written ZeroMQ in C, not C++ - http://www.250bpm.com/blog= :4 Thanks, -Jose
Jul 15 2012
What do you all think?All his arguments about C++ exceptions hold for plain return values, too.
Jul 15 2012
On Sun, Jul 15, 2012 at 3:00 PM, Tobias Pankrath <tobias pankrath.net> wrote:Yes but he would said that is not the point of his article. I think his point is that if you decide not to use exception in C++, for the reason he and others have mentioned, then C++'s classes/structs become nothing more than C structs with an uglier/more verbose syntax. I am wondering if you can extend his argument to D. Implementing RIIA becomes more verbose. The scope keyword is useless. Thoughts? Thanks, -JoseWhat do you all think?All his arguments about C++ exceptions hold for plain return values, too.
Jul 15 2012
On Sunday, 15 July 2012 at 22:27:02 UTC, José Armando García Sancio wrote:On Sun, Jul 15, 2012 at 3:00 PM, Tobias Pankrath <tobias pankrath.net> wrote:He is completely wrong. C++ is a multiparadigm language, you can do much more than just plain OO. It is a safer language than C, while offering higher level abstractions to several programming paradigms. D as a better C++ follows these principles as well. To this day I still don't understand why some developers prefer the pain of C to safer and more productive languages for systems programming. -- PauloYes but he would said that is not the point of his article. I think his point is that if you decide not to use exception in C++, for the reason he and others have mentioned, then C++'s classes/structs become nothing more than C structs with an uglier/more verbose syntax. I am wondering if you can extend his argument to D. Implementing RIIA becomes more verbose. The scope keyword is useless. Thoughts? Thanks, -JoseWhat do you all think?All his arguments about C++ exceptions hold for plain return values, too.
Jul 16 2012
On Sunday, 15 July 2012 at 22:27:02 UTC, José Armando García Sancio wrote:On Sun, Jul 15, 2012 at 3:00 PM, Tobias Pankrath <tobias pankrath.net> wrote:I read the article like this: Exceptions are bad because they spawn "undefined behaviour", thus I don't want to use exceptions. However if I try that in a language that is designed to use exceptions, i'll run into problems. And my thoughts about this are: The problems he seems to have with exceptions are more or less the same with error codes. So I'd say the premise of this article is wrong and the conclusion useless. But what if exception where really much worse than error codes and you want to avoid them in C++? Yeah .. you get the same problems than in C, i.e. split initialization. So whatever happens you not worse of than in C. And "what if developer puts code in here that my throw although he must not?" is more or less equivalent then: "What if the developer ignores all error codes ..?" You need to play by the rules and you can't force people to do this (Java proofed this). What you need to do is to make following rules easier than breaking.Yes but he would said that is not the point of his article.What do you all think?All his arguments about C++ exceptions hold for plain return values, too.
Jul 16 2012
On Sunday, July 15, 2012 15:26:53 Jos=C3=A9 Armando Garc=C3=ADa Sancio = wrote:On Sun, Jul 15, 2012 at 3:00 PM, Tobias Pankrath <tobias pankrath.net= =20wrote:, too.What do you all think?=20 All his arguments about C++ exceptions hold for plain return values==20 Yes but he would said that is not the point of his article. I think his point is that if you decide not to use exception in C++, for the reason he and others have mentioned, then C++'s classes/structs becom=enothing more than C structs with an uglier/more verbose syntax. =20 I am wondering if you can extend his argument to D. Implementing RIIA=becomes more verbose. The scope keyword is useless. Thoughts?C++ and D are designed to use exceptions. It's virtually impossible to=20= completely escape them. However, because D has nothrow, you can at leas= t=20 guarantee that your code doesn't throw them (though you still have to w= orry=20 about Errors)., even if it gets ugly in some cases like constructors, f= orcing=20 you to do nonsense like two-part initialization, and C++ doesn't have t= hat. D=20 also has stuff like scope and std.exception.collectException which can= help=20 cleanup exception-handling code quite a bit. So, D's better off than C+= + is,=20 even if the situation is similar. But I tend to disagree with anyone who argues that error codes are bett= er.=20 Exceptions force you to actually deal with the errors that occur, where= as=20 error codes can easily be skipped. At least some of that complication i= s=20 intrinsic to the problem, and using error codes instead of exceptions j= ust=20 means that you're probably not handling a lot of the errors correctly. - Jonathan M Davis
Jul 15 2012
On Sunday, 15 July 2012 at 23:17:15 UTC, Jonathan M Davis wrote:C++ and D are designed to use exceptions. It's virtually impossible to completely escape them.In many C++ projects, exceptions are disabled at compile time. There are only very few parts of STL which are off-limits then. Sure, if you are using external code, it can still throw exceptions, but you have the same problem when using that piece of code from an exception-less language. David (this post is mainly an experiment if posting from Links works)
Jul 16 2012