by Thaxll · 5y ago · 0 comments
Without prior knowledge you can jump into any code base and won't be suprised by something you never seen before or does not understand what it does. The language is simple to grasp because it has just a few concepts and keywords.
Sure, when reading Go, you aren't really encountering new language features; but you're often being forced to recognize things that should be language features, which are instead implemented as design patterns. (And, at that, often with those patterns reified into code by new-ish programmers who don't understand those design-patterns very well, rather than by language maintainers after much careful scrutiny.)
It's like doing OOP in C, and having to mentally parse vtable structs into the object-model they represent — with every project having done its own vtable implementation, all slightly different. Except that OOP is unusual in C, while concurrent infrastructure is near-universal in Go.
When reading Go, I'm essentially mentally "decompiling" it as I go into a higher-level representation within my mental-model. "These 50 lines are a parallel map-reduce; these 200 lines are a read-through cache with per-key synchronization to avoid duplicate work; etc." I'd rather just read that higher-level representation directly!
To me Go feels like a "modern" C language from 90's Bell Labs. Of course that is kind of true as Go is the spiritual successor to Alef and Limbo. Though it feels like it came out 10+ years too late.
That was the stated intent at the time Go was envisioned. They missed the mark a bit by not making Go a systems language, but oh well.
In any case, Go is Limbo with a bit of Oberon-2 facelift, and as such a bit too late to the party.
At least they might finally support some level of generics and catch up with CLU.
some people call not having native string/int/whatever sorting methods is "hard to write".
some people think the verbose `if err != nil` every other line is also "hard to write"
again, there is an upstart cost, which is to integrate yourself into the language community.
...which makes it also very easy to read.
To be more specific: the point isn't whether Go is "always" simpler to write but whether it is generally simpler to write. I think the latter is true for all the domains I've written code in Go and I've solved some pretty hard problems in Go (check out my Github repositories if you don't believe me).
The awesome thing about programming languages is that you're free to pick another language if that is a better fit for any specific domain or even personal preference. Hence why I've worked in more than a dozen different programming languages over the years. So rather than moaning that Go doesn't fit a particular pattern where you need to rely on generics, perhaps use a language that has generics to solve that problem and save Go for the occasions you don't need generics (which, if we're all honest, isn't something we need to rely on half as much as people claim when moaning about the lack of features in Go).
As a veteran developer, what really annoys me the most is people who pick a language that isn't well suited for solving the problem at hand and then moan that language needs to change, rather than developers picking the right tools for the job. I'd rather see a language lack features but focuses to serves its core demographic well than see everything and the kitchen sink is thrown at it and everyone using it even when they know they shouldn't simply because they're too afraid to learn anything new. What we need is more appreciation that "general purpose languages" doesn't mean "should be used to do practically anything in". Then I'd think we'd all get along better.
I find it especially powerful for writing tools.
That doesn't remove my rights to nitpick its shortcomings though.
I have kept a counter of many times I've told myself, over the past years, 'I wish Go had generics, this would really make my life easier right now'. It's currently at 5.
In my experience, the supposed issue of a lack of generics is _extremely_ overblown with regards to real world use. Sure, it would be nice to have them. I would've really liked them to exist a month ago when I was writing a generic container. But they're not going to make the language that much better for me, and there's always going to be more things PL people lust after (usually the next candidate would be GADTs, “Go does not have algebraic data types!” coming to HN comments very soon).
If I kept a similar counter for the past 3 years, it would be at least five per day.
Every time I `return x, err` and it's not a true tuple - and it almost never is - I wish I was returning an `Either<X, error>`. That's constant.
Every time I use atomic.Value (often) or sync.Pool (less often) or sync.Map (almost never because I end up rolling my own stupid map+mutex).
90% of the time I want to say a pointer can't be null. 100% of the time I want to handle optional JSON or SQL fields.
Fairly often, like > 30% of the time, when wrapping serdes or DTO conversions around data streams.
I don't believe the level of generics required to support these use cases requires compromising the other goals of Go. The deficiency should have been obvious as soon as they introduced `sync.Map`.
I can't imagine having this thought every single time. I don't want to sound harsh, but I don't know how else to ask this: can't you get over it?
Here are three options that were on the first page of google:
* https://github.com/kulshekhar/fungen
The famous "if err != nil {" boilerplate becomes expected after each call and you only notice if it changes.
I'm saying this as someone who is learning go for fun.