Gleam (programming language)

From Wikipedia, the free encyclopedia

Gleam
Lucy, the starfish mascot for Gleam[1]
ParadigmMulti-paradigm: functional, concurrent[2]
Designed byLouis Pilfold
DeveloperLouis Pilfold
First appearedJune 13, 2016; 7 years ago (2016-06-13)
Stable release
1.1.0[3] Edit this on Wikidata / 16 April 2024
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]

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

Gleam is a statically-typed language,[8] 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[9]. Packages are provided using the Hex package manager, and an index for finding packages written for Gleam is available.[10]

History[edit]

The first numbered version of Gleam was released on April 15, 2019.[11] Compiling to JavaScript was introduced with version v0.16.[12] Version v1.0.0 was released on March 4, 2024.[13]

Example[edit]

A "Hello, World!" example:

import gleam/io

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

Gleam supports tail call optimization:[14]

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[edit]

Gleam's toolchain is implemented in the Rust programming language[15]. 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[edit]

  1. ^ "gleam-lang/gleam Issues - New logo and mascot #2551". GitHub.
  2. ^ a b c "Gleam Homepage". 2024.
  3. ^ "Release 1.1.0". April 16, 2024. Retrieved April 23, 2024.
  4. ^ "Installing Gleam". 2024.
  5. ^ "Gleam License File". GitHub. December 5, 2021.
  6. ^ "Gleam: Past, Present, Future! • Louis Pilfold @ FOSDEM 2024". YouTube. 2024.
  7. ^ Krill, Paul (March 5, 2024). "Gleam language available in first stable release". InfoWorld. Retrieved March 26, 2024.
  8. ^ De Simone, Sergio (March 16, 2024). "Erlang-Runtime Statically-Typed Functional Language Gleam Reaches 1.0". InfoQ. Retrieved March 26, 2024.
  9. ^ Getting to know Actors in Gleam - Raúl Chouza | Code BEAM America 2024. Retrieved May 6, 2024 – via www.youtube.com.
  10. ^ "Introducing the Gleam package index – Gleam". gleam.run. Retrieved May 7, 2024.
  11. ^ "Hello, Gleam! – Gleam". gleam.run. Retrieved May 6, 2024.
  12. ^ "v0.16 - Gleam compiles to JavaScript! – Gleam". gleam.run. Retrieved May 7, 2024.
  13. ^ "Gleam version 1 – Gleam". gleam.run. Retrieved May 7, 2024.
  14. ^ "Tail Calls". The Gleam Language Tour. Retrieved March 26, 2024.
  15. ^ gleam-lang/gleam, Gleam, May 6, 2024, retrieved May 6, 2024

External links[edit]