14 ms·
The Brilliance of “nil” in Objective-C
- SemanticStrengh 5y agopeople should really try non-nullable types in typescript and kotlin, in addition to smart-casting. Then they would realize optionals are niche and cumbersome.
- chriskrycho 5y agoI’ve used TypeScript’s handling extensively as well as Rust’s, and I would say that there are actually significant tradeoffs, rather than it being an easy win for either. In particular, the fact that `| null | undefined` is just another union type can be very nice but also makes it annoying/impossible to implement a lot of the niceties like Rust’s `unwrap_or_default()` in a generic way (though some of that is just a function of how different Rust’s trait system is from JS). It also has weird fallout in the ways that it collapses together `map` and `andThen`/`flatMap`/`bind`. And it’s kind of annoying that it is a special case rather than having all the exact same tooling as all other types in the language the way sum type–based optional types do. On balance I very much prefer the Rust/Swift/etc. approach.
- hboon 5y agoMessage-eating nils helps you write elegant code. But it also makes it easier to crash when you didn't know what you were doing. I thought crashes like this were one of the reasons to create Swift. PS: The co-existence of nil, Nil, NULL and NSNull was just unfortunate.
- throwaway4good 5y agoNull is simple, straight-forward solution to the problem of missing values.
- happytoexplain 5y agoSimple and straightforward at write-time. A nightmare at run-time, modification-time, and debug-time.
- deltaonefour 5y agoA programming language without the concept of NULL can be created in a way such that it is impossible for the program to crash. Elm is such an example of this. Null solves the problem of missing values, but introduces the problem of undefined behavior. What happens to when you try to divide an integer with NULL? Often times the program just chooses to crash. To be fair though the problem isn't null itself. It's the failure of null to be incorporated into the type system. Instead null is used as a value to bypass the type system and silently propagate through your program and finally cause an error when you try to do an operation on it.
- rob74 5y agoI'm not fluent in either Objective-C or Swift, maybe that's the reason why the brilliance of having four types of "null"/"nil" escapes me? Ok, it probably works well if you're used to it, but it feels more like a kludge than anything else...
- throwaway4good 5y agoIt tells the tragic story of a language designer fighting to avoid null while building on/interfacing with an existing platform that has null.
- zaphirplane 5y agoKotlin kind of got away with it, in the sense that I (massive statically) don’t hear people complain about null on the Java interoperability calls
- throwaway4good 5y agoI think Kotlin took a more pragmatic approach - basically introducing ? and ! to signify that something could be null or something isn't null even though the compiler cannot see it.
- DonHopkins 5y ago"My favorite is always the billion dollar mistake of having null in the language. And since JavaScript has both null and undefined, it's the two billion dollar mistake." -Anders Hejlsberg "It is by far the most problematic part of language design. And it's a single value that -- ha ha ha ha -- that if only that wasn't there, imagine all the problems we wouldn't have, right? If type systems were designed that way. And some type systems are, and some type systems are getting there, but boy, trying to retrofit that on top of a type system that has null in the first place is quite an undertaking." -Anders Hejlsberg
- cxr 5y agoJS has null, the notion of a reference/binding being undefined, and the notion of a reference/binding being defined but assigned the value undefined.
- melling 5y agoNSArray *array = @[@"a", @"b", nil, @"c"]; // array = [@"a", @"b"] I sort of prefer Swift: let array = [“a”,”b”]
- happytoexplain 5y agoAnd the Swift version is even automatically typed as containing Strings using generics!
- astrange 5y agoThough this isn't precisely typed: let dict = ["a":[1],"b":["c"]] print(type(of:dict["a"])) = Optional<Array<Any>>
- drewcoo 5y agoObjC is similar to other things of the time. There used to be wonderful chaining nil/null check semantics. And duck-typed languages only made that better. if foo || bar || baz || you_do_not_even_know_what_comes_next break or: retval = foo || bar || baz || you_do_not_even_know_what_comes return retval &c I don't understand why it's notable except that it's not really JS or Pythonic . . .
- jamespwilliams 5y ago> Mostly used to recodesent null Is this line the victim of an overeager s/pre/code/g I wonder…
- Valodim 5y agoHaha, indeed. I can't think of an explanation for this one though: > switdhing to Swift “feels like a Jedi who’s trying to switdh from a lightsaber to a blaster,”
- cassepipe 5y agoOh thanks my mind just hopped over it without even trying. It's nice to see it was no knowledge gap but an well known word
- sillysaurusx 5y agoI found myself using nil in C++ everywhere. typedef std::optional maybe; using nil = std::nullopt; Not quite the right definition, but I’m on an iPad. When you combine those with an “either” function which returns either a maybe<T> else a default T, you end up with a nice way of having default args in C++. Everything defaults to nil, then you set it to either(foo, defaultFoo()) in the body of the function. Of course, C++ already has what it calls default arguments. But lisp has corrupted me. The defaults can’t be a function call, and the values can’t refer to other arguments, so they feel useless. Heckin C++. I feel like programmers 80 years from now will still be yearning for an escape, whereas C++100 will still be the dominant systems programming language. Golang was a nice attempt, and so is Rust, but empirically the evidence is that (at least in AI) you can’t escape C++. The best thing to do is to just dive in.
- deleted 5y ago[deleted]
- pjmlp 5y agoNot only in AI, anything GPGPU related (just look how many ISO C++ folks are on the payroll of the big three), and all major language and GUI runtimes.
- dataflow 5y agousing nil = std::nullopt; I don't think that compiles? The right hand side is a value, not a type.
- sillysaurusx 5y agoconstexpr auto nil = std::nullopt. I was on an iPad. :)
- teakettle42 5y agoIt’s only “brilliant” if you think data corrupting bugs that fail to run expected code and silently spread “nil” throughout your application’s data model are brilliant. If something can be nil, handle the case. There’s nothing brilliant about objective-C’s nil kludge.
- nicky0 5y agoLike any language feature, you have to know what you are doing.
- teakettle42 5y agoIt’s a foot-gun, and a significant source of bugs in just about all software of any complexity written in ObjC.
- nicky0 5y agoWriting code is a significant source of bugs in just about all software of any complexity.
- teakettle42 5y agoGood news, then; languages with an Optional<T> type don’t require you to write more potentially buggy code to check for (or forget to check for) nil.
- nicky0 5y agoMeh, different languages give you different tools, different degrees of nannying vs freedom. Some may give you a foot gun, but at least you have a gun and you aren’t required to point it at your foot.
- teakettle42 5y agoI prefer languages that make it easy for me to focus on solving novel problems, rather than wasting my mental energy just trying to not blow my foot off with a rusty musket.
- grenoire 5y agoAfter starting using Option<T>, no implementation of null is 'brilliant' any more. Not that any one of them ever was.
- deleted 5y ago[deleted]
- deltaonefour 5y agoI want to specify Option<T> with exhaustive pattern matching as the only way to extract the value out of the container is the safest way. Optionals without this feature/restriction are actually the same as a null. if(optional_value.has_value()) if(value != NULL) Both of the above checks are STILL required or it's an error. Optionals only propagate the null to another method call. There has to be exhaustive pattern matching for this feature to truly shine.
- blacksmithgu 5y agoEven optionals with bad 'is null / get' assessors are better than nulls, because they come with nullsafe operators like map / flatMap and the 'get' call usually always errors or panics on failure.
- deltaonefour 5y agoIt's the same thing right? flatMap or Map must call the has_value method to work without crashing.
- masklinn 5y agoIt's not because (I assume) even the shitty optional gives you a signal that the value is nullable and that you have to check. The important part is moving `null` out of every type in the language, and into its own little box that the compiler can tell you about. It's nice if you can make it a "library" utility without holes, but it's also fine if it's not perfect, or even if you have to make it a builtin magic thing, like C# &co. > flatMap or Map must call the has_value method to work without crashing. The implementation details don't really matter to the caller, what matters is that they're always operating in a safe environment without being bothered.
- planb 5y agoif (dict != nil && dict.containsObjectForKey[@"a"]) { ... } Can become this: if (dict.containsObjectForKey[@"a"]) { ... } This is probably the least-Swift thing ever, but, if you're used to coding in this style, it's fantastic Why is this better than a language that can guarantee that dict is not null?
- albertzeyer 5y agoBut this is potentially dangerous. E.g.: dict.setObjectForKey(@"b", @"a"); assert(dict.containsObjectForKey[@"a"]); A bit tangential related to the article: In Python, I often found that it is helpful to also have a separate "None"-like type despite None, which I called NotSpecified. Often in functions you have sth like: def func(opt: int = None): if opt is None: opt = get_default_opt() ... This works fine when you now that opt should not be None here. However, if None is allowed for opt and causes some other specific behavior, I now do: def func(opt: Optional[int] = NotSpecified): if opt is NotSpecified: opt = get_default_opt() ... This is also useful for dicts: my_dict.get("foo", NotSpecified)
- nicky0 5y agoAs an ObjC programmer, I concur.
- CraigJPerry 5y agoOption type was my favourite solution to this until i was introduced to nil punning. I still haven’t found a more pragmatic approach. Some languages allow you to say “this can never be null”, and in general, i find that really helpful and ergonomic but there’s cases where it’s not practical and you have to permit null and at that point, you’ve sunk the boat. Strict non-nullable with Option types has been moved to 2nd place solution since i experienced nil punning. Treat nil as a value, like in this article’s example of the array being terminated by nil. Don’t make it an exception to compare against nil. But don’t ascribe any other meaning to the value - that means no matter the context, nil can semantically fit your use case. It’s better than option primarily because it means a lot less code. You delete all “is this value present?” type code from your codebase because encountering nil in your happy path is rendered harmless. Very nice.
- HNHatesUsers 5y ago
- feanaro 5y agoThis sounds like an invitation for logic bugs and corruption. > It’s better than option primarily because it means a lot less code. Option doesn't need any extra code for checking the presence of a value when it's done right. In Rust, you just place a ? sigil at the end of the option expression. In Haskell, you just use the do syntax where val <- optional will assign the value to `val` if `optional` is some value rather that none, and it will exit the do block otherwise.
- CraigJPerry 5y ago>> Option doesn't need any extra code Ahh, those are both logic errors in your code. You do need the extra code to fix your errors here: >> In Rust, you just place a ? sigil at the end That changes the behaviour to bubble up that there was no value, the caller has been delegated responsibility and further processing has stopped at this point. Instead to accurately implement the required behaviour and replicate the nil punning logic, you’d need ? to behave in such a way that it inserts a suitable “empty” value for whatever type the option is guarding. So if this was an optional collection for example, the ? would need to figure out what type of collection then how to get an empty one to provide here (and you’d probably want that to be a singleton immutable collection, otherwise you’d be risking introducing logic bugs). In practice, you’d instead write code to provide that empty collection at the call site. At this point you’ve rendered the Option wrapper pointless though. It’s the exact same story for your Haskell example. You’ve given a different behaviour which is of course, a logic bug.
- terhechte 5y agoThe author seems to not know Swift very well, because this behaviour was ported over to Swift in a very nice, type safe manner: In Swift, you can call methods on Optional values, and they evaluate to null or the actual value. So the authors example: if (dict.containsObjectForKey[@"a"]) { ... } Would look like this: if dict?.contains("a") { ... } The `?` tells Swift to only call `contains` if `dict` is not null. The return value of this call would then be another optional. This second point is the improvement over Objective-C. There, you would not know whether the return value of `dict.containsObjectForKey` is a potential null value. This, in turn, would crash the app if you'd try to use this return value to, say index into an array or perform math on it. In Swift, the compiler yells at you to remind you that this value can be null. So, really, Swift has the same benefits, but better.
- mojuba 5y agoYes, but Objective-C is even more permissive than that. For example, [object method] where method is supposed to return an int, will return 0 if object is nil. This is of course a double-edged sword: it's too easy to make a mistake in your logic, but also you can use it to your advantage if you know what you are doing. The advantage really being just writing slightly less, i.e. eliminating extra if's. All this, however, didn't save Objective-C from being over all a very verbose language. At least from my experience of rewriting from ObjC to Swift, the latter can make your code half the size of the original and as an added bonus will make it so much safer too. This is why Objective-C is objectively and hopelessly dead now.
- Cloudef 5y agoIn swift you do mymethod?.call(...) Where method can be nil and it has the same effect. Similarly object?.something has the same effect. Use exclamation mark instead of question mark, to make swift runtime panic if the object or method is nil. Obj-c is objectively worse in every way and easy way to improve bugs in your code that go unnoticed for long time. Another cool thing is that you can use ?? At end of expression that can return nil to decide what to do if nil is returned (for example return something else). So swift actually reduces the amount of ifs required.
- threatripper 5y agoIn Kotlin you can have a similar behavior but it's explicit which I like more. var a : T; // cannot be null var b : T?; // can be null a.something; // OK b.something; // not possible because b could be null b!!.something; // assert that b is not null, then do the stuff b?.something; // if b is null, return null, else do the stuff So, each time you see the "?." you know to take extra care with that statement. On the other hand it's very short and easy to write chains of function calls that could return null which then falls through.
- happytoexplain 5y agoNote that this is all exactly how Swift works (though it uses one exclamation mark instead of two). The author is doing an extremely limited comparison, and simply doesn't mention these features.
- HNHatesUsers 5y ago
- Cloudef 5y agoNot sure if it's some runtime mode in kotlin but b?.something always threw panic for me when writing kotlin plugins for flutter, so I ended up having to guard the expressions with ifs anyways...
- seabrookmx 5y agoC# too.
- grahamlee 5y agoThis nil-swallowing behaviour works really well with the "out error parameter" pattern of Cocoa methods. In short, methods that can fail have a signature like: - (id)thingThatSometimesWorks:(NSError *)error; You can chain these to your heart's content. The one that fails sets the error and returns nil; following messages are sent to nil which does nothing and a particular characteristic of doing nothing is that it doesn't overwrite the error that was set. So you still get to see the error when the workflow finishes. As an objective-C programmer, I also have a tool in my toolbox which gives NSNull the same message-swallowing behaviour as nil. @implementation NSNull(GJLNilReceiver) - (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector { return [super methodSignatureForSelector:aSelector] ?: [NSMethodSignature signatureWithObjCTypes:"@@:"]; } - (void)forwardInvocation:(NSInvocation *)anInvocation { [anInvocation invokeWithTarget:nil]; } @end
- KMag 5y agoYou're better off having an operator in your language that explicitly chains together methods returning Result<T,E>s. That way, you can easily get this behavior if that's what you want, but it's clear from reading the code that it's intentionally not quite a simple chain of method calls.
- arcticbull 5y agoI mean this with love, this extension to NSNull gives me a brain aneurism. If I had this in my codebase I wouldn't be able to trust anything in a collection.
- grahamlee 5y agoYou might want to return NSNull instead of nil (easy to do: in fact I extracted this from an object in which the nil-return value is configurable but simplified it for the post), in which case it becomes map-safe because NSNull->NSNull on map. I use this pattern because then I can trust _everything_ in a collection. If an object, even an object that represents emptiness, receives a message, it will handle it and do something, even where that something represents emptiness.
- deleted 5y ago[deleted]
- yakshaving_jgt 5y agoCould there be a way to eliminate the problem of null values floating through your system? Maybe.
- happytoexplain 5y agoI see what you did there. And Swift, the very language the author is comparing to, has this functionality.
- deltaonefour 5y agoSo does Haskell and Rust. It's called exhaustive pattern matching on sum types with the Maybe monad (or Optional). I believe Haskell popularized this syntax and Rust and Swift borrowed it from Haskell. Strictly speaking though, haskell pattern matching isn't exhaustive but the compiler will give you a warning if your code doesn't handle every case. Elm is another language that exploits this feature to a scale where unless you use the FFI, elm programs cannot logically ever crash.
- happytoexplain 5y agoThis would be cool as a comparison to traditional null handling (i.e. crashing). But the comparison to Swift is ridiculous. This begs for overlooked nulls to silently create logic bugs. Also, the author admits there are two kinds of null in Swift, as compared to four in Obj-C. Is the second kind he's referring to `NSNull`? Doesn't that only exist to bridge with Obj-C APIs that haven't been updated yet? That's pretty misleading, if so.
- astrange 5y agoNSNull is used to store nulls in NSDictionaries when you really want them to, since they don't allow storing `nil`. An example being decoding JSON, which does allow it.
- happytoexplain 5y agoI was thinking that counted as one of the "Obj-C APIs that haven't been updated yet", but I guess it's not actually going away since it's qualitatively different from Swift's Dictionary (being a reference type instead of a value type).
- brundolf 5y agoOptional-chaining in other languages gives you the same ergonomics without the funky semantics
- happytoexplain 5y agoThere is this weird disconnect going on in this article and therefore the HN comments. The author's first sentence is, "I don’t code much in Objective-C these days but one thing I miss about it compared to Swift is how nil works." He's not just saying "this part of Obj-C's nil is good", he's saying, "this part is good even compared to Swift", which makes no sense because his "before" example in the before-and-after is Obj-C, and not Swift. The HN comments then proceed to enumerate the advantages of modern handlings of null, of which Swift is a prime example. The author's lack of clarity is understandably causing this.
- b3morales 5y ago`NSArray` is not `nil` terminated; the argument lists to some of its variadic initializers are, but the array itself simply does not contain `nil`. The literal syntax `@[ ... ]` gets transformed into an initializer call, which throws an exception if it is passed a `nil` value. And I can't remember, but I would expect the compiler to at least warn, if not error, if you put a literal `nil` in there.
- arcticbull 5y agoThey're just referring to -[NSArray arrayWithObjects:...] which takes a va_list. Same with -[NSDictionary dictionaryWithObjectsAndKeys:...] These both long predate the array and dictionary literal syntax.
- arcticbull 5y agoAs someone who started writing Objective-C on macOS in 2003, the whole nil messaging syntax is pure hell compared to any modern language that disavows nulls entirely (like Rust, and to a large extent Swift). You can literally never trust anything - ever - is not nil because `nonnull` is just a hint, and messaging nil will never crash. It'll just return 0 (or {0} or 0.0 depending on context), which is sometimes valid - and sometimes a horrible failure mode. Failing silently like that is the worst option. As such you end up having a ton of boilerplate all over the place checking the validity of input parameters to methods and initializers for conditions which shouldn't be representable in the first place - even when the method signature warrants that it's not representable, because it still won't crash on ya. Let's say you have a chain of property accessors, a.b.c.d, the where d is a float. They're all supposed to be nonnull. You get 0.0. Is that valid? Shrugasaurus rex. Time for the ol' NSParameterAssert(a.b.c != nil). [edit] Also, canonically, there's 5+1 'null' values: nil, Nil, NULL, -[NSNull null] and 0 - plus nullptr in Objective-C++.
- MaxBarraclough 5y ago> Failing silently like that is the worst option. > As such you end up having a ton of boilerplate all over the place checking the validity of input parameters to methods and initializers for conditions which shouldn't be representable in the first place Dynamically typed languages (at least, JavaScript and Python) have been gradually learning this lesson.
- deltaonefour 5y agoActually python fails hard and fast. This is very different from javascript. It actually makes python safer then C++ even though python is dynamically typed. It is far easier to debug a error caused by out of bounds memory writing/reading in python then it is in a strictly typed language like C++. This is because C++ doesn't actually fail hard and fast when you do this. If you ever programmed extensively in both languages you will actually see that python is by far less error prone then C++ despite being untyped. Javascript is actually the same, though a little worse then python because how an undefined can get propagated deep into a program. Still even though an undefined is hard to debug in javascript, it's still traceable through a step by step methodology. A C++ seg fault is not always so straight forward. I would argue that it doesn't depend on whether the language is dynamically typed, but more on the traceability of crashes.
- moth-fuzz 5y agoMy only contention with Optional<T> types as opposed to NULL/nil/null is that in practice they're almost useless. An Optional<T&> is a pointer, plain and simple. If NULL is one of the expected values, it should be handled as expected. This leads to a vast simplification of a number of algorithms and data structures and no need for `.unwrap().unwrap().excpect("unreachable")` in the cases you can't do anything anyway. I've rarely seen cases where null values were possible at the algorithmic level, and expected, and not handled, because, lazy programmers I guess? Honestly all I can say for that particular case is that if you write half an algorithm, expect it to fail half the time... On the other hand, if NULL is not an expected value, then how often do you really find the logic error at the same spot that the panic occurred? Not very often in my experience. We have callstacks for a reason. You usually find the NullPointerException at the bottom of the stacktrace or the None.panic() after 100-something other function calls in significantly complex codebases. No, if a function expects a value 100% of the time, and it was passed a NULL value, that's the caller's problem. And Option<T> won't help you if the user-facing calling code is still passing None or std::nullopt for whatever misguided or erroneous reason they may be doing so. Certainly I agree there're benefits to encoding this kind of behaviour into the type system, but I don't agree that it's ultimately a solution to the '4 billion dollar mistake', since mistakes ultimately still happen. You just swap NULL for None and you still have a bug in your logic, just no longer a bug in the types. It's kicking the can.
- b3orn 5y agoIn C a pointer is a version of the optional type, implementing an explicit version of it is therefore pointless. In other languages you could enforce that a pointer can't be null or even forbid it to be uninitialized therefore you need to have an optional type for the cases where you want to allow null, so if you get a pointer you can trust it a little more.
- potatolicious 5y ago> "This is probably the least-Swift thing ever, but, if you're used to coding in this style, it's fantastic." As someone who has been building on Objective-C for >10 years now... it's horrible. Sure, there's less compiler-yelling-at-you-itis, but the code sample the author gives is almost certainly the single biggest source of bugs in Objective-C codebases. The inclusion of Optionals in Swift is specifically to, in one fell swoop, eliminate the single largest source of bugs in Obj-C codebases. I get the appeal of getting the compiler to be less strict and yell at you less for just hacking around - but something you use to write production code needs be very liberal about error detection and yelling at you. Not to mention the same lack of verbosity is supported in Swift with all of the safeties of optionals: `if dict?.keys.contains("a")` Which is both semantically and typographically terser, and makes the intention of the code clear (i.e., "dict" is expected to sometimes be nil)
- jon889 5y agoI don’t see how it’s that different to Swift? All that would be needed is a ? after `dict` and a direct comparison to true. dict.containsObjectForKey[@"a"] Becomes roughly dict?.containsObjectForKey(“a”) == true
- hardwaresofton 5y agonullable types are bad and hopefully everyone knows it by now. Other things too but I’m too lazy (forgive the clickbait title): https://vadosware.io/post/how-and-why-haskell-is-better/ https://vadosware.io/post/how-and-why-haskell-is-better/
- rzwitserloot 5y ago> In a lot (most?) cases where there's a possibility that dict could be nil, the thing you want is for nothing to happen. And therein lies the root error which makes this entire blog post misguided. Trivial (hopefully) question: Would you rather fix 1 bug that takes 10 minutes to find, or 10 bugs that take 20 seconds each? Given that 'my code silently just... does.... nothing? That's odd' is tens to perhaps even a hundred times harder to find than 'you assumed this could not be null, right on this very line right here, here is the full stack trace how we got there - it IS null' - NPE is superior to this silent treatment. That's not to say runtime-only null checking (e.g. java without nullity annotations for example) is the only right answer. Far from it. But it's superior to leaving a trail of ticking time bombs like this. In effect, you make a difference choice about the semantic meaning of it. In Objective C, `nil` means: "A sentinel object that is real, has semantic meaning, and that meaning is that it returns nil for all things". Woe is you if you treat it as "An object that indicates the value is unknown or does not apply (no interaction with it was ever expected)". In java, `null` means: "A sentinel value that indicates the value is unknown/unset or does not apply - hence any attempt to interact with it will throw an error". Woe is you if you treat it as a sentinel. But less woeful - you simply get an exception pointing at the line where you made the brainfart. Unfortunately lots of program language ecosystems aren't quite as clear about what nil/null is supposed to actually mean (e.g. java where it's often used as sentinel, and then leads to code littered with `if (x == null || x.isEmpty())` style lines, a clear sign someone is not sticking to a meaning of `null` that works well with that particular language.
- trixie_ 5y agoNot crashing on null is part of what led to the remarkable stability of iPhone apps vs Android. Same with javascript apps. Can you imagine how painful the web would be if the entire page 'crashed/disappeared' every time an unhandled exception was hit in javascript. If programmers today treated software like a car, they would blow up the car every time the air conditioner button didn't work. Desktop and console apps work this way. Perfect is the enemy of the good, many times your app isn't running a nuclear reactor, and even if it was you might want it actually be able to recover from a failure. Think Erlang.
- hayley-patton 5y ago> Think Erlang. Conventional Erlang style is to crash a lot, but to limit the amount that crashes by using enough processes, I believe, c.f. "The How and Why of Fitting Things Together" <https://www.youtube.com/watch?v=ed7A7r6DBsM&t=1535s https://www.youtube.com/watch?v=ed7A7r6DBsM&t=1535s>. But the key part to handling failure is to detect it first, and silently passing through nil/null/etc is not that.
- trixie_ 5y agoNo matter how you do it, avoiding a hard crash is the point. Don’t throw away the users work because some feature threw an uncaught null exception.