4 ms·
> Yes, you MUST. That is just how Go does things. If it's something I "must" do, why doesn't the language force it to happen? Silent failure is a really bad de
by awj 13y ago
> Yes, you MUST. That is just how Go does things.
If it's something I "must" do, why doesn't the language force it to happen? Silent failure is a really bad default.
- AnimalMuppet 13y agoYou mean something like Java's checked exception? That has its value, but you have some programmers who write empty catch blocks just to get rid of the exception. Forcing the programmer to handle it is not the same as forcing the programmer to handle it.
- hackinthebochs 13y agoHow is this an argument for silently failing being superior? It seems like static checked exception handling could solve this problem easily, the compiler can just display a warning on an unhandled exception and then pass it up the chain.
- AnimalMuppet 13y agoIt's not an argument for silently failing being superior. It's a claim that too often, static checked exception handling gets subverted, and therefore doesn't work. Sooner or later, you have to trust the programmer to not be an idiot. If he/she is an idiot, the language can try to help, but can't really fix it. Static checked exceptions let the programmer know that there's something that needs to be handled. That's good. It can check that the programmer put a catch block somewhere, but it can't guarantee that the programmer did anything appropriate to handle the problem inside that block. It's better than nothing, but it's not enough. (And if you're going to ask what is enough, I have to reply: Nothing. If the programmer is determined to ignore the fact that there's an error to handle, the language can't fix things.)
- awj 13y agoI can see what you're saying, but ultimately there's no helping people who are doing something they don't really understand. I'm more interested in language features that remind me when I forget to do something I wanted to do.
- waps 13y ago> That has its value, but you have some programmers who write empty catch blocks just to get rid of the exception. That's why you have code review and code linters. If you have a linter, there's no way in hell you'll ever miss this has happened. Take a beginner's Go code ... do they check errors ? Just like with C the answer is plain and simple ... no, they don't.