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.

Why I Don't Like Golang (2016)

140 pointsby bravogammaalmost 3 years ago

17 comments

implyingalmost 3 years ago
They&#x27;ve fixed the import &#x2F; modules situation to a point where it&#x27;s usable and much improved, and generics have been added.<p>However, the issue this brings up about structs &#x2F; types not explicitly declaring which interfaces they implement is a real and unaddressed problem, especially in large codebases. The only tool that I&#x27;m aware of that finds implementations is GoLand, at steep JetBrains prices.<p>Figuring out what type an API is asking for should not require reading every line of code in the package, and slows down every developer of large Go projects
评论 #31734784 未加载
评论 #31734941 未加载
评论 #31734919 未加载
评论 #31735309 未加载
评论 #31734928 未加载
评论 #31735494 未加载
评论 #31735394 未加载
评论 #31735776 未加载
评论 #31735132 未加载
评论 #31736077 未加载
评论 #31735434 未加载
评论 #31735064 未加载
评论 #31734874 未加载
评论 #31738429 未加载
评论 #31763381 未加载
pvgalmost 3 years ago
Previously:<p>2019, 296 comments - <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=20166806" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=20166806</a><p>2018, 148 comments - <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=16414098" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=16414098</a><p>2016, 47 comments - <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=12356823" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=12356823</a>
x3n0ph3n3almost 3 years ago
I&#x27;m still baffled by their decision around date formatting.<p><a href="https:&#x2F;&#x2F;www.godateformat.com&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.godateformat.com&#x2F;</a>
评论 #31736146 未加载
评论 #31735232 未加载
评论 #31735352 未加载
LVBalmost 3 years ago
&gt;The tried and true approach of providing a compare method works great and has none of these drawbacks.<p>Agreed! <a href="https:&#x2F;&#x2F;pkg.go.dev&#x2F;sort#Slice" rel="nofollow">https:&#x2F;&#x2F;pkg.go.dev&#x2F;sort#Slice</a> is wonderful. (Added a bit after this article was written, I think.)
评论 #31735506 未加载
benhoytalmost 3 years ago
My thoughts on his points, from someone who really likes Go and has used it heavily on small and large projects (1M LoC):<p>1. Probably a matter of taste, but I love this feature, just because of the lack of noisy public&#x2F;private keywords everywhere that you see in Java et al. It also means you can tell from a usage (not just the definition) that something is exported, which is often useful.<p>As far as renaming goes, either rename the definition and see where the compiler complains, or get your IDE to do it (I use GoLand, but good things are said about gopls).<p>As for his example, the idiomatic way to write that is either just call it `usr` or `adminUser`, or use `user := &amp;user{}` which is valid (if a little confusing).<p>2. This is a <i>feature</i>: it allows you to define interfaces only where you need them (on the consumer side), and you define the interface with only the methods you actually need. This means that when you add a bunch of new methods on the implementation, you don&#x27;t need to change all the consumers. Go interfaces are amazing.<p>The downside he discusses almost never happens: it&#x27;s surprising, but even in large projects I&#x27;ve never had structs accidentally implementing interfaces or a IsAdmin method being implemented with reversed polarity by accident.<p>3. Definitely has its downsides. Tooling helps find unchecked errors. Though I&#x27;ve found the biggest downside to explicit errors is the verbosity. You do get used to it, and the explicitness is at least clear.<p>4. There are a couple of &quot;magical&quot; things like this, but they&#x27;re well known and documented, and simple to fix if you run into them. I love the fact I can just name a file foo_test.go and add TestFoo methods, and &quot;go test&quot; finds them automatically.<p>5. I have not found this to be the case, and in the rare cases it does happen, the compiler tells you loudly and it&#x27;s easy to fix.<p>6. Yeah, this is a slight pain, but the semi-official &quot;imports&quot; package (golang.org&#x2F;x&#x2F;tools&#x2F;imports) fixes it up, so you just run generated code through that (and it auto-formats the code as well). It&#x27;s a couple of lines of code. See: <a href="https:&#x2F;&#x2F;github.com&#x2F;benhoyt&#x2F;prig&#x2F;blob&#x2F;2df1b65a2bdf34c10bb5e57ecc99d1775bc9d196&#x2F;prig.go#L134" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;benhoyt&#x2F;prig&#x2F;blob&#x2F;2df1b65a2bdf34c10bb5e57...</a><p>7. Yeah, I wouldn&#x27;t mind a ternary operator. Easily misused, which is why they didn&#x27;t add it, but it would be really nice used judiciously, rather than the 4-line if-else block.<p>8. Fixed by sort.Slice, which avoids the need for Len and Swap (and even more so by the new generics &quot;slices&quot; package, coming soon). I guess this was added after the article was written?<p>9. Fixed by &quot;Go modules&quot;, which is really well designed and works well (though opinions differ).<p>10. Fixed with generics being added in Go 1.18. And generic helpers like &quot;slices&quot; and &quot;maps&quot; packages coming soon.<p>11. Yeah, slightly annoying for newbies, though as he mentioned, tooling tells you. I do like the control you (can) get over allocation and memory management with Go slices.<p>As far as his summary goes (eg: the type system getting in your way for large programs), I have definitely not found that to be the case. The author doesn&#x27;t like Go, and that&#x27;s okay! I don&#x27;t like Java. :-)
评论 #31735407 未加载
gorgoileralmost 3 years ago
I’d like to get into go but in the past I’ve always been burned by not being able to quickly refactor my code.<p>If I want to change the contract of get_kittens so that it returns a set instead of a list, I found it quite tiresome to then go to all the call sites of get_kittens and change their types to match.<p>What was I doing wrong?* Perhaps there’s a cleverer tool out there that can infer and implement these type changes for me, automatically?<p>* using vim? [joke]
评论 #31735762 未加载
评论 #31735835 未加载
评论 #31735485 未加载
thefaustalmost 3 years ago
Why isn&#x27;t Go good for large projects? Kubernetes is an example of a huge project built in Go
评论 #31735947 未加载
yashapalmost 3 years ago
Agreed with the article, though obviously it’s a bit dated (especially around generics and package management).<p>My take is that Go is basically the new Java, with fewer abstractions and faster compilation. Although, the pre-Java 8 Java, before Java started to get a bit functional.<p>Like Java it’s a practical, imperative, statically typed, garbage collected language with very good performance. Also like (pre-Java 8) Java, it’s very verbose, doesn’t allow for much “elegance”, and many find it not very fun to write. But it is a pretty decent language for getting shit done.<p>Overall, I don’t really enjoying writing Go, but it’s not the worst either. I’d code in it if necessary, but wouldn’t chose it for a personal project. I just have more fun and am more productive writing code in concise, mixed OOP&#x2F;FP languages like TypeScript or Scala, even if they don’t compile as fast.
评论 #31735548 未加载
评论 #31735399 未加载
评论 #31735193 未加载
评论 #31735172 未加载
评论 #31735210 未加载
ridofalmost 3 years ago
I just leave this here: <a href="https:&#x2F;&#x2F;github.com&#x2F;golang&#x2F;go&#x2F;issues&#x2F;49383" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;golang&#x2F;go&#x2F;issues&#x2F;49383</a><p>After such public disregard to the communnity and contributors as a whole, the talk about good or bad has no meaning until they learn the basics. For example how to work with community, and the fact that you have to provide your phone number in order to fix urgent bug or implement some feature is a plain stupid(or rather malicious).<p>Just imagine you&#x27;ve spent your free time working on the fix or feature, and instead of getting appreciation or sometimes bounty or just nothing, you&#x27;re being &quot;charged&quot; to contribute. Yeah, they really think it&#x27;s normal that contributors have to give up PI to the advertisement company that were accused of violating privacy many times before. They basically treat contributors, tech-savvy users who provide free labor, like their usual consumers. Just think about it for a second, this is insane.
评论 #31735810 未加载
weatherlitealmost 3 years ago
As a new Go user I seriously don&#x27;t get the hype. It feels like C with some (not many) niceties thrown on top, that&#x27;s not what we expect from high level languages. I am still waiting for the tada moment, hope it comes.
评论 #31735203 未加载
评论 #31735085 未加载
评论 #31735057 未加载
评论 #31735221 未加载
jjthebluntalmost 3 years ago
Title needs 2016
评论 #31735224 未加载
ngalaikoalmost 3 years ago
another person who can’t get over his java stockholm syndrome in three (!) years<p>one particular thing that tells that is the attitude to interfaces:<p>while in java (and most languages) interfaces are used to tell which contracts a class implements, in go it’s reversed. you must declare interfaces to _require_ certain contracts, for arguments in your functions<p>for example:<p>type interface Operator { Operate(int, int) int }<p>func IntOparation(a, b int, op Operator) int { return op.Operate(a, b) }<p>this is a major difference highlighting the ownership boundaries: * when I write a package and rely on a 3rd party contract, instead of referencing it and adhering to it, I will copy-paste parts that I need to my package and be independent
评论 #31735215 未加载
xigoialmost 3 years ago
&gt; if I name my source file i_love_linux.go, it won’t get compiled on my Mac<p>What the fuck?
评论 #31734939 未加载
评论 #31735063 未加载
评论 #31734955 未加载
评论 #31735354 未加载
评论 #31734978 未加载
评论 #31735219 未加载
shantnutiwarialmost 3 years ago
Why does Go get so much hate here? Almost all front page articles are about how Go suCkS mAn<p>I know Go isnt great or perfect, but still, why so much hate? I seriously want to know
评论 #31740053 未加载
评论 #31739311 未加载
评论 #31741154 未加载
Mathnerd314almost 3 years ago
2016. Generics have been added.
评论 #31735230 未加载
crowdyriveralmost 3 years ago
&gt; Go doesn’t have exceptions. It uses multiple return values to return errors. It’s far too easy to forget to check errors...<p>Yes, because it is easy and predictable to track exceptions in nested try catches and hidden control flow.
评论 #31735228 未加载
nemothekidalmost 3 years ago
&gt;<i>There’s no ternary (?:) operator. Every C-like language has had this, and I miss it every day that I program in Go. The language is removing functional idioms right when everyone is agreeing that these are useful.</i><p>And everyone agreed so hard that it was removed from almost every modern C replacement (Rust, Nim, Zig, Elixir, Kotlin).
评论 #31734770 未加载
评论 #31734881 未加载
评论 #31734863 未加载
评论 #31734748 未加载
评论 #31734968 未加载
评论 #31735110 未加载
评论 #31735096 未加载