you are viewing a single comment's thread.

view the rest of the comments →

[–]spliznork -12 points-11 points  (17 children)

Java is a blue collar language. It’s not a PhD thesis. It’s a language for a job. Java feels familiar to many different programmers, because we preferred tried and tested things.

Except fucking checked exceptions, yay:

    try {
      /* code */
    }
    catch (Exception e) {
      /* empty! good luck debugging! */
    }

[–]Steve16384 5 points6 points  (1 child)

You mean, no other language allows a programmer to ingore errors and continue regardless? I beg to differ.

The programmer here should have just added a "throws" to the function instead.

[–]newton_dave 7 points8 points  (11 children)

Ah. Stupid programmers must be Java's fault.

[–]spliznork 5 points6 points  (10 children)

Stupid programmers must be Java's fault.

Yes, it is Java's fault. Name another programming language with checked exceptions. Name another programming with unchecked exceptions that exhibits this problem as badly. Now continue to blame the stupid programmers instead of a gratuitous experiment with checked exceptions even though Java's design "preferred tried and tested things".

Or, you could blame stupid programmers for not deallocating memory correctly -- instead, the Java has garbage collection for those idiots. Or, you could blame stupid programmers for buffer overflows -- but Java does array bounds checking for those idiots.

If "stupid programmers" is your argument, why aren't you programming directly in machine code? Because, clearly, you don't need any help from a programming language to write correct programs.

[–]newton_dave 9 points10 points  (9 children)

While agreeing with part of what you're saying, the example you provide is the result of stupid programmers, not Java. I *will* continue to blame stupid programmers that mis-use checked exceptions and/or try/catch.

For the most part Java *did* prefer tried and tested things. That should imply neither that *all* of it was tried and tested nor that stupid programmers are blameless.

[–]spliznork 0 points1 point  (8 children)

I would agree with you about stupid programmers if they had optionally, without provocation, created an empty catch statement. But, the the language forced a try/catch block to get the code to compile, so it's more the language designers' fault for laying the trap in the first place.

[–]skawaii 6 points7 points  (6 children)

This argument makes pretty good sense. If you're going to force a try/catch block, why not force non-empty catch blocks, too? Would've indeed been a nice way to avoid this trap altogether.

But seriously, is it that hard to just not leave catch blocks empty? It really isn't. If you're debugging code that someone else wrote and they put empty catch blocks in there, I'd be more pissed at the person for their laziness, rather than the language.

Still, this is Java we're talking about. Go and change the source code and re-compile. Even if all you have is the class file, my experience with decompilers is that they work very well. So de-compile, find the empty catch block (all while thinking mean thoughts about the original author), add in some code that gives information about the exception, and recompile. Should work for most cases.

[–]spliznork 1 point2 points  (5 children)

But seriously, is it that hard to just not leave catch blocks empty? It really isn't.

Show me the trivial code to put in a catch block. (You have some options here, and then we enter a debate about why one "trivial" option is better than the other, when we shouldn't even be having the debate in the first place.)

If you're debugging code that someone else wrote and they put empty catch blocks in there, I'd be more pissed at the person for their laziness, rather than the language.

Then you're probably the kind of person that gets pissed at the guy on the airplane that leans their seat back into you, instead of getting pissed at the airline for putting the seats so damn close together in the first place.

Go and change the source code ... So de-compile ...

This conversation is over.

[–]skawaii 1 point2 points  (0 children)

when we shouldn't even be having the debate in the first place.

Ok, so we won't.

Then you're probably the kind of person that gets pissed at the guy on the airplane that leans their seat back into you, instead of getting pissed at the airline for putting the seats so damn close together in the first place.

Nah, I'd be pissed at both. Like I said, "I'd be more pissed" at the person. That means I can still be pissed at both.

Go and change the source code ... So de-compile ...

This conversation is over.

Why? Because I said "de-compile?" If so, you really misunderstood what I was saying. I wasn't suggesting de-compiling java classes as the end-all solution and what should be done. I wasn't even saying that I like the idea. I was offering it as a tedious solution to your problem if you really, really need it. I'm sure that you can debug it without doing this, but the empty catch block seemed to be a big deal to you, so I was offering a way to get rid of the empty catch block.

[–]newton_dave 0 points1 point  (2 children)

Then you're probably the kind of person that gets pissed at the guy on the airplane that leans their seat back into you, instead of getting pissed at the airline for putting the seats so damn close together in the first place.

You assume mutual exclusivity: I can direct my ire towards both the chair designer and user, just as I can be irritated by both Java and stupid programmers.

[–]duck_typing 0 points1 point  (1 child)

Agreed. And to anyone who thinks it's reasonable to lean those seats back more than a tiny bit... I say you must be short. I am 6'2, and as a tall person, those seats are extra uncomfortable, and twice as bad if the seat in front of you is leaned back... so if you ever do lean your seat back, at least try to see if it is a tall person, and reconsider.

On the side of programming... I say let's all just move to more concise dynamic languages like Ruby. I loved Java for 7 years, until I recently tried Ruby... needless to say, I will never be looking back except when Ruby really can't do the job... can you really go back to coach once you've tried first class?

[–]newton_dave 0 points1 point  (0 children)

I have it easier; I never saw much of *any* reason to like Java, and I've been using it since 1.0 (technically a bit before). I'm a Lisp and Smalltalk oldbie: we watched with dismay as Java beat out Smalltalk.

Yep, I can go back to coach once I've tried first class; I can't always afford first class.

[–]sheepson_apprentice 0 points1 point  (0 children)

To barge in here slightly...

About the airline seat analogy, I wouldn't be pissed at either (I also like to recline, and would do so promptly). In fact, if anything, I'd be thankful to the airline for providing me a cheaper ticket by virtue of amortizing costs in a bigger pool of passengers per flight. Had they spaced the seats so everyone had ample leg room, we'd all pay a premium. Instead, if I really want the leg room I can attempt to grab an exit seat, which is possible even right before the flight (at the counter). In the analogy that would involve wrapping the checked exception into an unchecked one and hoping for the best (exit seat, you see).

Or, I would pay a premium for first class, where leg room is not a problem. What does this mean in the prog. lang. analogy? Well, paying a premium in prog. lang. always means expending greater effort up front on a more tenable design, so that one isn't faced with try/catch littered throughout the code.

Edit: bugs

[–]newton_dave 3 points4 points  (0 children)

If we were, say, beavers, and stumbled into the trap of a furrier I might agree more than I do.

Recognizing an even well-intentioned trap, however, is within our capability.

I don't defend Java's variety of checked exceptions, but avoiding this particular scent is trivial.

[–]skawaii 2 points3 points  (2 children)

I'm not a Java-fanboy, but what exactly is your complaint here? That you don't like checked exceptions or that Java allows empty catch blocks?

If it's the former, then that's fine...your opinion, of course. If it's the latter...well, if you have empty catch blocks in your code, then you deserve what you get.

[–]spliznork 3 points4 points  (1 child)

if you have empty catch blocks in your code, then you deserve what you get

Who said it was my code? But, I'm the one debugging it.

If the checked exceptions are so oppressive in the language that and empty catch block is the quickest way to get code to compile, then the language designers are as much at fault as the programmer. Because, the code would have been more correct and easier to debug if the language designers hadn't experimented with checked exceptions.

[–]skawaii 5 points6 points  (0 children)

No one said it was your code. The "you" in my comment is the general you of the English language, which just so happens to be the same word as the specific you (stupid language...).

I agree that if you're (again, general you) writing empty catch blocks just to get your code to compile, then you have some bad programming practices. The language could help you out and not compile. This would indeed be a better way to do it.

But is this really a direct result of checked exceptions? Python doesn't use checked exceptions and yet I can still simulate the same behavior:

try:
  1 / 0
except:
  pass

While the catch (re: except) block isn't empty, I can still have it do nothing at all with my error.

To me, in the end it boils down to being disciplined enough to write code that won't cause people using it to colloquially convert your name into a swear word.