News for hackers. Stuff that matters.
Re:How can C Programs be so Reliable? by jwilliams on Tuesday November 11, 2008 @09:29PM (#361286)
You don't need an exception mechanism to deal with this - good libraries will let you find out the exact condition (if you do get a -1 for example).

By the same token, dozens of Java libraries only throw ABCException, with no other information... Might as well be -1.

Re:How can C Programs be so Reliable? by wvenable on Tuesday November 11, 2008 @09:40PM (#361299)
But you can't ignore the ABCException, your app will crash. If you ignore the -1, then you're app will happily continue on doing something wrong.
Re:How can C Programs be so Reliable? by jwilliams on Tuesday November 11, 2008 @10:05PM (#361324)
Well I don't know your experience, but most Java developers I've seen either throw the exception, or suppress it... If they throw it, it eventually ends up as ABCGenericException and you've probably got no chance to reasonably recover. If you suppress it you end up with a nasty side effect (a null somewhere perhaps) that causes the app to bomb in another unexpected piece of code.

Exceptions are a language semantic - in itself it doesn't make your code robust. You still need to apply it correctly.

But! The reality is the same applies to C too. What the original author was alluding to what that the mentality of C encourages coders to look deeper into their errors.

Re:How can C Programs be so Reliable? by DarkShikari on Tuesday November 11, 2008 @09:47PM (#361307)
Sure you can ignore it. You don't want to know the number of times I've seen people using the "try, catch, toss away the exception" structure in Java code.
Re:How can C Programs be so Reliable? by mstevens on Wednesday November 12, 2008 @05:20AM (#361665)
But you have to actively decide to ignore it.

Whereas when you're dealing with return codes, the default is to ignore.

Re:How can C Programs be so Reliable? by silentbicycle on Wednesday November 12, 2008 @06:02PM (#362443)
In OCaml, you're required to do something with the return from any non-void function. You can just say "ignore (f x)" to discard the result, so it's not hugely inconvenient, but causes suspect code to accumulate warning signs.

It seems like a good compromise.

Re:How can C Programs be so Reliable? by mstevens on Tuesday December 09, 2008 @11:07AM (#391381)
This also seems like a pretty good strategy. I really need to take that OCaml book off the shelf.