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.

Golang generics proposal has been accepted

276 pointsby komuWover 4 years ago

20 comments

dcolkittover 4 years ago
IMO the biggest factors for the success of Go are 1) super-fast compile times, 2) easy to interpret compiler errors, and 3) dead simple shipment of high performance, native static binaries.<p>I think Go has succeeded, despite, not because of the language itself. One very big limitation being the lack of generics or any sort of ability to leverage higher-order types. Sometimes making a small modification to a large codebase can require a huge footprint of lines modified, just because so much code winds up duplicated in slightly different contexts.<p>That being said, I really hope that Go&#x27;s core team understands the drivers of its popularity and doesn&#x27;t compromise the operational side for the sake of language improvements. Although higher-typed languages have no trouble achieving good runtime performance, it seems like there&#x27;s a fundamental tradeoff at compile time. Scala, Haskell, even Typescript have painful compile times. I don&#x27;t know if there&#x27;s any theoretical reason for it to hold, but more typing complexity inevitably leads to slow compile times.<p>And as for the topic of clear error messages, the higher-typed languages are all atrocious at this. Even templates in C++ are notorious for puking near impossible to decipher errors. This is something I&#x27;m sure can be fixed with enough engineering effort, but it would probably take <i>a lot</i> of effort to get there.<p>In general, I bitch about the Go language all the time. But I think we should recognize that the simplicity of the language gives us developers a lot of peripheral really nice usability benefits.
评论 #26094630 未加载
评论 #26095827 未加载
评论 #26094560 未加载
评论 #26099873 未加载
评论 #26096772 未加载
评论 #26095165 未加载
评论 #26094858 未加载
ciesover 4 years ago
This was to be expected. But I&#x27;m glad for Go.<p>In some years a language that interops with Go comes out, where all the Go types have a ?-suffix indicating they are nullable. The language will be mostly null-safe. Also it will sport sumtypes and pattern matching&#x2F; destructuring in switch statements.<p>It will be called: Gotlin.
评论 #26094105 未加载
评论 #26094170 未加载
评论 #26094077 未加载
评论 #26094500 未加载
smasher164over 4 years ago
This is a significant milestone for Go, and I&#x27;m extremely happy for the community. I didn&#x27;t imagine getting here when I first started using the language, and yet here we are.<p>Special props to Ian Lance Taylor and Robert Griesemer for their continued revisions of drafts, and exemplary discussion with the community in implementing feedback.
2pEXgD0fZ5cFover 4 years ago
As someone who hasn&#x27;t followed the discussion all this time, is there an up to date example of what the generics syntax will look like?
评论 #26094025 未加载
zxcvbn4038over 4 years ago
Nobody will have anything to complain about once go has generics, we&#x27;ll never hear about Golang on Hacker News again! It&#x27;ll just be the Rust people complaining. ;)
评论 #26095344 未加载
评论 #26099168 未加载
dangover 4 years ago
A few days ago: <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=26018649" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=26018649</a><p>A few weeks ago: <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=25750582" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=25750582</a>
gautamcgoelover 4 years ago
This will probably be downvoted, but I personally never felt a huge need for generics. C doesn&#x27;t have them and is arguably the most successful language in history. Yes, they are convenient, but they also add a lot of complexity to the language and toolchain. I suspect that this proposal being accepted is largely due to the huge growth of the Go community - I bet the original team (in particular, I&#x27;m thinking of Rob Pike) are at best ambivalent about this proposal and were outvoted.<p>Personally, the proposal I was most excited about was to make ints be arbitrary precision by default. As someone who does a lot of math, this would have made Go much easier for me to use. Sadly, this proposal was scrapped a while back.
评论 #26094075 未加载
评论 #26094045 未加载
评论 #26094198 未加载
评论 #26094276 未加载
评论 #26094337 未加载
评论 #26094620 未加载
评论 #26095523 未加载
评论 #26094343 未加载
评论 #26094361 未加载
lastofusover 4 years ago
Out of curiosity, what changed between now, and when proposals for generics came up in years past?
评论 #26094245 未加载
评论 #26094419 未加载
评论 #26094355 未加载
评论 #26094400 未加载
maurysover 4 years ago
I wonder if over time, Golang will pick up more type features like Java and other languages have.<p>The general consensus seems to be that powerful type systems are very effective.<p>Personally, the low footprint runtime and concurrency primitives are enough for me and I wouldn&#x27;t mind the language becoming &quot;less simple&quot; if it helps the ecosystem.<p>Once generics are implemented, I can imagine people requesting for the next &quot;missing&quot; thing.
评论 #26094138 未加载
评论 #26094213 未加载
评论 #26094301 未加载
评论 #26095982 未加载
babyover 4 years ago
I really really hope that this does not end up in people abusing generics in Golang code and making Golang code harder to read. The biggest argument of Golang in my opinion is that it is extremely easy to audit and read and understand at the moment.
评论 #26094425 未加载
评论 #26095626 未加载
wmilover 4 years ago
I&#x27;m kind of sad that they didn&#x27;t allow you to use inuktitut characters as a joke about this classic comment.<p><a href="https:&#x2F;&#x2F;www.reddit.com&#x2F;r&#x2F;rust&#x2F;comments&#x2F;5penft&#x2F;parallelizing_enjarify_in_go_and_rust&#x2F;dcsgk7n&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.reddit.com&#x2F;r&#x2F;rust&#x2F;comments&#x2F;5penft&#x2F;parallelizing_...</a>
pjmlpover 4 years ago
Finally! At least one pain point less when dealing with Docker&#x2F;K8s eco-system.
tick_tock_tickover 4 years ago
What does this mean for a timeline on when we can start using them?
评论 #26094690 未加载
samuellover 4 years ago
Very much excited that this is finally moving forward. Such sweet improvements this will allow for SciPipe and FlowBase when this nears completion [1,2].<p>It will make it so much easier to enable typed port objects, which can still re-use all the handy functionality for connecting inports&#x2F;outports, traversing the dataflow graph, etc etc.<p>[1] <a href="https:&#x2F;&#x2F;scipipe.org" rel="nofollow">https:&#x2F;&#x2F;scipipe.org</a><p>[2] i<a href="https:&#x2F;&#x2F;flowbase.org" rel="nofollow">https:&#x2F;&#x2F;flowbase.org</a>
lalaithionover 4 years ago
Sad to see that we won&#x27;t be getting type parameters on methods. I hope they fix the issues with it and can get that working in a future proposal.
midrusover 4 years ago
&quot;We don&#x27;t need generics&quot;<p>&quot;We don&#x27;t need exceptions&quot;<p>&quot;We don&#x27;t need ORMs&quot;
评论 #26094631 未加载
评论 #26094661 未加载
andreygrehovover 4 years ago
How are generics implemented under the hood? Reflection?
hnlmorgover 4 years ago
I really wish they went with angle brackets like everyone else does. I get the argument about not wanting to break existing parsers but this is a significant enough language change to warrant that.
评论 #26094217 未加载
评论 #26094412 未加载
评论 #26099186 未加载
评论 #26094596 未加载
_spoonmanover 4 years ago
Is generics akin to overloading functions?
评论 #26095912 未加载
otabdeveloper4over 4 years ago
Nice to know.<p>So what&#x27;s the timeline for proper exceptions now?