logoalt Hacker News

I tried Gleam for Advent of Code

237 pointsby tymscaryesterday at 5:00 PM133 commentsview on HN

Comments

bnchrchyesterday at 5:46 PM

Gleam is a beautiful language, and what I wish Elixir would become (re:typing).

For those that don't know its also built upon OTP, the erlang vm that makes concurrency and queues a trivial problem in my opinion.

Absolutely wonderful ecosystem.

I've been wanting to make Gleam my primary language, but I fear LLMs have frozen programming language advancement and adoption for anything past 2021.

But I am hopeful that Gleam has slid just under the closing door and LLMs will get up to speed on it fast.

show 4 replies
WJWyesterday at 7:24 PM

Gleam is really quite a nice language. I did AoC in it this year as well and came away with the following: (incomplete list for both positive and negative, these are mainly things that come to mind immediately)

Positive:

- It can be pretty performant if you do it right. For example, with some thought I got many days down to double digit microseconds. That said, you do need to be careful how you write it and many patterns that work well in other languages fall flat in Gleam.

- The language server is incredibly good. It autoformats, autocompletes even with functions from not-yet-imported-but-known-to-the-compiler packages, shows hints with regarding to code style and can autofix many of these, autofills missing patterns in pattern matches, automatically imports new packages when you start using them and much much more. It has definitely redefined my view of what an LSP can do for a language.

- The language is generally a joy to work with. The core team has put a lot of effort into devex and it shows. The pipe operator is nice as always, the type system is no haskell but is expressive enough, and in general it has a lot of well-thought out interactions that you only notice after using it for a while.

Negative:

- The autoformatter can be a bit overly aggressive in rewriting (for example) a single line function call with many arguments to a function call with each argument on a different line. I get that not using "too much" horizontal space is important, but using up all my vertical space instead is not always better.

- The language (on purpose) focuses a lot on simplicity over terseness, but sometimes it gets a little bit much. Having to type `list.map` instead of `map` or `dict.Dict` instead `Dict` a hundred times does add up over the course of a few weeks, and does not really add a lot of extra readability. OTOH, I have also seen people who really really like this part of Gleam so YMMV.

- Sometimes the libraries are a bit lacking. There are no matrix libraries as far as I could find. One memoisation library had a mid-AoC update to fix it after the v1.0 release had broken it but nobody noticed for months. The maintainer did push out a fix within a day of realizing it was broken though. The ones that exist and are maintained are great though.

show 4 replies
zelphirkaltyesterday at 10:45 PM

I like Gleam, but I am somewhat annoyed by the fact, that I don't have the full functional freedom in calling recursive (inner) functions wherever I want. I don't know, why new functional languages do not get this right all the way, straight from some rnrs document or implementation. Another thing is the separate operators like .> and .< and so on. What I liked were of course pipes and pattern matching.

To me it felt less elegant than Scheme (GNU Guile) which I usually use (with nice parallelism if I want to, pipelines, and also pattern matching), and, aside from syntax, conceptually perhaps less elegant than Erlang. On the other hand it has static typing.

I also tried OCaml this year, but there are issues in the ecosystem making a truly reproducible environment/setup, because opam doesn't produce proper lock files (only version numbers) and it seemed silly to not be able to even include another file, without reaching for dune, or having to specify every single file/module on command line for the OCaml compiler. So I was left unsatisfied, even though the language is elegant and I like its ML-ness. I wish there was a large ecosystem around SML, but oh well ...

Might be I should take another look at Erlang soon, or just finally get started with Haskell. Erlang using rebar3 should have proper lock files, has pattern matching, and if I remember correctly no such limitations for calling functions recursively. No longer sure how or whether Erlang did inner functions though.

titanomachyyesterday at 7:37 PM

I don’t know gleam, but surely

    list.map(fn(line) { line |> calculate_instruction })
Could be written

   list.map(calculate_instruction)

?
show 2 replies
scuff3dyesterday at 6:03 PM

Gleam is a great language. It didn't click for me when I was trying it out, but I'm glad to see more people enjoying it.

And I wonder if Gleam + Lustre could become the new Elm.

show 2 replies
marliechilleryesterday at 5:40 PM

One thing im wondering with the LLM age we seem to be entering: is there value in picking up a language like this if theres not going to be a corpus of training data for an LLM to learn from? Id like to invest the time to learn Gleam, but I treat a language as a tool, or a means to an end. I feel like more and more I'm reaching for the tool to get the job done most easily, which are languages that LLMs seem to gel with.

show 16 replies
mono442yesterday at 7:05 PM

I've looked at Gleam before but it didn't seem to have any mechanism for dynamic dispatch like interfaces or type classes. Did it change in the meantime?

show 2 replies
tasukiyesterday at 11:55 PM

> You can do [first, ..rest] and you can do [first, second].

> But you cannot do [first, ..middle, last].

I don't think you're supposed to do that! It's probably expensive!

theThreeyesterday at 11:21 PM

I don't know if I'm the only one experiencing this: It's too hard to find the download link from their website.

croisillonyesterday at 6:18 PM

fortunately the blog title police stepped in as soon as possible https://news.ycombinator.com/item?id=45426996

show 1 reply
jsmoyesterday at 8:04 PM

Nice, thanks for the write-up! Any pros/cons that jump out to you for someone whose been trying to pick up Elixir on the side?

show 1 reply
bbkaneyesterday at 5:44 PM

I keep running into Gleam posts and podcasts and videos. I think it could be an especially attractive alternative to JS for UI with the Lustre library. Haven't tried it yet, my backlog is ever growing...

periodjetyesterday at 6:49 PM

Ruined by ligatures. Use them in your own private coding time, not when trying to communicate with others. It obfuscates rather than clarifies.

show 2 replies
throwaway091025yesterday at 6:05 PM

[dead]

threethirtytwoyesterday at 5:46 PM

It’s really good. But it needs generics. This is a huge downside. It’s a typed and clean functional programming language but it arbitrarily followed golangs early philosophy of no generics. Ironically golang is one of the most hated languages among many fp advocates.

By the developers own action of adding generics ultimately the golang team admits they were wrong or that generics are better. If gleam gets popular I think much of the same will occur.

There’s simply too much repeated code without generics. I tried writing a parser combinator in gleam and it wasn’t pretty.

show 5 replies