XCODX |

Brachylog 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 Brachylog

Declarative logic programming gets the golfing treatment in Brachylog, created by Code Golf Stack Exchange member Julien Cumin (known as Fatalize). The first version appeared in 2015 and the heavily redesigned v2 in 2017; both are built on top of SWI-Prolog. A Brachylog program is a chain of constraints relating an implicit input to an implicit output, so many challenges are solved by simply describing the answer and letting unification plus backtracking find it. That makes it a favorite for decision problems and combinatorics on Code Golf Stack Exchange. XCODX runs the full SWI-Prolog-backed interpreter in a genuine terminal session, so you can feed test cases through stdin interactively instead of configuring a Prolog stack yourself.

Hello World in Brachylog

"Hello, World!"w
How it works: the string literal unifies the current value with "Hello, World!", then the predicate w writes that value to standard output. A Brachylog program is one chain of goals, so no boilerplate is needed.

When to use Brachylog

Brachylog shines on Code Golf Stack Exchange challenges that reduce to search or verification: primality, permutation properties, subset sums, and puzzle solving such as Sudoku-style constraints. Because backtracking is free, a few bytes can express what imperative golf languages need explicit loops for. It is also a compact way to introduce logic programming to students who find full Prolog syntax heavy, and a fun bridge for Prolog users into the esolang scene.

Common questions

Do I need to know Prolog to use Brachylog?

It helps but is not required. Brachylog inherits unification, nondeterminism, and backtracking from Prolog, so understanding those concepts makes programs click faster. The surface syntax is entirely different, though: single-character predicates chained left to right, with implicit input and output variables. Many golfers learn it directly from the GitHub wiki and existing Code Golf Stack Exchange answers.

How does Brachylog compare to Jelly or 05AB1E in byte counts?

On general challenges Jelly and 05AB1E usually win because of their larger built-in vocabularies and string compression. Brachylog pulls ahead when the task is naturally a constraint or decision problem, since stating a property is often shorter than computing it. A primality check or a find-the-permutation task can be dramatically terser in Brachylog.

How does Brachylog read input and produce output?

By convention the program's implicit input variable is bound to the first command-line input, and the final output variable is printed if the predicate succeeds. Decision problems can simply succeed or fail, which interpreters report as true or false. Explicit writing is available through predicates like w, and stdin can supply values interactively in the XCODX terminal.

How Brachylog runs on XCODX

Sandbox filename
main.brachylog
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

"Hello from Brachylog!"w