Live data from Hacker News

Ask HN: What do you like/dislike about Golang?

news.ycombinator.com

41–50 of 111 posts

Re: Ask HN: What do you like/dislike about Golang?

#41
Languages must choose tradeoffs, and I think Go gears its tradeoffs towards large projects.

Generally the larger a project becomes, the longer it takes to add features and fix bugs - so to combat this Go favors quick compile times, easy monorepos, simple tooling, and most of all: very consistent code. Go's limited syntax is a feature, not a bug.

Syntax sugar in a language allows for writing code quickly, but it (arguably) opens up more opportunities for bad code - e.g. using language features inappropriately, mixing the "sugar" approach with the "manual" approach in the same codebase, being terse and hard to read, etc. If most of a developer's interaction with code is spent reading rather than writing, then it makes sense to value quick to read but long to write code. Go's philosophy of there being "one way" to do things (arguably) achieves that.

Having a very transparent control flow (including treating errors as simply values) is in line with that. Yes errors pollute one's code - I would like an operator for that, but I'm glad the error conditions are being represented clearly.

Go is perhaps not a good language if you want to get an MVP going quickly, or write something with a performance focus.

Disclaimer: I love Go. I taught myself Go while I was working as a Java dev and it was a big factor in me finding a new job.

Re: Ask HN: What do you like/dislike about Golang?

#42
post #31
post #29

Earlier quoted context omitted.

Wait, what prior programming language is compiled, can be statically linked, and has an https implementation in it's standard library?

fwsgonzo never said anything about it being in the standard library.

Well that's not on him man. You are the one calling him out for being unaware of static linking, when you don't even seem to understand the full set of pros he listed in his first sentience.

Re: Ask HN: What do you like/dislike about Golang?

#43
LIke:

- Decent speed of compiling and execution.

- Expressiveness.

- I like the struct/receiver/interface interplay to create an analog of classes.

- Nice standard library.

- Cross compilation.

Things I wish for:

- Ternary operator.

- Something a bit closer to inheritance. Embedding structs in other structs fools you into thinking there's inheritance, but you quickly learn that it doesn't work the way you think it will.

- At the same time, fully implementing a functional programming paradigm isn't particularly easy either.

But all in all, I'm a big fan.

Re: Ask HN: What do you like/dislike about Golang?

#45
post #22
post #16

As someone who likes async/await/coroutines, I really miss them in Go. Channels are the GOTO of synchronisation, they lead to confusing spaghetti code because there is no structure. Go is really nice to read (once you get used to the fact that half the lines of code in any function are for error handling) unless it uses a lot of channels. Then you need to take great care to understand every <-.

> As someone who likes async/await/coroutines, I really miss them in Go Interesting. Most complain about languages with async/await and say they want goroutines. What is it about async/await that you prefer over Go's approach?

Not OP, but I am also in the camp of "like goroutines, not a fan of channels". Low cost threads are great - but channels can represent so many intermediate states, especially when error handling is involved. I wish there was a simpler default for coordinating goroutines

(Do we add an error field to the struct we send through a channel? Do we close the channel on error, or only on success? Do we make a separate channel to send errors on - and if we close that one it means for sure that there were no errors? If we select on the two dependent channels, do we have to make sure that they are in different sequential selects, so that we don't go out-of-order or deadlock?)

Re: Ask HN: What do you like/dislike about Golang?

#46
I'm a sysadmin type, so take this with a grain of salt.

Like:

- Compiled and can be run as a scripting language.

- Easy to learn, quite simple to use (even concurrency!)

- Cross compilation is an environment variable setting.

- Fast compilation, though apparently this gets worse with reflection and generics (and it's not that important to me honestly)

Dislike:

- The opinionated build/dependency system, which sort of doesn't work with monorepos unless you do things that "are not recommended" like `insteadOf`

- When deserialising things (JSON for example), an omitted key becomes an empty value. As many will tell you, there is a difference between 0 and Null/None.

- Case based visibility. That feels like the opposite of clear.

- Slice semantics, easy to accidentally override values if you're not careful. (slices are references to arrays, you can reference a subset of a slice which looks like a new slice, but appending to it will overwrite a value in original array, because when you do `var slice_new := slice_old[0:30]`; it's really just a reference to slice_old, not a new slice with the contents from 0-30.

Re: Ask HN: What do you like/dislike about Golang?

#47
At 2/3 of every screen, error handling is absurdly noisy. A DSL for wrapping and bubbling up errors (the 99% case) is desperately needed.

The builtin containers just suck. They’re always mutable. Map write conflicts might panic, yet there’s no support for preventing them. They aren’t comparable, which can cause panics elsewhere. You have to pretend slices have move semantics, because copies may or may not share state after an append. They don’t implement any interfaces, so you can’t even replace them or reuse their sugar.

Functions can return tuples, but tuples aren’t first-class, there are no maps or channels of tuples.

No overloading, each type sig needs its own func name and IDE refactoring won’t choose the right one.

Reflection is very limited. No access to types or functions by name. No type or func or arg annotations, just a single string on a struct field.

The GC design is pretty old and people go out of their way to avoid relying on its throughput.

Liked: The memory footprint is pretty small. Parts of the community are starting to rely on code generation to work around the base language (e.g., piles of ignored boilerplate because Mockito can’t be implemented at runtime).

Re: Ask HN: What do you like/dislike about Golang?

#48
Likes:

- The build/test tool is pretty good

- Opinionated formatting/style is nice (even if I disagree with some choices, it removes a huge organizational bikeshedding problem)

- Explicit error handling

Dislikes:

- The generics implementation leaves a lot to be desired

- Structural typing: may as well be a dynamically typed language (I know it’s not that bad, but sometimes it feels like it)

- The terrible implementation of nested/embedded errors and lack of support for structured, pattern match inspection of error return values tend to make error handling unnecessarily verbose

- The insane use of interfaces literally everywhere, and the tendency for hidden/unexpected use of “reflect” leading to funky performance issues

Re: Ask HN: What do you like/dislike about Golang?

#49

1. Static linking. I'm astonished by how many languages expect the end user to install dependencies/runtime themselves, and something about it feels very impure . 2. The "go" keyword (and the whole goroutine system underneath it). Threads are clunky, somewhat unportable and generally unscalable. Goroutines just feel right. 3. Ability to use multiple major versions of a library. Diamond dependencies are an unsolved pr…

Good list. Regarding (4) Implicit interfaces -- to me, it's implicit interfaces that feel wrong :) Something having a method with a particular signature doesn't seem to me to be any kind of promise that it's intended to be used for the interface that expects that method. 'implements X', is a clear statement that yes, this method is made just for that specific interface. But this is just academic. I've never actually…

[deleted]

Re: Ask HN: What do you like/dislike about Golang?

#50
post #31
post #29

Earlier quoted context omitted.

Wait, what prior programming language is compiled, can be statically linked, and has an https implementation in it's standard library?

fwsgonzo never said anything about it being in the standard library.

The convenience of building network clients in Go is heavily implied. Strictly you can say that assembly code can make standalone binary HTTPS endpoints, but that would be a bit silly.

To be sure you might write such a program in assembly, but you’d be doing it for fun or aesthetics. No engineering manager would commission such a thing.

Though of course this is inviting the trading maniacs to tell stories of hyper optimized clients…

Post reply on HN