HOME

TheInfoList



OR:

Gleam is a general-purpose,
concurrent Concurrent means happening at the same time. Concurrency, concurrent, or concurrence may refer to: Law * Concurrence, in jurisprudence, the need to prove both ''actus reus'' and ''mens rea'' * Concurring opinion (also called a "concurrence"), a ...
,
functional Functional may refer to: * Movements in architecture: ** Functionalism (architecture) ** Form follows function * Functional group, combination of atoms within molecules * Medical conditions without currently visible organic basis: ** Functional s ...
high-level High-level and low-level, as technical terms, are used to classify, describe and point to specific goals of a systematic operation; and are applied in a wide range of contexts, such as, for instance, in domains as widely varied as computer scienc ...
programming language A programming language is a system of notation for writing computer programs. Most programming languages are text-based formal languages, but they may also be graphical. They are a kind of computer language. The description of a programming l ...
that compiles to Erlang or
JavaScript JavaScript (), often abbreviated as JS, is a programming language that is one of the core technologies of the World Wide Web, alongside HTML and CSS. As of 2022, 98% of Website, websites use JavaScript on the Client (computing), client side ...
source code. Gleam is a statically-typed language, which is different from the most popular languages that run on Erlang’s virtual machine
BEAM Beam may refer to: Streams of particles or energy * Light beam, or beam of light, a directional projection of light energy ** Laser beam * Particle beam, a stream of charged or neutral particles **Charged particle beam, a spatially localized g ...
, Erlang and
Elixir ELIXIR (the European life-sciences Infrastructure for biological Information) is an initiative that will allow life science laboratories across Europe to share and store their research data as part of an organised network. Its goal is to bring t ...
. Gleam has its own type-safe implementation of OTP, Erlang's actor framework. Packages are provided using the Hex package manager, and an index for finding packages written for Gleam is available.


History

The first numbered version of Gleam was released on April 15, 2019. Compiling to JavaScript was introduced with version v0.16. In 2023 the Erlang Ecosystem Foundation funded the creation of a course for learning Gleam on the learning platform
Exercism Exercism is an online, open-source, free coding platform that offers code practice and mentorship on 74 different programming languages. History Software developer Katrina Owen created Exercism while she was teaching programming at Jumpstart ...
. Version v1.0.0 was released on March 4, 2024.


Features

Gleam includes the following features, many common to other functional programming languages: *
Result type In functional programming, a result type is a Monadic type holding a returned value or an error code. They provide an elegant way of handling errors, without resorting to exception handling; when a function that may fail returns a result type, th ...
for error handling *
Immutable object In object-oriented and functional programming, an immutable object (unchangeable object) is an object whose state cannot be modified after it is created.Goetz et al. ''Java Concurrency in Practice''. Addison Wesley Professional, 2006, Section 3 ...
s *
Algebraic data type In computer programming, especially functional programming and type theory, an algebraic data type (ADT) is a kind of composite type, i.e., a type formed by combining other types. Two common classes of algebraic types are product types (i.e., ...
s *
Pattern matching In computer science, pattern matching is the act of checking a given sequence of tokens for the presence of the constituents of some pattern. In contrast to pattern recognition, the match usually has to be exact: "either it will or will not be ...
* No
null pointer In computing, a null pointer or null reference is a value saved for indicating that the pointer or reference does not refer to a valid object. Programs routinely use null pointers to represent conditions such as the end of a list of unknown lengt ...
s * No
implicit type conversion In computer science, type conversion, type casting, type coercion, and type juggling are different ways of changing an Expression (computer science), expression from one data type to another. An example would be the conversion of an integer (c ...
s


Example

A "Hello, World!" example: import gleam/io pub fn main() Gleam supports
tail call In computer science, a tail call is a subroutine call performed as the final action of a procedure. If the target of a tail is the same subroutine, the subroutine is said to be tail recursive, which is a special case of direct recursion. Tail recur ...
optimization: pub fn factorial(x: Int) -> Int fn factorial_loop(x: Int, accumulator: Int) -> Int


Implementation

Gleam's toolchain is implemented in the
Rust programming language Rust is a multi-paradigm, general-purpose programming language. Rust emphasizes performance, type safety, and concurrency. Rust enforces memory safety—that is, that all references point to valid memory—without requiring the use of a garb ...
. The toolchain is a single native binary executable which contains the compiler, build tool, package manager, source code formatter, and language server. A
WebAssembly WebAssembly (sometimes abbreviated Wasm) defines a portable binary-code format and a corresponding text format for executable programs as well as software interfaces for facilitating interactions between such programs and their host environmen ...
binary containing the Gleam compiler is also available, enabling Gleam code to be compiled within a web browser.


References


External links

* * Programming languages JavaScript Erlang (programming language) Concurrent programming languages Free and open source compilers Free software projects Functional languages High-level programming languages Multi-paradigm programming languages Pattern matching programming languages Programming languages created in 2016 Software using the Apache license Statically typed programming languages {{prog-lang-stub