Java Checked Exceptions

H

Hung Jung Lu

Hi,

Just ran into this article

http://www.mindview.net/Etc/Discussions/CheckedExceptions

And I felt kind of reliefed. When I programmed in Java I always
thought its usage of "checked exceptions" was kind of... silly.
"Checked exceptions" are Non-RuntimeException exceptions, your method
declaration must specify them, and also you need to catch them or
otherwise your code won't compile. It's a huge attention distractor
for developers. (Java seems to be loaded with lots of attention
distractors.)

Python and C# actually are quite similar in that they both use
unchecked exceptions, and exception handling in these languages are
nice to use. I just don't know why Java had to embark on the
checked-exception experiment.

Hung Jung
 
P

Peter Otten

Hung said:
Hi,

Just ran into this article

http://www.mindview.net/Etc/Discussions/CheckedExceptions

And I felt kind of reliefed. When I programmed in Java I always
thought its usage of "checked exceptions" was kind of... silly.
"Checked exceptions" are Non-RuntimeException exceptions, your method
declaration must specify them, and also you need to catch them or
otherwise your code won't compile. It's a huge attention distractor
for developers. (Java seems to be loaded with lots of attention
distractors.)

Python and C# actually are quite similar in that they both use
unchecked exceptions, and exception handling in these languages are
nice to use. I just don't know why Java had to embark on the
checked-exception experiment.

Hung Jung

I actually liked checkd exceptions ... until I had to work with them :)

Still, I would like a tool that could tell what kind of exceptions a
particular chunk of Python code can raise. I find myself too often doing
something like
Traceback (most recent call last):

which becomes impractical as code complexity increases.

Peter
 
J

Jarek Zgoda

Hung Jung Lu said:
Python and C# actually are quite similar in that they both use
unchecked exceptions, and exception handling in these languages are
nice to use. I just don't know why Java had to embark on the
checked-exception experiment.

Java was written by marketoids. They always have better knowledge.
 
P

Paul Rubin

Python and C# actually are quite similar in that they both use
unchecked exceptions, and exception handling in these languages are
nice to use. I just don't know why Java had to embark on the
checked-exception experiment.

I don't know either, but I think it's not a trivial question. It
could be that if you're distracted a lot by constantly adding more
exception checks at the high levels of your program, then it's because
your program isn't dealing with exceptions enough at the lower levels.
 
J

John Roth

Paul Rubin said:
I don't know either, but I think it's not a trivial question. It
could be that if you're distracted a lot by constantly adding more
exception checks at the high levels of your program, then it's because
your program isn't dealing with exceptions enough at the lower levels.

There's an interview of Anders Hejlsberg on http://www.artima.com/index.jsp
that discusses the checked exception issue, and why C# doesn't
have them.

My take on the issue is that at the time Java was designed,
the whole notion of checked exceptions was a hot topic in
the academic and language design community, and so it got
in before there was enough experience with using it in large
programs to show that it simply didn't scale well.

John Roth
 
P

Paul Rubin

John Roth said:
My take on the issue is that at the time Java was designed,
the whole notion of checked exceptions was a hot topic in
the academic and language design community, and so it got
in before there was enough experience with using it in large
programs to show that it simply didn't scale well.

But I thought Ada uses checked exceptions, and huge systems have been
built in Ada. What's the deal?
 
J

John Roth

Paul Rubin said:
But I thought Ada uses checked exceptions, and huge systems have been
built in Ada. What's the deal?

I'm believe Ada has enough differences that they're not
directly comparable. The initial versions of Ada weren't,
for example, even object oriented, and much of the power
of that language comes from its generics.

John Roth
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,175
Latest member
Vinay Kumar_ Nevatia
Top