BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Erlang-Inspired Language Gleam Now Compiles to JavaScript

Erlang-Inspired Language Gleam Now Compiles to JavaScript

This item in japanese

Gleam, which self-describes as a language for building type-safe, scalable systems for the Erlang virtual machine, now also compiles to JavaScript.

Gleam, a statically typed language for the Erlang VM, is inspired by the ML family of languages. Gleam compiles to Erlang and boasts zero-cost interoperation with other BEAM languages (e.g., Erlang itself, Elixir, LFE (Lisp Flavored Erlang). The latest release of Gleam (v0,16) now compiles to JavaScript.

Gleam’s core maintainer explained the rationale behind the adoption of JavaScript as a compilation target as follows:

The Erlang virtual machine is second-to-none for long-running services that run on servers, but outside of this space, it may not always be the best tool for the job. […]
JavaScript […] has robust concurrency features and respectable single-threaded performance thanks to highly optimised runtimes such as Google’s V8 engine […]
By compiling to JavaScript […] Gleam can be used for a much wider range of problem spaces and domains, and be accessible to a wider range of people. A team writing a backend web API in Gleam can now choose to also write their website frontend in Gleam, sharing code between both platforms and enjoying the friendly and productive type-based programming style of Gleam throughout their application stack.

As a new member of the long list of compile-to-JavaScript languages, Gleam differentiates itself with three key features: actor-based multi-core concurrency, Erlang-style fault tolerance, and algebraic data types.

Gleam’s core maintainer addressed comments from developers and Gleam’s roadmap on Reddit. In particular, he signaled interest in leveraging the new compilation to JavaScript to experiment with a full-stack web framework:

[A developer:] This is awesome. I’ve been looking forward to a Phoenix-like framework in Gleam, and now I can totally see the same language being used on the frontend too.
[Gleam’s core maintainer:] A full-stack web framework is certainly something we want to explore in the future.

Developers may download a prebuilt version of the compiler for their operating system (Linux, Windows, macOS). As Gleam compiles to Erlang code, having Erlang installed is a prerequisite to run compiled Gleam code. Interested developers can review the full description of language features in the online documentation.

Rate this Article

Adoption
Style

BT