Urgent.News

What's breaking now, across thousands of outlets.

Tech

Try Gleam

Gleam is a functional programming language designed to work with the BEAM virtual machine (Erlang VM), allowing for interoperability with Erlang and Elixir systems. Gleam offers a simple syntax and can also be compiled into JavaScript for use with Node.js. This makes Gleam an appealing choice for developers who prefer Rust's functionality but want a more approachable language with fewer complexities.

One of the key features of Gleam is its simplicity compared to other functional languages like OCaml, Haskell, and Erlang. Gleam's syntax is straightforward, with most complex aspects hidden by the runtime. This simplicity extends to its functional programming features, which closely resemble those of Rust but omit certain imperative elements.

Three notable aspects of Gleam are its piping operator (|), use pattern, and tail-call optimization (TCO). The piping operator is reminiscent of JavaScript's callback nesting problems, providing a cleaner alternative. The use pattern allows for cleaner syntax when passing callbacks as arguments to functions, with the callback always being the last argument.

Gleam does not use loops, favoring recursion for most iteration tasks. For more complex scenarios, recursion is employed, relying on TCO to prevent stack overflow issues commonly associated with deep recursion in imperative languages.

Unlike Elixir, which is dynamically-typed, Gleam emphasizes static typing, offering a strong type system that ensures data integrity and eliminates certain undesired states. Gleam's types are algebraic data types, encompassing both enums and structs, ensuring that any potential issues are caught at compile time. Moreover, Gleam's compilation capability to both the BEAM virtual machine and JavaScript provides versatility, enabling seamless communication between BEAM-based applications and JavaScript-based web applications.

This dual compilation feature enhances Gleam's utility in modern, multi-platform development environments.

Written by urgent.news from Hacker News's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at nchagnet.eu →

More in Tech

Slightly better interpolating spline

  • S9 is a new interpolating spline designed for aesthetically pleasing round objects
  • S9 uses a curve parameterized by two angles, a challenging task
  • S9 is not a comprehensive path construction solution for CAD applications

More from Monday 9 November →