11 ms·
The Gleam Programming Language
- rapnie 9mo agoNow here's a type-safe functional programming language I recently bumped into, which with their focus on simplicity, ease of use, and developer experience, and compiling to either Erlang or Javascript, is really tempting to delve in deeper.
- brandonpollack2 9mo agoI really like the idea of gleam but I don't want to hand implement serialization for every type (even with an LSP action) in 2026.
- ocean_moist 9mo agoBiggest issue with this language. But... fairly trivial to implement codegen with gleam/glance[0]. No good libraries do this well right now (e.g. support for discriminated unions). [0] https://hexdocs.pm/glance/glance.html https://hexdocs.pm/glance/glance.html
- worthless-trash 9mo agoI rarely serialise every type in my gleam code, My quick back of the napkin math is less than 5%.
- brandonpollack2 9mo agoBut 100 percent of projects writing the same stuff
- worthless-trash 9mo agoI don't think anyone is serializing exactly the same stuff that i'm doing.
- virtualwhys 9mo agoDart has the same glaring issue (yes, yes, you can use a codegen library but it's not the same).
- lawn 9mo agoIndeed. Gleam is a sort-of mix between Elixir and Rust, yet you don't have to explicitly implement serialization for either of them. It's definitely something they should figure out.
- azhenley 9mo agoA recent post about using Gleam for Advent of Code: https://news.ycombinator.com/item?id=46255991 https://news.ycombinator.com/item?id=46255991
- tombert 9mo agoI remember playing with Alpaca a few years ago, and it was fun though I didn’t find the resulting code to significantly less error-prone than when I wrote regular Erlang. It’s inelegant, but I find that Erlang’s quasi-runtime-typing with pattern matching gets you pretty far and it falls into Erlang’s “let it crash” philosophy nicely. Honestly, and I realize that this might get me a bit of flack here and that’s obviously fine, but I find type systems start losing utility with distributed applications. Ultimately everything being sent over the wire is just bits. The wire doesn’t care about monads or integers or characters or strings or functors, just 1’s and 0’s, and ultimately I feel like imposing a type system can often get in the way more than it helps. There’s so much weirdness and uncertainty associated with stuff going over the wire, and pretty types often don’t really capture that. I haven’t tried Gleam yet, and I will give it a go, and it’s entirely possible it will change my opinion on this, so I am willing to have my mind changed.
- sfvisser 9mo agoI don’t understand this comment, yes everything going over the wire is bits, but both endpoints need to know how to interpret this data, right? Types are a great tool to do this. They can even drive the exact wire protocol, verification of both data and protocol version. So it’s hard to see how types get in the way instead of being the ultimate toolset for shaping distributed communication protocols.
- tombert 9mo agoBits get lost, if you don’t have protocol verification you get mismatched types. Types naively used can fall apart pretty easily. Suppose you have some data being sent in three chunks. Suppose you get chunk 1 and chunk 3 but chunk 2 arrives corrupted for whatever reason. What do you do? Do you reject the entire object since it doesn’t conform to the type spec? Maybe you do, maybe you don’t, or maybe you structure the type around it to handle that. But let’s dissect that last suggestion; suppose I do modify the type to encode that. Suddenly pretty much every field more or less just because Maybe/Optional. Once everything is Optional, you don’t really have a “type” anymore, you have a a runtime check of the type everywhere. This isn’t radically different than regular dynamic typing. There are more elaborate type systems that do encode these things better like session types, and I should clarify that I don’t think that those get in the way. I just think that stuff like the C type system or HM type systems stop being useful, because these type systems don’t have the best way to encode the non-determinism of distributed stuff. You can of course ameliorate this somewhat with higher level protocols like HTTP, and once you get to that level types do map pretty well and you should use them. I just have mixed feelings for low-level network stuff.
- lxdlam 9mo agoI still suspect the effectiveness of plugging in a type system patch to a complete system, like typescript to javascript. We still observe so many `as any` or `as unknown as` at every corner. Despite of the suspicion, Gleam provides a better and elegant syntax for those who are not familiar with Erlang or functional programming languages, which I loved most.
- giacomocava 9mo agoThere’s no “unknown” or “any” in Gleam, it’s not possible to cheat the type system that way
- __jonas 9mo agoThat doesn’t really apply to Gleam, it’s not a type syntax for another language that can be stripped, it’s its own language that compiles to Erlang and JS
- stanlogin 9mo agoI think they have an issue on homepage: there is no "download/get start" link. All big buttons link to a tour page, and stopped there.
- zethsg 9mo agoI was able to find that in the Docs https://gleam.run/documentation/ https://gleam.run/documentation/ ( from gleam.run )
- dematz 9mo agotbf https://gleam.run/ https://gleam.run/ -> https://gleam.run/documentation/ https://gleam.run/documentation/ -> https://gleam.run/getting-started/installing/ https://gleam.run/getting-started/installing/ is two clicks, maybe it should only be one although the playground is a much gentler introduction than installing gleam+erlang+rebar3
- pkos98 9mo agoComing from Elixir, I gave Gleam a try for a couple of days over the holidays. Reasons I decided not to pursue: - No ad-hoc polymorphism (apart from function overloading IIRC) means no standard way of defining how things work. There are not many conventions yet in place so you won’t know if your library supports eg JSON deserialization for its types - Coupled with a lack of macros, this means you have to implement even most basic functionality like JSON (de)serialization yourself - even for stdlib and most popular libs’ structs - When looking on how to access the file system, I learned the stdlib does not provide fs access as the API couldn’t be shared between the JS and Erlang targets. The most popular fs package for erlang target didn’t look of high quality at all. Something so basic and important. - This made me realise that in contrast to elixir which not only runs on the BEAM („Erlang“) but also runs with seamless Erlang interop, Gleam doesn’t have access to most of the Erlang / Elixir ecosystem out of the box. There are many things I liked, like the algebraic data types, the Result and Option types, pattern matching with destructuring. Which made me realize what I really want is Rust. My ways lead to Rust, I guess.
- nesarkvechnep 9mo agoI’ve been doing Elixir for 9 years, 5 professionally. Nobody cares about ad-hoc polymorphism. The community doesn’t use protocols except “for data”. Whatever that means. Global singleton processes everywhere. I’m really discouraged by the practices I observe but it’s the most enjoyable language for me still.
- krainboltgreene 9mo agoIMHO this is an education problem.
- nesarkvechnep 9mo agoProblem which plagues 90% of the people? How to overcome it?
- threethirtytwo 9mo ago
- behnamoh 9mo agoI'd rather them stick with ONE: JS or BEAM. Everytime a project claims it can do multiple things at once, it can't do either very well. It's confusing too. Is Gleam suitable for distributed computing like Elixir/Erlang on BEAM? Would that answer change if I compile it to JS?
- Ndymium 9mo agoGleam is technically as suitable for distributed computing as Erlang: since it compiles to Erlang, it can do anything that Erlang can. You can use Erlang and Elixir libraries and write FFI code to do things that would be unergonomic to do in Gleam. Sure the experience is different and if you want to embrace the guarantees of static typing, then the APIs will look different, like gleam_otp. If you compile it to JS, then the guarantees change to JS's guarantees. Personally I've felt that the JS target is a big plus and hasn't detracted from Gleam. Writing a full stack app with both sides being in Gleam and sharing common code is something I've enjoyed a lot. The most visible impact is that there's no target specific functions in the stdlib or the language itself, so Erlang related things are in gleam_erlang and gleam_otp, and e.g. filesystem access is a package instead of being in the stdlib. If you're just into Erlang, you don't need to interact with the JS target at all.
- wink 9mo agoSame here, I've only been using it for a bit and have 100% been ignoring the JS part and the only time where I felt I needed to think about it for a moment was when I was writing a patch for someone else's code that did not ignore it, so basically when contributing to a library you might have to do extra work. Of course I can't say if anyone ever made any decisions based on the other target that would have repercussions for me only using the BEAM.
- tunderscored 9mo agoI've used gleam for a toy project in uni, and AoC My main friction point is that the Int type maps to different concepts in erlang and js In erlang it's a arbitrary precision Int In js it the js number type, which is a 64bit float iirc. Also recursion can hit limits way sooner in js. For me, my code rarely ran in both js and erlang. But could be skillissue
- Kindercrusher 9mo ago[dead]
- wiskiy 9mo agoI am in love with Gleam! As a young computer science student, I found that Gleam brought back the joy of programming just when I felt like I was seriously burning out. I was never a fan of functional programming languages. I had tried other BEAM languages like Elixir and Erlang before, but Gleam is the one I’ve enjoyed the most :)
- replwoacause 9mo agoHave you tried F#? That usually gets a lot of praise in FP discussions.
- systems 9mo agoF# seem to be in abandon-ware state the creator of F# moved to another job as his primary work the forum and community are very dry Nothing interesting being created in F# As much as I had high hopes for F# I think its safe at this point, to not pursuit it any further .Net is C# If you want an Ocaml like language, that is not Ocaml, your best bet is Rescript and that being said, Rescript is probably more of a competitor to gleam, since gleam also have javascript as a target
- pjmlp 9mo agoI would assert that Microsoft's management always behaved as if they repented to have added F# to VS 2010, with all the maintenance guarantees it implies, throughout the years they have searched how to sell it. Nowadays CLR has effectively changed meaning to C# Language Runtime, and ironically the JVM is more lively as the original goal of the CLR back in 2001.
- throw1235435 9mo agoThe language is still ahead of C#, and still receiving features and keeping up by and large with the .NET ecosystem. Tbh I don't get the sheer negativity; the same thing could be said for Gleam or any other functional language these days tbh especially with AI coming along w.r.t long term support. Eventually things just work and are mostly complete; things don't have to get reinvented or get better forever. > As much as I had high hopes for F# I think its safe at this point, to not pursuit it any further I find this attitude interesting; you wanted it to be more than it was. I don't have high hopes for any language; other than it building my software which it and many others can do. Right tool for right job. I'm not attached to my code, other than if it can be maintained, changed, has sane defaults/guardrails to introduce less defects, etc. F# can do this, as many others. Interestingly I've seen the same attitude eventually happen to all languages of this class other than Rust; Scala, OCaml, etc are in similar positions. Funnily enough Opus/CC has a number of times for my projects has suggested Rust, and if that doesn't work (too much for the team) went F# even over Java based langs assuming domain modelling code and the need for more perf (e.g. value types, and other stuff) without explicit prompting. Its then generated fsx scripts to run experiments, etc that seem to be more reliable than the default Python ones it runs (package errors and static typing fixes mostly). `dotnet fsi` fits well into the agentic workflow. > Rescript and that being said, Rescript is probably more of a competitor to gleam Depends on your target. F# at least has a backdoor into the C# ecosystem - from a risk perspective that makes it more palatable. New languages have an initial "excitement" about them; but generally they are just tools. Pick something that fits your team and build. F# does work, and so do many other tools. In the age of AI IMO the ecosystem and guardrails for the AI matter more than the language and its syntax IMO other than readability. In this regard F# still is "less risky" with its .NET interop.
- pjmlp 9mo agoGlean is interesting from language nerd point of view, however I never had a reason to use Erlang at work, and probably never will, and I suspect that relates to most folks.
- misiek08 9mo agoIt’s funny how we avoid the technologies we can’t complain about much. Seeing an Elixir projects on production I always wonder „why we are not using it more often”. More talking about Elixir here. For Elixir I saw a simple distributed job scheduler - it was dead simple in code and was ripped, because it didn’t require maintenance for ~8 years just working without issue and people who knew anything about it left company or switched part of company and acted as they forgot everything. The other example is medium sized (in terms of features and code) web app - maintained by <30 people now, delivering more than 800 people at the other company, no stress, no issues and with great DX because of the BEAM (other company is drowning in JVM based nano-services).
- pjmlp 9mo agoThe way many of us get work assignments is: - Have to deploy product XYZ (because we don't write everything from scratch) - Need to extend said product - Use one of the official SDKs, because we aren't yak shaving for new platforms Thus that is how we end up using the languages we kind of complain about. To be fair, languages like Elixir and Gleam do exist, because too many complain about Erlang, which me with my Prolog background see no issues with.
- wink 9mo agoI think the problem is that there is Erlang, the syntax, then Erlang, the features, and then there's OTP. It's a bit much all in one if you might have not done FP before, and then only with C-like syntax languages (e.g. Java). When I joined an Erlang project I also had some aha moments with the syntax and how stuff is structured, and I found Elixir much nicer to work with (without any real Ruby experience). I don't want to say Erlang is not modern enough, but some things felt like they were around half the work (and more enjoyable) with some Elixir libraries (vastly bigger ecosystem than pure Erlang), for example handling XML. It might be a bit simplistic, but I don't think you really lose anything meaningful when using Gleam or Elixir over pure Erlang. Just like you don't lose anything when using Clojure or Kotlin over pure Java.
- kristopolous 9mo agoI've always thought this would be an excellent language for coding agents.
- kevsim 9mo agoTo use to write coding agents or for coding agents to write code in?
- librasteve 9mo agothought I’d try the showcase example in Raku (https://raku.org https://raku.org), so this Gleam import gleam/io pub fn main() { io.println("hello, friend!") } becomes this Raku say “hello, friend!” well maybe you really want to have a main() so you can pass in name from the command line #!/usr/bin/env raku sub MAIN($name) { say "hello, $name!” }
- okkdev 9mo agoRaku looks sweet, but what is the point of this comparison? :)
- librasteve 9mo agoI love coding in Raku - and I am sure that Gleam is nice too. But I get the feeling that Raku is underappreciated / dismissed by many due to the perl5 / perl6 history. So my thinking is, when I see a new language showcase an example on their website, presumably a carefully chosen snippet that showcases their language at its best, I like to see how Raku compares to that. You know the take-aways from the comparison are quite instructive: - do I need to import the io lib? (shouldn't this just be included) - do I need a main() in every script? (does this rule out one liners like `> raku -e "say 'hi'"`) - is `io.println` quite an awkward way to spell `print`? I am not making the case that these are right or wrong language design decisions, but I do think that they are instructive of the goals of the designers. In the case of raku its "batteries included" and a push for "baby raku" to be as gentle on new coders as eg. Python.
- brabel 9mo agoThe differences you mentioned are advantageous for Gleam depending on what you want. Like, having to namespace symbols instead of implicitly importing symbols makes it explicit where things come from which is good. Needing main, same thing. But the big differences are that Gleam is both functional, so everything is immutable, and fully typed safe. Completely the opposite of Perl/Haku so comparing these languages makes zero sense. If you don’t need types or functional programming you probably would just never use Gleam.
- phplovesong 9mo agoGleam is nice. However it is still very lacking in the stdlib. You will need lots of dependencies to build something usable. I kind of wish Gleam could target something like Go, then you would have the option to go native without a "heavy" VM like the BEAM.
- lpil 9mo agoIn a world with package management there’s no practical difference between the core modules being in one package or multiple packages.
- cmoski 9mo agoSurely the BEAM is one of the major selling points.
- phplovesong 9mo agoNot for executables. Not everything needs an runtime.
- Papipo 9mo ago[dead]
- erlend_sh 9mo agoFor a fairly advanced example project I can recommend looking at Quickslice, a dev toolkit for making AT protocol applications. https://tangled.org/slices.network/quickslice https://tangled.org/slices.network/quickslice
- idoubtit 9mo agoFor anyone opening the link and wondering why the expected "gleam.toml" is missing: the project contains 2 Gleam sub-projects. The server/ directory is the BEAM server (no framework) and the client/ directory is the gleam-compiled-js client (lustre framework). Unfortunately, there are many tests for the server, and none for the client.
- kunley 9mo agoOne of programming languages with political agenda.
- lexx 9mo agoSince when not being an asshole is a political agenda?
- tinfoilhatter 9mo agoThis is a terrible take. Just because your personal opinions / morals / values don't align with others in a community, doesn't automatically make you an asshole. If people can't handle others having differing opinions, they have some growing up to do and shouldn't be leading a community.
- Papipo 9mo ago[dead]
- yellowapple 9mo agoWhen one of those “differing opinions” is “you should be oppressed”, then yeah, that kind of does automatically make someone an asshole.
- tinfoilhatter 9mo agoSomeone not being a BLM supporter, doesn't equate to them holding the opinion that anyone should be oppressed. Only someone who views everything through a binary lens / is trapped in dualistic thinking, would suggest such a thing. One shouldn't automatically claim someone else is an asshole for not agreeing to think the exact same way they do.
- akkad33 9mo agoIt didn't say BLM supporter. It says black lives matter. If you take offence to that, that's a you problem
- liampulles 9mo agoI'm now working on a real world legacy Elixir project in my day job and man oh man do I miss well defined types. Coming from Go, it makes a huge difference to my productivity when I'm able to click through fields and find usages of things, which comes down to the excellence of the Go language server. I know that the Elixir language server can infer some of this, but the language server in my experience is very fickle and flat out doesn't work if you have an older Elixir project. I'm paying keen attention to Gleam to see if it can provide a robust development experience in this way, in the longer term.
- mercer 9mo agoDo the big updates to Elixir's type system help at all? afaik the most recent update added a huge amount of coverage that should extend to older code automatically.
- liampulles 9mo agoI don't want to go into details of my work project too much, but the fundamental issue is that ElixirLS only supports 1.12+ (at least last time I checked).
- heliumtera 9mo agoOne of the best things about erlang/elixir is the repl driven development/manual testing. Gleam has no `interpreted` story, right? Something like clojure, common lisp, etc. I think this matters because debugging on beam is not THAT great, there are tools in erlang/elixir to facilitate debugging, like inspect() or dbg(). If anyone has experience in this language, what is the mindset with gleam? How you guys debug?
- lpil 9mo agoYou can use all the BEAM debuggers and tracing tools, and Gleam has a print debugging keyword. Unfortunately there is not yet a plugin for the BEAM debuggers for them to use Gleam syntax.
- __jonas 9mo ago> If anyone has experience in this language, what is the mindset with gleam? How you guys debug? There is the echo keyword now, which is comparable to elixir's dbg(), I use that a lot. Lacking a REPL, what I normally do is make a dev module, like 'dev/playground.gleam' where I'm testing things out (this is something that the gleam compiler supports, /dev is similar to /test) and then run it with 'gleam run -m playground'. Sometimes I also use the Erlang shell. You can get an Erlang shell with all the gleam modules from your project loaded in with the 'gleam shell' command. You just need to know the Erlang syntax, and how Gleam modules are named when compiled to Erlang (they use an '@' separator, so gleam/json becomes 'gleam@json').
- heliumtera 9mo agoCool, thanks! I really like Erlang syntax, will try that in the afternoon.
- lexx 9mo agoGleam is ready and is amazing. We use gleam as the main language in our company
- tekkk 9mo agoWell. Coming from TS, Gleam just wasn't/isn't my jam. It's a nice programming language research project, but it just goes against the grain for me a little too much. All the made-up rules early returning always being weird `use` call, the type boilerplate—no inline object types as I remember. Lot of inventions that just makes me go "why?" Like the opposite ideology of Go. And yes I've used Haskell before (didn't like it) and Rust (kinda like it) and others in smaller quantity. I am more excited about making things rather than fetishizing about some language paradigms so, I acknowledge that Gleam just isn't for me. I did give me the insight that for me, it might be the best to stick with the common denominator languages for the foreseeable future.
- css_apologist 9mo agolearning curve isn’t always a bad thing to effectively critique a language you must understand the design trade offs made
- brightball 9mo agoSaw a great talk about Gleam last year at the Carolina Code Conference. https://youtu.be/vyEWc0-kbkw?si=AayavKhhoqO5Mydh https://youtu.be/vyEWc0-kbkw?si=AayavKhhoqO5Mydh
- smweber 9mo agoI’m trying Gleam out right now, and having most recently been writing Go, I’m really loving: - No nil, instead Option and Result - ADTs - Pattern matching + destructuring - Immutable everything by default - `use` syntactic sugar (weird at first, but once you’re used to it it’s pretty elegant) - LSP server works great for such a young language But most of all I think the overall simplicity of the language is really what’s standing out to me. So far I think the lack of ad-hoc poly and macros are a plus - it really reduces the impulse to write “magical” code, or code with lots of indirections. In the past I’ve definitely been guilty of over-abstracting things, and I’m really trying to keep things as simple as possible now. Though I’ve yet to try Gleam with a large project - maybe I’ll miss the abstractions as project complexity increases. I suspect Gleam will be a great language for small to medium sized projects written with LLM assistance (NOT vibecoded) - the small language, strong typing and immutability gives good guardrails for LLM-generated code, and encourages a simple, direct style of programming where a human programmer can keep the whole structure in their head. Letting an LLM run free and not understanding what it’s written is I think where projects run into big problems.
- packetlost 9mo agoThe use <- syntax is even more crazy when you realize that it's a programmer-friendly way of doing continuation-passing style.
- perrygeo 9mo agoIn a language that is otherwise as simple as it could possibly get away with (no `if`!), `use <-` initially feels like magic and somewhat out of place. But take look at nested callback code, the pyramid of doom, and you see why it's pragmatically necessary. It's a brilliant design that incorporates just enough metaprogramming magic to make it ergonomic. The LSP even lets you convert back and forth between nested callback style and `use`, so you can strip away the magic in one code action if you need to unravel it.
- sureglymop 9mo agoI prefer kotlins trailing lambdas, which do mostly the same. But the way they are written allows code to almost look like JSON/some declarative DSL. But use is nicer to avoid callback hell and all the indentations/scoping.
- akanapuli 9mo agoI am really interested in whether anyone has evaluated the performance of Gleam? The language is simple, easy to understand, like `Go` for example, but is it really performant like Go, or does it have any performance cost since it runs on top of a VM?
- packetlost 9mo agoI would look at benchmarks for Erlang and Elixir to get a rough idea of how Gleam performs at runtime. It's faster than Python generally, but not by a lot. It's for this reason that I really wish Gleam had a LLVM or Golang backend instead of JS / BEAM. Here's some webserver benchmarks that cover a handful of popular languages: https://stressgrid.com/blog/webserver_benchmark/ https://stressgrid.com/blog/webserver_benchmark/ I believe BEAM got a JIT compiler built into the runtime not too long ago (after that post, iirc), so it might perform a bit better now.
- onlyrealcuzzo 9mo agoI'm working on a similar language. The facts about Gleam: 1. It runs on the BEAM - exceptionally slow compared to Go, but infinitely scalable by default in a way that Go is not - in practice, very rarely matters. 2. They will argue the slowness doesn't matter -> if ~97% of time is spent waiting on I/O -> you can be 10x slower and that means you're only ~30% for typical applications -> it's easier to scale more machines on the BEAM than it is to scale a single machine -> this is true, but largely irrelevant in Go's core market -> it's almost as if Go was built by smart people. 3. The reality is that predictability is much harder to guarantee once you start moving components to different machines. Correct, predictable distributed computing makes correct, predictable concurrent programming look easy. 4. The BEAM does not allow shared memory, Go does (unsafely). There are many cases where the performance impact of this is night and day (why Go ultimately allowed unsafety). I assume Gleam claims to make this just work. But as someone working in this space, this seems like trying to abstract away the difference between taking a boat to Europe or a plane. Gleam may be nice if you're building something for the BEAM (massively scalable single app that just makes sense with the actor model, typically chat / telecom). Though I question why you would use it over Elixir. Go's syntax kind of blows, but it is so INCREDIBLY good at what it does, that you are not going to beat Go by just having better syntax and being "infinitely scalable" by default. In practice, Go is easily scalable enough for almost anyone. If it isn't congrats, you're a $10B+ company. You can afford to rearchitect and optimize your hot paths.
- s_trumpet 9mo agoI have worked extensively on Elixir in the past and had a decent enough time, some warts aside. How different is programming in Gleam in the day-to-day apart from type safety?
- qwertfisch 9mo agoAs with many languages that compile to a VM, I always ask myself: that’s all nice, but how do I interact with anything OUTSIDE of my program? Can I do networking? Can I do system calls to my OS? Display graphics and sound? Can I import a C library that will do all that and call its functions? And if so, how? I just can’t see it from any documentation. Yes, I can call functions from other BEAM-based languages, but then I’m going in circles.
- __jonas 9mo agoIf you mean specifically on the BEAM (ignoring JS runtimes), the two options are ports and NIFs, both of which unfortunately have their drawbacks. The Erlang docs on this are here: https://www.erlang.org/doc/system/overview.html https://www.erlang.org/doc/system/overview.html
- qwertfisch 9mo agoThank you for the docs and explanation.