Removing Language Features?
As a language grows by the addition of features, it necessarily gets more complex. After all, you can't remove existing language features because existing programs use those features, but each additional feature adds complexity. Right?
Fellow Googler Matt Shulman asked me a question about the Closures for Java
specification. He observed that much of the complexity arises
because of support for checked exceptions in the spec. Things like throws
type parameters, disjunctive types, and throws clauses on function
interfaces would be unnecessary without checked exceptions. Matt asked
me if we had considered if things would be simpler without all that. At
first I misunderstood his question to be referring to just the Closures
specification, so I answered that the facility wouldn't fit
into the language as well without support for checked exceptions.
Matt clarified that he was asking not just about removing support for checked exceptions from the Closures spec, but from the entire programming language.
There has been an ongoing debate on the utility of checked exceptions. Many people are critical of Java's checked exceptions, characterizing them as a failed experiment in software engineering. In practice, checked exceptions can result in API complexity, and programs appear to be cluttered with exception handling code just to satisfy the compiler. Some people believe checked exceptions are a good language feature but are misused, even in the JDK. With the "experts" being such poor role models, how can we expect ordinary Java programmers to do better?
We did a Google search to see how many people have written in support of checked exceptions and how many people don't like them. The discussion seems to be lopsided against checked exceptions, but on the other hand that may be due to the fact that checked exceptions are the status quo.
This isn't a question I had thought much about. I believe the language could be simplified by treating all exception types as unchecked without breaking existing programs. This could also result in a simplification of future language extensions and APIs. But would the language and platform be better off without checked exceptions?