4 ms·
> The culture of single letter variables in golang, at least in the codebases I've seen, undoes this. The convention, not just in Go, is that the smaller the s
by lelanthran 2y ago
> The culture of single letter variables in golang, at least in the codebases I've seen, undoes this.
The convention, not just in Go, is that the smaller the scope, the smaller the variable reference.
So, sure, you're going to see single-letter variables in short functions, inside short block scopes, etc, but that is true of almost any language.
I haven't seen single-letter variables in Go that are in a scope that isn't short.
Of course, this could just mean that I haven't seen enough of other peoples Go source.
- marcosdumay 2y ago> that is true of almost any language You'd be surprised how often language-local cultures break that rule on either side. And a few times it's even an improvement.
- iudqnolq 2y agoI like using l for logger and db for database client/pool/handle even if there's a wider scope. And if the bulk of a file is interacting with a single client I might call that c.
- lanstin 2y agoZipf's law, right - these rules are a formalization of our brain's functionality with language. Of course, with enough code, someone does everything.
- kazinator 2y agoE.g. food and art are very important in Japan, so stomach is i and a drawing/painting is e.
- BrandoElFollito 2y agoFood is very very important in France so we call it nourriture :)