3 ms·
Surprisingly, you see that sort of issue (perhaps in a more subtle way) a lot, even in evolved libraries and languages. By "I consider NullPointerException for
by michaelochurch 12y ago
Surprisingly, you see that sort of issue (perhaps in a more subtle way) a lot, even in evolved libraries and languages.
By "I consider NullPointerException for any reason to be a bug" I mean that, even if the program is going to crash hard, it should give a better error message. Crashing hard is sometimes the right thing, but high error-failure distance is never good.
This may have changed, but for a while, OCaml raised the dreaded (and useless) Not_found error on List.head [], and it wasn't until 3.10 that you got a stacktrace on a runtime error. (Of course, most people who use OCaml or Haskell in production rename those functions to, e.g., unsafeHead and make the optionized versions the default.)
Debugging and error-handling culture has come a long way, even in the past 10 years. Clojure, for example, is a great language and I am overall a huge fan, but it was painful to debug when it first came out, and it used to be fairly common for runtime errors to manifest as NullPointerException.