Gleam (programming language)

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

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 statically-typed language,[8] which is different from the most popular languages that run on Erlang’s virtual machine BEAM, Erlang and Elixir.

Example edit

import gleam/io

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

Gleam supports tail call optimization:[9]

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)
  }
}

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. ^ "Tail Calls". The Gleam Language Tour. Retrieved March 26, 2024.

External links edit