Gleam (programming language)

{{Short description|Programming language}}

{{Use American English|date=March 2024}}

{{Use mdy dates|date=March 2024}}

{{Notability|date=March 2024}}

{{Infobox programming language

| name = Gleam

| logo = frameless

| logo size = 128px

| logo caption = Lucy, the starfish mascot for Gleam{{cite web | url=https://github.com/gleam-lang/gleam/issues/2551 | title=gleam-lang/gleam Issues – New logo and mascot #2551| website=GitHub}}

| paradigm = Multi-paradigm: functional, concurrent{{cite web | url=https://gleam.run/ | title=Gleam Homepage|date=2024}}

| year = {{start date and age|2016|6|13}}

| designer = Louis Pilfold

| developer = Louis Pilfold

| latest release version = {{wikidata|property|preferred|references|edit|Q66370905|P348}}

| latest release date = {{wikidata|qualifier|preferred|single|Q66370905|P348|P548=Q2804309|P577}}

| typing = Type-safe, static, inferred

| memory management = Garbage collected

| programming language = Rust

| dialects =

| influenced_by = {{cslist|

Alpaca|

Elm|

Erlang|

Elixir|

Go|

JavaScript|

OCaml|

Rust|

}}{{cite journal | url=https://www.youtube.com/watch?v=clsTrQUt-4M&t=304 | date=2024-02-07 | title=Gleam: Past, Present, Future! | first=Louis | last=Pilfold | journal=Fosdem 2024 | via=YouTube }}

| influenced =

| operating_system = FreeBSD, Linux, macOS, OpenBSD, Windows{{cite web|url=https://gleam.run/getting-started/installing/|title=Installing Gleam|date=2024}}

| license = Apache License 2.0{{cite web|url=https://github.com/gleam-lang/gleam/blob/main/LICENCE|title=Gleam License File|website=GitHub |date=5 December 2021}}

| file_ext = .gleam

| website = {{URL|https://gleam.run/}}

}}

Gleam is a general-purpose, concurrent, functional high-level programming language that compiles to Erlang or JavaScript source code.{{cite news | url=https://www.infoworld.com/article/3713460/gleam-language-available-in-first-stable-release.html | title=Gleam language available in first stable release | first=Paul | last=Krill | work=InfoWorld | date=5 March 2024 | access-date=26 March 2024}}{{cite news | url=https://thenewstack.io/introduction-to-gleam-a-new-functional-programming-language/ | title=Introduction to Gleam, a New Functional Programming Language | first=David | last=Eastman | work=The New Stack | date=2024-06-22 | access-date=2024-07-29}}

Gleam is a statically-typed language,{{cite news | url=https://www.infoq.com/news/2024/03/gleam-erlang-virtual-machine-1-0/ | title=Erlang-Runtime Statically-Typed Functional Language Gleam Reaches 1.0 | first=Sergio | last=De Simone | work=InfoQ | date=16 March 2024 | access-date=26 March 2024}} 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.{{Cite AV media |url=https://www.youtube.com/watch?v=WaHx6n2UZJg |title=Getting to know Actors in Gleam – Raúl Chouza | series=Code BEAM America | date=2024-03-27 |language=en |access-date=2024-05-06 |via=YouTube}} Packages are provided using the Hex package manager, and an index for finding packages written for Gleam is available.{{Cite web |title=Introducing the Gleam package index – Gleam |url=https://gleam.run//news/introducing-the-gleam-package-index/ |access-date=2024-05-07 |website=gleam.run |language=en-GB}}

History

The first numbered version of Gleam was released on April 15, 2019.{{Cite web |title=Hello, Gleam! – Gleam |url=https://gleam.run//news/hello-gleam/ |access-date=2024-05-06 |website=gleam.run |language=en-GB}} Compiling to JavaScript was introduced with version v0.16.{{Cite web |title=v0.16 – Gleam compiles to JavaScript! – Gleam |url=https://gleam.run//news/v0.16-gleam-compiles-to-javascript/ |access-date=2024-05-07 |website=gleam.run |language=en-GB}}

In 2023 the Erlang Ecosystem Foundation funded the creation of a course for learning Gleam on the learning platform Exercism.{{Cite web |last=Alistair |first=Woodman |date=December 2023 |title=Erlang Ecosystem Foundation Annual General Meeting 2023 Chair's Report |url=https://erlef.org/public_records/}}

Version v1.0.0 was released on March 4, 2024.{{Cite web |title=Gleam version 1 – Gleam |url=https://gleam.run//news/gleam-version-1/ |access-date=2024-05-07 |website=gleam.run |language=en-GB}}

In April 2025, Thoughtworks added Gleam to its Technology Radar in the Assess ring (languages & frameworks worth exploring). {{cite web | url=https://www.thoughtworks.com/radar/languages-and-frameworks/gleam | title=Thoughtworks Technology Radar, Gleam|date=2025}}

Features

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

Example

A "Hello, World!" example:

import gleam/io

pub fn main() {

io.println("hello, world!")

}

Gleam supports tail call optimization:{{cite web | url=https://tour.gleam.run/flow-control/tail-calls/ | title=Tail Calls | website=The Gleam Language Tour | access-date=26 March 2024}}

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.{{Cite web |title=gleam-lang/gleam |date=2024-05-06 |url=https://github.com/gleam-lang/gleam |access-date=2024-05-06 |publisher=Gleam}} 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

{{Reflist}}