Browse Clojure Foundations for Java Developers

When to Use Macros

A decision framework: use macros for syntax and evaluation control, not for cleverness.

Macros are worth it when a function cannot do the job because a function always evaluates its arguments before it runs.

Good reasons to write a macro:

  • You need to control evaluation (like when, and, or).
  • You want to introduce bindings or a control-flow shape that reads cleanly.
  • You want a small DSL that removes boilerplate without hiding behavior.

Bad reasons:

  • “It’s shorter.”
  • “It’s faster.” (performance usually comes from algorithm/data choices, not macros)
  • “It feels more Lispy.”

If you can solve the problem with a function and good naming, that is usually the better choice.

In this section

Revised on Friday, April 24, 2026