Convert Figma logo to code with AI

erlang logootp

Erlang/OTP

11,297
2,938
11,297
429

Top Related Projects

17,363

⭐️ A friendly language for building type-safe, scalable systems!

2,309

Lisp Flavoured Erlang (LFE)

1,439

Functional programming inspired by ML for the Erlang VM

æternity blockchain - scalable blockchain for the people - smart contracts, state channels, names, tokens

Quick Overview

Erlang/OTP is the official repository for Erlang, a functional programming language, and its Open Telecom Platform (OTP) framework. It is designed for building scalable, fault-tolerant, and distributed real-time systems. The repository contains the complete source code for the Erlang language, runtime system, and OTP libraries.

Pros

  • Excellent support for concurrency and distributed systems
  • Built-in fault tolerance and error handling mechanisms
  • Soft real-time capabilities for responsive applications
  • Hot code reloading for seamless updates in production

Cons

  • Steep learning curve for developers new to functional programming
  • Limited ecosystem compared to more mainstream languages
  • Syntax can be unfamiliar and challenging for beginners
  • Performance may not be optimal for CPU-intensive tasks

Code Examples

  1. Spawning a process and sending a message:
Pid = spawn(fun() ->
    receive
        {From, Message} ->
            From ! {self(), "Received: " ++ Message}
    end
end),
Pid ! {self(), "Hello"},
receive
    {_, Response} -> io:format("~s~n", [Response])
end.
  1. Implementing a simple gen_server:
-module(counter).
-behaviour(gen_server).
-export([start_link/0, increment/1, get_count/1]).
-export([init/1, handle_call/3, handle_cast/2]).

start_link() -> gen_server:start_link(?MODULE, 0, []).
increment(Pid) -> gen_server:cast(Pid, increment).
get_count(Pid) -> gen_server:call(Pid, get_count).

init(Count) -> {ok, Count}.
handle_call(get_count, _From, Count) -> {reply, Count, Count}.
handle_cast(increment, Count) -> {noreply, Count + 1}.
  1. Pattern matching and list comprehension:
% Define a list of tuples
Data = [{1, "Apple"}, {2, "Banana"}, {3, "Cherry"}].

% Extract elements using pattern matching and list comprehension
[{Id, Fruit} || {Id, Fruit} <- Data, Id rem 2 == 1].

Getting Started

To get started with Erlang/OTP:

  1. Install Erlang from the official website or using a package manager.
  2. Create a new Erlang module file (e.g., hello.erl):
-module(hello).
-export([world/0]).

world() ->
    io:format("Hello, World!~n").
  1. Compile and run the module in the Erlang shell:
c(hello).
hello:world().

This will compile the module and execute the world/0 function, printing "Hello, World!" to the console.

Competitor Comparisons

17,363

⭐️ A friendly language for building type-safe, scalable systems!

Pros of Gleam

  • Modern, type-safe language with a focus on developer ergonomics
  • Seamless interoperability with Erlang and Elixir ecosystems
  • Compiles to Erlang bytecode, leveraging BEAM's concurrency and fault tolerance

Cons of Gleam

  • Smaller ecosystem and community compared to Erlang/OTP
  • Less mature, with potential for breaking changes as the language evolves
  • Limited documentation and learning resources compared to Erlang

Code Comparison

Gleam:

pub fn factorial(n: Int) -> Int {
  case n {
    0 | 1 -> 1
    _ -> n * factorial(n - 1)
  }
}

Erlang:

-spec factorial(non_neg_integer()) -> pos_integer().
factorial(0) -> 1;
factorial(N) when N > 0 -> N * factorial(N - 1).

Summary

Gleam is a newer language built on top of the BEAM, offering modern features like static typing and a more approachable syntax. It aims to provide better developer experience while maintaining compatibility with the Erlang ecosystem. However, OTP is a mature, battle-tested framework with a vast ecosystem and extensive documentation. The choice between Gleam and Erlang/OTP depends on project requirements, team expertise, and the balance between modern language features and ecosystem maturity.

2,309

Lisp Flavoured Erlang (LFE)

Pros of LFE

  • Lisp-like syntax, which can be more expressive and concise for some developers
  • Seamless interoperability with Erlang, allowing use of all OTP libraries and features
  • Macros and metaprogramming capabilities, enhancing code reuse and abstraction

Cons of LFE

  • Smaller community and ecosystem compared to Erlang
  • Potentially steeper learning curve for developers not familiar with Lisp-style languages
  • Less documentation and learning resources available

Code Comparison

Erlang (OTP):

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

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

LFE:

(defmodule hello
  (export (hello-world 0)))

(defun hello-world ()
  (io:format "Hello, World!~n"))

Summary

LFE (Lisp Flavoured Erlang) is a Lisp syntax frontend to the Erlang compiler, while OTP (Open Telecom Platform) is the standard library and runtime system for Erlang. LFE offers a Lisp-like syntax on top of Erlang's powerful concurrency and fault-tolerance features. It provides full interoperability with Erlang and OTP, allowing developers to leverage existing Erlang libraries and tools while writing in a Lisp-style language. However, LFE has a smaller community and fewer resources compared to Erlang/OTP, which may impact its adoption and support.

1,439

Functional programming inspired by ML for the Erlang VM

Pros of Alpaca

  • Simpler syntax and more approachable for developers coming from other languages
  • Focuses on functional programming concepts with a modern type system
  • Designed to be more lightweight and easier to deploy than OTP

Cons of Alpaca

  • Smaller community and ecosystem compared to OTP
  • Less mature and battle-tested in production environments
  • Lacks some of the advanced features and tools available in OTP

Code Comparison

Alpaca:

let add x y = x + y
let result = add 5 3

OTP (Erlang):

-module(math).
-export([add/2]).

add(X, Y) -> X + Y.

Key Differences

  • Alpaca aims for a more concise syntax, while OTP (Erlang) has a more verbose, traditional functional style
  • Alpaca uses type inference, whereas OTP (Erlang) relies on dynamic typing
  • OTP provides a comprehensive framework for building distributed systems, while Alpaca focuses on being a lightweight functional language

Use Cases

  • OTP: Large-scale, distributed systems with high concurrency and fault tolerance requirements
  • Alpaca: Smaller projects or microservices where a simpler, functional approach is preferred

Community and Support

  • OTP has a larger, more established community with extensive documentation and resources
  • Alpaca is still in early stages of development, with a growing but smaller community

æternity blockchain - scalable blockchain for the people - smart contracts, state channels, names, tokens

Pros of Aeternity

  • Focused on blockchain and smart contract functionality
  • Implements state channels for scalability
  • More recent project with modern blockchain features

Cons of Aeternity

  • Smaller community and ecosystem compared to OTP
  • Less mature and battle-tested in production environments
  • Narrower scope, primarily for blockchain applications

Code Comparison

OTP (Erlang):

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

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

Aeternity (Sophia):

contract HelloWorld =
  entrypoint hello() : string =
    "Hello, World!"

Key Differences

  • OTP is a general-purpose framework for building distributed systems, while Aeternity is specifically designed for blockchain applications.
  • OTP uses Erlang as its primary language, whereas Aeternity introduces Sophia, a custom language for smart contracts.
  • Aeternity incorporates blockchain-specific features like consensus mechanisms and token economics, which are not present in OTP.

Use Cases

  • OTP: Telecommunications, large-scale distributed systems, fault-tolerant applications
  • Aeternity: Decentralized applications (dApps), smart contracts, blockchain-based solutions

Community and Support

OTP has a larger, more established community with extensive documentation and long-term support from Ericsson. Aeternity, being newer, has a smaller but growing community focused on blockchain innovation.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Erlang/OTP

Erlang is a programming language and runtime system for building massively scalable soft real-time systems with requirements on high availability.

OTP is a set of Erlang libraries, which consists of the Erlang runtime system, a number of ready-to-use components mainly written in Erlang, and a set of design principles for Erlang programs. Learn more about Erlang and OTP.

Learn how to program in Erlang.

Examples

There are several examples on the website to help you get started. The below example defines a function world/0 that prints "Hello, world" in the Erlang shell:

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

world() -> io:format("Hello, world\n").

Save the file as hello.erl and run erl to enter the Erlang shell to compile the module.

Erlang/OTP 24 [erts-12.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit]

Eshell V12.2  (abort with ^G)
1> c(hello).
{ok,hello}
2> hello:world().
Hello, world
ok

Learn more about the Erlang syntax of modules, functions and expressions on Erlang.org.

Installation

Binary Distributions

Erlang/OTP is available as pre-built binary packages by most OS package managers.

apt-get install erlang

Compiling from source

To compile Erlang from source, run the following commands. The complete building and installation instructions can be found here.

git clone https://github.com/erlang/otp.git
cd otp

Checkout the branch or tag of your choice

git checkout maint-27    # current latest stable version

Configure, build and install

./configure
make
make install

Alternatively, you can use Kerl, a script that lets you easily build Erlang with a few commands.

Bug Reports

Please visit our GitHub Issues page for reporting bugs. The instructions for submitting bugs reports can be found here.

Security Disclosure

We take security bugs in Erlang/OTP seriously. Please disclose the issues regarding security by sending an email to erlang-security [at] erlang [dot] org and not by creating a public issue.

Contributing

We are grateful to the community for contributing bug fixes and improvements. Read below to learn how you can take part in improving Erlang/OTP. We appreciate your help!

Contribution Guide

Read our contribution guide to learn about our development process, how to propose fixes and improvements, and how to test your changes to Erlang/OTP before submitting a pull request.

Help Wanted

We have a list of Help Wanted bugs that we would appreciate external help from the community. This is a great place to get involved.

Awesome-Erlang

You can find more projects, tools and articles related to Erlang/OTP on the awesome-erlang list. Add your project there.

License

Erlang/OTP is released under the Apache License 2.0.

%CopyrightBegin%

Copyright Ericsson AB 2010-2024. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

%CopyrightEnd%