Do variable names matter for AI code completion? (2025)

1 yakubov_org 3 7/25/2025, 11:35:25 PM yakubov.org ↗

Comments (3)

yakubov_org · 22h ago
When GitHub Copilot suggests your next line of code, does it matter whether your variables are named "current_temperature" or just "x"?

I ran an experiment to find out, testing 8 different AI models on 500 Python code samples across 7 naming styles. The results suggest that descriptive variable names do help AI code completion.

Full paper: https://www.researchsquare.com/article/rs-7180885/v1

ssalka · 22h ago
The names of variables impart semantic meaning, which LLMs can pick up on and use as context for determining how variables should behave or be used. Seems obvious to me that `current_temperature` is a superior name to `x` – that is, unless we're doing competitive programming ;)
yakubov_org · 21h ago
My first hypothesis was that shorter variable names would use fewer tokens and be better for context utilisation and inference speed. I would expand your competitive programming angle to the obfuscated C challenge ;)