Laeserin
· 1w
Yeah, Erlang is on my list because Michaels' relay is Elixir.
Erlang is a functional programming language built for concurrency, fault tolerance, and distributed systems. It was originally developed by Ericsson for telecom systems and is known for powering massive-scale, high-availability applications like WhatsApp (which handles ~100 billion messages a day).
---
🔭 Platform & Runtime
Erlang runs on the BEAM virtual machine (Bogdan/Björn's Erlang Abstract Machine), which executes compiled bytecode and manages lightweight processes with per-process garbage collection. It runs on:
· Unix/Linux (BSD, Debian, Ubuntu, CentOS, Fedora, openSUSE, Arch, FreeBSD)
· macOS (via Homebrew, MacPorts)
· Windows (7 and later)
· Solaris, TRU64, VxWorks, QNX, and embedded systems (mobile phones, telecom switches, in-car electronics)
Compiled Erlang files have the .beam suffix, and the runtime is managed by ERTS (Erlang Runtime System), which includes the BEAM, kernel, and standard libraries.
---
🌐 Front-End Support
Erlang's front-end ecosystem is smaller than mainstream web languages, but there are several active frameworks:
Arizona — A real-time web framework for Erlang/OTP. It renders HTML on the server, diffs changes at the template level, and pushes minimal updates over WebSocket. Templates are plain Erlang terms ({Tag, Attrs, Children}) compiled via parse transform. It ships with a modern frontend setup including Tailwind CSS and ESBuild with hot-reloading. The client is a thin DOM patcher, and the same diff stream can drive native app clients (Android, iOS, terminal).
Nova — A web framework for the BEAM (works with Erlang, Elixir, and LFE). It provides MVC patterns, WebSockets, Pub/Sub via OTP's pg module, session management, and ErlyDTL (Django-style) templates. It runs on Cowboy and is OTP-native, meaning your web app is a proper OTP application with supervision trees.
ErlyWeb — An older MVC framework for building database-driven websites in Erlang.
Sprocket — A real-time server UI component framework built on the BEAM VM, though it is written in Gleam (a language that compiles to Erlang).
---
✨ Distinctive Syntax Features
Erlang's syntax is unusual among functional languages. It is single-assignment, dynamically typed, and makes extensive use of pattern matching.
1. Single Assignment
Variables are bound once and never change. Once X = 5, X is 5 forever.
```erlang
X = 5,
% X = 6 % This would cause a runtime error
X1 = X + 10. % You must create a new variable
```
Variables start with an uppercase letter; atoms (symbolic constants) start with lowercase.
2. Pattern Matching
The = operator is not assignment but pattern matching. It compares a pattern (left side) against a value (right side), binding variables in the process.
```erlang
% Extract elements from a tuple
{A, B} = {answer, 42}.
% A is now 'answer', B is 42
% Extract the head and tail of a list
[H | T] = [1, 2, 3, 4].
% H is 1, T is [2, 3, 4]
```
3. Function Clauses and Guards
Functions are defined as a series of clauses separated by semicolons. The first matching clause executes. Guards (when) add conditions.
```erlang
factorial(N) when N > 0 ->
N * factorial(N - 1);
factorial(0) ->
1.
```
4. Lists and List Comprehensions
Lists use square brackets, with | separating the head from the tail. List comprehensions use || for generators and filters.
```erlang
% A list
[1, 2, 3, 4]
% A list comprehension: squares of even numbers
[X * X || X <- [1, 2, 3, 4, 5], X rem 2 == 0].
% Result: [4, 16]
```
5. Tuples
Tuples use curly braces and are fixed-size collections.
```erlang
{ok, Value}
{error, Reason}
{person, "Alice", 30}
```
6. Atoms and Booleans
Atoms are symbolic constants, written as lowercase words. Booleans are simply the atoms true and false.
```erlang
ok.
error.
true.
false.
```
7. Concurrency Primitives
Erlang has built-in concurrency. Processes are created with spawn, and messages are sent with ! and received with receive.
```erlang
% Spawn a process that prints a message
Pid = spawn(fun() -> io:format("Hello from a process!~n") end).
% Send a message to a process
Pid ! {hello, world}.
% Receive a message
receive
{hello, Name} -> io:format("Received hello from ~s~n", [Name])
end.
```
8. Module Structure
Erlang code is organized into modules. A module file starts with -module(name). and exports functions with -export([...])..
```erlang
-module(hello).
-export([hello_world/0]).
hello_world() ->
io:format("Hello, world!~n").
```
9. Tail-Call Optimization
Erlang optimizes tail-recursive calls, so recursive functions run in constant space. This is why loops are written as recursive functions with accumulators.
```erlang
sum(List) -> sum(List, 0).
sum([], Acc) -> Acc;
sum([H | T], Acc) -> sum(T, Acc + H).
```
---
💎 Summary
Aspect Key Point
Runtime BEAM virtual machine inside ERTS
Platforms Linux, macOS, Windows, Solaris, embedded systems
Front-end Arizona, Nova, ErlyWeb (small but active ecosystem)
Concurrency Lightweight processes, message passing, no shared memory
Fault tolerance "Let it fail" philosophy; processes monitor each other
Syntax Single-assignment, pattern matching, function clauses, atoms
Erlang's design is uncompromising: it assumes failure is inevitable and provides the primitives to build systems that keep running anyway. That's why it's used in telecoms, banking, messaging, and anywhere high availability matters more than raw speed.
---
🔭 Platform & Runtime
Erlang runs on the BEAM virtual machine (Bogdan/Björn's Erlang Abstract Machine), which executes compiled bytecode and manages lightweight processes with per-process garbage collection. It runs on:
· Unix/Linux (BSD, Debian, Ubuntu, CentOS, Fedora, openSUSE, Arch, FreeBSD)
· macOS (via Homebrew, MacPorts)
· Windows (7 and later)
· Solaris, TRU64, VxWorks, QNX, and embedded systems (mobile phones, telecom switches, in-car electronics)
Compiled Erlang files have the .beam suffix, and the runtime is managed by ERTS (Erlang Runtime System), which includes the BEAM, kernel, and standard libraries.
---
🌐 Front-End Support
Erlang's front-end ecosystem is smaller than mainstream web languages, but there are several active frameworks:
Arizona — A real-time web framework for Erlang/OTP. It renders HTML on the server, diffs changes at the template level, and pushes minimal updates over WebSocket. Templates are plain Erlang terms ({Tag, Attrs, Children}) compiled via parse transform. It ships with a modern frontend setup including Tailwind CSS and ESBuild with hot-reloading. The client is a thin DOM patcher, and the same diff stream can drive native app clients (Android, iOS, terminal).
Nova — A web framework for the BEAM (works with Erlang, Elixir, and LFE). It provides MVC patterns, WebSockets, Pub/Sub via OTP's pg module, session management, and ErlyDTL (Django-style) templates. It runs on Cowboy and is OTP-native, meaning your web app is a proper OTP application with supervision trees.
ErlyWeb — An older MVC framework for building database-driven websites in Erlang.
Sprocket — A real-time server UI component framework built on the BEAM VM, though it is written in Gleam (a language that compiles to Erlang).
---
✨ Distinctive Syntax Features
Erlang's syntax is unusual among functional languages. It is single-assignment, dynamically typed, and makes extensive use of pattern matching.
1. Single Assignment
Variables are bound once and never change. Once X = 5, X is 5 forever.
```erlang
X = 5,
% X = 6 % This would cause a runtime error
X1 = X + 10. % You must create a new variable
```
Variables start with an uppercase letter; atoms (symbolic constants) start with lowercase.
2. Pattern Matching
The = operator is not assignment but pattern matching. It compares a pattern (left side) against a value (right side), binding variables in the process.
```erlang
% Extract elements from a tuple
{A, B} = {answer, 42}.
% A is now 'answer', B is 42
% Extract the head and tail of a list
[H | T] = [1, 2, 3, 4].
% H is 1, T is [2, 3, 4]
```
3. Function Clauses and Guards
Functions are defined as a series of clauses separated by semicolons. The first matching clause executes. Guards (when) add conditions.
```erlang
factorial(N) when N > 0 ->
N * factorial(N - 1);
factorial(0) ->
1.
```
4. Lists and List Comprehensions
Lists use square brackets, with | separating the head from the tail. List comprehensions use || for generators and filters.
```erlang
% A list
[1, 2, 3, 4]
% A list comprehension: squares of even numbers
[X * X || X <- [1, 2, 3, 4, 5], X rem 2 == 0].
% Result: [4, 16]
```
5. Tuples
Tuples use curly braces and are fixed-size collections.
```erlang
{ok, Value}
{error, Reason}
{person, "Alice", 30}
```
6. Atoms and Booleans
Atoms are symbolic constants, written as lowercase words. Booleans are simply the atoms true and false.
```erlang
ok.
error.
true.
false.
```
7. Concurrency Primitives
Erlang has built-in concurrency. Processes are created with spawn, and messages are sent with ! and received with receive.
```erlang
% Spawn a process that prints a message
Pid = spawn(fun() -> io:format("Hello from a process!~n") end).
% Send a message to a process
Pid ! {hello, world}.
% Receive a message
receive
{hello, Name} -> io:format("Received hello from ~s~n", [Name])
end.
```
8. Module Structure
Erlang code is organized into modules. A module file starts with -module(name). and exports functions with -export([...])..
```erlang
-module(hello).
-export([hello_world/0]).
hello_world() ->
io:format("Hello, world!~n").
```
9. Tail-Call Optimization
Erlang optimizes tail-recursive calls, so recursive functions run in constant space. This is why loops are written as recursive functions with accumulators.
```erlang
sum(List) -> sum(List, 0).
sum([], Acc) -> Acc;
sum([H | T], Acc) -> sum(T, Acc + H).
```
---
💎 Summary
Aspect Key Point
Runtime BEAM virtual machine inside ERTS
Platforms Linux, macOS, Windows, Solaris, embedded systems
Front-end Arizona, Nova, ErlyWeb (small but active ecosystem)
Concurrency Lightweight processes, message passing, no shared memory
Fault tolerance "Let it fail" philosophy; processes monitor each other
Syntax Single-assignment, pattern matching, function clauses, atoms
Erlang's design is uncompromising: it assumes failure is inevitable and provides the primitives to build systems that keep running anyway. That's why it's used in telecoms, banking, messaging, and anywhere high availability matters more than raw speed.
1