Live data from Hacker News

Lies we tell ourselves to keep using Golang (2022)

fasterthanli.me

11–20 of 526 posts

Re: Lies we tell ourselves to keep using Golang (2022)

#11
The article is great. The bigger picture, of course, is that it’s always “pick your poison”.

On one hand, say, I love operator overloading, I love how Python does it (once you satisfy an interface, its operators Just Work).

On the other hand, I can appreciate the choice not to do it at all because half of the ecosystem will do it, and another half won’t. Also, it would require implementing function overloading, and it is a can of worms.

Or generics and rich type systems, which all come with their own tradeoffs. I hear that Rust cajoles you into tinkering with the type system, and wach tweak requires refactoring of more codebase than anyone would like (don’t take my word for it, it’s just what I heard from a few different sources). I know that Nim is so expressive that it can be annoyingly trivial to be too clever and run into a valid edge case that will make the compiler barf and die. Go sidesteps the issue by not wading into that territory, and that may be perfectly okay, albeit verbose.

It’s always picking your poison, so I guess check your tolerances and allergies so it doesn’t kill you before you get the job done…

Re: Lies we tell ourselves to keep using Golang (2022)

#12
post #5

This article makes a lot of great points about the shortcomings of Go. I don’t think explicit error handling is one of them however. I’ve previously spoken about my loathing of exception handling because it adds a “magic” layer to things which is way too easy to mess up. From a technical standpoint that isn’t necessarily a good argument, but from a pragmatic standpoint and decades of experience… well I will take expl…

It's actually very rare that it should be the caller who has to handle the errors.

Go, however, forces you to spread your error handling over a thousand little pieces with zero overview or control of what's happening.

Rust eventually realised this and introduced try! and ? to simplify this

Re: Lies we tell ourselves to keep using Golang (2022)

#13
> I've mentioned "leaving struct fields uninitialized". This happens easily when you make a code change from something like this:

Really? Are you not using gopls? It absolutely will warn you about this. And the mutex case. And a lot of the other similar criticisms.

> Go not letting you do operator overloading, harkening back to the Java days where a == b isn't the same as a.equals(b)

In languages that have it I've never used operator overloading to produce anything good or that was obviously better than just using methods.

> The Go toolchain does not use the assembly language everyone else knows about.

Honestly I've never noticed or had to care. And you can build plenty of things that don't require CGO.

The whole "gnostic" tone in language articles on HN is becoming overbearing. There are parts of the language to criticize but couching it in this "lies _we_ tell ourselves" and somewhat kitchy writing that presents minor matters of taste as fully existential issues makes this an unsatisfying read.

Re: Lies we tell ourselves to keep using Golang (2022)

#15

Not sure why Go is compared to Rust all the time, whilst most appropriate comparison is Java.

I think this is exactly the right way to understand Go - it's targetted at building servers in environments where having strong consistency of code and a short ramp up time for junior engineers is valuable - i.e. it's perfect for all the big corp scenarios that Java was used for.

I think maybe the more common, but less helpful comparison of go vs rust comes from the fact that they are both part of a new wave of languages and that they both default to producing staticly linked binaries.

Re: Lies we tell ourselves to keep using Golang (2022)

#16
There _are_ two problems with Golang that I _would_ like to wave a magic wand and fix if that was a power I had.

1) Sum types (E.G. C/C++ union types) - Yeah, something similar to that should exist... it's syntax sugar over #2

2) 'casting' / reshaping perspective on data ; as long as something has the same struct size a programmer should be able to tell the compiler 'but this is actually that'. Which also implies a way of fixing the layout of a given data structure. I figure that's why Golang doesn't allow this already.

Yeah, 24 bytes (len, cap, pointer) per slice (dynamic array) has a cost, but if that really gets your goat use a fixed size array, or pointer/reference to such [n]thing.

3) Seriously, for a slice, make it like a map, a pointer/reference to a len,cap,blob - so that when I pass a slice by value I pass the WHOLE slice, not a COPY of len and cap and a reference to the slab. Current golang has the worst of all worlds with passing slices around, in that changes mutate, UNTIL it's resized or manually copied. The current design has the behavior it does to support slices of slices, which requires the pointer to the blob. A more complex scheme of a container behind the slice, and references to that could also work, but would be an entirely different datatype.

Re: Lies we tell ourselves to keep using Golang (2022)

#18

Not sure why Go is compared to Rust all the time, whilst most appropriate comparison is Java.

Because someone decides what language to write a new thing in is very likely to consider Go and Rust. They are very unlikely to consider Java.

Are Rust and Go sufficiently different that they should each be chosen in different cases? Sure! But that’s literally why someone would consider both and pick one.

Re: Lies we tell ourselves to keep using Golang (2022)

#19
I liked the idea of a language with minimal syntax that is easy to learn and easy to understand because the code is forced to be straightforward. It didn't work out that way to me in practice.

It's a bit too low level for many use cases in my opinion, and that does get in the way somewhat. It also works against the "easy to learn" part unless you start with developers familiar with low level programming.

I also found some types of library code surprisingly difficult to read, especially when empty interfaces where used.

The standard library was great though, it covered stuff that others don't and it just worked out of the box.

Post reply on HN