hn.today

Gleam doesn't compile to Erlang source anymore

gleam.run65 points9 comments
Screenshot of Gleam doesn't compile to Erlang source anymore

Gleam v1.19.0 changes the Erlang backend from emitting Erlang source to emitting Erlang abstract forms - the parser-produced intermediate representation encoded in the Erlang external term format. Emitting abstract forms lets Gleam skip the front-end of the Erlang compiler, improving compile performance and making runtime location metadata map precisely to original Gleam source (so BEAM crash reports and stack traces show correct Gleam line numbers). Benchmarks using a 100-module/100-function test show a marked speedup versus v1.17.0, and the team explains why generating BEAM bytecode directly was rejected: bytecode evolves, requires constant maintenance and reimplementing decades of Erlang optimisations, and is not cost-effective for a community-funded project. The approach follows Elixir’s precedent and raises compiler code-quality by replacing an old generator with a cleaner design.

The release also ships several practical JVM/JS and tooling improvements. JavaScript compilation flattens pattern-match decision trees into single-condition checks, reducing branches and intermediate variables; short Gleam list literals now compile to direct prepend chains instead of building arrays and converting them, improving runtime for many cases. TypeScript declaration generation gains overloads to preserve type information for variant-checking helpers. Build-tool integration improvements include automatic .app file generation, a compile-package --no-dev flag, and export commands that can write to stdout or files, easing use from Mix/rebar3. Key contributors named include Giacomo Cavalieri, John Downey and Rodrigo Álvarez.

Read on gleam.run9 comments on Hacker News

Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.

More in Programming

Worth Building

Worth Building

Building tools without the need to monetize allows for more personal, enjoyable, and quick development of useful applications. This shift enables more people to create small, polished tools for their own needs or ideas, regardless of broader market appeal. (armstr.ng)

The daily digest

Today's best Hacker News stories, summarized and screenshotted, one email a day.