Gleam is a relatively new functional programming language built on the Erlang Virtual Machine. This was first experience and discovery of it. I have positive thoughts...
Originally published on Medium on March 22, 2024
Happy Friday! (If it’s still Friday as you’re reading this). I write this post with a genuine smile on my face. It’s been a while since I discovered a programming language that made be want to find an excuse to write some code in it.
Maybe it’s that darn happy star:
The Gleam Star “Lucy” is nothing like the adorably terrifying star from the Mario Movie
The Old
The last time I had this feeling was with Scala on the JVM, which along with Cassandra as my first foray into NoSQL databases, and a bunch of other expectations, had attracted me to a new lead engineering role.
Unfortunately, though, Scala had its faults and failed to catch on with most of my future colleagues perhaps due to its complexity over Java and at the time the lack of integration into our standard engineering tools like code coverage, static type checking, some pretty painful migrations, even syntax highlighting in some of our code review tools.
I do have it to thank for discovering the actor model of concurrency, first with Scala Actors and then with Akka — which I used at the time to build a robust bi-temporal historical service / database which ran for years dynamically scaling to increasing demand without needing to be touched. (I mean this without exaggeration or pride: At one point it was 2 years between code changes on a very heavily used distributed system). It was also great fun using Scala for building various DSLs that underpinned our data model and code generation.
I also have nostalic for Haskell — though haven’t touched it for eons, very briefly looked at F# — which looked fun but never got an excuse to start using it, wrote a few necessary and exploratory bits and bobs in Kotlin — because Java has become boring but necessary, and regularly enough use Python but none of them have looked quite as fun to write (or read) as Gleam.
The New
Enter Gleam
Per its — so-slim it’s almost non-existent — wikipedia entry:
Gleam is a general-purpose, concurrent, functional high-level programming language that compiles to Erlang or JavaScript source code.
I recently finished the excellent Gleam Language Tour within a long lunch and came away thinking that they’ve created the perfect 1 programming language!
Hello, World! in Gleam
Now of course, there’s no such thing as the perfect programming language…
Wait, what??…nevertheless it did have me beaming. Perhaps that’s the point: It’s called ‘Gleam’ because it rhymes with ‘Beam’ — the name of the Erlang Virtual Machine.
I’m a big fan of syntax sugar like this that makes code more readable, especially for anyone familiar with streaming/pipelines in *nix command shells. For example:
Outputs:
Further, Gleam ticks those familiar, necessary boxes for building scalable modern systems. From the website:
Running on the battle-tested Erlang virtual machine that powers planet-scale systems such as WhatsApp and Ericsson, Gleam is ready for workloads of any size.
Thanks to a multi-core actor based concurrency system that can run millions of concurrent tasks, fast immutable data structures, and a concurrent garbage collector that never stops the world, your service can scale and stay lightning fast with ease.
So my next long lunch, hopefully coming soon, looks like it will be experimenting with gleam otp to test that out.
So whether you’re an engineering manager, an engineer, or just intrigued in general I’d encourage you to give it a try — I know I will be. (We may not have long left to enjoy it to ourselves):
The blindingly rapid advance of Generative AI, mass technology layoffs, every other update on artificial intelligence signals the end of an era. The information age had its time, the experience age has barely made a blip - this is the age of AI. Coding, as we knew it, is dead — long live engineering!
Disclaimer:
The views and opinions expressed in this blog are based on my personal experiences and knowledge acquired throughout my career. They do not necessarily reflect the views of or experiences at my current or past employers
References
Footnotes
-
Editors Note (2024-04-27): Where its “perfection” is its simplicity. No
for
loops, and noif
statements is a strong choice. So, though, is choosing Go over C++/Rust, or RISC over CISC. Anything over Perl is a good choice - where you have a million different ways to do the same thing. Functional languages that encourage a different way of looking at problems, and avoid side-effects and branching have always held a special place for me. ↩