514 karma · joined March 7, 2019
I don't get it. These are literally all exactly the same thing, all slightly varying in ergonomics and compiler support. They may differ slightly but to call them two different categories of solution is just creating a false dichotomy for yourself.
> However, the type system is a little more flexible than with option types. The type system understands that a union type is a supertype of its branches. In other words, int is a subtype of int?. That means we can pass a definitely-present-integer to something that expects a maybe-present-integer since that’s safe to do.
You can do that in Swift, despite being placed as an example of "Solution 1".
> The short answer is that, yes, it is entirely possible to live without null, and languages like Rust do.
If you can call say that Swift has "null", then you can equally say that Rust has "null"--it's called "None". The only way "None" and "null" from other languages differ is in built-in compiler support.
The idea that "you can't write safe C" is a big joke. C is as safe as you make it.
1. Because it's healthy and feels good
2. Because it's healthy and may stop future problems
3. Because it may stop future problems
4. Because it feels good
So why lose weight for the sake of losing weight? It's neither healthy nor fun if you do it the wrong way.