Erlang is a Programming Language created by Ericsson.

Example of “Hello World!” In Erlang:

-module(hello).
-export([hello_world/0]).

hello_world() ->
  io:format("Hello, World!~n", []).

BEAM

BEAM is the Virtual Machine which Erlang runs on top of. Concurrency in the BEAM virtual machine refers to its ability to efficiently handle many lightweight processes (also called actors or lightweight threads) concurrently. These processes are isolated from each other and communicate through message passing, promoting a highly responsive and fault-tolerant system. BEAM’s scheduler ensures fair execution, making it well-suited for building highly concurrent and distributed systems.

BEAM Scheduler

The BEAM scheduler ensures fair execution of lightweight processes (actors) through a mechanism known as “preemptive scheduling.” Unlike traditional operating systems, where processes are often preempted based on time slices, the BEAM scheduler uses a different approach:

  1. Processes voluntarily yield control
  2. Priority-based queue system

Processes are given control until they voluntarily yield by performing a specific action, such as waiting for a message or executing a blocking operation. When a process yields, the scheduler can quickly switch to another process that is ready to execute. This approach minimizes the overhead of context switching and allows processes to run for longer periods if they’re not blocked, improving overall system performance.

The priority-based queue system, where processes with higher priority (such as important system tasks) are given a chance to execute before lower-priority processes. This ensures that critical tasks are addressed promptly while maintaining fairness among processes.