Comment by pjmlp
4 days ago
Languages like Go, is how you end up with what appears simple on the surface, while in reality is full of gotchas and boilerplate for what complex languages support out of the box.
That is how you get double nils, exception handling that pretends not to be one, url based imports that requires source code and rewrites when the host changes, generators by code patterns, generics that miss some language constructs,....
Written a few hundred kloc of go and I'd never heard of double nil. Turns out it's nasty.
While this behavior can be counterintuitive, it's easy to understand once you have the right mental model of interface values. A nil interface is an empty interface. Once p is assigned to i, then i is no longer empty: it holds a nil pointer to an int. Whether the interface is empty or not is one question, answered by comparing it against nil. Whether the value the interface holds is a nil value is another question, answered by downcasting and then checking the resulting value.
I don't blame people for being confused by this the first time they encounter it. However, anyone who finds it persistently challenging to understand is not going to have much luck with the subtler language features of C++, Rust, Typescript, etc.
Just because you can easily understand something doesn't mean it isn't a footgun.
That seems like the reasoning that given the amount of UNIX and C code in the industry, memory corruption bugs only happen to those that don't understand their job.
Never used go, but I assume interface is some kind of indirection? If so, this doesn't seem anymore confusing than:
None of those are real problems in reality, I don't think Go has more gotchas than other languages.
Having gotchas is natural in language design, often times they only surface after field experience.
The problem with many Go's gotchas is the initial refusal to learn how other languages approached the same problems, the gotchas they got in the process, only to come up with some patch work afterwards, e.g. pseudo-exceptions with panic/defer/recover, rewriting import urls in go.mod,...
> url based imports that requires source code and rewrites when the host changes
This is not the case. It can be avoided quite easily with 'replace' directives and/or GOPROXY.
Yes, I meant that with my mention of rewrites, and it is design wart that such workarounds are required in first place.