4 ms·
Rob Pike, one of the three creators of Golang, disagrees with you. In his blog post less is exponentially more[1] he shares a list of significant simplification
by anonfunction 11y ago
Rob Pike, one of the three creators of Golang, disagrees with you. In his blog post less is exponentially more[1] he shares a list of significant simplifications in Go over C and C++ which includes:
> no exceptions
1. http://commandcenter.blogspot.pt/2012/06/less-is-exponentially-more.html http://commandcenter.blogspot.pt/2012/06/less-is-exponential...
- dragonwriter 11y agoAnd yet "panics" exist, with very similar semantics to exceptions in C++/Java/Python/Ruby. Sure, there's differences between Go panics and any one of those implementations of exceptions (just as there are between them, or between any of them and Perl 6 exceptions.) But panics are clearly a variation on the exception theme, just as each of those forms of exceptions is. The strong idiom of not having panics exposed across public interfaces of libraries is a cultural change, which to the extent that it is followed does present a simplification compared to ecosystems where you have to deal with both returns and exceptions in library code. But panics very much are exceptions, and changing the name doesn't change that.
- anonfunction 11y agoAs I was originally answering a question regarding whether it was normal to return errors or raise exceptions, and because I've read Dave Cheney and Rob Pike's blog posts explicitly stating Go does not have exceptions I replied as such. However, after doing some research I learned that in addition to Panic() there's also Recover()[1], so I'll concede that there is similarity between panic/recover and throw/catch. Prior to my learning about Recover() I was under the assumption that Panic was just used to print a message and close a program with a non-zero status. 1. https://github.com/golang/go/wiki/PanicAndRecover https://github.com/golang/go/wiki/PanicAndRecover