Go Is a Well-Designed Language
mattjhall.co.uk
mattjhall.co.uk
Specifically the map type. Unlike some Map implementations in Java, maps in Go are not ordered and there is no way to order them unless you want to keep a slice representing the order of the keys. Keys in these maps must be comparable, which means that unlike Java, you can't just implement equals() and hashCode() to make your type comparable. Maps and slices are not comparable, so if you use either in a struct, that struct is no longer comparable. Since map keys must be comparable, you'll have to convert your struct to a comparable type like a string if you want to use it as a key to a map.
You can always look for a third party library for more data structures, but the last time I looked those libraries didn't support generics yet.
Sometimes you'll find a standard library function that takes an interface{} and might panic if you give it a value it doesn't like. This is especially the case for library functions that want to operate on slices. Slices can be generic, but you'll still find many functions that accept interface{}, so you're left with library functions and third party libraries that take any as the type of an argument and expect you to read the documentation so that you don't accidentally pass the wrong type.
interface{}s are comparable sometimes, and if you compare two types that aren't actually comparable, you'll get a panic.
Although there are some decent libraries out there for this kind of thing, my complaint mostly stems from the fact that a lot of existing code doesn't involve generics yet.
I think I remember skimming an article about for range loops on Hacker News a while back, but again, my main complaint is still that existing code exists in a way that doesn't incorporate all these new features yet.
I have personally fallen into the category of "you can say you don't like Go, but you can't say it's not well designed". I've admitted as much here in years past. What has changed though is that I've written a few more apps/services with it and come to love the no-nonsense value-add. Go compiles fast, the tooling is great (The LSP for NeoVim just works) and the code written by seniors isn't vastly different than code written by mid/juniors. While I'm still not wild about the community attitude of "just build that yourself" I'm glad that the standard lib includes enough to make it possible.
I'll take the boring "easy to read" code over the "let me show you how much I know about Category Theory" most days. Please excuse the dig on FP - I do truly love OCaml, Elixir and now Gleam... I also just like the simple life some days.
I kinda like it; the Node community showed what happens if every triviality ends up in a library, and optimizing dependency management is one of the primary goals of Go. It's not even a language feature - there's nothing stopping anyone from creating 1000+ github repos with trivial utility functions.
That said, there will be a library at this point for anything nontrivial.
The problem that the wild ride post has is not that the filesystem api doesn't work for windows. It just uses it to illustrate a broader point: golang opts for silent failures (for example by just making up file permission bits for a file on windows), and just chugging along pretending everything is fine when it's not. This design choice goes well beyond the filesystem api.
Now, whether I think that's a fair criticism or not is beside the point. All I'm saying is that this post is not a valid response to the criticism illustrated by comparing Rust's filesystem api to that of Go.
Last time it was generics that were missing, now everyone is raging about sum times and of course explicit error is a topic of constant concern and why panics and not exceptions?
Go is well designed to build good software quickly. Easy dependency handling, good tooling, vast ecosystem.
Go is well designed to help developers with automation and help them catch mistakes, that's why it's easy to parse and all language design decisions take that into account.
It's also designed to produce a lot of code and that requires the language to be easy to understand and programs easy to tweak and that's what it provides, since you'll have a lot of developers tweaking the code.
We're in the industry of shipping different kinds of products and that imposes different constraints and results in different languages being used. Also, different people care about different stuff and languages form clusters of similar minded people around them, that's a choice too.
If anyone says Go is Great without addressing this issue, they've drunk the koolaid.
I don’t like go much - languages that can have nil pointer errors can take a hike, but what I like even less than a nil pointer error while handling a request, is for my whole process to die unrecoverably because someone forgot to check a nil in an infrequently called API. Or when comparing something that’s not allowed to be compared. Like the language would be better if these mistakes were impossible to make, but as long as we have a language with a plethora of garden variety syntax can panic like `a.b` or `a == b` we should be able to mitigate that risk at runtime.
Definitely, V (Vlang) is in the trajectory of a better Go or Go and C alternative. When you read V (Vlang), you can see how it's improving upon or advancing various Go concepts, while being C-like. Rust, because of the OCaml heritage, is a bit both odd and unique. It's positioned as a C/C++ replacement or alternative, but there is no easy recognition or transition from those languages. Possibly why there is a lot of friction and controversy surrounding Rust, as people haven't familiarized themselves with (or don't want to) with OCaml and that family of languages.
For illustration, when I google “C# install”, the top hit is “Install .Net on Windows” from Microsoft, a W3CSchools URL, and then a plethora of YouTube videos. The Microsoft link has several tables listing various different packages and whatnot. Is .Net the same thing as C#? I’m on a Mac anyways so it’s useless. I am stumped on how to even use this language before I get started.
When I Google “go install” the top hit is a page with simple instructions for each operating system (Windows, Linux, Mac. No tables to read or oracles to consult.
Perhaps make sure that the statements are true first?
Anyway
brew install dotnetWhen I said “I’m on a Mac anyways so it’s useless” I’m referring to the results I get googling for “C# install” instructions, not the language itself. I don’t know why it’s so hard to find https://dotnet.microsoft.com/en-us/download/dotnet/9.0 or why that windows specific page has so many different thingies listed in all its tabes.