News for hackers. Stuff that matters.
Re:Why nullable types? by ibraheemdev on Monday December 07, 2020 @09:44PM (#25341032)
> it is entirely possible to live without null, and languages like Rust do.

It seems as though there is this common misconception that Rust does not have a concept of null. Rust does have null pointers [1]! The reason many people do not see null often is because working with and dereferencing raw pointers is an unsafe operation

1: https://doc.rust-lang.org/std/ptr/fn.null.html

Re:Why nullable types? by joshgev on Monday December 07, 2020 @10:05PM (#25341213)
> It seems as though there is this common misconception that Rust does not have a concept of null.

I don't think that's quite relevant, though. Rust doesn't have a concept of nulls like like Java, Javascript, Python, etc do in which just about any variable might contain a value or null. Rust certainly doesn't have that.

Re:Why nullable types? by ibraheemdev on Tuesday December 08, 2020 @08:33AM (#25344764)
I would not say that it is not relevant. Raw pointers are a fundamental part of the language. It is just that Rust abstracts over them so that many users do not have to worry about them.

I see your point though.

Re:Why nullable types? by viraptor on Monday December 07, 2020 @10:06PM (#25341218)
I don't think people mean it doesn't have a raw null pointer. Normally it's about a null object reference that you can assign to (almost) anything like Java's / c's null.
Re:Why nullable types? by Cyph0n on Tuesday December 08, 2020 @12:52AM (#25342339)
Of course Rust has a null pointer type. Otherwise, it wouldn’t really be a systems programming language :)

But most users would rarely if ever need to use that type. Option<T> is how Rust deals with optional/nullable values.

Re:Why nullable types? by ChrisSD on Tuesday December 08, 2020 @01:32AM (#25342520)
Note that nowadays the preferred way to handle null pointers in APIs is the `Option<NonNull>` type. This unfortunately wasn't available in Rust 1.0.

https://doc.rust-lang.org/std/ptr/struct.NonNull.html