I'm still of the opinion they made a mistake by not having exceptions. When programming in Python exceptions are wonderful because they let me put error handling code in the appropriate place without having to litter all the intermediary code to where errors happen with error flags. (Panic is not the same thing.)
The usual complaint about exceptions is "expense", but the same claims can be made about gc. The Go FAQ is more concerned about people labelling non-exception things as exceptions (so what?) or that try/except/finally is ugly. I agree with the latter, but even worse is littering code with if statements doing the manual equivalent of try/except/finally.
The reason we didn't include exceptions in Go is not because of expense. It's because exceptions thread an invisible second control flow through your programs making them less readable and harder to reason about.
In Go the code does what it says. The error is handled or it is not. You may find Go's error handling verbose, but a lot of programmers find this a great relief.
In short, we didn't include exceptions because we don't need them. Why add all that complexity for such contentious gains?
I'm with the grandparent. Every language that I've used that was created after C has included exceptions, and never once have I missed checking errno.
I can understand why, coming from a C++ context, you'd want to avoid them like the plague, but other languages (Python, Java, Smalltalk, ...) do a good job of making them a first-class citizen in the language, which saves a LOT of boilerplate typing. Seeing call stacks implementing a half-assed exception catching mechanism makes me sad. (Okay, Java only gets half credit here, since its checked exceptions inflict a different kind of boilerplate, but my larger point remains.)
Lack of exceptions is half the reason I'm not interested in writing Go code yet. The other half is that anything that seriously intends to replace C++ does need an escape hatch to allow manual memory management for when the GC's one-size-fits-all approach is simply a poor fit. For a language whose goal was explicitly to replace C++, this is an odd place to be tone deaf. I'm disappointed to see an attitude of "haha stupid C++ programmers don't understand that programmer efficiency is more important than CPU efficiency," instead of realizing that there are valid use cases where you do need to care about this and addressing them.
Did you miss the part where he says: "We weren't trying to design a better C++, or even a better C. It was to be a better language overall for the kind of software we cared about."
You're missing the forest for the trees. The topic of the article is about how good was motivated by creating a better language for systems software than C++, and hypothesizing why it's nevertheless getting more traction with the scripting crowd than C++ programmers.
"We—Ken, Robert and myself—were C++ programmers when we designed a new language to solve the problems that we thought needed to be solved for the kind of software we wrote. It seems almost paradoxical that other C++ programmers don't seem to care."
> In Go the code does what it says. The error is handled or it is not. You may find Go's error handling verbose, but a lot of programmers find this a great relief.
I'm sorry but you are on the wrong side of history on this question (and I happen to think you're also wrong in your characterization of exceptions).
Forcing callers to deal with error numbers right here right now only gives you the illusion of clarity and robustness but it gives you neither.
Every Go program I read is littered with "err,ok := Foo(); if err {}" every ten lines or so. It's brutally verbose and hides the intent of the code.
And it also forces callers to handle error codes that they might not be able to, while a caller a few stack frames above would do a much better job at it.
We learned all these lessons in the 90's, pity Go chose to ignore them.
I just want to point out that just because go lacks a good way of handling error conditions, doesn't mean exceptions are the best way. Haskell has exceptions, and I wish it didn't. Because it has better options for dealing with error conditions, like Maybe and Either. If you are checking for an error condition every ten lines, those are by far nicer than using exceptions.
> In short, we didn't include exceptions because we don't need them.
I would say that not only I don't need exceptions, I absolutely don't want them.
A really annoying thing about languages with exceptions is how they contaminate code, exceptions are (often hidden and badly documented) part of the interface of libraries and packages which you have to deal with when you least expect it.
I hear this from Rich Hickey about Clojure all the time. I'm certainly not at the brain-power level to fully absorb all the implications of that phrase, but I'm starting to "get it". I think this is probably one of the most compelling things to strive for in a medium that is used to "make stuff", like a programming language.
After using Go for a while (and Python and Java and many other languages with exceptions for years), lack of exceptions is one of my favorite things about Go.
Handling errors is not something magical that you have to worry might happen when and where you least expect it.
Exceptions are specially bad in Python, because often they are not even documented as part of the API, so you are never sure when you call a library what it might or might not throw and when.
And that is without going into how they are abused for convoluted control flow.
I agree that exceptions done badly are poor. That is especially the case with C++ where they were introduced later, and they are one of the things some people omit when picking the subset of C++ they use. I also don't think exceptions should be done without GC. Java's checked exceptions are very annoying.
My experience in Python is the opposite than yours, but then I've only been using it for 12 years :-) Undocumented serious exceptions are no different than Go's panic - they will probably terminate the program. But the usual case is extremely useful and not littering intermediate functions with error handling is wonderful.
And sure they can be abused, but virtually any functionality gives you "power" and that power can be used wrong. That isn't a good reason to take something away from the developers who would use them right.
> Undocumented serious exceptions are no different than Go's panic
They are very different, in Go you only panic() for programmer errors: panic() is never part of any API, when you access any API you never have to worry about whatever it will panic() or not.
Meanwhile in Python any function or method might throw an exception for almost any reason imaginable, but of course most people pretend they don't, because exception handling code would swamp your code.
I have done plenty of Python programming, failure to properly handle exceptions is very common.
> And sure they can be abused, but virtually any functionality gives you "power" and that power can be used wrong.
Exceptions are particularly problematic because they are a hidden part of APIs, and you have to be aware of and deal with this hidden part libraries all the time, not just in code you write.
One school of thoughts is that exception is a non-local goto that might span many levels of calls, and that can be non-trivial to understand. Languages without exception has clear paths of return in a function.
True, but so what. The code I like the best is the code I don't even have to write. Having to write all the intermediary code between where an exception happens and where I'd like to handle it is annoying.
And the "understanding" argument applies to other things, such as using a compiled language instead of assembly or GC instead of manual memory allocation.
You should mind writing code that the compiler can write for you, which is exactly what you do when you don't have exceptions (you simulate bubbling up the error manually).
The assumption here being that if you do not have exceptions, one must write all the intermediate code. That exceptions are the only way of avoiding this.
While in Go this may be the case, it is not true in general. One could use an error monad to achieve the exact same thing, albeit in a much safer manner.
The usual complaint about exceptions is "expense", but the same claims can be made about gc. The Go FAQ is more concerned about people labelling non-exception things as exceptions (so what?) or that try/except/finally is ugly. I agree with the latter, but even worse is littering code with if statements doing the manual equivalent of try/except/finally.