Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> I've seen checked exceptions cause numerous bugs.

I've seen quite a few in for-loops, so I'm not sure that's tracking for me.

> Why? Because they encourage you to put catch clauses everywhere

Java forces you to handle author-specified error conditions (CS error), but jr developers do tend to create their own more often than necessary.

While I agree that a global exception handler is good practice for Spring applications, individual exception handling is very common and important to modern software. eg If Web APIs get more complex (multiple datastores), you find you don't want to bubble everything up. I get a request, want to check a cache (which might throw) then look it up in a DB (which might throw) then look it up in a file (etc), then return a response.

I do wish I could handle exceptions simpler than making the choice to add 4 lines (+ any actual logging, etc) or blackhole-traveling through the stack to add checked exception signatures everywhere (code AND tests).



> I've seen quite a few in for-loops, so I'm not sure that's tracking for me.

The difference is that for-loops are almost an essential language feature – the vast majority of languages have them (or a close equivalent), and they make certain algorithms a lot easier to state clearly. Sure, there are some languages which lack them, but they tend to be either languages with non-mainstream paradigms (such as pure functional or logic programming languages) which put all the emphasis on recursion instead, or else really old legacy languages which predate the development of structured programming (such as pre-1980s versions of COBOL–modern COBOL versions have for loops)

By contrast, almost nobody considers checked exceptions an "essential language feature" – languages which lack them vastly outnumber languages which possess them, indeed, Java stands out as the only major mainstream language to possess them

Given the argument "this unusual inessential language feature causes more bugs than it prevents", the response "this essential language feature which the vast majority of languages have sometimes causes bugs too" isn't very convincing




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: