Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

There are several ways to deal with nil in language design:

1. The "default value" approach as Go, or how Java treats primitive types: It's simpler and safer.

2. Universal nil, or how Java handles non-primitive types: Bad idea. It's Sir Tony Hoare's "million-dollar mistake". It leads to unsafe code and feels pretty backward for a modern language.

3. Union/sum type/algebraic data types: The Haskell and Rust approach. It solves the problem faithfully but does introduce mental overhead. Whether it's suitable for languages like Go which strive for simplicity is subject to debatable.

As for Enum and Exception, in principle, it's the same situation that there are three camps of ideas:

1. A minimal approach which is the Golang we have. For enum is there is no enum. For error handling is treating errors as return values.

2. A mainstream approach like Java and alike. For enum is enum like in Java. For error handling its exceptions and ad-hoc syntaxes like "?." operators.

3. A full solution like Rust and Haskell. For enum, it's ADT. For error handling it's also ADT-based Either type and monadic operators.

It's interesting that how often these three camps talk past each other, and even more challenging to hold the community together and make the right decision for the language.



Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: