News for hackers. Stuff that matters.
Re:How can C Programs be so Reliable? by cageface on Thursday September 22, 2011 @06:33AM (#3025560)
I don't see how any language that depends on manual handing of error return codes can ever be considered "reliable". It's far, far too easy to leak memory and other resources. As other posters have noted, the only reason a lot of popular C programs are reliable is that they've been groomed with a fine-toothed comb.

The only low-level language that has any innate claim to reliability is C++ with proper use of the RAII idiom.

Re:How can C Programs be so Reliable? by eru on Thursday September 22, 2011 @06:56AM (#3025602)
> The only low-level language that has any innate claim to reliability is C++ with proper use of the RAII idiom.

Or rather a very carefully chosen subset of C++. See http://yosefk.com/c++fqa/exceptions.html#fqa-17.3 for some of the problems.

By the way, what about ADA?

Re:How can C Programs be so Reliable? by cageface on Thursday September 22, 2011 @09:17AM (#3025937)
I have to admit a total ignorance of ADA. In domains where it's appropriate it may be a good choice. It's certainly a niche language compared to C/C++ though.

I think some of Yosef's advice on C++ is out of date WRT to the C++11 standard too. shared_ptr is now the recommended smart pointer, for instance.

Re:How can C Programs be so Reliable? by tomjen3 on Thursday September 22, 2011 @08:06AM (#3025749)
Ada is typically less well known and not used a lot, but if you want reliable code, it is pretty nice.

Be aware that it is a b&d language.

Re:How can C Programs be so Reliable? by eru on Thursday September 22, 2011 @09:06AM (#3025894)
I usually use Haskell at work, which is even more b&d in a sense and it's pretty reliable. But you can not call Haskell low-level.
Re:How can C Programs be so Reliable? by absconditus on Thursday September 22, 2011 @02:06PM (#3027028)
PL/SQL is similar to Ada in many ways.
Re:How can C Programs be so Reliable? by marshray on Thursday September 22, 2011 @11:01AM (#3026283)
It's like finding an old circus tightrope walker who has performed for 30 years without a net and saying:

My goodness look at that, how can those tightropes be so reliable?

Re:How can C Programs be so Reliable? by Roboprog on Thursday September 22, 2011 @12:52PM (#3026703)
First, you have to decide if you are building a batch program, or an interactive program. Then, you make your own I/O and memory wrappers with an appropriate error handling strategy: exit(), or longjmp(), etc. In addition, for a batch process, you might have isolated blocks of logic that use setjmp/longjmp to log and skip over blocks of crappy input.

The point is that, as mentioned elsewhere, C is "build your own system" level -- VERY LOW (level). The overhead of wrapping primitives with strategies for your app is minimal, once you know it's an issue.