Variable Naming Conventions

The cluster debates the use of short, single-letter variable names versus longer, descriptive ones in programming code, focusing on readability, maintainability, and contextual appropriateness like math-heavy vs. business logic.

📉 Falling 0.3x Programming Languages
4,085
Comments
20
Years Active
5
Top Authors
#630
Topic ID

Activity Over Time

2007
8
2008
30
2009
57
2010
96
2011
107
2012
206
2013
191
2014
153
2015
210
2016
315
2017
271
2018
171
2019
313
2020
361
2021
373
2022
399
2023
310
2024
283
2025
212
2026
19

Keywords

IfExpressionParser A1 e.g CPU www.ittc CommandRec OK ID SimpleBeanFactoryAwareAspectInstanceFactory WRT variable names variables naming code single letter meaningful character short

Sample Comments

sweezyjeezy Oct 2, 2018 View on HN

Why do you hate variable names longer than 4 characters so much? :b

rookie May 11, 2011 View on HN

eww, single character variable and function names make me ill

hamandcheese Jan 16, 2021 View on HN

I’d love to understand the rationale for preferring extremely short variable names.

mirekrusin Mar 15, 2017 View on HN

I always thought it's the same reason as when doing math on paper starting in elementary school you'd call things x, y, z, h, w, w2... etc. instead of triangle_width... etc.In math'ish problems naming/algorithm (noise ratio) needs to be kept low, otherwise you can't read through it.You want to elevate symbols between type/vars in reader's attention (what's happening) as opposed to being detailed in naming (which is less of a problem to recall).It&

fragmede Jun 1, 2024 View on HN

haven't you ever written code with single letter variable names and it makes sense to you? and then been forced to read somebody else's code with single character variable names and found it completely inscrutable? this is just that on (a lot of) steroids

youngtaff Aug 24, 2022 View on HN

Might help understanding if the author used ‘meaningful’ variable names…

whatnotests Aug 27, 2017 View on HN

Can we collectively move on from single character variable names?The code examples are full of variables like "q" "a" and "v" -- it slows down everything as we must grok the surrounding statements like some kind of Rosetta Stone to interpret what "a" could possibly be in this context.Please fix it.

np_tedious Feb 12, 2024 View on HN

If you're in an abstract/general mathematical function, then sure: single letters. If you're doing more business logic kind of stuff (iterating through a list of db/orm objects or processing a request body) then the names should be longer

antoineMoPa Jan 25, 2022 View on HN

entirely_too_long_variable_names -> I prefer very long variable names which are self-explaining and easy to grep. Abbreviations make code less consistent and less greppable. Also what's the point of making shorter variable names if you need a comment to explain what it's doing - or worse I need to email the author to find the answer. A variable name should be the minimal representation of the role of this variable, but without cryptic shortcuts or abbreviations.

davidmurdoch Jun 1, 2024 View on HN

I've written code with single letter variable names lots if times! But later on it most certainly does not make sense to me.