On Wed, Oct 15, 2014 at 1:14 AM, Brenden <
bso...@gmail.com> wrote:
> I've heard a lot of strong opinions of some Go software projects based on
> how idiomatic they are, but from what I can tell these idioms are highly
> subjective.
Idioms are naturally subjective. They are patterns that are NOT
built-in to the language. They have a lot of value, as they form a
pattern-oriented shorthand useful for both reading and writing code.
> Some coders say using Go reflect is not idiomatic and yet Go's
> own JSON package uses it (and couldn't really work without it). For example,
> how is one Go web framework less Go idiomatic than the next? Why is "magic"
> bad? And so on.
Again, this is all very subjective. If you are experienced with Go
when you open idiomatic Go, it should be very comfortable. The way
errors are handed, the way the code is organized, none of it should be
particularly surprising. This lets you focus on the problem at hand,
rather than all that other nonsense. Idioms provide shorthand.
Go values explicitness (in both code and costs), and hence attracted
developers who value the same. So having "magic" (non-explicit, hard
to understand costs) naturally goes against the grain of the
community. I don't think reflection (or any other feature) is
inherently non-idiomatic, but nearly any feature can be abused and
turned into a mess.
> I just want to know who/what/where the authority of what great Go code is
> (aka idiomatic Go code) can be found.
Start with How to Write Go Code, Effective Go and of course the
standard library. But in the end, the authority will be what the
community accepts and rejects.
--
Robert Melton |
http://robertmelton.com