by preommr · 5y ago · 0 comments
If anybody wants to learn go, ignore everything about how easy it is to learn. Because it's extremely deceptive. Take time to actually read through a lot of the important underlying concepts like how slices work.
Ignore comments about how go is simple to write. There's a fair amount of bad go code and people break rules all the time. From official sdks to standard libs. Go can be extremely difficult to both write and read. It's implicit interfaces and judicious abuse of interface{} can make tracing how a library is supposed to work a PITA. Writing go can be difficult because of a lack of some language constructs that leave you unsure how to proceed.
If you can, use goland. I use vscode and it's... not pretty. Almost every single thread I've seen on reddit recommends goland. My experience with vscode has been very unpleasant, particularly with go plus.
OTOH, things like criticisms about it's error handling are overblown. At best it's a mild nuisance, and more often than not, a good thing that makes error handling explicit and clear.
There are many things about go that have made me appreciate it's existence. There are also many things that have left me absolutely baffled at how bad it is.
This is one of the most famous straw man arguments made in software development and I've seen it used against a plethora of different programming languages -- each time completely missing the point that you can get bad developers writing bad code in any language. The fact it happens in Go isn't a testament not to how difficult it is but rather how good of a job the language has done attracting newer developers.
> Go is not a simple language. Please learn from my mistakes, and ignore arbitrary metrics like how go has fewer keywords. The complexity doesn't go away, it's hidden away somewhere.
I completely disagree. Having fewer keywords does make Go simpler to learn and simpler to read other peoples code. The opinionated nature of Go also makes it simpler to collaborate.
Writing software isn't simple but that complexity of turning ideas into code doesn't change significantly from one language to another (generally speaking). You still have to solve a problem using logic and functions. I find the harder problems with software development is collaboration (eg ensuring everyone is following the same coding styles) and reading back old code. Go makes those things easier than some -- not all but definitely some -- languages.
I say this based on 30 years of experience writing software in more than a dozen different programming languages.
Go carefully touts how few reserved keywords it has, but I think it would actually be a simpler to reason about language if it had more reserved keywords.
For example, you may notice that "true", "false", "len", "new", etc all aren't reserved keywords.
This sometimes does lead to bugs, for example someone may make a function, like "func memoize(new func(...interface{}) interface{}) func(...interface{}) interface{}", which shadows a common builtin function with a function argument.
Usually, the above leads to a compiler error when you try to use the "copy" argument (a value) as a function, but every once in a while, you end up with a type-compatible shadow, at which point things can really break.
It would be less confusing if things like "new", "len", "copy", and "true" were keywords, rather than builtins that someone may accidentally alias and shadow.
If you account for things like rather essential builtins as well, go's list of keywords starts to look far less impressive, and on-par with java or C#.
IF IF = THEN THEN THEN = ELSE ELSE ELSE = ENDIF ENDIF
...assuming IF, THEN, ELSE, and ENDIF are all variables.that sounds like saying that latin-alphabet languages are easier to read than chinese or japanese because they have fewer characters. the complexity just goes in the way those characters are assembled together.
but that's because you come from a latin background. I lived with a japanese girl for a long time and she was adamant that kanji were much easier and faster to parse for her than western text
One study I recall (on my phone now, will cite later) reported that fewer 20-year-olds have "fluent" levels of reading comprehension for what they read in the [ideographic] newspaper in Japan or China, than in neighbouring countries with alphabetic languages derived from those same historical ideographic roots (Korea, Vietnam, Thailand.)
Another study (will cite later) reported that the reading-comprehension rate for ideograph-heavy works in Japan is also decreasing over time, as more people spend their time reading mostly explicit "[ideograph-]light" novels, rather than literature that would actually teach them kanji. (Which is a vicious cycle.)
Given that ideograph radicals are kind of analogous to alphabetic morphemes, this is kind of surprising. I think it's mostly because it's self-evident how to pronounce alphabetic morphemes if you know the pronunciation rules of the language, while
1. the names for ideographic radicals need to be memorized, more like the names of alphabetic letters (but with there usually being far more radicals in common use per ideographic language, than there are letters in an average alphabet.) And
2. ideograms aren't usually linear, but rather structured (things above/below/beside things, things inside things, things bonded to other things and reduced in the process, etc); and there's no universal cultural fluency for speakers of these languages in an ordering system for spelling out these radicals. You usually have to see a character written before you can truly know how to "spell out" its radicals.
Because of these two problems, you can't just look at an ideograph you don't know, and casually, conversationally spell it out to someone else, in order to ask how it's pronounced / whether you're pronouncing it correctly. Unless, that is, you both know the names of all the involved radicals, and have a good geometric guess for the ordering. In practice, most people don't try to ask this question verbally, but either need to show someone the character written; or need to use a dictionary.
I've noticed that this actually results in distinct approaches to how people treat "literature with words they don't know", between people whose first language is an alphabetic one vs. people whose first language is an alphabetic one. Given an alphabetic-language work with word they don't know, alphabetic-native people seem to be much more confident in just jumping in and looking words up as they go; while ideographic-native people seem to be more reticent. I believe they're subconsciously expecting new [alphabetic] words to be a much larger barrier for them than they actually would be, as they're used to thinking in terms of the barrier that novel ideographs impose.
The World Bank puts China (97%) behind Korea (98%), but ahead of Vietnam (95%) and Thailand (94%). They don't have data on Japan, but I'd be surprised if their literacy rate were much lower. (I'm also on my phone, but here's the link: https://data.worldbank.org/indicator/SE.ADT.LITR.ZS?location... )
I think those literacy rates mostly reflect the quality of these countries' respective education systems, rather than any inherent properties of the scripts used.
This is a fair point since I wasn't very clear, and I am talking about something that's fairly subjective and abstract. I think the more claims a language makes, the more open it is to failure. I just googled is "rust difficult to learn", and the first answer is "no". It's all relative, but I am sure that most of us have heard that rust does have a steep learning curve. The only other language that I can think of that advertises itself as easy is python. And I think it has a lot of faults in those claims too. But python does a much better job of being easy than go does. It's completely different leagues.
Again, this is a messy point to make, either somebody understand what I am trying to say or they should leave it at that because trying to qualify ideas like this is fuitless.
> I completely disagree. Having fewer keywords does make Go simpler to learn and simpler to read other peoples code.
I really don't think skipping keywords like public and using casing makes things simpler. A quick google search shows that go has 6 less keywords than c. I mean, c'mon...
> I say this based on 30 years of experience writing software in more than a dozen different programming languages.
If you've had years of experience in old school c/cpp, then (I would assume) go will be a lot easier, and a lot better in comparison.
In my opinion old school C++ was a lot easier to learn than modern C++. I'm talking about the language specification specifically. The tooling is undoubtedly better.
Visual Basic 6 easily wins the "easiest language" award in my opinion though. But it's often seen as a faux pas to mention VB amongst developers
I partly disagree. It might be easier for you with 30 years of experience. Sysadmin with 8yrs of experience and having to manage operations utilizing Go is not easy.
The code looks neat on the page; under the hood is really un-understandable at times unlike Perl, Ruby, TCL where the code is staring you in the face. The importation of modules off github is fundamentally wrong too.
Are you able to elaborate on this a little more? I love Perl and in fact that was my favourite language for a long time (despite all of its warts). But languages like Go are a lot more explicit that Perl so I'm not really sure what you mean by "under the hood" and "code is staring you in the face.
> On vent: I also really loathe importing modules off github.
I must admit that really annoyed me too but in fairness it's a pretty common pattern (eg brew, npm, etc). In a way Perl (CPAN) is an edge case rather than the norm. The difference is other systems add a shim around the code source even if they do still pull directly from (or from a cache populated directly from) Github et al
We use Prometheus exporters, most of the exporters are written in Go. And this is a snip from the vmware-exporter for our VMware estate.
metrics.go
The first throw was this: import (
"context"
"github.com/prometheus/client_golang/prometheus"
log "github.com/sirupsen/logrus"
"github.com/vmware/govmomi/find"
"github.com/vmware/govmomi/view"
"github.com/vmware/govmomi/vim25/mo"
"github.com/vmware/govmomi/vim25/types"
So as it currently stands I have no idea what those modules are and what I am loading. Browsing each of those repos sure will tell me, but that's not my role. My role is to make X operational.And if that repo doesn't exist anymore and you go to compile, it fails. More overhead if I need to make changes to any of those modules. I would need to git clone it somewhere, make the change and then either recommit it to git, or do something to make it locally available. At least with NPM, CPAN they are local to the file system.
So lets start:
var (
prometheusHostPowerState = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Namespace: namespace,
Subsystem: "host",
Name: "power_state",
Help: "poweredOn 1, poweredOff 2, standBy 3, other 0",
}, []string{"host_name"})
I understand all of that. Power_state, display the help, power status description etc, however prometheus.NewGaugeVec --
Sounds great. What is it? Where do I find this? What module is this related too?That's where it falls down for me. I now have to duck in to the rabbit hole of github to find out where that function is phrased and in this sense "under-the-hood" could also count for library .pm files in perl, but now having to navigate GitHub really messes with my workflow.
Here is the Go spec: https://golang.org/ref/spec. Firefox's print dialogue tells me it's 105 pages long. You can read the spec in an afternoon and digest most of it.
Here is the ECMAScript 11.0 spec (known as JavaScript to its friends): https://262.ecma-international.org/11.0/. Firefox's print dialogue tells me it's 1181 pages long.
Here's the Java SE 16 spec: https://docs.oracle.com/javase/specs/jls/se16/jls16.pdf. It's 844 pages long.
I can't post the C++20 spec because it's an ISO standard and it costs $399AUD for the privilege of reading it, but it's 1853 pages long in PDF form: https://www.iso.org/standard/79358.html.
On a factual level, Go is a simple language, but so is the language Brainfuck, which has a sort-of-spec that's 9 pages long: https://github.com/brain-lang/brainfuck/blob/master/brainfuc.... Simplicity is not ease of use.
Still, even if they added these, it would likely stay significantly shorter than even Java.
I dont think it affects your point but those are implementation details rather than features of the language itself. Obviously it's still important to understand the language implementation so you can make reasonable guesses about performance etc. when you're programming.
For example, is this piece of code correct?
x := 7
go func() {
if x == 7 {
fmt.Println("x = 7")
} else {
fmt.Println("x != 7")
}
}()
x = 8
What are its possible valid outputs? (for the record, as far as I know this is incorrect code in Go, as atomic access is not guaranteed for any variable, so not only could this print any of the two outputs, it could also observe invalid values for x)What about this code:
x := 7
c := make(chan struct{}, 0)
go func() {
if x == 7 {
fmt.Println("x = 7")
} else {
fmt.Println("x != 7")
}
c<-struct{}{}
}()
<-c
x = 8
Can you tell from the language spec whether this code is safe, and what it's output will be? (~~it's not safe, as far as I know~~ reading the memory model[0], I believe it is safe).Perhaps. But what use is a language that is simple if it doesn't make it simpler to use or easier to learn? I think most people who claim that Go is simple are claiming the latter, because the former is mostly uninteresting. It's good for IDE support I guess.
Following the JS spec alone, it would probably be hard to find any code on the entire internet before 2015 that wouldn't run on your implementation (even though it would undoubtedly run slower).
In contrast, if you followed only the go spec, ZERO go code out there would actually run because it doesn't include the rest of the language and core features.
If you want a fair comparisasion, include the standard library for the other languages.
In total, it's 1622 pages. Without the cross-references and the index it's only 1486 pages. Also excluding the standard library, it's 520 pages.
There, the fair comparison is:
Go: 105 pages
C++17: 520 pagesBy the way, Java, Python and .NET ones top the C++ one.
Some languages have stdlibs that just contain "stuff everybody needs" — stuff every app or library written in the language will use (common data structures, concurrency primitives, etc.), such that anyone who "knows the language" would also be expected/required to know (or at least know of) those components, if they have any hope of being productive in the language.
But other languages have huge stdlibs, that include a bunch of stuff that almost nobody is even aware of, such that most developers won't actually need to know about it in order to effectively maintain other people's code in the language. These are essentially just weird niche libraries that happen to ship with the runtime for some reason.
Examples of weird niche libraries that are technically "stdlib":
• PHP has an Ingres driver built in. That's Ingres, the predecessor to Postgres.
• Ruby ships with a CJK character-normalization CLI utility.
• Erlang/OTP has "Megaco" (http://erlang.org/doc/apps/megaco/megaco_intro.html) — an H.248 media gateway daemon library.
Admittedly, languages do tend to gradually factor these weird niche bits out into separate packages. (Ruby just moved almost all of its stdlib into ecosystem packages in 3.0. Some ecosystem packages are just now install-by-default — but maybe won't be in the future.)
Also, the behavior of these weird niche bits is not usually specified as part of the language's spec... but that doesn't mean much, as often, these languages don't even have specs. In those cases, the reference implementation is the spec — and so, if the reference impl includes these libs, "the language" includes these libs.
Do people say that? I've never heard anyone claim that Go is simple to write.
Pike, I believe (may have been someone else), claimed something to the effect that new grads with limited exposure to real-world codebases were able to understand existing projects written in Go more quickly than in other languages at Google. I have seen that message distilled down into "Go is simple to read."
Go was built on the premise that people spend more time reading code than writing code and Go attempts to make tradeoffs towards reading optimization rather than writing optimization. Whether or not it is successful in that is another topic for another day.
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.
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 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).
Yeah, it was Pike, and I have also seen it distilled (in bad faith) into "Go is a primitive language for inexperienced programmers, so it's beneath me to touch it". And yes, it is easier to write and read compared to other languages (old and new), but it does have some concepts that you should follow to write "idiomatic" Go code, e.g. don't throw panics as liberally as you would throw exceptions in other languages, use composition and interfaces where you would use inheritance in other languages etc. But I'm afraid people who have been indoctrinated with disregarding Go as "simple", but want to try it nevertheless (or are forced to use it), won't take the time to get into these details, and will see their preconceived opinions confirmed...
I think the two are related, directly. However in my experience i don't even agree with Pike. Go is not easy to read. Yes, a single small function in Go is much easier to read (perhaps) than X lang. However Go requires a huge (brain)memory table to remember everything, because it spreads logic out. So you have to remember X function, scroll up, look at Y function remembering how it interacts with X, etcetc.
> Whether or not it is successful in that is another topic for another day.
I guess i bikeshedded, sorry :s
The article we are discussing now has a big subtitle "A simple language."
For me, the simplicity, batteries-included, and minimal primitives are a breath of fresh air, whereas in many languages I've felt like I have to learn "a whole new thing" each time I plug in a new library or try a new framework. Go has a web server, JSON, SQL, crypto, compression, and more built in, and it's all stuff you'd want to use directly in production. In Go, code and docs are just easier to write and navigate too. Compare, for instance, the prevalence of Reader/Writer types to how all-over-the-place implementations of buffers and asynchronous code are in other languages and ecosystems, or how many different build systems, dialects, and frameworks most languages have. The locality of most Go packages means you'll find better docs and help, and more canonical examples of how to do something.
Swift is another "deceptively simple" language to me. Swift has quite a few features, which means more prerequisite knowledge to read code "in the field". You're less likely to understand code by looking at it because there's more ways it can pan out while the developer is thinking about how to write it. I found that to be an especially big problem with JavaScript; I generally tell people to start writing JavaScript with a particular toolchain like React/TypeScript so they can set up a project and get on the right track fast. Go's ecosystem is opinionated but still just flexible enough, as I would say most of the features are.
Yea, i'm a bit critic of Go (used it professionally for ~5 years, but no longer), but it's error handling is fine. Would i like Rust's `?` error handling syntax? Yes. Would i prefer better language tools for error handling (like enums/etc) rather than usually just wrapping strings? Absolutely.
But the actual _need to error check_ itself is fine. I think it's funny, because to me the Go audience is one similar to NodeJS/JavaScript, aka one that favors features to improve prototyping. And while much of Go feels (at first glance) to promote this, the error handling does not.
I prefer Go error handling. But i wonder if Try/Catch would have been more inline with much of Go's audience.
[0] https://github.com/golang/tools/blob/master/gopls/README.md
I feel like I haven't had to use it as much recently.
The hardest part of Go is learning how to effectively use things like goroutines and channels.
Slices might catch some noobs out, but at the end of the day it's as simple as saying "a slice is a view on a block of memory", so 2 slices can point at the same data, and changing data with 1 slice can be reflected in the other. Once you realise that a slice doesn't hold values there's no issues. That's simple, I just explained slices in 5 seconds.
I think implicit interfaces are amazing. Yes it can be hard to figure out what implements it, but an IDE is used for that. Like you say, Goland is really good. Abuse of interface{} is bad, it's the worse decision that was ever made for the language in my opinion. But I don't think it's that big of a deal in the grand scheme of things. Generics will remove a lot of it's current uses anyway. I write microservices and the only time I have to touch interface{} is when using contexts.
It's not for everyone, but people saying "Go isn't simple" are just as bad. You've got to understand people from all sorts of backgrounds have learned Go. For me, I really think it's easy to learn and simple to use. Others might think it's the hardest thing they've ever done.
For me, using context and stuffing and retrieving things from it is the most painful part of go.
If anything from go should die in a fire, it’s Context - well, the key value storage anyway. The canceling part is fine.
I'm of the opinion that (if you're writing web services) anything related to the request should just be passed to the function using it. Shouldn't be stored on context and passed along 20 middleware handlers. If you need to share state this way then it's a failure of your design. Putting the meat of your business logic in multiple handlers is not the way. A handler is how you get the data into your application, then you can forget about them. But some people don't really understand that and start having authentication middleware, session middleware, user middleware etc. Just pointless complexity.
Design of context and the key/value storage there is wrong.
Which is ironic given that the golang designers and users tend to shun IDEs and mock that languages like Java rely on them. When in fact, to do anything useful in golang you also need an IDE.
Other languages are simple in the same way that landing a rover on Mars is simple: not simple at all. Every caveat I listed for Go and Tetris also applies to these other languages.
So, all other things being equal, Go's simplicity wins, for me.
Given how complex computers and programming is, it's easy to argue that any language is not simple.
It's a more interesting question to ask which of the languages is simplest.
One big example is Go slices, which are "easy to use" and "just do the right thing" up until they don't. If you append to a slice, it might or might not allocate a new backing array depending on the slice capacity, so whether your function is mutating an original or not can suddenly change based on changes in other parts of the code, and it's a huge pain to track down bugs like that.
Go's channels are "Easy to get started with", but very difficult to correctly compose, or do anything nontrivial with. Reading from a closed channel will "successfully" generate zero values instead of failing to read a value. You have to replace your variables with a nil channel instead.
When writing Go, I feel like programming by coincidence. With a lot of careful thought and work and testing, I can arrange for something that works, but it's fragile under refactoring and maintenance due to spooky action at a distance.
None of the stdlib collections are threadsafe, but if you mistakenly share one between threads, it works fine up until you hit sufficient concurrency to have multiple concurrent mutations.
Go is "easy" due to garbage collection, but that only handles memory, and offers you zero assistance in handling any other resources. There's no destructors, and no RAII, so you still have to carefully manually manage resource cleanup for files, database connections, locks, mutexes.
Go's type system is too weak to express a mutex owning its guarded value, so it's left up to careful code review to ensure that the guarded value is only accessed while the mutex is locked.
I feel like "the language" is simple, sure, but to successfully use it, you have to also learn many little constructs you have to repeatedly type out, and techniques to protect yourself from all the sharp edges.
For me, the Go Language was faster to learn than the Rust Language, but learning to reliably build correct programs with Rust was way easier than learning to reliably build correct programs with Go.
I like Rust because I am a mediocre programmer with poor working memory. Rust lets me build abstractions I can rely on, and reason locally in small parts while working on a program larger than I can easily fit into my head.
Go makes some operations "easy", but unfortunately also makes shooting myself in the foot much easier than doing something safe and correct.
The Go language itself is very simple because it abdicates all responsibility for correctness, leaving it entirely up to the programmer. You still need to handle all of the same responsibilities regarding ownership, resource lifetimes, locking, thread-safety, error-checking, exhaustiveness-checking, etc. but Go leaves all of that up to individuals to learn for themselves through trial-and-error, and ignores all advances in PL theory on how languages can assist with these problems.
I could understand some of the appeal of Go if it was people saying they like to use it for half-assed one-off scripts that don't grow to large sizes and don't have any long-term maintenance, but instead I keep seeing people build large production systems with it.
I feel this strongly as someone who prefers to write code which always works versus the "works except on edge cases" approach of most Go code. It's a step up from bash though.
What is your standard for "simple" if learning how to use slices is complex? Go slices are just windows into contiguous blocks of memory. There are pitfalls--if you have two juxtaposed slices backed by the same contiguous block of memory, growing the former will write over the latter, but you quickly learn that you should virtually never be appending to slices that don't have sole ownership over their backing memory. Probably the worst part is that there aren't higher-level functions for prepending or deleting an item, so you have to build them yourself with append, copy, etc primitives (but even this has the nice property of exposing the cost of these operations, e.g., deleting from the middle of a slice is expensive and your average Pythonista probably doesn't understand this).
> Ignore comments about how go is simple to write. There's a fair amount of bad go code and people break rules all the time. From official sdks to standard libs. Go can be extremely difficult to both write and read.
This hasn't been my experience.
> implicit interfaces
I love structural sub typing ("implicit interfaces")--I can define an interface for a third party type which in a nominally subtyped language would require wrapping the third party type in a new type whose only purpose is to express the suitability of a particular interface. And for no real gain at all (or at least I've never felt myself wanting nominal subtyping; perhaps it's a difference in workflow).
> judicious abuse of interface{}
Putting aside the contradiction of "judicious abuse", I don't think `interface{}` is very common in Go, and where it exists it's usually appropriate, for example, JSON de/serialization or Printf. `interface{}` is used very sparingly in Go, and considering that people build real, successful applications in languages like Python and JavaScript where everything is an `interface{}`, Go's use isn't that bad.
> Writing go can be difficult because of a lack of some language constructs that leave you unsure how to proceed.
I particularly disagree here as well. There's often one way to do something in Go, and I've had very good luck by Googling "How to do x in Go?".
> OTOH, things like criticisms about it's error handling are overblown. At best it's a mild nuisance, and more often than not, a good thing that makes error handling explicit and clear.
Agree here. Maybe I'm an unusually fast typer, but the majority of criticisms seem to be about how long it takes people to type out the `if err != nil {` boilerplate.
Personally my biggest criticism of Go is the lack of sum types (IMO I would much prefer sum types to generics). There are a lot of cases where it would be nice to express OR constraints. There are workarounds in Go--for example, using an interface with a private method that the variants must implement, but that's a lot of error-prone boilerplate and it tends to result in unnecessary allocations and dynamic dispatch (as opposed to a switch statement).
Another criticism is that the compiler doesn't optimize as aggressively as I would like, including that many abstractions are runtime abstractions that could be compile-time abstractions (specifically, Go doesn't have semantics for distinguishing between a run- and compile-time abstractions and the compiler pretty much always assumes that all abstractions are runtime abstractions.
> If you can, use goland. I use vscode and it's... not pretty. Almost every single thread I've seen on reddit recommends goland. My experience with vscode has been very unpleasant, particularly with go plus.
I've been pretty happy with vim. I haven't used goland. vscode became noticeably worse around the time that modules landed, and IMO never fully recovered. `gopls` has also been disappointing. Go's editor story used to be best in class in general, but it seems to have gone downhill. Still, I think it's well above average (especially with respect to the dynamically typed languages).
You also may have to learn the hard way that saving a pointer to an entry of a slice that is later appended to may, or may not, depending on len()<cap(), produce an unintended copy.
>I particularly disagree here as well. There's often one way to do something in Go, and I've had very good luck by Googling "How to do x in Go?".
How about deciding whether a heavily-used pure-function method should take a whole struct as its receiver, or instead a pointer to it?
If a whole struct, then non-modification of the receiver is guaranteed by the compiler, a great boon to the code maintainer.
If a pointer, then any number of members may be added to the struct with no performance penalty per invocation.
How to choose?
It seems like you answered your own question. I’m not really sure what you’re looking for here...
> You also may have to learn the hard way that saving a pointer to an entry of a slice that is later appended to may, or may not, depending on len()<cap(), produce an unintended copy.
That’s all pretty inductive from the simple definition of a slice: a growable view into a backing array (where “grow” implies copying to a new, larger backing array). But yes, it can be surprising if you are jumping into Go without ever reading the basics. In general, the best practice is to avoid multiple references into a mutable slice (this seems like generally good advice in any language).