Hacker News new | past | comments | ask | show | jobs | submit login

Go has both error codes, and exceptions (panic/recover). Basic errors implicitly panic, such as null pointer exceptions, arithmetic errors, ...

So in Go you have the worst of both worlds. Constant error handling code everywhere, AND you have to treat every single expression as if it may suddenly throw panics.

Oh and to make matters even worse, Go has typed nil, which is not equal to untyped nil. So you cannot correctly check interfaces against nil, the most common cause of panics in my experience.

// t is some kind of interface if (t == nil) { // t is untyped nil } else { // t is non-nil OR a typed nil }

I'm not even sure what the correct fix is. Should every interface come with a isValid() method to check if it's usable ?




Join us for AI Startup School this June 16-17 in San Francisco!

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

Search: