▲ | nulld3v a day ago | ||||||||||||||||
This 100%, I was just about to type a long rant up about this. There are so many weird parts of the language that took me forever to grasp, and in many cases, I still don't have an intuitive grasp of things. And plenty of other examples that aren't in that article: - You have a struct with an embedded interface. Does the outer struct satisfy the embedded interface? And can I type assert the outer struct into whatever embedded struct is fulfilling the inner interface? - When should I pass by value and when should I pass by reference? Like I generally know when to choose which, but do I really know without performing a benchmark? And what about arrays? Should I store pointers in them? But it also seems that people just don't care and just randomly roll the dice on when to return a pointer or a value? - Shorthand variable declaration. How does it work when you shorthand declare two variables but one of them already exists? Don't both answering the questions, that's not the problem. The problem is that it's just not intuitive enough such that I'm confident I know the correct answer. | |||||||||||||||||
▲ | B-Con 19 hours ago | parent | next [-] | ||||||||||||||||
The first is simply a question about what an embedded interface is. Any way in which you learned about this feature should also answer the question. The second isn't related to Go. The third I can see as being a bit confusing, but isn't it something you try once and then remember forever? Here's one: Creating a new variable via shorthand that shadows a variable in an outer scope - that can be confusing and an easy mistake to make. But broadly, I would strongly advocate that it is simpler than most other languages, even if it has some quirks. In the same vein of "If I had more time, I'd write a shorter letter", sometimes it takes a bit of time to understand why something is simpler than the alternatives. No language has zero ramp-up. Go doesn't exist in a vacuum, you have to compare it's learning curve and complexity to other languages. | |||||||||||||||||
▲ | dondraper36 a day ago | parent | prev | next [-] | ||||||||||||||||
I am not going to answer the questions, but this is a very strange complaint, to be honest. For example, passing by value/passing by reference is something covered immediately in the Go FAQ document once and for all. Everything is passed by value in Go, that is it. There should be no confusion at all. If you spend 15 minutes reading Russ Cox's post on the internals of the most common data types, you will also understand what data structures have implicit pointers under the hood. | |||||||||||||||||
| |||||||||||||||||
▲ | KingOfCoders a day ago | parent | prev | next [-] | ||||||||||||||||
Your thinking is too complex for Go. You might be better of with Rust. Same about benchmarking, if you want and need the fastest code, or the best memory management, use Rust. If you need something faster than Python in general but not the fastest, use Go. | |||||||||||||||||
| |||||||||||||||||
▲ | ralegh a day ago | parent | prev [-] | ||||||||||||||||
> but do I really know without performing a benchmark? Not really. But that’s one of Rob Pikes rules [1], I think the intention is to write whatever is simplest and optimize later. The programmer doesn’t need to remember 100 rules about how memory is allocated in different situations. | |||||||||||||||||
|