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

Erlang is a functional language built for concurrency, created at Ericsson in the mid-1980s by Joe Armstrong, Robert Virding, and Mike Williams to run reliable telecom systems. Its model is based on lightweight, isolated processes that share no memory and communicate only by passing messages, which makes highly concurrent and fault-tolerant software natural to write. Code runs on the BEAM virtual machine and is organized with the OTP framework in production, and that same runtime also hosts Elixir. Erlang remains actively maintained and still powers messaging platforms and network infrastructure at large scale. On XCODX, Erlang runs in a cloud sandbox as an escript, so you can try the language and its standard library without installing the runtime.

Hello World in Erlang

%% Erlang escript entry point (main/1)
main(_Args) ->
    Squares = [N * N || N <- lists:seq(1, 5)],
    io:format("Squares: ~w~n", [Squares]),
    case io:get_line("Your name: ") of
        eof -> io:format("Hello, stranger!~n");
        Name -> io:format("Hello, ~s~n", [string:trim(Name)])
    end.

When to use Erlang

Erlang excels at systems that must handle many simultaneous activities and keep running through failures — messaging, telephony, and distributed backends are its classic homes. Its process model and message passing make concurrency far less error-prone than shared-memory threading in many other languages. Reach for it when uptime, soft real-time behavior, and massive concurrency matter more than raw single-threaded speed. It is a weaker choice for CPU-bound numerical work or small one-off scripts, where its syntax and runtime overhead offer little advantage.

Common questions

How do I run Erlang code here, and where is the entry point?

The sandbox runs your file as an escript, so define a main/1 function; it receives the command-line arguments as a list and is called automatically. You do not need a module declaration or a separate compile step for a simple program.

How do I read input from stdin in Erlang?

Use io:get_line(Prompt) to read one line as a string, or io:fread/2 for formatted input; io:get_line returns the atom eof at end of input. On XCODX you can type into the live terminal, which blocks until you press Enter, or paste into the Stdin Box up front, and Ctrl+D closes the stream.

Can I use rebar3 or Hex packages?

No. There is no rebar3, no mix, and no Hex, and the sandbox has no network to fetch dependencies. You have the Erlang/OTP standard library — modules like lists, string, maps, io, and re — but no third-party packages.

Can I spawn processes and use message passing?

Yes. spawn, send with the ! operator, and receive all work, so you can demonstrate Erlang's actor-style concurrency within a single run. What you cannot do is distribute across nodes or open network connections, and everything must finish within the short run timeout.

Is this the same as Elixir?

No. This runs Erlang, though Erlang and Elixir share the BEAM virtual machine and standard library. The syntax here is Erlang's, and Elixir code will not run in this environment.

Which Erlang/OTP version does XCODX use?

The Erlang/OTP version is shown in the badge next to the editor. It is free with no signup and no local install, and each run executes in a fresh sandbox with no saved state.

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").