Re:Why people in Google hate Go?
by madeofpalk on Friday November 03, 2023 @06:58AM
(#38126886)
Single letter variables. A terrible pattern the go community picks up.
[ Parent
| on HN ]
I've heard that this is the result of snake-case refugees from C, Python etc. Single letter variables are camel and snake, everyone's happy.
Eh. Yes and no. I have not worked on a team that enforces that and I do agree with using them for short functions with 1 or 2 types. I do this in python as well
with open(..) as f:I have never seen this done in enterprise Go code, and I don't think it's been strongly recommended since the mid 2010's?
For small functions where you can see everything in a single page, this is fine. Though I think they should always be avoided except the most common cases (`i` for index) because keeping a codebase grep-able is a high priority. Using constant, verbose variable names can make tracing through a codebase much easier.
My guess is that he means, he would prefer variables to be more descriptive. Easier to read and follow.
Single letter variables like `i`, `j`? How `index1`, `index2` is any better?