It really is a neat language. Sort of like the smaller more elegant language that has been waiting to break out of Haskell, but combined with Erlang. Definitely not the "standard" programming language but very very nice.
The core language is pretty small too. Any moderately experienced programmer can probably burn through the language tour and be ready for a few simple AoC problems in an afternoon or so. This is due to the language designer having a very strict dedication to keeping the language as simple as possible. (Much to the chagrin of my muscle memory, as I keep expecting pattern matching on function arguments to work but it doesn't)
munchler · 3h ago
> I’ve also heard that functional languages lend themselves especially well to parsing tasks, and I’ve never understood why, so it’s a good opportunity to learn.
This is mainly due to a technique called "parser combinators", which can be expressed very cleanly in functional languages. The idea is to start with a standard set of primitive general-purpose parsers and combine them into more complex parsers that are specific to the task at hand. If you have an interest in either functional programming or parsing in general, parser combinators are good to have in your toolkit.
It looks like Gleam has at least two parser combinator packages that you might be able to use:
• party (https://hexdocs.pm/party/)
• parser_gleam (https://hexdocs.pm/parser_gleam/)
IshKebab · 1h ago
I don't think parser combinators are any more difficult in imperative languages like Python than functional ones? I found a few for Python and C++.
sfvisser · 1h ago
Don’t know about difficult, but at least less elegant. Lazy evaluation, type inference, abstractions like Functor/Applicative/Alternative/Monad make them so incredibly natural to work with in a language like Haskell. Sure, they exist in other languages (made a few myself) but it’s not the same.
munchler · 1h ago
The general notion of a “combinator” comes from functional programming, so parser combinators are native to FP. They can definitely be done in imperative languages also, but in my experience (C# specifically) are much more clunky. A dynamically typed language like Python might be suitable, because the interpreter is lenient, but I’m dubious about C++.
One thing you will definitely need in any language to produce a concise parser is the ability to define custom operators, like >>. and .>>. These are the “combinators”.
phplovesong · 54m ago
Id say mostly because of recursion is usually better for tree like ds, and builtin tco and exhaustive pattern matching. This is why ocaml is usually the goto for building a new languge prototype.
asplake · 2h ago
Or thanks to algebraic data types and pattern matching? Even in a modest recursive descent parser, these can be really nice to use.
munchler · 2h ago
Sure, although those are great FP features for all kinds of programming, not just parsing.
jszymborski · 3h ago
Gleam has long kinda seemed like my idea programming language. My only real hang-up is maybe an irrational one, but I don't love that it needs either a VM (BEAM) to run, or for it to be compiled to an interpreted language (javascript). I really wish it could target LLVM or something so it could be compiled down to native.
Maybe someone can sell me on BEAM though.
EDIT: The comments below are indeed beginning to sell me on BEAM, I'm realizing my reluctance might come from some negative experiences I've had dealing with the JVM.
brightball · 2h ago
The BEAM is very lightweight and necessary within Erlang to enforce one of its greatest tradeoffs:
- No universal garbage collector, every process (aka green thread) has its own heap that is reclaimed when it dies.
- No process can takeover the CPU. If you run a hugely intensive task in one process, everything else, millions of other processes potentially, will continue responding normally and consistently. The hugely intensive task will just take longer.
There’s more that applies to some advanced use cases, but these are the 2 core elements that are awesome.
gmassman · 2h ago
The BEAM is an amazing piece of technology. It’s built to scale massive concurrent systems and has great developer ergonomics. I’ve used it with Elixir and it’s really a breath of fresh air as far as running a webserver goes. Much more flexible and simpler to manage than a python or nodejs runtime, and also capable of scaling up with far fewer resources than you would think. Highly recommend giving it a go!
Cyph0n · 2h ago
I have never seriously used a BEAM language (Elixir/Erlang/Gleam), but for me, it’s the opposite: the most attractive part of Gleam is that it runs on BEAM :)
My reservations at this point are mostly around maturity of the language, the stdlib, and the library ecosystem; although I haven’t been following progress too closely.
obeavs · 32m ago
You can try Moonbit. It's extraordinarily well designed and compiles to highly optimized JS, WASM or even native
tcoff91 · 2h ago
You need the BEAM because operating systems we have available do not have the properties of the BEAM.
OS processes are far to heavy and slow to start, and the scheduler doesn’t work the way erlang needs it to. The BEAM solves those issues amongst others.
Also you need the BEAM for hot swapping code at runtime without taking the system offline.
thayne · 1h ago
My biggest problem with gleam is the lack of any kind of ad-hoc polymorphism (interface, trait, typeclass, protocol, etc.).
It also seems weird to make a language for BEAM that depends on a separate library for actors and concurrency.
Nezteb · 1h ago
I thought so too, although treating everything as data and functions is really nice [1].
Regarding the BEAM and why Gleam has a separate library for actors: [2]
> "One notable difference between Elixir and Gleam is that Elixir gets to just re-use the OTP code as-is (with some Elixir wrappers on top for convenience). Gleam concluded that the OTP is built expecting dynamic types, and that for best results in Gleam they'd need to re-implement the key primitives. That's why the example shown is an "Actor" not a GenServer - it serves the same purpose, and might even fit in a Supervision tree, but isn't actually a GenServer."
There's a brief snippet mentioning this in the Gleam OTP readme as well: [3]
> "Actors do not yet support all OTP system messages, so some of the OTP debugging APIs may not be fully functional."
> [...] It’s an Elixir-like language that supports static typing.
Maybe just me, but when I tried Gleam it really came off much more like Rust. In fact, other than running on the BEAM (and having some OTP libs in the works), it doesn't really _feel_ like Elixir at all to me, but that is definitely an opinion.
sbrother · 1h ago
How good is the interop story with Elixir/Erlang currently? Can I include a few gleam modules in my Elixir application and let mix take care of compiling and linking everything properly?
sodapopcan · 3h ago
They probably just mean "BEAM language that isn't Erlang."
All BEAM languages always bring something new to the table aside from just syntax (for Gleam it's static type, for Elixir it's macros and, well, mix!) but none of them try and abstract away the core tenants of the BEAM being functional working with modules and processes. So ya, in that sense you could say it's like Elixir.
tengbretson · 3h ago
I've kind of gotten a
Scala : Gleam :: JavaScript : Lua
vibe from it.
jszymborski · 3h ago
It also most reminded me of Scala.
oDot · 35m ago
I moved to Gleam with all of my projects and am not going back. The language is fantastic but really the most impactful are the coding paradigms that it enables, especially the actor model and especially on the front end (The Elm Architecture)
brightball · 2h ago
There was a great talk on Gleam at the Carolina Code Conference in 2024.
I tried with Gleam, I really wanted to like it. I really like Louis Pilfold and I like his goals for the language. But something about it just didn't click for me. It's a good language, but at the end of the day I just didn't enjoy writing it.
It might be something the author talked about, but I think the language might be too small. It's one of the things I dislike about Rust too. I prefer a more batteries included approach because I can't stand having to pull in a bunch of small dependencies.
datboi_420 · 3h ago
This was a great read! One thing that def makes Gleams error handling _look_ nicer, is utilizing `result.try` with the `use` keyword.
IncreasePosts · 3h ago
I'm glad I'm not the only one who hoarded all their AIM log data. Whenever I want to cringe I can pull up a random file
lordofgibbons · 3h ago
Gleam has caught my eye for the past year or so, and I'd totally learn it if I didn't believe firmly that we won't be coding by hand within the next 9 months. It'll all be done by LLMs so syntax and ergonomics won't mean too much. At least as soon as LLMs learn to stop being turbo-slop generators.
IshKebab · 1h ago
9 months? I mean... 9 years maybe. There's absolutely no way we won't be coding by hand in 9 months, unless the only thing you do is landing pages and CRUD forms.
arcanemachiner · 51m ago
Never underestimate the ability of the software industry to shit in its own mouth.
Doe LLMs write valid Gleam programs? Trying with ChatGPT three years ago, it did not. Workarounds, like "here is the syntax as a system prompt", put into the prompt I would not consider understanding, as Gleam idioms and patterns will certainly not all fit.
adastra22 · 2h ago
GP is crazy, but if you are basing your view of what LLMs can do based on ChatGPT 3 years ago, that is just as much out of touch.
0x3f · 3h ago
You should learn Gleam then.
echelon · 3h ago
> if I didn't believe firmly that we won't be coding by hand within the next 9 months.
LLM-assisted coding is awesome, but it feels like a self-driving style problem.
It's going to take 20 years to get there.
back2dafucha · 3h ago
The only languages Im interested in are future proof AI resistant languages. Since LLMs need alot of training (because they cant read language ASTs and write code correctly), a language that either isnt possible to express using fonts and character sets on the Internet, can only live in a private cloud, and is known to only verified practitioners runs on everything, and yet cant be decompiled.
You can launch a nuclear war in 5 lines of Visual Basic. I want a language AI doesnt know and cannot ever know.
It might be resistant to human uptake in that case, too? Brett Victor I suppose has some interesting human-first or human-only physical computers.
back2dafucha · 3h ago
Thats ok. We have done enough language research to build another powerhouse language that is AI resistant that practitioners can use. Its uptake is only relevant to those that wish to exclude LLMs from the picture to resist the agents. When LLM agents are everywhere secret societies will become the norm.
We may even have the expertise to actually transpile every single program into a unique programming language so that if the source were available LLM bots would not recognize it in any volume enough to learn from it.
The core language is pretty small too. Any moderately experienced programmer can probably burn through the language tour and be ready for a few simple AoC problems in an afternoon or so. This is due to the language designer having a very strict dedication to keeping the language as simple as possible. (Much to the chagrin of my muscle memory, as I keep expecting pattern matching on function arguments to work but it doesn't)
This is mainly due to a technique called "parser combinators", which can be expressed very cleanly in functional languages. The idea is to start with a standard set of primitive general-purpose parsers and combine them into more complex parsers that are specific to the task at hand. If you have an interest in either functional programming or parsing in general, parser combinators are good to have in your toolkit.
It looks like Gleam has at least two parser combinator packages that you might be able to use:
One thing you will definitely need in any language to produce a concise parser is the ability to define custom operators, like >>. and .>>. These are the “combinators”.
Maybe someone can sell me on BEAM though.
EDIT: The comments below are indeed beginning to sell me on BEAM, I'm realizing my reluctance might come from some negative experiences I've had dealing with the JVM.
- No universal garbage collector, every process (aka green thread) has its own heap that is reclaimed when it dies.
- No process can takeover the CPU. If you run a hugely intensive task in one process, everything else, millions of other processes potentially, will continue responding normally and consistently. The hugely intensive task will just take longer.
There’s more that applies to some advanced use cases, but these are the 2 core elements that are awesome.
My reservations at this point are mostly around maturity of the language, the stdlib, and the library ecosystem; although I haven’t been following progress too closely.
OS processes are far to heavy and slow to start, and the scheduler doesn’t work the way erlang needs it to. The BEAM solves those issues amongst others.
Also you need the BEAM for hot swapping code at runtime without taking the system offline.
It also seems weird to make a language for BEAM that depends on a separate library for actors and concurrency.
Regarding the BEAM and why Gleam has a separate library for actors: [2]
> "One notable difference between Elixir and Gleam is that Elixir gets to just re-use the OTP code as-is (with some Elixir wrappers on top for convenience). Gleam concluded that the OTP is built expecting dynamic types, and that for best results in Gleam they'd need to re-implement the key primitives. That's why the example shown is an "Actor" not a GenServer - it serves the same purpose, and might even fit in a Supervision tree, but isn't actually a GenServer."
There's a brief snippet mentioning this in the Gleam OTP readme as well: [3]
> "Actors do not yet support all OTP system messages, so some of the OTP debugging APIs may not be fully functional."
[1] https://mckayla.blog/posts/all-you-need-is-data-and-function...
[2] https://news.ycombinator.com/item?id=40645489
[3] https://github.com/gleam-lang/otp#limitations-and-known-issu...
Maybe just me, but when I tried Gleam it really came off much more like Rust. In fact, other than running on the BEAM (and having some OTP libs in the works), it doesn't really _feel_ like Elixir at all to me, but that is definitely an opinion.
All BEAM languages always bring something new to the table aside from just syntax (for Gleam it's static type, for Elixir it's macros and, well, mix!) but none of them try and abstract away the core tenants of the BEAM being functional working with modules and processes. So ya, in that sense you could say it's like Elixir.
Scala : Gleam :: JavaScript : Lua
vibe from it.
https://youtu.be/vyEWc0-kbkw?si=3o-KasK4H2n-0_KD
It might be something the author talked about, but I think the language might be too small. It's one of the things I dislike about Rust too. I prefer a more batteries included approach because I can't stand having to pull in a bunch of small dependencies.
LLM-assisted coding is awesome, but it feels like a self-driving style problem.
It's going to take 20 years to get there.
You can launch a nuclear war in 5 lines of Visual Basic. I want a language AI doesnt know and cannot ever know.
It might be resistant to human uptake in that case, too? Brett Victor I suppose has some interesting human-first or human-only physical computers.
We may even have the expertise to actually transpile every single program into a unique programming language so that if the source were available LLM bots would not recognize it in any volume enough to learn from it.