Browse Clojure Foundations for Java Developers

Lambdas in Java vs Clojure

Clojure's fn, anonymous function shorthand, and how it compares to Java lambdas.

Java and Clojure can both express “pass behavior to another function”, but the default style looks different.

  • In Java, lambdas are strongly typed and usually tied to a functional interface (Function, Predicate, etc.).
  • In Clojure, functions are values, and you typically pass a var (named function) or an anonymous fn.
1(map (fn [x] (* x 2)) [1 2 3])
2(map #(* % 2) [1 2 3])

Practical guidance

  • Use the shorthand #() when it stays short and readable.
  • Prefer a named function when the logic has a real name or is more than a couple of expressions.

Java mental model: method references and lambdas map well to passing vars and anonymous functions, but Clojure encourages smaller functions and more composition.

The goal is not to memorize syntax. It is to pick the form that makes the pipeline easiest to read and maintain.

In this section

Revised on Friday, April 24, 2026