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

> the fundamental tenet in Go is that every error should be handled.

That's true in Java as well.




I think the point is that in Go, you expect failure. Failure is not exceptional. It's a first class part of the logic.

Java conditions you to view failure as an exception to the rule, and the happy path as the real code (which is the attitude you express in your first comment). Lots of us have since observed that this approach to failure leads to errors because programmers ignore failures, allowing them to be handled by a catch-all at the top of the stack, which typically just dumps a stacktrace and calls it a day.

The paradigm espoused by Go sees errors as just another program state, and one whose implications are just as important to consider as the desired behavior. This forces programmers to consider all the implications of a failure, rather than just adding another `throws` clause.


> Lots of us have since observed that this approach to failure leads to errors because programmers ignore failures, allowing them to be handled by a catch-all at the top of the stack, which typically just dumps a stacktrace and calls it a day.

That's not typical Java code. You could do that in quick & dirty code, but I haven't seen such code in production code.


> That's not typical Java code. You could do that in quick & dirty code, but I haven't seen such code in production code.

It sounds to me like you're an extremely lucky person. I've seen too much of that sort of thing in production code, including a catch-all for Throwable at the top that didn't even dump a stacktrace.


Anecdata: but I see this pattern all the time in production code. It’s not limited to Java: I’ve seen it in TS/JS, Python, and C++. I haven’t (yet) seen it our Go codebases.


Typically this is passed to production and not seen by devs. Ie. there's no point to handle NullPointer explicitly (programmer error).


Then you're lucky. I have, both on the developer side and on the user-getting-a-stacktrace side. It's not pretty from either end.




Consider applying for YC's Summer 2025 batch! Applications are open till May 13

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

Search: