Re:Go Developer Survey 2022 Q2 Results
by lenkite on Thursday September 15, 2022 @03:53PM
(#32857632)
Java stack-traces are extraordinarily informative - they give line number, class, method and even offset inside relative lambda when an exception occurs. Few languages do better and Go is not one of them.
My eyes glaze over when I'm trying to read stack traces in Java or Python, and then it turns out I can't figure out what's wrong because the stack trace doesn't include the path of the file that failed to parse.
What we care about is stuff like:
- Program tried to parse file X,
- Failed because file X doesn't exist, or because file contains syntax errors, or something
- Some context giving us the reason why program tried to read file X, which is usually at a fairly high level (something like "could not load config").
Putting the function name in the error-handling code is something that you SOMETIMES do, but only when it adds important context. If you do it all the time you end up with something completely unreadable, like a stack trace. There are various libraries you can use that give you stack traces for errors in Go, if that's what you want.
If I get an error that X is not a valid JSON file--often, that's all I need to know, because I can open X and see the syntax error and fix it. Knowing the name of the function that detected the syntax error is unhelpful, usually, and we have logging + debuggers to help with those cases.