Java Checked Exceptions

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Hung Jung Lu

    Java Checked Exceptions

    Hi,

    Just ran into this article



    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-RuntimeExceptio n 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
  • Peter Otten

    #2
    Re: Java Checked Exceptions

    Hung Jung Lu wrote:
    [color=blue]
    > Hi,
    >
    > Just ran into this article
    >
    > http://www.mindview.net/Etc/Discussi...ckedExceptions
    >
    > 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-RuntimeExceptio n 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[/color]

    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
    [color=blue][color=green][color=darkred]
    >>> [][0][/color][/color][/color]
    Traceback (most recent call last):
    File "<stdin>", line 1, in ?
    IndexError: list index out of range[color=blue][color=green][color=darkred]
    >>>[/color][/color][/color]

    which becomes impractical as code complexity increases.

    Peter

    Comment

    • Jarek Zgoda

      #3
      Re: Java Checked Exceptions

      Hung Jung Lu <hungjunglu@yah oo.com> pisze:
      [color=blue]
      > 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.[/color]

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

      --
      Jarek Zgoda
      Registered Linux User #-1
      http://www.zgoda.biz/ JID:jarek@jabbe rpl.org http://zgoda.jogger.pl/

      Comment

      • Paul Rubin

        #4
        Re: Java Checked Exceptions

        hungjunglu@yaho o.com (Hung Jung Lu) writes:[color=blue]
        > 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.[/color]

        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.

        Comment

        • John Roth

          #5
          Re: Java Checked Exceptions


          "Paul Rubin" <http://phr.cx@NOSPAM.i nvalid> wrote in message
          news:7xy8wr45b9 .fsf@ruckus.bro uhaha.com...[color=blue]
          > hungjunglu@yaho o.com (Hung Jung Lu) writes:[color=green]
          > > 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.[/color]
          >
          > 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.[/color]

          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


          Comment

          • Paul Rubin

            #6
            Re: Java Checked Exceptions

            "John Roth" <newsgroups@jhr othjr.com> writes:[color=blue]
            > 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.[/color]

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

            Comment

            • John Roth

              #7
              Re: Java Checked Exceptions


              "Paul Rubin" <http://phr.cx@NOSPAM.i nvalid> wrote in message
              news:7xd6e3vzu3 .fsf@ruckus.bro uhaha.com...[color=blue]
              > "John Roth" <newsgroups@jhr othjr.com> writes:[color=green]
              > > 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.[/color]
              >
              > But I thought Ada uses checked exceptions, and huge systems have been
              > built in Ada. What's the deal?[/color]

              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


              Comment

              Working...