Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
One Letter Variable Names (simblob.blogspot.com)
1 point by ingve on Jan 4, 2023 | hide | past | favorite | 1 comment


I don't agree with the "rule" that one-letter variable names are bad per se. Variable names give context, and sometimes, `i` is all you need for context.

`this_is_the_loop_counter_for_the_only_loop_in_sight_have_a_nice_day = 1` isn't more helpful, it's worse than `i`.

Often time it's even more clarifying not to have to name a variable at all, e.g. through chaining or piping. This prevents you from having to invent useful names for all the intermediate results.

In general, more concise code is easier to understand, if the level of context is kept the same. This is the secret of the array languages.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: