Skip to main content

Posts

Showing posts with the label optional

NullPointer to Optional. How did we get here?

Null References: In 1965 while designing  Algol W,  British scientist  Tony Hoars  introduced the concept of  null  to programming languages. It started as a simple concept,  “ null is a pointer reference that is not pointing to any value ”. But he did not stop there, he wanted to ensure that the usage of pointer references is absolutely safe, so he made the compiler check for null references and throw errors. This is where everything started downhill. Here is a great talk from  The legend  himself. Null References: The Billion Dollar Mistake — Tony Hoare This compiler’s null check  error  in  Algol W  was the seed for java’s dreaded  java.lang.NullPointerException  class Java NullPointerException Since  NullPointerException  can occur almost anywhere in a program, Java designers decided to make it a  RuntimeException.  So developers do not need to write any code to catch and recover from it. ...