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

I don't love that Go doesn't have exceptions. But it was a choice made thoughtfully:

https://golang.org/doc/faq#exceptions https://go.dev/blog/errors-are-values



There is one more reason. When you write something that works in a loop, e.g. web server, exceptions are a huge potential issue. I was working on a C++ project with a very complex state machine. One day our service started using all 128 CPU cores just for stack unwinding. It was an ordinary exception in 3thrd party library raised on every request in the loop. We have tried to make a lot of optimisations in different unwind libraries. But it was far away from the performance of a simple Optional-like errors container as a return value. Exceptions are really Zero-cost if they occur only once when application should be terminated.




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

Search: