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

(yakubov.org)

Comments

yakubov_org 13 hours 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 13 hours 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 ;)