3 ms·
I wish more languages treated null like objective-c. Where if a method is called on a null object, nothing happens and the method returns null. In user land a '
by pixie_ 14y ago
I wish more languages treated null like objective-c. Where if a method is called on a null object, nothing happens and the method returns null. In user land a 'null bug' in objective-c often results in a feature not responding, as opposed to the entire app crashing. It's a much better user experience, and I can write code less paranoid about null values as well.
The car doesn't need to blow up if the air conditioning isn't working.
- Too 14y agoKeeping the program running with corrupted data sounds very dangerous and brittle. Reminds me of php where passing the number 5 or the string "5" into a function returns the same thing whereas passing the number 0 or the string "0" can behave completely different. Not caring about what data you have and just trying to keep running is just sweeping the problems under the carpet and waiting for them to come bite you when you least expect it.
- pixie_ 14y agoIs it better for you, or for your user? Are you building a game, a social app, or space shuttle software? These questions should guide your decision in language requirements.
- mikec3k 14y agoYou still have to worry about calling a method on a released object or a method it doesn't respond to. Making sure you set an object to null when you release it is good practice for that reason.
- pixie_ 14y agoTrue, I wish I could take Objective-C's handling on null and put it into C# or Java.