variable
A variable is a named storage location in a program where data is placed so it can be retrieved or modified later by referring to its name.
In plain terms
Imagine a labeled jar in the pantry. The label says 'jam', but the jar contains whatever you just put in. A variable is the same in the world of programming: a name (the label) and a corresponding value (the content).
It is useful so the program does not have to keep everything in mind. If an online store remembers your name, the total of your cart, or whether you are logged in, these all reside in individual variables. The program references the name and always gets the value currently in it.
The name comes from the fact that its content can change: the total in the basket will be different if you add another product, but the label remains the same. This distinguishes it from a constant, whose value is set once and cannot be overwritten afterward.
It appears constantly with AI tools. The coding agent creates and names variables, and in prompt templates the curly-brace placeholders (for example {customer_name}) work the same way: the name remains, the content changes occasionally.
How it works
- Creation: the programmer (or coding agent) gives the variable a name, such as "age" or "total_amount". The machine assigns the memory area where the value is stored to this name.
- Value assignment: a value is placed into a variable, for example the age value becomes 34. In many languages, you must also specify what type of data fits: number, text, or yes/no value.
- Usage: the program reads the value by referencing the name, calculates with it, compares it to something else, or outputs it to the screen.
- Modification: the value can be overwritten. If it is your birthday, the age becomes 35, and the old value is lost.
- End of life: a variable's name is accessible only within a specific part of the program (this is called scope), and its value persists only as long as it is needed. Afterwards, the machine eventually frees up its space.
An everyday example
When a newsletter starts with "Dear Kata!", the template actually says: "Dear {first_name}!". The first name is a variable into which the system inserts a different value for each recipient. If the letter arrives literally with the greeting "Dear {first_name}!", then the substitution did not occur, for example, the placeholder name was misspelled. If it says "Dear !", then the variable remained empty.
Who is affected
A common misconception
Limits and risks
- A meaningless name (for example, "a", "data2", "temp") does not break the program but makes understanding and debugging very difficult.
- If a variable has no value, or data of a different type than the program expects is entered, this is one of the most common sources of errors.
- By default, a variable's content exists only while the program runs. If you want to preserve it permanently, you must save it to a file or database.
- Do not enter passwords or API keys directly as variable values in code, as they can easily leak along with the code. Use environment variables or a secrets manager instead.
Similar, but not the same
- konstans – A constant's value is set once and cannot be changed afterward; a variable's can be overwritten at any time.
- parameter – A parameter is a variable that receives a value from outside when the function is called, thus serving as input.
- mathematical variable – In mathematics, a variable denotes an unknown or arbitrary quantity, while in programming it refers to a specific memory location holding a stored value.
Related concepts
programming, source code, memory
environment variable, global variable, local variable
A brief history
The concept moved from mathematics into programming, where quantities denoted by letters have been used for centuries. In the 1950s, assembly languages already allowed programmers to refer to memory addresses by symbolic names. The Fortran language, released in 1957, made it common to use variables with mathematics-like names in formulas.
Where things stand
The variable is an essential basic concept in programming, present in practically every language. In late 2026, code is increasingly written by coding agents, but the role of variables has not changed, and meaningful naming matters for both machine and human readers.
In the news
- Skilled workers are increasingly valuable in Hungarian industry, says Job Impulse headOct 22, 2026 · Ipar
- Nova Scotia classroom AI rules vary, prompting calls for a provincewide policyOct 19, 2026 · Education & Family
- Hungarian mathematicians answer an Erdős question using AI only as a toolOct 2, 2026 · Education & Family
- US law schools respond to AI with laptop bans and new tech coursesSep 21, 2026 · Education & Family
- AI visibility sources vary widely by health category, report findsSep 14, 2026 · Marketing
- Google DeepMind's AlphaGenome Atlas predicts effects of 9 billion DNA variantsSep 8, 2026 · Agent Age
- Vara receives world-first CE certification for autonomous AI in breast cancer screeningSep 2, 2026 · Health
- Google releases Gemini 3.8 Flash, its third Flash model in six weeksSep 1, 2026 · Agent Age
Also known as
variable · variable · var · program variable
Sources
This entry was machine-edited and has undergone machine expert review; the “In the news” section updates automatically from Agent Age stories.