Gleam Syntax Postcard
Published on: Mon Apr 14 2025
Introduction
Smalltalk is a programming languages developed in the 1970s at Xerox PARC, a research and development company that pioneered many of modern computer concepts, such as graphical user interfaces and the computer mouse. One of its creators, Alan Kay, it attributed to have coined the term “object oriented programming (or OOP)“.
Unfortunately smalltalk has been largely forgotten and is not being taught at universities, as far as I know. But today I do not want to get into forgotten gems or the history and development of programming languages. I would much rather like to talk about something else: syntax.
Syntax is at the core of every programming language. There has to be a structured way to represent the concepts, that you are able to access in your programming environment in a way that the computer can later break down and process.
Consequenctly programming languages can vary drastically in complexity. C, one of the oldest and most used programming language, has a famously simple syntax. It only has 25 reserved keywords (Depending on the standard, but roughly). As a comparison, Java has 55 and C++ has 95!
Obviously the amount of keywords is not a perfect measure of general programming language complexity. But it does give an indication of the range of primitives, sugar syntax, etc. that it enables. And that is before we even talk about pre-processor pipelines, macros, etc, which can make a language very extensible, but thereby even more complex.
And this is where smalltalk really takes the stage! All of its syntax, concepts and reserved keywords fit on a singular postcard. 8 lines of code and 255 characters.

This is the “relevant” syntax part, without the comment:
exampleWithNumber: x
|y|
true & false not & (nil isNil) ifFalse: [self halt].
y := self size + super size.
#($a #a "a" 1 1.0)
do: [:each | Transcript show: (each class name);
show: ' '].
^ x < y
No types, no async/await, just simple functions and blocks.
The Gleam Equivalent
As amazing as smalltalk is, it is not the star of today’s show. This is where Gleam joins us.
The slogan on its website is “Gleam is a friendly language for building type-safe systems that scale!“. In technical terms, it is a statically typed functional language, that compiles to Erlang and JavaScript and can run in both environments.
I could ramble for hours, how amazing, refreshing and productive I find Gleam to use, but let us get back to what all of this is about: the syntax.
Gleam deliberately leaves out a lot of more complex features, that you other wise find in programming langauges. It does not even have if statements! Neither does it have macros, sub-typing, type classes, unions, etc… So its type system is not nearly as complex or advanced as the likes of OCaml or Haskell. And that is not meant as an insult. Quite the contrary. It is so simple to the point, that it is very easy to pick up and build stuff in a pragmatic way.
Now this is not to say, that Gleam does not have any nice features or syntax. Because it leaves out so much, it is really focused and gets the good stuff right: custom types, immutability, pattern matching, pipes, records and result & optional types. It is like an amazing concoction of C or Go with functional programming.
So in the spirit of simplicity I tried to come up with a program that is syntactically correct and makes use of all of the concepts, that Gleam has to offer.
So, in all its glory, here it is:
(Made with ray.so)
Admittedly it is not as short and concise as the Smalltalk one. This version is still 44 lines of code. But that is ok, Gleam just is a bit more complex than Smalltalk.
Here is the Gleam code as a playground, if you would like to play around with it: Gleam Playground
And here is an overview of the concepts that are shown off (in no particular order):
- module imports
- functions & anonymous functions
- labelled arguments
- types (opaque, generics)
- let assignment
- working with records
- pattern matching
- guards
- pipes
- data types, tuples, lists
- bit arrays
- working with strings
- reserved keywords: panic, echo, assert, todo
use
sugar syntax
If you would like to take a deeper look at the Gleam syntax, check out the Tour!