[フレーム]
BT

InfoQ Software Architects' Newsletter

A monthly overview of things you need to know as an architect or aspiring architect.

View an example

We protect your privacy.

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Unlock the full InfoQ experience

Unlock the full InfoQ experience by logging in! Stay updated with your favorite authors and topics, engage with content, and download exclusive resources.

Log In
or

Don't have an InfoQ account?

Register
  • Stay updated on topics and peers that matter to youReceive instant alerts on the latest insights and trends.
  • Quickly access free resources for continuous learningMinibooks, videos with transcripts, and training materials.
  • Save articles and read at anytimeBookmark articles to read whenever youre ready.

Topics

Choose your language

InfoQ Homepage News Erlang-Runtime Statically-Typed Functional Language Gleam Reaches 1.0

Erlang-Runtime Statically-Typed Functional Language Gleam Reaches 1.0

This item in japanese

Mar 16, 2024 2 min read

Write for InfoQ

Feed your curiosity. Help 550k+ global
senior developers
each month stay ahead.
Get in touch

Gleam, an actor-based highly-concurrent functional language running on the Erlang virtual machine (BEAM), has reached version 1.0, which means it is now ready to be used in production systems with a guarantee of backward compatibility based on semantic versioning.

Gleam aims to be a language with a small surface area, easy to read and understand, and expressive.

Gleam runs on the Erlang virtual machine, a mature and battle-tested platform that powers many of the world’s most reliable and scalable systems, such as WhatsApp. Gleam can also run on JavaScript runtimes, making it possible to run Gleam code in the browser, on mobile devices, or anywhere else.

Gleam follows in the line of strong statically-typed languages like Elm, OCaml, and Rust, providing robust static analysis and compile-time guarantees. It also adopts immutable data structures implemented with structural sharing as in Clojure to ensure efficient operation. Concurrent access to mutable state is achieved through actors or Erlang's in-memory key-value database ETS.

According to the language core team, Gleam's concurrency system can run millions of tasks concurrently and scale easily thanks to immutable data and a garbage collector that never stops the world.

Gleam programs can use packages created for BEAM independently from the language used to write them. Additionally, it is possible to mix Erlang and Elixir code in a Gleam program. This is possible thanks to Gleam build tool being able to compile Elixir dependencies as well as Elixir source files and supporting a specific syntax that enables importing external functions to call them from Gleam code. Gleam also supports seamless integration with JavaScript code when compiling for the JavaScript runtime:

pub fn register_event_handler() {
 let el = document.query_selector("a")
 element.add_event_listener(el, fn() {
 io.println("Clicked!")
 })
}

Gleam can also use Erlang hot code reloading but without any additional guarantees to those provided by Erlang itself. Specifically, upgraded code cannot be type checked since it is not possible to know which types are used in the running code.

The arena of languages for the Erlang virtual machine sports several Gleam competitors, including Alpaca, Caramel, and Elixir. Both Alpaca and Caramel are statically-typed languages that differ from Gleam in a number of ways. In particular, Caramel is based on OCaml and even forks the OCaml compiler to generate code, while Gleam and Alpaca are original languages. Gleam is the only one of the set that also targets JavaScript. On the other hand, Elixir is, without doubt, the most mature and popular alternative to Erlang on BEAM, providing a Ruby-like syntax and a dynamical type system.

About the Author

Sergio De Simone

Show moreShow less

Rate this Article

Adoption
Style

Related Content

The InfoQ Newsletter

A round-up of last week’s content on InfoQ sent out every Tuesday. Join a community of over 250,000 senior developers. View an example

We protect your privacy.

BT

AltStyle によって変換されたページ (->オリジナル) /