Fixing the billion dollar mistake in Go by borrowing from Rust
Blog post from Stream
The text explores the challenges and implications of using nil pointers and interfaces in the Go programming language, emphasizing that these can lead to runtime errors and production panics when not handled properly. It highlights that while nil can be useful for indicating missing values, it often results in programming errors when functions that don't handle nil inadvertently receive such inputs. The article discusses various workarounds, such as documenting that nil should not be passed to certain functions or using static analysis tools, but notes that these solutions are not robust. A potential solution inspired by Rust and C++ is proposed, which involves introducing a non-nil-able pointer type to eliminate the possibility of nil pointers, although this does not address nil interfaces. The text argues for language-level support to prevent nil-related errors, noting that other nil-capable types like slices and channels can also cause issues but were not addressed in detail.