by kubb · 5y ago · 0 comments
Of course just because I'm not well suited for it doesn't mean it's not for others. But there's a lot that we've collectively learned about programming, that's not acknowledged in Go's design.
You can start coding in it pretty fast, that much is true.
Go seems like it would be great for motivating someone to figure out the simplest possible way of solving a computing problem. Unfortunately for software development (but fortunately for humanity) not all problems allow engineers the freedom to brutally simplify the solution. Many domains come with hundreds of rules and exceptions that were all added for nontechnical, human-driven reasons, and your company probably does not have the power to throw out all existing business practices, human expectations, and regulatory requirements in your domain and replace them with something simple to implement. You just have to suck it up and implement the requirements in the most programmer-friendly way you can, and Go doesn't offer very good tools for that.
Admittedly, Go sets a higher floor than more expressive languages. A smart programmer with poor judgment can do a lot worse in Java or Scala than they could in Go. But Go's ceiling isn't much higher than its floor.
If you don't have to think too much about what code does, you can get a better overview of what's going on.
Plus, there's more developers available if your code is simple. That is one unspoken (yet written down!) reason why Go was devised - to be able to have mediocre developers still be productive.
Clever code is illegible by most people, unless they wrote it, are very smart themselves, and are actually interested in the code in front of them.
Go code is readable and comprehensible by everyone.
If I can understand every line of a 10,000 line program, is it not still noise compared to a 100 line program that accomplishes the same goal?
> If you don't have to think too much about what code does, you can get a better overview of what's going on.
That's the problem with Go. I do have to think about what the code does, because the ability to abstract things to a higher level is virtually nonexistent.
Take the following:
items
.select { |item| whitelist.include?(item) }
.sort_by { |item| item.price }
.map { |item| item.name }
I don't have to think about what this code does at all. It's obvious. And I am extremely confident that there are no bugs. The Golang equivalent? var tmp []item
var res []item
for _, item := range items {
for _, entry := range whitelist {
if item == entry {
tmp = append(tmp, item)
break
}
}
}
sort.Slice(res, func(i, j item) bool {
return tmp[i].Price < tmp[j].Price
})
for _, item := range items {
res = append(res, item.Name)
}
Sure I can understand every line of the latter. It's still noise. And it's only comprehensible by sitting down and carefully reading every single line. Are there bugs? I think not, but I'd have to think through it to be sure. Go took what should have been a simple problem and somehow turned it into something that would feel at home if I was writing a device driver.Sure if you have a 100 lines of pure Go, that should be readable. But take a look for instance at the source for go tool cover. How much time do you need to spend to understand it? Then imagine Rob didn’t write it, but a junior. How much more convoluted would it be?
Hashicorp's tools are great examples; before you could find endless posts online about using their tools I'd often dive into portions of Consul or Nomad with questions. Both of these are complicated pieces of software and being able to read the source helped a lot. On the other hand, trying to debug Werkzeug and Flask in Python is a nightmare of objects inheriting weird properties and all sorts of control flow weirdness, despite Flask ostensibly being a lightweight web framework.
The standard library manages to pack a lot of functionality in little code. Its probably not easy to write simple concise code in Go but it is certainly possible.
Crypto stuff - yes. Reflection, AST processing, concurrent hash map - I'm not convinced. Some parts will be terser than others.
The standard library doesn't implement typical business logic. So it's not the best benchmark.
Not to mention the lack of reusable data structures.