by kev009 · 7y ago · 0 comments
"Go's error type is simply an interface to a function returning a string.
Go lacks pattern matching & abstract data types.
Go lacks immutable variables.
Go lacks generics.
Go lacks exceptions"
I've been searching for as succinct a criticism as this and now have it, thanks.
And the select code [0] is kind of horrifying.
I am going to disagree with this, though:
> Go's native package system does not support specifying versions or commits in the dependency information. Instead, the go community recommends that each major release have its own separate repository; github.com/user/package/package-{v1,v2,v3}.
As far as I'm aware, you don't create a new repo for a new major version - just a new branch, or a subdirectory. This comment [1] from Russ Cox describes it pretty well IMO. (Though it appears that the page hasn't been updated since 2017, and Go Modules is more recent than that)
0: https://github.com/golang/go/blob/master/src/runtime/select....
We have a senior dev whose software caused a memory leak in prod. One of our less senior devs (who has an engineering PhD in concurrent systems theory) immediately identified that the senior was trying to do clever optimizations for single threadedness that simply cannot work when concurrent... I wouldn't be surprised if his code is causing a goroutine leak.
I am convinced that go is popular because it's comfortable to elder seniors and makes them think they can use their aging python/c/c++ skills in something flashy, new, concurrent, "supported by Google" and... Well at least it's genuinely safer.
Disclaimer: I'm an aging dev myself.
Mono/C# is better, but the learning curve is pretty steep compared to Go with all the missing reference assemblies, diverse runtime versions, etc. Gopath sucks and sucks to configure but it's less complicated than .net.
So you can ask a junior web dev to learn a new language in a week and write a native windows application, and they might actually deliver. Whether this is empowering or signals the death of Quality remains a hotly contested issue.
It’s true that you can write bad Go by trying to do things that are not a good idea, but I’m not sure what you’d expect. The Go ecosystem is damning evidence of the ease of writing pretty good code in the language.
Disclaimer: I work for Google (but I do not work on Go and I did not work for Google when I first began writing Go.)
There are, however major footguns, I find it hard to read other people's, or even my own code (parsing nested if conditionals is no fun when you're debugging under duress), and CSP is really just.... Not the best concurrency paradigm.
I've had the opportunity to talk with a few people who were involved in Go's design and they explicitly said the idea was to get fresh-out-of-school programmers to be productive on web systems immediately.
Looks like your senior dev has completely missed that.
> Similarly, the len function on strings returns the number of bytes in the string, which is not necessarily the number of characters.
Should len do unicode normalization (NFC)? Than it's extremely complex. Or should it count code points? Then it's simply broken.
Counting bytes is fine, I'll do explicit normalization if I need to.
>can be conveniently concatenated with +, and can be used as map keys.
Does Go do a normalization for a concatenated string as it should?
But when it comes to Go, I absolutely adore its simplicity. I find myself wanting to write more Go code and I sometimes even catch myself trying to find reasons to write implementations in Go.
Anyways, that's just my two cents.
> Because strings are just slices of bytes, there is no simple way to index or slice a string if it contains non-ASCII characters.
Indexing into a UTF-8-encoded string is expensive -- O(n) instead of O(1) -- so it's good that it also looks expensive.
> Despite the above, Go has two competing types for representing text, string and []byte.
As has any other serious language. Byte arrays and strings are just not the same thing. My only real gripe with Go's treatment of strings is that converting from []byte to string is a simple cannot-fail cast. That should be an operation that checks for valid encoding, and returns an error otherwise, like Rust's str::from_utf8.
> Deleting the nth element from a slice sure doesn't look like deletion: [code snippet]
This is a fair criticism, but IMO way overblown. I cannot remember the last time I had to delete individual elements from slices. Most of the time I'm doing map() or filter(), or rather, the equivalent spelled-out for loops since Go does not have generics.
> If you import a library or declare a variable, but do not use it, your program will not compile even if everything else is valid.
And that's great. I don't want old libraries bloating my program needlessly. It's sometimes a bit annoying to have to write
_ = foo
into unfinished functions because otherwise it will not compile due to "error: foo is never used", but I like my compilers strict.Also to this point: You can set up your editor to run your code through goimports automatically, which will completely do all the adding, removing and ordering of imports for you, as well as format your code according to the standard style. More languages need this.
> If multiple channels are available to receive from or send to, the select statement picks a case at random, meaning that to prioritize one channel over another you have to write: [lengthy code snippet]
Having to prioritize channels manually is a bit of a code smell in my opinion. I would need a real-world example to judge, but it smells like the real problem is how you slice up your work into goroutines.
> Two implementations of random numbers, math/rand and crypto/rand.
Again, this is completely standard for any serious language. For mathematical simulations, you don't care about cryptographic properties of your RNG and want the extra speed that a simpler RNG like a Mersenne twister gives you.
> The errors package is twenty lines long, because Go's error type is simply an interface to a function returning a string.
You forgot the criticism here.
> Go's native package system does not support X
All of these are wrong. Go has added a proper native package system in 1.11.
> The contributors don't listen to the community.
One of the two examples shows that the contributors do listen.
> Almost nothing in this list can be fixed, because of the Go 1 compatibility promise. Until Go 2.0, that is, but that may never happen.
That's the problem with crystal balls.
TIL, you need a crystal ball to foresee the features and design decisions invented many decades ago and polished by the industry.
Who knew that living without parametric polymorphism in a static language would be painful. Of course this requires a handful of RFCs because nobody knows how to implement parametric polymorphism right as if ML didn't do it decades ago with soundness proofs and all needed extensions.
Who knew that `if err != nil` is error prone, verbose and noisy way of dealing with errors. Again, nobody knew how to do it right, there were no Common Lisp, Scheme, Haskell who already did this right. There are Monads, Exceptions, Effects, Conditions for error handling, lets throw all of this experience away and invent some obscure `try` keyword.
Reinventing the wheel is fun. Rooting your work in previous rigid and battle-tested (or even formally verified) experience is boring and complex.