3 ms·
Go doesn't have exception handling. How practical is it to use such a language for large code bases?
by kamaal 14y ago
Go doesn't have exception handling.
How practical is it to use such a language for large code bases?
- Devilboy 14y agoIt has explicit error handling (via multiple return values) which the authors argue is superior (even if more verbose) because they know from experience that programmers tend to make mistakes forgetting to check for errors in their code. If the error code comes back as a return value the programmer has to consciously decide what to do with it immediately, leading to better code on average.
- osi 14y agoas long as you aren't calling what you consider to be a 'return void' function (like writing data to a socket). then it is easy to forget to check the return value.
- icebraining 14y agoPractical is subjective, but there are a lot of large, successful projects written in C, so it's definitively feasible.
- kamaal 14y agoOf course if you say 'you have to live with it' then you really have to 'live with it'. After some time, you no longer complain about it. But this is 2013, there are somethings that expected to come from a language default. Exceptions are one of them, few such things I can think of are things like regular expressions, closures etc.
- seabrookmx 14y agoExceptions are extremely controversial in programming language circles. They reduce encapsulation, and the try/catch syntax as seen in java encourages bad error handling. Any idiot can put their whole program in a giant try/catch block. It's really a hard design problem. I agree that some form of error handling should be a language default, but I'm not sure if "traditional" exceptions should be it. As a C++ dev who has worked on projects with and without exceptions, I can say there is pros and cons to both.
- lucian1900 14y agoIt's not that hard, basically a solved problem in Common Lisp and more recently Rust: use conditions. They only unwind (not re-wind), so there's no worry about exception safety (as in C++) and they allow strictly more power than exceptions.
- redbad 14y agoBut this is 2013, there are somethings that expected to come from a language default. Very true! Exceptions are one of them, Very false! :) Exceptions have a lot of detractors.