Everything Bad in Java is Good for You

<p>&ldquo;Everything Bad is Good for You&rdquo; is a&nbsp;pop culture book&nbsp;that points out that some things we assume are bad (like TV) have tremendous benefits to our well-being. I love the premise of disrupting the conventional narrative and was reminded of that constantly when debating some of the more controversial features and problems in Java. It&rsquo;s a feature, not a bug&hellip;</p> <p>One of my favorite things about Java is its tendency to move slowly and deliberately. It doesn&rsquo;t give us what we want right away. The Java team understands the requirements, looks at the other implementations, and then learns from them.</p> <p>I&rsquo;d say Java&rsquo;s driving philosophy is that the early bird is swallowed by a snake.</p> <h1>Checked Exceptions</h1> <p>One of the most universally hated features in Java is checked exceptions. They are the only innovative feature Java introduced, as far as I recall. Most of the other concepts in Java existed in other languages, checked exceptions are a brand new idea that other languages rejected. They aren&rsquo;t a &ldquo;fun&rdquo; feature; I get why people don&rsquo;t like them. But they are an amazing tool.</p> <p>The biggest problem with checked exceptions is that they don&rsquo;t fit nicely into functional syntax. This is true for nullability as well (which I will discuss shortly). That&rsquo;s a fair complaint. Functional programming support was tacked onto Java, and in terms of exception handling, it was poorly done. The Java compiler could have detected checked exceptions and required an error callback. This was a mistake made when these capabilities were introduced in Java 8. For example, if these APIs were better introduced into Java, we could have written code like this.</p> <p><a href="https://betterprogramming.pub/everything-bad-in-java-is-good-for-you-71b8de5133b5">Click Here</a></p>