Gleam 1.7 Improves Performance
Written by Alex Denham   
Thursday, 09 January 2025

Gleam 1.7 has been released with faster record updates and more secure package manager credential handling. Gleam is a statistically typed-language the compiles to Erlang or JavaScript.

Gleam was first released in 2019 as a friendly language for building type-safe systems that scale. It is statically-typed and has its own type-safe implementation of OTP, Erlang's actor framework. Users of Gleam say it provides the simplicity of Erlang with the benefits of being statically typed and functional.

gleam

The main developer of Gleam, Louis Pilfold, says Gleam uses the lessons learned from ML to enhance BEAM (the Erlang virtual machine), but isn't an actual ML language. This focus means Gleam provides simple interop in both directions, doesn't have auto-currying or an effects system, but does have an Erlang style module system.

All data structures in Gleam are immutable and are implemented using structural sharing so they can be efficiently updated. If your application needs to hold on to some mutable state then it can be held by an actor (which immutably wraps mutable state using recursion) or you can use ETS, the Erlang in-memory key-value database.

Gleam's ability to compile to JavaScript means code can run in the browser, and it has a significantly more powerful type system than Go.

The first improvement in Gleam 1.7 is faster record updates. While Gleam is a language with immutable data, it has a syntax for creating a new record from an old one with some updated fields. Until now it used a similar technique to a JavaScript update, only copying the references to the fields, not the data itself, and using a small amount of dynamic code at runtime to construct the new record with the new fields. The compiler now instead monomorphises record updates, meaning it generates exactly the most efficient code to construct the new record on a case-by-case basis, removing the runtime conditional logic and its associated cost entirely.

This release also adds more secure package manager credential handling. Gleam uses the Erlang Hex package manager, meaning developers need to provide their Hex account credentials to publish a package to Hex. The new version only asks for your Hex credentials once, and uses that to create a long-lived API token, which will be stored on your filesystem and encrypted using a local password of your choosing. For all future interactions with Hex Gleam will ask for the local password, use that to decrypt the API key, and then use it to authenticate with the Hex APIs.

Another improvement is package namespace checking. Because the Erlang virtual machine has a single namespace for modules, if two packages define modules with the same name that can cause a build failure. Gleam now checks for top-level namespace pollution. It also adds core team package name checking for a similar reason.

Other improvements include a new generate decoder code action; variant deprecation; and JavaScript bit array compile time evaluation and slicing optimization.

Gleam 1.7 is available now.

gleam

More Information

Gleam On GitHub

Gleam Website

Related Articles

Programming Languages, Love and Money

Functional And Dysfunctional Programming

Programming Languages Not To Learn First

First Class Functional Programming Books

To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.

Banner


C++ For The 21st Century
17/02/2025

C++ is a language under attack from newer languages such as Rust and from more primitive languages such as C, yet it has a large community of committed and enthusiastic users. How can things be made b [ ... ]



OpenAI Benchmarks Economic Impacts of AI
26/02/2025

Using a new benchmark, OpenAI researchers have revealed a significant shortcoming in the ability of the latest LLMs to perform real-world software engineering tasks. These AI tools may improve product [ ... ]


More News

espbook

 

Comments




or email your comment to: comments@i-programmer.info

Last Updated ( Thursday, 09 January 2025 )