Gleam (programming language)

Last updated

Gleam
Gleam Lucy.png
Lucy, the starfish mascot for Gleam [1]
Paradigm Multi-paradigm: functional, concurrent [2]
Designed by Louis Pilfold
Developer Louis Pilfold
First appearedJune 13, 2016;7 years ago (2016-06-13)
Stable release
1.1.0 [3]   OOjs UI icon edit-ltr-progressive.svg / 16 April 2024
Typing discipline Type-safe, static, inferred [2]
Memory management Garbage collected
Implementation language Rust
OS FreeBSD, Linux, macOS, OpenBSD, Windows [4]
License Apache License 2.0 [5]
Filename extensions .gleam
Website gleam.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]

Contents

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

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

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

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

Example

A "Hello, World!" example:

importgleam/iopubfnmain(){io.println("hello, friend!")}

Gleam supports tail call optimization: [15]

pubfnfactorial(x: Int)-> Int{// The public function calls the private tail recursive functionfactorial_loop(x,1)}fnfactorial_loop(x: Int,accumulator: Int)-> Int{casex{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. [16] 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.

Related Research Articles

<span class="mw-page-title-main">Erlang (programming language)</span> Programming language

Erlang is a general-purpose, concurrent, functional high-level programming language, and a garbage-collected runtime system. The term Erlang is used interchangeably with Erlang/OTP, or Open Telecom Platform (OTP), which consists of the Erlang runtime system, several ready-to-use components (OTP) mainly written in Erlang, and a set of design principles for Erlang programs.

OCaml is a general-purpose, high-level, multi-paradigm programming language which extends the Caml dialect of ML with object-oriented features. OCaml was created in 1996 by Xavier Leroy, Jérôme Vouillon, Damien Doligez, Didier Rémy, Ascánder Suárez, and others.

Standard ML (SML) is a general-purpose, modular, functional programming language with compile-time type checking and type inference. It is popular for writing compilers, for programming language research, and for developing theorem provers.

<span class="mw-page-title-main">F Sharp (programming language)</span> Microsoft programming language

F# is a general-purpose, strongly typed, multi-paradigm programming language that encompasses functional, imperative, and object-oriented programming methods. It is most often used as a cross-platform Common Language Infrastructure (CLI) language on .NET, but can also generate JavaScript and graphics processing unit (GPU) code.

<span class="mw-page-title-main">D (programming language)</span> Multi-paradigm system programming language

D, also known as dlang, is a multi-paradigm system programming language created by Walter Bright at Digital Mars and released in 2001. Andrei Alexandrescu joined the design and development effort in 2007. Though it originated as a re-engineering of C++, D is now a very different language drawing inspiration from other high-level programming languages, notably Java, Python, Ruby, C#, and Eiffel.

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 recursion is particularly useful, and is often easy to optimize in implementations.

<span class="mw-page-title-main">Scala (programming language)</span> General-purpose programming language

Scala is a strong statically typed high-level general-purpose programming language that supports both object-oriented programming and functional programming. Designed to be concise, many of Scala's design decisions are intended to address criticisms of Java.

In computer programming, an anonymous function is a function definition that is not bound to an identifier. Anonymous functions are often arguments being passed to higher-order functions or used for constructing the result of a higher-order function that needs to return a function. If the function is only used once, or a limited number of times, an anonymous function may be syntactically lighter than using a named function. Anonymous functions are ubiquitous in functional programming languages and other languages with first-class functions, where they fulfil the same role for the function type as literals do for other data types.

<span class="mw-page-title-main">Node.js</span> JavaScript runtime environment

Node.js is a cross-platform, open-source JavaScript runtime environment that can run on Windows, Linux, Unix, macOS, and more. Node.js runs on the V8 JavaScript engine, and executes JavaScript code outside a web browser.

Dart is a programming language designed by Lars Bak and Kasper Lund and developed by Google. It can be used to develop web and mobile apps as well as server and desktop applications.

Mustache is a web template system. Mustache is described as a logic-less system because it lacks any explicit control flow statements, like if and else conditionals or for loops; however, both looping and conditional evaluation can be achieved using section tags processing lists and anonymous functions (lambdas). It is named "Mustache" because of heavy use of braces, { }, that resemble a sideways moustache. Mustache is used mainly for mobile and web applications.

<span class="mw-page-title-main">Red (programming language)</span> Computer programming language released in 2011

Red is a programming language designed to overcome the limitations of the programming language Rebol. Red was introduced in 2011 by Nenad Rakočević, and is both an imperative and functional programming language. Its syntax and general usage overlaps that of the interpreted Rebol language.

<span class="mw-page-title-main">Elm (programming language)</span> Functional programming language

Elm is a domain-specific programming language for declaratively creating web browser-based graphical user interfaces. Elm is purely functional, and is developed with emphasis on usability, performance, and robustness. It advertises "no runtime exceptions in practice", made possible by the Elm compiler's static type checking.

Elixir is a functional, concurrent, high-level general-purpose programming language that runs on the BEAM virtual machine, which is also used to implement the Erlang programming language. Elixir builds on top of Erlang and shares the same abstractions for building distributed, fault-tolerant applications. Elixir also provides tooling and an extensible design. The latter is supported by compile-time metaprogramming with macros and polymorphism via protocols.

<span class="mw-page-title-main">Nim (programming language)</span> Programming language

Nim is a general-purpose, multi-paradigm, statically typed, compiled high-level systems programming language, designed and developed by a team around Andreas Rumpf. Nim is designed to be "efficient, expressive, and elegant", supporting metaprogramming, functional, message passing, procedural, and object-oriented programming styles by providing several features such as compile time code generation, algebraic data types, a foreign function interface (FFI) with C, C++, Objective-C, and JavaScript, and supporting compiling to those same languages as intermediate representations.

<span class="mw-page-title-main">Mix (build tool)</span> Build automation software for Elixir

Mix is a build automation tool for working with applications written in the Elixir programming language. Mix was created in 2012 by Anthony Grimes, who took inspiration from Clojure's Leiningen. Soon after, Mix was merged into the Elixir programming language itself and to this day is one of the six applications that are part of the Elixir language. Mix provides functionality for creating, compiling, and testing Elixir source code and for managing dependencies and deploying Elixir applications.

BEAM is the virtual machine at the core of the Erlang Open Telecom Platform (OTP). BEAM is part of the Erlang Run-Time System (ERTS), which compiles Erlang source code into bytecode, which is then executed on the BEAM. BEAM bytecode files have the .beam file extension.

<span class="mw-page-title-main">PureScript</span> Strongly-typed language that compiles to JavaScript

PureScript is a strongly-typed, purely-functional programming language that transpiles to JavaScript, C++11, Erlang, and Go. It can be used to develop web applications, server side apps, and also desktop applications with use of Electron or via C++11 and Go compilers with suitable libraries. Its syntax is mostly comparable to that of Haskell. In addition, it introduces row polymorphism and extensible records. Also, contrary to Haskell, the PureScript language is defined as having a strict evaluation strategy, although there are non-conforming back ends which implement a lazy evaluation strategy.

<span class="mw-page-title-main">Reason (programming language)</span> Syntax extension and toolchain for OCaml

Reason, also known as ReasonML, is a syntax extension and toolchain for OCaml created by Jordan Walke, who also created the React framework, at Facebook. Reason offers a syntax familiar to JavaScript programmers, and compiles to native code using OCaml's compiler toolchain. Reason code may also be compiled to JavaScript using the ReScript compiler.

<span class="mw-page-title-main">Zig (programming language)</span> A general-purpose programming language, toolchain to build Zig/C/C++ code

Zig is an imperative, general-purpose, statically typed, compiled system programming language designed by Andrew Kelley. It is intended to be a successor to the C programming language, with the intention of being even smaller and simpler to program in while also offering more functionality.

References

  1. "gleam-lang/gleam Issues - New logo and mascot #2551". GitHub .
  2. 1 2 3 "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. Alistair, Woodman (December 2023). "Erlang Ecosystem Foundation Annual General Meeting 2023 Chair's Report".
  14. "Gleam version 1 – Gleam". gleam.run. Retrieved May 7, 2024.
  15. "Tail Calls". The Gleam Language Tour. Retrieved March 26, 2024.
  16. gleam-lang/gleam, Gleam, May 6, 2024, retrieved May 6, 2024