Exceptions (Was RE: [ANN] Cleaned up KomHttpServer on SM)

goran.krampe at bluefish.se goran.krampe at bluefish.se
Mon Nov 8 09:38:28 UTC 2004


Hi!

Blake <blake at kingdomrpg.com> wrote:
> On Fri, 5 Nov 2004 08:51:56 +0200, <goran.krampe at bluefish.se> wrote:
> 
> > A sidenote of interest: In Java you have the forced
> > "throws/try/catch"-hysteria causing less experienced developers to
> > sprinkle their code with more or less empty try-catches. That is very,
> > very bad. Since Java forces you to either handle exceptions thrown by
> > the lower layers OR declare that you also will throw them (unlike
> > Smalltalk) this has the effect on developers that they, at least early
> > on in development, tend to write empty catch-code because they "just
> > want the damn code to compile and run".
> 
> How is it forced?
> 
> The Java system is not unlike the Delphi system (raise/try/except/finally)  
> but you're never forced to use it. It simply provides a default graceful  

You are indeed forced if the API you are using throws exceptions - and
they generally do. :)
You need to either catch them or declare that you too throw them.

> handling of exceptions. You add stuff in when you actually want to handle  
> something differently (differently from displaying an error message and  
> exiting the current routine while leaving the program running).
> 
> The net result is that you only handle exceptions when you feel like it;  
> and it's pretty robust. People still misuse it, of course, but that's not  
> the fault of the language.

I am not saying it is a "fault" (when I wrote "That is very, very bad" I
meant that empty try-catches are bad) of the language - I am simply
pointing out the effect it has. I haven't thought it through enough to
form an opinion on how *I* would like it to work in Java. I think though
that I would prefer it to work like in Smalltalk - but perhaps technical
details would prevent that.

regards, Göran



More information about the Squeak-dev mailing list