Was It Really a Billion Dollar Mistake?
4 months ago
- #programming
- #memory-management
- #language-design
- Tony Hoare coined the term 'Billion Dollar Mistake' to describe the invention of null references in 1965, which he later regretted due to the errors and crashes they caused.
- Null pointers are just one type of invalid memory address and are easier to catch at runtime compared to other memory issues like use-after-free or incorrect pointer arithmetic.
- The article argues that removing null pointers introduces trade-offs in language design, such as requiring explicit initialization or complicating memory management.
- Odin, a systems-level programming language, retains nil pointers to maintain a C-like feel and avoid the architectural overhead of explicit initialization.
- The author critiques the 'individual-element mindset' in programming, which focuses on managing each element's lifetime separately, leading to inefficient and bug-prone code.
- A 'grouped-element mindset' is advocated, where collections of elements are managed together, reducing the need for complex ownership semantics and improving performance.
- Language design decisions, like those in Odin, reflect a conscious choice to nudge programmers towards better architectural practices rather than enforcing compile-time safety for every possible error.