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.

Introducing Go 2.0

58 pointsby spaceyover 8 years ago

6 comments

zigzigzagover 8 years ago
This title is pretty misleading. There's no Go 2.0, it's just a bunch of miscellaneous thoughts on how a Go 2.0 might work or look.
评论 #12786474 未加载
aikahover 8 years ago
If Go2 wants to happen it needs to happen right now while the language adoption is still low. I personally think there won&#x27;t be any Go2 or it will be admission of design failure from their maintainers who kept swearing to developpers &quot;You don&#x27;t need that with Go&quot;.<p>The Go mailing list is full of improvments requested by developers that the Go team refuses to hear, and most of them would still allow legacy code to run. So it doesn&#x27;t make sense to suggest there will be a Go2 to begin with. the Go team is absolutely resistant to changes.<p>I suggested for instance to new container types like sets, and a way to write type safe parametric functions without adding generics AKA allowing developers to write their own container types. So you could have generic functions at the package level like :<p><pre><code> func Foo&lt;T&gt;(bar :[]T)T func Bar&lt;T,V&gt;(baz func(T)V) </code></pre> used that way :<p><pre><code> var x int = Foo&lt;int&gt;([]int{0,2}) </code></pre> No user defined generic container type has been introduced (ie no Struct&lt;T&gt;{} ) , and the code is type safe at compile time. It would be a nice trade off. It would take care of 80% of generic use cases (like writing array,slice,sets,queue generic methods only once instead of copying and pasting for each type) and would eliminate the majority of methods using unsafe catch-all interface{} .<p>I always found it strange that Go designers don&#x27;t understand the fact that developers want to write compile time type safe code, while the formers are adding reflection features to the language (1.7 allows adhoc struct type creation), that are not compile time safe. Nobody wants generics for the sake of it. While compilation speed is one of the goals of Go, runtime performance should also be one, and reflection disallow any compile time optimization thus introduces a performace hit.<p>People suggesting the use of Go generate to transform Go code into a different Go code are just writing their own compiler extension without knowing it which leads to language fragmentation as they introduce 3rd party dependencies in the compilation step.<p>I think at that point anybody who is dissatisfied with Go type system should stop using it, as it completely unlikely to change dramatically in the future. There won&#x27;t be any &quot;Go2&quot;. It&#x27;s too bad, because Go has a few nice ideas, like implicit interfaces and struct&#x2F;interface embedding that are a nice way to do object composition.
评论 #12785081 未加载
stirnerover 8 years ago
This seems plausible to me, but Rob is known for being pretty hostile to clever ideas for &quot;fixing&quot; Go.<p>I really like the idea of using make instead of new, following the familiar ergonomics of the function (&quot;create a variable of this type&quot;).
jonehollandover 8 years ago
This is exactly how .net added generics in 2.0
sjellisover 8 years ago
A thoughtful articles, but funnily enough, the thing that I like most about it is not the main proposal, but the recognition that the standard library needs improvement. One of the things that I find most offputting about Go is the aggressive insistence that some folks have that the standard library is all you need.
lgierthover 8 years ago
tl;dr &quot;combine code written in Go 1.0 and a proposed Go 2.0 in one program using the package level as the boundary between language versions&quot;<p>Thumbs up from me.
评论 #12785412 未加载