Atoms and Terms
In Erlang, a term is any piece of data the language can represent: numbers, atoms, tuples, lists, binaries, and more. An atom is a constant whose name is its own value — literals like 'ok', 'error', 'undefined', or 'true' are atoms, written in lowercase starting with a letter, or quoted with single quotes if they contain spaces or start with an uppercase letter. Atoms are used pervasively as tags and status markers throughout idiomatic Erlang code.
Cricket analogy: The atom 'out' in an Erlang tuple like {out, bowled} works like an umpire's raised finger: a fixed, unambiguous signal whose meaning never changes no matter which match it appears in.
Tuples: Fixed-Size Grouped Terms
A tuple groups a fixed number of terms together using curly braces, such as {ok, 42} or {error, not_found}. The convention of tagging a tuple's first element with an atom like 'ok' or 'error' is so common in Erlang that it has a name — the 'tagged tuple' pattern — and it lets a function's caller pattern-match on the tag to decide whether an operation succeeded before even looking at the rest of the tuple's contents.
Cricket analogy: A tagged tuple like {out, caught, fielder_name} mirrors a scorecard entry that always leads with the dismissal type before the details, letting a reader instantly know the outcome.
Lists: Ordered, Variable-Length Terms
A list is a variable-length, ordered collection written with square brackets, like [1, 2, 3] or [ok, error, ok]. Internally, a non-empty list is a pair of a head element and a tail list, conventionally written [Head | Tail], and Erlang strings are actually just lists of integer character codes under the hood, which is why "abc" and [97, 98, 99] print identically in the shell.
Cricket analogy: An Erlang list like [4, 6, 1, 0, 2] recording a batter's runs ball by ball is a variable-length, ordered sequence, exactly like the [Head|Tail] structure of the deliveries so far.
How Terms Combine
Real Erlang programs nest these building blocks: a list of tagged tuples like [{name, "Ada"}, {age, 36}] is the classic Erlang way to represent a simple key-value structure before maps became common, and a tuple can itself contain a list, as in {student, "Ada", [maths, physics, chemistry]}. Because every term has a well-defined comparison order and equality rule, terms can be used directly as map keys, sorted with lists:sort/1, or matched precisely in function clauses.
Cricket analogy: A nested term like {player, "Kohli", [century, fifty, duck]} mirrors a player profile card combining a tagged name with a list of innings outcomes, just like combined Erlang terms.
1> Status = ok.
ok
2> Result = {error, not_found}.
{error,not_found}
3> Student = {student, "Ada", [maths, physics, chemistry]}.
{student,"Ada",[maths,physics,chemistry]}
4> Scores = [95, 88, 76].
[95,88,76]
5> [Head | Tail] = Scores.
[95,88,76]
6> Head.
95
7> Tail.
[88,76]
8> is_atom(ok).
true
9> is_tuple(Result).
trueErlang atoms are stored in a global atom table that is never garbage collected in older OTP releases, so historically it was considered bad practice to dynamically create atoms from untrusted user input (e.g. via list_to_atom/1) because that could exhaust the atom table and crash the node. Modern OTP releases raise the practical limit substantially, but the discipline of only using statically known atom literals remains good practice.
'true', 'false', and 'undefined' look like special keywords but are ordinary atoms — there is no separate boolean type in Erlang. This means is_atom(true) evaluates to true, and it's entirely possible (though bad style) to shadow these atoms as ordinary values in the wrong context.
- A term is any value Erlang can represent: numbers, atoms, tuples, lists, binaries, and more.
- An atom is a constant whose name is its own value, written lowercase or single-quoted.
- Tuples group a fixed number of terms with curly braces, often tagged with a leading atom like ok or error.
- Lists are variable-length ordered collections built from a head element and a tail list, [Head | Tail].
- Erlang strings are actually lists of integer character codes under the hood.
- true, false, and undefined are ordinary atoms, not a distinct boolean type.
- Terms nest freely — lists of tuples and tuples containing lists are the backbone of idiomatic Erlang data modeling.
Practice what you learned
1. What is an atom in Erlang?
2. What is the internal structure of a non-empty Erlang list?
3. In the tuple {error, not_found}, what is the idiomatic name for this pattern?
4. Which statement about true and false in Erlang is correct?
5. Why is it historically discouraged to create atoms dynamically from untrusted user input?
Was this page helpful?
You May Also Like
What Is Erlang?
An introduction to Erlang's origins, design philosophy, and the concurrent, fault-tolerant systems it was built to run.
Pattern Matching in Erlang
How Erlang's = operator, function clauses, and guards use pattern matching to bind variables and control program flow.
Your First Erlang Program
Writing, compiling, and running a real Erlang module, from module declaration and exports through the shell workflow.
Related Reading
Related Study Notes in Programming
Browse all study notesApache Spark Study Notes
Programming · 30 topics
ProgrammingApache Flink Study Notes
Programming · 30 topics
ProgrammingHadoop Study Notes
Programming · 30 topics
ProgrammingSnowflake Study Notes
Programming · 30 topics
ProgrammingApache Airflow Study Notes
Programming · 30 topics
Programmingdbt (Data Build Tool) Study Notes
Programming · 30 topics