XCODX |

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

Ericsson engineers designed Erlang in 1986 to run telephone switches that were never allowed to stop — and that requirement produced a language decades ahead of its time. Lightweight processes, message passing, supervision trees, and hot code swapping let systems achieve legendary uptime; WhatsApp famously served hundreds of millions of users with a tiny Erlang team, and RabbitMQ, CouchDB, and much telecom infrastructure run on it today. The runtime (BEAM) is actively developed, with OTP 27 and 28 as recent releases. Erlang is also academically significant as the canonical actor-model language, cited in virtually every concurrency course. Here you can execute Erlang in a live terminal — io:get_line reads what you type mid-run, with zero toolchain setup.

Hello World in Erlang

main(_) ->
    Name = string:trim(io:get_line("What's your name? ")),
    io:format("Hello, ~s! Spawning a process for you.~n", [Name]),

    Parent = self(),
    spawn(fun() -> Parent ! {note, "delivered by a lightweight process"} end),
    receive
        {note, Msg} -> io:format("Message ~s~n", [Msg])
    end,

    {ok, [N]} = io:fread("Factorial of what number? ", "~d"),
    io:format("~b! = ~b~n", [N, fact(N)]).

fact(0) -> 1;
fact(N) when N > 0 -> N * fact(N - 1).

When to use Erlang

Erlang shows up in two career paths: distributed-systems engineering (messaging infrastructure like RabbitMQ, telecom, IoT backends) and as the foundation beneath Elixir, where understanding OTP concepts distinguishes senior candidates. Concurrency and programming-languages courses assign Erlang to teach the actor model, immutability, and pattern matching with guards — exactly the constructs you can drill on this page. It's also the fastest way to test recursion patterns, list comprehensions, and message-passing snippets from Armstrong's 'Programming Erlang' without configuring rebar3 or a local OTP release.

Common questions

Can I type responses to io:get_line while the program runs?

Yes. io:get_line and io:fread block the running program until you enter a line in the terminal, and io:format output appears immediately beforehand — so prompts and answers interleave live, like an escript run in a local shell. Sequential interactive prompts work without any special handling.

How should I structure my code — module or escript style?

Write it script-style with a main/1 entry point, as in the example: execution starts at main and you can define additional functions below it with the usual clause-and-guard syntax. This mirrors how escript runs single files, so translating your code into a proper -module(...) later is mechanical.

Are OTP behaviours like gen_server available?

The standard library and OTP modules that ship with Erlang (lists, maps, string, ets, gen_server and other behaviours) are present — no external packages, no rebar3 dependencies, single file only. Full supervision-tree applications are awkward in one script, but you can absolutely exercise processes, messages, and ets tables.

How Erlang runs on XCODX

Sandbox filename
main.erl
Entry point
single main source file
Editor grammar
erlang
Reading stdin
io:get_line()
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

-module(main).
-export([main/1]).
main(_) ->
    io:format("Hello from Erlang!~n"),
    io:format("Welcome to XCODX Online Compiler!~n").