gnu-arch-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gnu-arch-users] Nit


From: Andrew Suffield
Subject: Re: [Gnu-arch-users] Nit
Date: Mon, 20 Oct 2003 19:54:32 +0100
User-agent: Mutt/1.5.4i

On Mon, Oct 20, 2003 at 04:51:37PM +0200, Thomas Zander wrote:
> On Monday 20 October 2003 16:14, Andrew Suffield wrote:
> > On Mon, Oct 20, 2003 at 08:21:13PM +1000, Robert Collins wrote:
> > > On Mon, 2003-10-20 at 18:56, Thomas Zander wrote:
> > > > Its all the things that people use Exceptions for; since it allows
> > > > for bugs to be made without creating non-sane conditions, which
> > > > allows creating software bug-free the first time around.
> > > > You are right that c can do this; but most developers just don't
> > > > because its so damn hard!
> > > >
> > > > How often is a malloc done without a check if it succeeded?  Do a
> > > > grep to find out, same with file-open and all those nice little
> > > > problems.
> > >
> > > Y'know, reading hackerlab would be a very good start for you, as you
> > > appear to be talking from a position of ignorance [of tla's internals]
> > > rather than one of knowledge.
> > >
> > > Oh, and as for exceptions being 'all that' ? Exceptions don't prevent
> > > bad state in objects, they don't prevent bugs, all they do is ensure
> > > that cleanup routines have a chance at trapping abnormal events within
> > > the same process.
> >
> > Most of the time they don't even do that.
> >
> > All that exceptions normally give you is a more descriptive error
> > message.
> >
> > If you want to actually handle the error and continue in a sensible
> > fashion, then you need to design your interface to clearly and
> > usefully define the error states it can cause, and probably provide
> > some cleanup/restart handling. Once you've got that, you don't need
> > exceptions any more, because it's just part of your library
> > interface.
> 
> This kind of reasoning is why I said that I don't buy into 'tla is stable'.
> Its clear I can't explain exception aware programming in a single email; and 
> it really is not the place to do so either.  I'll just be considered a 
> troll that has no idea how to program good C code (that last part is 
> probably correct :). While I feel you guys are missing out on where 
> exception programming can make your program more robust and easier to 
> debug.
> For the interrested:
> http://www.artima.com/intv/solidP.html

This is a common but empirically false notion. The article you cite is
really comparing java-with-exceptions to
C-without-error-handling. Clearly java-with-exceptions will handle
errors better than C-without-error-handling, but it's not appreciably
better than C-with-error-handling - I've done both, in code that aimed
for five nines uptime. Exceptions don't help.

[Incidentally, due to shoddy exceptions in the java standard library
itself, java's blocking sockets interface is utterly useless for
writing reliable network code; you must use the java 1.4 non-blocking
sockets interface. So java-with-exceptions is actually worse than
C-with-error-handling in some cases]

In particular, the article's claims about error handling for network
applications are entirely unsubstantiated. I've seen code which makes
the mistakes they describe, but I have been writing C code which
doesn't do this for the past three years or so (more or less
exclusively - it's my field of choice). These are not an innate part
of the problem, they're merely the result of lousy
programming. Exceptions won't help you there (as the java standard
library has so aptly demonstrated).

-- 
  .''`.  ** Debian GNU/Linux ** | Andrew Suffield
 : :' :  http://www.debian.org/ |
 `. `'                          |
   `-             -><-          |

Attachment: signature.asc
Description: Digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]