The whimsical nature of interfaces is definitely different coming from other languages. An `io.Flusher` might be nice, but it's not really necessary. You can just write:<p><pre><code> type Interface interface {
io.Writer
Flush() error
}
func someFunction(w Interface) error {
w.Write(nil)
w.Flush()
panic("etc...")
}
</code></pre>
Or even drop the type name:<p><pre><code> func someFunction(w interface {
io.Writer
Flush() error
}) error {
w.Write(nil)
w.Flush()
panic("etc...")
}
</code></pre>
But maybe that looks too weird.
What's worse, defer's function-scoped nature means that the only way to compile it is to dynamically push closures onto a stack <i>at runtime</i> and then pop them off one-by-one before returning. The compiler may be able to optimize this in specific cases, but in the general case the semantics are extremely dynamic for no real benefit. Designing defer in this way is an especially strange decision for a language that in many ways is architected to make life easy for the compiler writer.
The article is on a suspect domain:<p><pre><code> https://https.www.google.com.tedunangst.com/flak/post/griping-about-go
</code></pre>
Is there any legit reason to have https.www.google.com in there?
Automatic closeout remains a hard problem. "Defer" has the same problem as RAII - what if the closeout fails? Python's "with" clause, and how it interacts with exceptions, is one of the few constructs that can handle multiple closeout faults correctly.<p>Trying to get rid of exceptions seems to force workarounds that are worse than exceptions. C++ and Java exceptions were botched and gave the concept a bad name. Go's "panic" and "recover" are an exception system, but not a good one. Python comes closer to getting it right.<p>Key concepts for successful exceptions:<p>- A predefined exception hierarchy. Catch something in the tree, and you get everything below it. Python added this in the 2.x era, and it made exceptions usable. (Then they messed it up in the 3.x era, putting too much stuff under "OSerror".) This solves the problem of "Have I caught everything"?<p>- The case where a closeout event raises an exception has to work. This is hard. Attempts to get it right resulted in such horrors as "re-animation" in Microsoft Managed C++. It needs something like the Rust borrow checker model to make sure that object lifetimes are properly enforced on all error paths.
I think go has some serious other problems.<p>Like the billion dollar mistake. Why is this repeated in any new language? It is just plain awful and stupid.
This is easily my biggest gripe with the language (apart from missing generics).<p>Go combines that greatly with the bonkers error handling:<p><pre><code> if err != nil {...}
</code></pre>
Half of all go code ever written consists of the line above.<p>Now combine that with defer (or go routines) returning errors...
Here's one of my favorite gotchas in Go: why does this error?<p><a href="https://play.golang.org/p/6LTbtuocu5-" rel="nofollow">https://play.golang.org/p/6LTbtuocu5-</a>
I heard it's better now but when I was trying to do grpc I couldn't get this to build:<p><a href="https://github.com/improbable-eng/grpc-web/tree/master/go/grpcwebproxy" rel="nofollow">https://github.com/improbable-eng/grpc-web/tree/master/go/gr...</a><p>Basically there was dependency that changed, and it caused it to not build. The maintainer was just pointing fingers at google. I had no idea what to do, but it just scared the crap out of me.
Blog seems to have collapsed under HN weight (link is bad too).<p>Archive of archive of page: <a href="https://app.pagedash.com/p/d5c8c4bf-d88a-470b-a7f3-adb986ccb1fe/4tbHK69h6Z0EaM51gvUm" rel="nofollow">https://app.pagedash.com/p/d5c8c4bf-d88a-470b-a7f3-adb986ccb...</a>
> as opposed to passing large byte slices or strings around. In theory, this should be more efficient<p>Why would passing a "large" slice be inefficient?? Maybe on x86 due to a lack of registers, but on 64-bit?
> Usually this can be resolved by creating a new function and calling that from the loop. But frequently not. [etc.]<p>For me this is the appeal of the language; I really prefer things confined and manually scoped rather than having things globally scoped which would cause a lot of debate just around that. You often have to think about what you want to expose and where, but that's a good thing in my opinion.
> I mostly like go, but after working with it a bit more I realize there are a few jibs of which the cut I do not like.<p>What is this supposed to parse to?
Defer also encourages the unsafe behavior of not checking error results. You can't propagate errors from it. About the best you can do is wrap whatever function you were deferring in another function, and then panic if there is an error.
what kind of domain is this ?<p><a href="https://https.www.google.com.tedunangst.com/flak/post/griping-about-go" rel="nofollow">https://https.www.google.com.tedunangst.com/flak/post/gripin...</a>