TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Griping about Go

63 pointsby dmitover 6 years ago

16 comments

cdoxseyover 6 years ago
The whimsical nature of interfaces is definitely different coming from other languages. An `io.Flusher` might be nice, but it&#x27;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(&quot;etc...&quot;) } </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(&quot;etc...&quot;) } </code></pre> But maybe that looks too weird.
评论 #19113797 未加载
pcwaltonover 6 years ago
What&#x27;s worse, defer&#x27;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.
评论 #19109856 未加载
评论 #19114627 未加载
评论 #19109537 未加载
评论 #19109686 未加载
barrystaesover 6 years ago
The article is on a suspect domain:<p><pre><code> https:&#x2F;&#x2F;https.www.google.com.tedunangst.com&#x2F;flak&#x2F;post&#x2F;griping-about-go </code></pre> Is there any legit reason to have https.www.google.com in there?
评论 #19113783 未加载
评论 #19113163 未加载
Animatsover 6 years ago
Automatic closeout remains a hard problem. &quot;Defer&quot; has the same problem as RAII - what if the closeout fails? Python&#x27;s &quot;with&quot; 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&#x27;s &quot;panic&quot; and &quot;recover&quot; 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 &quot;OSerror&quot;.) This solves the problem of &quot;Have I caught everything&quot;?<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 &quot;re-animation&quot; 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.
评论 #19111409 未加载
评论 #19109843 未加载
评论 #19109739 未加载
评论 #19114663 未加载
LordHeiniover 6 years ago
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...
hombre_fatalover 6 years ago
Here&#x27;s one of my favorite gotchas in Go: why does this error?<p><a href="https:&#x2F;&#x2F;play.golang.org&#x2F;p&#x2F;6LTbtuocu5-" rel="nofollow">https:&#x2F;&#x2F;play.golang.org&#x2F;p&#x2F;6LTbtuocu5-</a>
评论 #19109664 未加载
评论 #19109624 未加载
评论 #19109679 未加载
rhackerover 6 years ago
I heard it&#x27;s better now but when I was trying to do grpc I couldn&#x27;t get this to build:<p><a href="https:&#x2F;&#x2F;github.com&#x2F;improbable-eng&#x2F;grpc-web&#x2F;tree&#x2F;master&#x2F;go&#x2F;grpcwebproxy" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;improbable-eng&#x2F;grpc-web&#x2F;tree&#x2F;master&#x2F;go&#x2F;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.
ernsheongover 6 years ago
Blog seems to have collapsed under HN weight (link is bad too).<p>Archive of archive of page: <a href="https:&#x2F;&#x2F;app.pagedash.com&#x2F;p&#x2F;d5c8c4bf-d88a-470b-a7f3-adb986ccb1fe&#x2F;4tbHK69h6Z0EaM51gvUm" rel="nofollow">https:&#x2F;&#x2F;app.pagedash.com&#x2F;p&#x2F;d5c8c4bf-d88a-470b-a7f3-adb986ccb...</a>
favoritedover 6 years ago
Is there a reason that go&#x27;s defer is only function-scoped?
评论 #19109341 未加载
评论 #19109421 未加载
atilanevesover 6 years ago
&gt; as opposed to passing large byte slices or strings around. In theory, this should be more efficient<p>Why would passing a &quot;large&quot; slice be inefficient?? Maybe on x86 due to a lack of registers, but on 64-bit?
vldoover 6 years ago
&gt; 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&#x27;s a good thing in my opinion.
评论 #19109879 未加载
LandRover 6 years ago
&gt; 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?
评论 #19113523 未加载
评论 #19113626 未加载
nvarsjover 6 years ago
Defer also encourages the unsafe behavior of not checking error results. You can&#x27;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.
评论 #19113235 未加载
abbiyaover 6 years ago
what kind of domain is this ?<p><a href="https:&#x2F;&#x2F;https.www.google.com.tedunangst.com&#x2F;flak&#x2F;post&#x2F;griping-about-go" rel="nofollow">https:&#x2F;&#x2F;https.www.google.com.tedunangst.com&#x2F;flak&#x2F;post&#x2F;gripin...</a>
dekken_over 6 years ago
#notasuspectURL
评论 #19109552 未加载
评论 #19109119 未加载
dana321over 6 years ago
I avoid using defer
评论 #19109682 未加载
评论 #19109528 未加载