XCODX |

Pure Online Compiler & Interpreter

Select Language
Online Code Compiler
Full HTML IDE
Py main.py
Program Output Ready
  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.
Success
Operation completed

About Pure

Pure is a modern functional term-rewriting language created by Albert Gräf in 2008 as a successor to the Q language. It marries the equational style of Mathematica with dynamic typing, lazy evaluation on demand, and LLVM-backed JIT compilation that delivers performance competitive with C in tight numeric loops. Pure has first-class macros, list and stream comprehensions, multiple-dispatch pattern matching, and an interactive REPL. Run Pure programs in this browser-based compiler — no LLVM toolchain install, no Pure interpreter setup.

Hello World in Pure

// Hello World in Pure — equational definitions + list comprehension
greet name = "Hello, " + name + "!";

langs = ["Python", "Rust", "Go", "Pure"];
greetings = [greet n | n = langs];

do puts greetings;

// Bonus: factorial via term-rewriting equations
fact 0 = 1;
fact n = n * fact (n - 1) if n > 0;

puts ("10! = " + str (fact 10));
// => 10! = 3628800

When to use Pure

Use Pure for mathematical computing (it's particularly strong at symbolic algebra thanks to Mathematica-style rewriting), algorithm prototyping where you want to write equations directly as code, computer-algebra-system extensions, scientific-computing experiments, and teaching declarative programming. Pure's LLVM backend makes it surprisingly fast for a small-community language — competitive with Haskell on many numeric benchmarks while keeping a syntax that reads like a math paper.

Common questions

How is Pure different from Haskell?

Both are functional, but Pure is dynamically typed (no compile-time type system to satisfy) and uses term-rewriting as its core semantics where Haskell uses lazy graph reduction with a strong static type system. Pure's syntax is closer to Mathematica — you write equations directly. Pure also has a much smaller standard library and ecosystem than Haskell, which suits research and mathematical scripting more than production back-end work.

What is term rewriting?

Term rewriting means your program is a set of equations — like 'fact 0 = 1; fact n = n * fact (n-1);' — and the runtime keeps applying matching equations to terms (expressions) until no more rules apply. It's the same paradigm Mathematica uses for symbolic math, generalised as a programming model. Algorithms end up reading like mathematical definitions, which is a huge win for code that maps directly to math.

Is Pure still actively maintained?

Pure 0.68 (2020) was the last major release; the language is feature-complete and the community is small but active on the github.com/agraef/pure-lang repository. It's a great choice for one-off scripts, academic work, and personal projects where you want maximum expressiveness per line of code, but production teams would generally pick a language with a larger ecosystem like Haskell, OCaml, or Scala.

Is Pure lazy like Haskell or eager?

Pure evaluates eagerly by default, unlike Haskell's pervasive laziness, but it offers laziness on demand: its stream comprehensions build lists whose tails are computed only as you consume them, so you can work with conceptually infinite sequences. This mix lets you keep ordinary code strict and predictable while reaching for lazy streams exactly where they help.

Why is Pure fast for a small research language?

It compiles through LLVM with a just-in-time compiler, so your equations become optimized native code rather than being walked by a tree interpreter. On tight numeric loops that puts Pure in the neighborhood of C, and competitive with Haskell on many benchmarks, which is unusual for a dynamically typed term-rewriting language with such a compact implementation.

What happens to an expression that matches no equation?

It stays as-is. In a term-rewriting language a term with no applicable rule is already in normal form, so Pure returns it unevaluated as a symbolic value rather than raising an error. That's precisely what enables the Mathematica-style symbolic algebra Pure is known for: undefined operations become symbolic terms you can rewrite further with more rules.

How Pure runs on XCODX

Sandbox filename
main.pure
Entry point
single main source file
Editor grammar
plain text — no highlighter ships for this language
Reading stdin
no standard input construct
Input delivery
live WebSocket stream
Prompt flushing
flush manually before reading input
Compile limit
10 s
Run limit
3 s batch · up to 3 min live
Memory
256 MB per stage
Max source
50,000 characters

Default program on this page

using system;
puts "Hello from Pure!";
puts "Welcome to XCODX Compiler!";