Re:Perseus – NextJS alternative in Rust
by madeofpalk on Sunday April 09, 2023 @05:22PM
(#35506602)
null/undefined is type checked in Typescript so the compiler will make sure you check whether your value is defined or not and handle it appropriately.
Go having nullability isn’t the problematic part - it’s how nil is not type checked, so a value might secretly be nil and you won’t know until your program crashes at runtime.
Rust avoids this by just not having null, instead using things like Result and Option types, which is pretty neat with pattern matching.
As opposed to Typescript's null, undefined, or optionally defined types? I don't use Go or Rust, but I do use Typescript so maybe I'm a bit confused by this statement. Go allowing nullability doesn't seem like a dramatic shift from Typescript's 3 different ways to represent a potentially ill defined object, and it wouldn't turn me away from the language.