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.

Constraints in Go

211 pointsby gus_leonel6 months ago

3 comments

pansa26 months ago
I&#x27;m surprised by the complexity of Go&#x27;s generic constraints, given the language&#x27;s focus on simplicity. Things like the difference between &quot;implementing&quot; and &quot;satisfying&quot; a constraint [0], and exceptions around what a constraint can contain [1]:<p>&gt; <i>A union (with more than one term) cannot contain the predeclared identifier comparable or interfaces that specify methods, or embed comparable or interfaces that specify methods.</i><p>Is this level of complexity unavoidable when implementing generics (in any language)? If not, could it have been avoided if Go&#x27;s design had included generics from the start?<p>[0] <a href="https:&#x2F;&#x2F;stackoverflow.com&#x2F;questions&#x2F;77445861&#x2F;whats-the-difference-between-types-implements-and-types-satisfies" rel="nofollow">https:&#x2F;&#x2F;stackoverflow.com&#x2F;questions&#x2F;77445861&#x2F;whats-the-diffe...</a><p>[1] <a href="https:&#x2F;&#x2F;blog.merovius.de&#x2F;posts&#x2F;2024-01-05_constraining_complexity&#x2F;" rel="nofollow">https:&#x2F;&#x2F;blog.merovius.de&#x2F;posts&#x2F;2024-01-05_constraining_compl...</a>
评论 #42164048 未加载
评论 #42164982 未加载
评论 #42164801 未加载
评论 #42164004 未加载
评论 #42176376 未加载
indulona6 months ago
i have been writing Go exclusively for 5+ years and to this day i use generics only in a dedicated library that works with arrays(slices in Go world) and provides basic functionality like pop, push, shift, reverse, filter and so on.<p>Other than that, generics have not really solved an actual problem for me in the real world. Nice to have, but too mush fuss about nothing relevant.
评论 #42163244 未加载
评论 #42165141 未加载
评论 #42163834 未加载
评论 #42165680 未加载
评论 #42163415 未加载
评论 #42165270 未加载
评论 #42163189 未加载
评论 #42164296 未加载
评论 #42163694 未加载
评论 #42164983 未加载
guilhas6 months ago
I like in Go how the code looks like a execution graph, by avoiding smarts and just copying code, when you have an error in the log you can generally just follow it through the code as there is only one path to get there. In C# I would have mostly to debug to understand where did it came from<p>Not just because of the language, but of the simplify culture. Let&#x27;s see how generics will change that