Welcome to XCODX Online Compiler
Quick Start:
Ctrl+Enter Run code
Ctrl+S Save / Download
Ctrl+L Clear output
Select a language and start coding.
Welcome to XCODX Online Compiler
Quick Start:
Ctrl+Enter Run code
Ctrl+S Save / Download
Ctrl+L Clear output
Select a language and start coding.
Clojure is a modern Lisp created by Rich Hickey and first released in 2007, designed to run on the Java Virtual Machine. It is a dynamically typed, functional language built around immutable, persistent data structures and a small set of composable core functions. Because it compiles to JVM bytecode, Clojure programs can call Java classes directly and lean on that host platform instead of reinventing a runtime. Its code is written as data — the parenthesized s-expressions of the Lisp family — which makes macros and code transformation first-class. On XCODX, Clojure runs in a cloud sandbox, so you can try the core language and its immutable collections without installing a JDK or a build tool.
(require 'clojure.string)
;; Clojure on the JVM: immutable data and higher-order functions
(println "Type a sentence, then press Enter:")
(let [line (read-line)
words (remove clojure.string/blank? (clojure.string/split (or line "") #" "))]
(println "Word count:" (count words)))
(println "First five squares:" (mapv #(* % %) (range 1 6)))
Clojure shines when you want expressive, data-centric code with strong support for immutability and concurrency, and its JVM foundation gives real projects access to a mature ecosystem of Java libraries. Teams reach for it in backend services, data pipelines, and anywhere reliable state management matters. It is a natural fit if you like Lisp's flexibility but want to deploy on the JVM. It is a poor fit for tiny scripts or latency-sensitive command-line tools, since JVM startup adds noticeable overhead before your code even begins.
Use (read-line), which pulls one line of text from standard input (*in*). On XCODX you can type into the live terminal — the program pauses at read-line until you press Enter — or paste everything into the Stdin Box before running. Pressing Ctrl+D closes the input stream, after which read-line returns nil.
No. The sandbox has no build tool and no network access, so there is no Leiningen, no deps.edn resolution, and no way to pull libraries like core.async or Ring. Only Clojure's built-in namespaces such as clojure.string, clojure.set, and clojure.walk are available, alongside the standard Java classes on the JDK.
Clojure compiles to Java bytecode and runs on the JVM, which has to boot before your code executes. That startup cost is normal, but keep the short run timeout in mind and avoid heavy work that would push a quick demo past the limit.
This runs Clojure on the JVM, not ClojureScript. There is no JavaScript target, no browser, and no npm; your code is compiled and executed server-side, with plain text sent to the terminal.
Yes. Classes from the Java standard library are on the classpath, so calls like (Math/sqrt 2) or (java.time.LocalDate/now) work. What you cannot do is load external JARs, since there is no dependency resolution and no network.
The exact runtime version is shown in the badge next to the editor. It is a fixed build with no signup and no local setup required, and every run starts from a clean environment with no saved files.
main.cljclojureread-line(println "Hello from Clojure!")
(println "Welcome to XCODX Online Compiler!")
(def message "Clojure is a Lisp!")
(println message)