3 ms·
Among the 20 most popular programming languages listed at the Tiobe index (Basic, C, C++, C#, Java, JavaScript, Lisp, Objective-C, Perl, PHP, Python, Ruby and m
by jicea 12y ago
Among the 20 most popular programming languages listed at the Tiobe index (Basic, C, C++, C#, Java, JavaScript, Lisp, Objective-C, Perl, PHP, Python, Ruby and more) none of them has null-safety built-in.
Juste some nuances for Objective-C: in Objective-C, it's perfectly valid to send any message to nil. For instance:
id someObject = nil;
[someObject setVisible:YES];
Is a valid code. I really appreciate this language feature, and avoid you a lot of boilerplate test. The problem is that nil as a parameter of a function (selector in Objective-C world) can trigger exception:
id someObject = nil;
[myArray addObject:someObject];
will trigger an exception.
- darylteo 12y agoMy gripe with that is that fail-silent scenarios can lead to some very nasty hard-to-find bugs. I've been bitten by it on several occasions. Fail fast and with lots of explosions, is the way to go for me.
- zak_mc_kracken 12y ago> and avoid you a lot of boilerplate test. You call it boilerplate testing, I call it error checking. Of course code becomes much simpler once you stop checking for error conditions, but it's still a terrible idea to do so (and I think Objective C silently accepting to send messages to nil is a never ending source for hard to find bugs)