Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Languages that use checked exceptions

I'm just curious, is there any other languages besides Java that uses checked exceptions ?

I did try to find information about this but couldn't find any answers.

like image 767
Christiaan Avatar asked Mar 29 '18 06:03

Christiaan


People also ask

Does Python have checked exceptions?

Java have checked and unchecked exceptions because Java is a complied programming language, checked exception comes in compiling. In python, there is no such exception because Python is an interpreted language. This has nothing to do with the language being compiled or interpreted.

Why does C# not have checked exceptions?

C# does not have checked exceptions. They decided to leave this issue up to the application developers (interview). Checked exceptions are controversial because they can make code verbose, while developers sometimes handle them trivially with empty catch blocks.

Is Java Lang exception a checked exception?

Exception hierarchy lang. Throwable class. All the instances of the Throwable and Exception classes are checked exceptions and the instances if the RuntimeException class are run time exceptions. For example if you create an user-defined exception by extending the Exception class this will be thrown at compile time.


1 Answers

The reason you couldn't find information on any other languages using checked exceptions is they learned from Java's mistake.

EDIT: So to clarify a little more checked exceptions were entirely a Java thing that in theory sounded like a really great idea, but in practice actually create a tight coupling between the consuming function and the function being consumed. It also makes it more tedious to handle an exception where it can be handled. Instead you have to catch and re-throw in every function in between where the exception was thrown and where it can actually be handled. I could rewrite it all here but I think this post does a magnificent job of explaining why checked exceptions are really not a good idea.

https://blog.philipphauer.de/checked-exceptions-are-evil/

like image 57
TheDude Avatar answered Sep 28 '22 08:09

TheDude