Gleam Is Pragmatic
Drew Olson discusses the Gleam programming language, which merges Haskell and OCaml features, supports immutable data, simplifies callbacks, and enhances usability with custom types, showing promise for functional programming.
Read original articleDrew Olson shares his experiences with the Gleam programming language, highlighting its pragmatic design choices that combine the strengths of Haskell and OCaml while minimizing their downsides. Gleam is a strongly-typed functional programming language targeting the BEAM and JavaScript, featuring immutable data structures and allowing untracked side effects. Olson appreciates Gleam's use expressions, structural equality for all types, and the absence of ad-hoc polymorphism. He provides examples demonstrating Gleam's syntax, including optional type annotations, first-class functions, and the use of the |> operator for function pipelines. The article also discusses monadic-style APIs in Gleam, showcasing how the language simplifies callback-based programming through the use construct, which flattens nested callbacks. Olson compares Gleam's handling of custom types with Haskell and OCaml, noting Gleam's ease of use without requiring additional boilerplate for custom types in dictionaries. He concludes that Gleam's design decisions make it a promising option for both newcomers and experienced functional programmers, expressing enthusiasm for its future development.
- Gleam combines features from Haskell and OCaml, offering a pragmatic approach to functional programming.
- The language supports immutable data structures and allows untracked side effects.
- Gleam simplifies callback-based programming with its use expressions, reducing complexity.
- Custom types in Gleam can be used without additional boilerplate, enhancing usability.
- Olson expresses optimism about Gleam's potential for functional programming enthusiasts.
Related
Enhancing Your Elixir Codebase with Gleam
Gleam is a statically typed language for the BEAM platform, enabling type safety in Elixir projects. The article details integrating Gleam for managing student enrollments, emphasizing testing and robustness.
First impressions of Gleam: lots of joys and some rough edges
Gleam is a functional programming language for BEAM and JavaScript, offering strong documentation, a supportive community, and effective pattern matching, but lacks traditional loops and can produce confusing type alias errors.
The basics for a fullstack SPA in Gleam
Gleam is a functional programming language with a C-style syntax. It uses the Lustre framework for frontend development, emphasizing immutable data structures and message dispatching for state management and routing.
My first experience with Gleam Language
Alex Pliutau shares his positive experience with the Gleam programming language, highlighting its easy installation, challenges with YAML parsing, and appreciation for its concurrency and error handling features, motivating future projects.
Shine with Gleam
Rocky Jaiswal, with 22 years of programming experience, praises the Gleam language for its functional programming features, simplicity, and efficiency, despite some challenges in handling nested results.
- Users express curiosity about Gleam's integration with Erlang and whether Erlang's error messages affect Gleam programming.
- There are concerns regarding the documentation for JavaScript support and the clarity of package compatibility.
- Some commenters find the syntax and features of Gleam, such as the `use` statement, intriguing but confusing.
- Critiques focus on the need for manual serialization/deserialization and the necessity of importing basic libraries, which some view as impractical.
- Comparisons to other languages like F# and concerns about missing features, such as partial application and native code compilation, are also discussed.
Am I crazy, or did he just give a really good definition of monads in programming? I think that it benefits by not letting itself get bogged down in Category Theory nomenclature which doesn't actually matter when programming.
In Erland and Elixir, actors and actor-based concurrency hold the central place in the corresponding ecosystems, well supported by extensive documentation.
In Gleam, actors and OTP are an afterthought. They are there somewhere, but underdocumented and abandoned.
JavaScript support looks interesting. Browsing the package repo, I don't see how to tell which packages are supported on Erlang's VM, when compiling to JavaScript, or both. JavaScript-specific documentation seems pretty thin so far?
Is the `use` statement blocking (in which case it doesn't seem that useful)? Or does it return immediately and then await at the point of use of the value it binds?
I’d like to dig into the OTP library (I’m curious if anyone has worked with it much?) and create a state chart library with it, but I’m still firmly in the “I don’t totally get it” camp with a few parts of Gleam. I don’t deny that it’s pragmatic. Maybe it’s more so that I’m not up to speed on functional patterns in general. I was for years, but took a hiatus to write code for a game engine and supporting infrastructure. It was so Wild West, but I kind of liked it in the end. Lots of impure, imperative code, haha.
Does a Gleam programmer in practice need to deal with Erlang? Do Erlang error messages leak through?
```
import gleam/dict.{type Dict}
import gleam/int
import gleam/io
import gleam/result
import gleam/string
```
Related
Enhancing Your Elixir Codebase with Gleam
Gleam is a statically typed language for the BEAM platform, enabling type safety in Elixir projects. The article details integrating Gleam for managing student enrollments, emphasizing testing and robustness.
First impressions of Gleam: lots of joys and some rough edges
Gleam is a functional programming language for BEAM and JavaScript, offering strong documentation, a supportive community, and effective pattern matching, but lacks traditional loops and can produce confusing type alias errors.
The basics for a fullstack SPA in Gleam
Gleam is a functional programming language with a C-style syntax. It uses the Lustre framework for frontend development, emphasizing immutable data structures and message dispatching for state management and routing.
My first experience with Gleam Language
Alex Pliutau shares his positive experience with the Gleam programming language, highlighting its easy installation, challenges with YAML parsing, and appreciation for its concurrency and error handling features, motivating future projects.
Shine with Gleam
Rocky Jaiswal, with 22 years of programming experience, praises the Gleam language for its functional programming features, simplicity, and efficiency, despite some challenges in handling nested results.