Gleam (programming language)

Programming language From Wikipedia, the free encyclopedia

Gleam (programming language)

Gleam is a general-purpose, concurrent, functional high-level programming language that compiles to Erlang or JavaScript source code.[2][7][8]

Quick Facts Paradigm, Designed by ...
Gleam
Lucy, the starfish mascot for Gleam[1]
ParadigmMulti-paradigm: functional, concurrent[2]
Designed byLouis Pilfold
DeveloperLouis Pilfold
First appearedJune 13, 2016; 8 years ago (2016-06-13)
Stable release
1.8.1[3] 
Typing disciplineType-safe, static, inferred[2]
Memory managementGarbage collected
Implementation languageRust
OSFreeBSD, Linux, macOS, OpenBSD, Windows[4]
LicenseApache License 2.0[5]
Filename extensions.gleam
Websitegleam.run
Influenced by
[6]
Close

Gleam is a statically-typed language,[9] which is different from the most popular languages that run on Erlang’s virtual machine BEAM, Erlang and Elixir. Gleam has its own type-safe implementation of OTP, Erlang's actor framework.[10] Packages are provided using the Hex package manager, and an index for finding packages written for Gleam is available.[11]

History

The first numbered version of Gleam was released on April 15, 2019.[12] Compiling to JavaScript was introduced with version v0.16.[13]

In 2023 the Erlang Ecosystem Foundation funded the creation of a course for learning Gleam on the learning platform Exercism.[14]

Version v1.0.0 was released on March 4, 2024.[15]

Features

Gleam includes the following features, many common to other functional programming languages:[8]

Example

A "Hello, World!" example:

import gleam/io

pub fn main() {
  io.println("hello, world!")
}

Gleam supports tail call optimization:[16]

pub fn factorial(x: Int) -> Int {
  // The public function calls the private tail recursive function
  factorial_loop(x, 1)
}

fn factorial_loop(x: Int, accumulator: Int) -> Int {
  case x {
    1 -> accumulator

    // The last thing this function does is call itself
    _ -> factorial_loop(x - 1, accumulator * x)
  }
}

Implementation

Gleam's toolchain is implemented in the Rust programming language.[17] The toolchain is a single native binary executable which contains the compiler, build tool, package manager, source code formatter, and language server. A WebAssembly binary containing the Gleam compiler is also available, enabling Gleam code to be compiled within a web browser.

References

Loading related searches...

Wikiwand - on

Seamless Wikipedia browsing. On steroids.