The Ceylon language takes a different approach to reading and writing files than Java. Consider the following methods in Java:
Better Checked Exception Handing… If Java Had Default Generics
I believe that, if done right, checked exceptions can benefit an API. However, they weren’t given the proper TLC in the new Java 8 APIs, particularly in the Streams. But if Java was enhanced with default generics, the mess could be cleaned up.
Should methods return null or throw an exception?
As API authors, one thing we have to think about is, what happens when a method cannot fulfill its contract? Should it return
null or throw and exception? Sometimes we write both the API and its consumer. Our job—especially if your API will be used by developers that aren’t us—is to make that API as easy to use and understand as possible. While you might have heard the phrase, “use exceptions only for exceptional conditions”1, if done correctly, throwing and catching exceptions can ensure a level of correctness in our programs.