# Erlang/OTP — Battle-Tested Language for Fault-Tolerant Distributed Systems > Erlang/OTP is a functional programming language and runtime designed for building highly concurrent, fault-tolerant, and distributed systems with hot code upgrades. ## Install Save in your project root: # Erlang/OTP — Battle-Tested Language for Fault-Tolerant Distributed Systems ## Quick Use ```bash # Install Erlang (Ubuntu/Debian) sudo apt install erlang # Interactive shell erl # > io:format("Hello, Erlang!~n"). # Compile and run a module echo '-module(hello). -export([start/0]). start() -> io:format("Hello!~n").' > hello.erl erlc hello.erl && erl -noshell -s hello start -s init stop ``` ## Introduction Erlang is a functional programming language created at Ericsson in the 1980s for building telecom-grade systems. Together with OTP (Open Telecom Platform), it provides a framework for building applications that must run continuously with minimal downtime. Erlang powers systems at WhatsApp, Discord, and RabbitMQ. ## What Erlang/OTP Does - Runs millions of lightweight processes on the BEAM virtual machine - Provides built-in fault tolerance through supervisor trees and process isolation - Supports hot code swapping for upgrades without stopping the system - Enables transparent distribution across multiple nodes - Includes OTP behaviors (gen_server, gen_statem, supervisor) for common patterns ## Architecture Overview Erlang runs on the BEAM virtual machine, which schedules lightweight processes across CPU cores using preemptive scheduling. Each process has its own heap and communicates via asynchronous message passing. OTP provides standardized abstractions: gen_server for client-server patterns, supervisors for automatic restart strategies, and applications for packaging releases. ## Self-Hosting & Configuration - Install via package managers or use kerl/asdf for version management - Configure releases with `rebar3` or `mix` (for Elixir interop) - Set VM flags in `vm.args` for memory limits, scheduler count, and node naming - Use `sys.config` for application-level environment variables - Deploy as self-contained releases with `rebar3 release` ## Key Features - Lightweight processes (millions per node) with per-process garbage collection - "Let it crash" philosophy with automatic process restart via supervisors - Hot code loading for live system upgrades - Pattern matching and immutable data by default - Battle-tested in telecom, messaging, and financial systems for decades ## Comparison with Similar Tools - **Elixir** — Elixir runs on the BEAM and adds modern syntax; Erlang is the original with deeper OTP integration - **Go** — Go has goroutines but lacks built-in supervision trees and hot code swapping - **Rust** — Rust focuses on memory safety; Erlang focuses on fault tolerance and uptime - **Akka (Scala/Java)** — Akka implements the actor model on the JVM but lacks BEAM's per-process isolation - **Node.js** — Node is single-threaded with async IO; Erlang is truly concurrent with preemptive scheduling ## FAQ **Q: Is Erlang still relevant today?** A: Yes. Erlang powers WhatsApp, RabbitMQ, CouchDB, and many telecom systems. Its concurrency model remains unmatched for certain workloads. **Q: What is the relationship between Erlang and Elixir?** A: Elixir is a separate language that compiles to BEAM bytecode and can call Erlang libraries directly. They share the same runtime. **Q: Can Erlang handle millions of connections?** A: Yes. The BEAM VM was designed for this. WhatsApp reportedly handled two million connections per server using Erlang. **Q: How does hot code swapping work?** A: The BEAM can load a new version of a module while the old version is still running. Active processes migrate to the new code on their next function call. ## Sources - https://github.com/erlang/otp - https://www.erlang.org/docs --- Source: https://tokrepo.com/en/workflows/asset-fb99e834 Author: AI Open Source