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.
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.
%% 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.
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.
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.
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.
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.
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.
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.
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.
main.erlerlangio:get_line()-module(main).
-export([main/1]).
main(_) ->
io:format("Hello from Erlang!~n"),
io:format("Welcome to XCODX Online Compiler!~n").