Browse Learn Clojure Foundations as a Java Developer

Symbols and Keywords

Learn the distinction Java engineers need early: symbols are names Clojure resolves in code, while keywords are self-evaluating labels used in data.

Symbols and keywords look similar at first because both are compact identifiers. They play different roles:

  • A symbol is a name used by the evaluator and compiler. It resolves to a local binding, a var, a namespace-qualified reference, or a Java class name.
  • A keyword is a value used in data. It evaluates to itself, commonly labels map entries, and can be called as a function to look itself up in a map.

Java mental model: symbols are how you refer to code; keywords are how you label data.

Practical Defaults

Use Prefer Example
Local names and function parameters Symbols user, email, subtotal
Function and var names Symbols normalize-user, str/trim
Java class names Symbols String, java.time.Instant
Map keys and domain attributes Keywords :user/id, :invoice/status
Enum-like states Keywords :active, :draft, :cancelled
Code treated as data Quoted symbols 'user/id, '(map inc xs)

Prefer keywords for maps that represent domain data:

1{:user/id 42
2 :user/name "Ada"
3 :user/status :active}

Prefer symbols when you are talking about code: locals in let, function parameters, vars created with def or defn, and namespace-qualified references like str/join.

Tiny Examples

1(def user {:user/id 42 :user/name "Ada"})
2
3(:user/id user)        ;; => 42   (keyword as a function)
4(get user :user/name)  ;; => "Ada"

When you see a plain token like user in code, it’s usually a symbol being resolved. When you see :user/id, it’s a keyword value being used to label and access data.

    flowchart LR
	    A["Token in Clojure code"] --> B{"Leading colon?"}
	    B -->|Yes| C["Keyword: literal data label"]
	    B -->|No| D{"Quoted?"}
	    D -->|Yes| E["Symbol data: not resolved"]
	    D -->|No| F["Symbol: resolved as a name"]

This distinction is small, but it unlocks a lot of Clojure reading fluency. Java engineers often look for fields, constants, enums, and imports; in Clojure, symbols and keywords cover much of that surface with less ceremony.

In this section

  • Symbols in Clojure
    Understand symbols as Clojure names that resolve to locals, vars, namespace-qualified references, class names, or quoted code data.
  • Keywords in Clojure
    Use Clojure keywords as self-evaluating labels for maps, statuses, options, qualified domain attributes, and data-first APIs.
  • Symbols vs Keywords in Clojure
    Choose symbols for code-facing names and keywords for data-facing labels, with Java comparisons, map examples, review heuristics, and common migration mistakes.
Revised on Saturday, May 23, 2026