3 ms·
I believe you're conflating "simple in design" with "simple/easy to learn". Go is simple is design. It's not targeted to be easy to learn for someone without ba
by zbobet2012 4y ago
I believe you're conflating "simple in design" with "simple/easy to learn". Go is simple is design. It's not targeted to be easy to learn for someone without basic cs knowledge. As a meta some time spent watching simple made easy https://www.youtube.com/watch?v=kGlVcSMgtV4 https://www.youtube.com/watch?v=kGlVcSMgtV4 will help on the difference. For example:
> There is a "type" struct at the top, but then another struct without a type later on.
1) You not being familiar with anonymous types, does not make go complex. Anonymous types (var d struct) have been around for a _very_ long time.
> Then there's a nested struct, and then backticks with double quotes and json with colons - one with the backticks after float64, and the other after a brace.
2) Anonymous types and tagging. The tags are a convenient, orthogonal language feature.
> Then rather than returning the result of the json response with an equal sign, the json decoder line takes in both the response and the output as function parameters! And one of them has an ampersand in front?!
The json decoder in go works on structs by reference to improve speed. You'll need to understand passing by reference vs value to understand why this code is structured the way it is.
All three of these things are _simple_ features but they may not be easy to understand.
By the way the equivalent go code for the python you posted is actually:
d := make(map[string], interface{})
json.Unmarshal(resp.Body, d)
fmt.Println(d)
- ternaryoperator 4y ago> It's not targeted to be easy to learn. Not sure where you get that idea. "Easy to learn" is literally the second bullet point on the go home page. [0] The golang authors (Russ Cox, etc.) in Communications of the ACM (May 2022): "Go is efficient, easy to learn, and freely available..."[1] ...and many other places similarly. [0] https://go.dev/ https://go.dev/ [1] https://cacm.acm.org/magazines/2022/5/260357-the-go-programming-language-and-environment/fulltext https://cacm.acm.org/magazines/2022/5/260357-the-go-programm...
- zbobet2012 4y ago_without basic cs knowledge_ is the second part of that sentence you cut out. Go is easy to learn, for developers who already have fluency with notions such as pass by reference, typing, etc.