top | item 38126832

(no title)

guntherhermann | 2 years ago

Can you give an example of 'shitty code'? We've got murmurs of Go being adopted by some teams so if you have first hand experience it'd be really useful

discuss

order

carb|2 years ago

As a counter anecdote, I've worked at two large companies with monsterous Go codebases and they are totally fine to maintain. There is no justification to the claim that Java repos are "easier to maintain" by the above commenter, as we have decade-old Go codebases that doing great.

I'm just as fast/productive in Go (8 years of experience) as I am in Python (13 years of experience), but the resulting code is:

    * more maintainable (enforced typing vs typehints+mypy)

    * faster (compiled vs interpreted)

    * consistently structured / opinionated (until recently we didn't have generics, which meant that engineers often had to do things the "boring and verbose way" instead of the "clever and concise way" which, though frustrating short-term, has proven to be much better for maintainability long-term.
There's no reason that your company can't support multiple languages. Uber has large Go monorepos, Java monorepos, Python monorepos, etc. and they all work in harmony and with different requirements.

madeofpalk|2 years ago

Single letter variables. A terrible pattern the go community picks up.

leetrout|2 years ago

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:

carb|2 years ago

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.

favadi|2 years ago

Single letter variables like `i`, `j`? How `index1`, `index2` is any better?

jjgreen|2 years ago

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.

cultavix|2 years ago

My guess is that he means, he would prefer variables to be more descriptive. Easier to read and follow.

lm28469|2 years ago

Is that really the best argument against Go lmao ?