I tried Gleam for Advent of Code

(blog.tymscar.com)

89 points | by tymscar 2 hours ago

8 comments

  • periodjet 14 minutes ago
    Ruined by ligatures. Use them in your own private coding time, not when trying to communicate with others. It obfuscates rather than clarifies.
    • tymscar 12 minutes ago
      I actually agree. I don’t even use them in my private code. I will look into removing them from my blog!
      • seritools 9 minutes ago
        For a quick fix: `font-variant-ligatures: none;` on body or similar.
    • huflungdung 13 minutes ago
      [dead]
  • scuff3d 1 hour ago
    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.

    • rapind 3 minutes ago
      I recently used Gleam + Lustre for a small app that I normally would have built with Elm + PostgREST. It went very well, and I'm now planning to use it for a larger rewrite (of a rails app).
    • tempest_ 53 minutes ago
      As a mostly back end dev Elm looked really nice but all the conflict with the creator and then the lack of compiler releases made me shy away a bit.

      I have bumped into "the Elm architecture" in other projects though and it was nice.

      • rapind 0 minutes ago
        > all the conflict with the creator

        Just so no one misunderstands this. The creator (Evan) didn't get into any drama himself that I ever noticed. I've been on the edges of the community for probably a decade now (lurker), and all of the drama came from other people who simply didn't like the BDFL and slow releases strategy.

      • styluss 29 minutes ago
        Which conflicts? Gleam seems to be released often?
        • OtomotO 22 minutes ago
          The elm drama
  • threethirtytwo 1 hour ago
    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.

    • nonethewiser 6 minutes ago
      Go touted it's lack of features as simplicity. And it is: on the language writing side. Go is an incomplete language masquerading as a simple one.
    • NathanaelRea 57 minutes ago
      I saw your other comment that you meant interface. But an example of a language that went without a feature people thought the language desperately needed was Go with generics. They only added them more than ten years later, when they figured out the best way to implement them.

      It might be the same with gleam, with first version in 2019 and 1.0 in 2024. The language authors might think they are either uneeded and lead to anti patterns, or are waiting to see the best way to implement them.

    • akkad33 20 minutes ago
      Why does it need generics? There's a great blog post about how you can replace a lot of trait behaviour with just functions. Maybe something like that can be done for generics
    • kace91 1 hour ago
      Perhaps this is a silly question but how do you do functional with no generics? Arent they pretty much required for map/reduce/filter?
      • threethirtytwo 1 hour ago
        Sorry my comment was wrong. It’s been a while when I messed with gleam and I remember it was missing a critical thing but I misremembered what it was.

        Gleam doesn’t support interfaces. Not generics. You are completely right.

      • chongli 21 minutes ago
        There are multiple levels of possible generics at play here: the container type and the element type. You can have a map/reduce/filter that operate on any element type (generic elements) while still being specialized to linked lists. On the other hand, you might prefer a generic map that can operate on any container type and any element type, so that you can use the same map method and the same function to map over arrays of numbers, sets of numbers, lists of numbers, trees of numbers, or even functions of numbers!

        Haskell allows both sorts of generics. In Haskell parlance they call this higher-kinded polymorphism and the generic version of map they call fmap (as a method of the class Functor).

  • bnchrch 1 hour ago
    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.

    • sbuttgereit 24 minutes ago
      > For those that don't know its also built upon OTP, the erlang vm

      This isn't correct. It can compile to run on the BEAM: that is the Erlang VM. OTP isn't the Erlang VM; rather, "OTP is set of Erlang libraries and design principles providing middle-ware to develop [concurrent/distributed/fault tolerant] systems."

      Gleam itself provides what I believe is a substantial subset of OTP support via a library: https://github.com/gleam-lang/otp

      Importantly: "Gleam has its own version of OTP which is type safe, but has a smaller feature set. [vs. Elixir, another BEAM language with OTP support]"

    • agos 12 minutes ago
      the Erlang vm is called BEAM, not OTP. sadly, Gleam's implementation of OTP is not at the same level as Elixir's or Erlang.
  • marliechiller 1 hour ago
    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.
    • victorbjorklund 58 minutes ago
      I feel that was more true 1-2 years ago. These days I find Claude Code write almost as good (or as bad depending on your perspective) Elixir code as JavaScript code and there must be less Elixir code in the training data.
      • jszymborski 21 minutes ago
        I personally find it much more painful to generate valid Rust code that compiles and does what I want than e.g. valid python code that runs and does what I want.
      • agos 10 minutes ago
        in my daily experience Claude Code writes better Elixir code than JS (React). Surely this has to do with the quality of the training material
      • stanmancan 45 minutes ago
        There's certainly a lot more JS code out there to train on, but the quality of the Elixir code is likely overall much better.
    • thefaux 29 minutes ago
      In the medium to long term, if LLMs are unable to easily learn new languages and remap the knowledge they gained from training on different languages, then they will have failed in their mission of becoming a general intelligence.
    • kace91 1 hour ago
      If you just see language as a tool, unless you’re self employed or working in open source, wouldn’t the lack of job market demand for it be the first blocker?
    • c-hendricks 1 hour ago
      I hope this isn't the future of "new" languages. Hopefully newer AI tools can actually learn a language and they won't be the limiting factor.
      • bbatha 28 minutes ago
        I’m more interested in what happens when a language is designed specifically for llms? When doing vibe coding a lot of code is a lot more verbose than I’d do normally. Do we drop down the abstraction level because llms are just so good a churning out boilerplate?
      • whimsicalism 1 hour ago
        it’s easy enough for them as soon as they have an RL environment for the language
      • positron26 1 hour ago
        This is the answer. We need online learning for our own code bases and macros.
    • dragonwriter 44 minutes ago
      Its pretty much the same thing as in every previous age, where not having a community of experience and the supporting materials they produce has been a disadvantage to early adopters of a new language, so the people that used it first were people with a particular need that it seemed to address that offset that for them, or that had a particular interest in being in the vanguard.

      And those people are the people that develop the body of material that later people (and now LLMs) learn from.

    • armchairhacker 1 hour ago
      Gleam isn’t a very unique language. The loss from generalizing may be less than the improved ergonomics, if not now then as LLMs improve.
      • mikepurvis 44 minutes ago
        I don't know Gleam at all so I can't comment on that specifically, but I think everyone has the experience of a coworker who writes C++ as if it's C or Python as if its Java or whatever else.

        A language doesn't have to be unique to still have a particular taste associated with its patterns and idioms, and it would unfortunate if LLM influence had the effect of suppressing the ability for that new style to develop.

    • Hammershaft 1 hour ago
      This was one of my bigger worries for LLM coding: we might develop path dependence on the largest tools and languages.
    • timeon 32 minutes ago
      Seems like you are not target audience for these new languages and that is OK. But I guess there are still many people that want to try new things (on their own even).
    • jedbrooke 50 minutes ago
      where do you think the corpus of training data comes from?
    • ModernMech 1 hour ago
      Yes, because LLMs don't change the fact that different programming languages have different expressive capabilities. It's easier to say some things in some languages over others. That doesn't change if it's an LLM writing the code; LLMs have finite context windows and limited attention. If you can express an algorithm in 3000 loc in one language but 30 loc in another, the more expressive language is still preferred, even if the LLM can spit out the 3000 lines in 1s. The reason being if the resulting codebase is 10 - 100x larger than it needs to be, that has real costs that are not mitigated by LLMs or agents. All things being equal, you'd still prefer the right tool for the job, which does not imply we should use Python for everything because it dominates the training set, it means we should make sure LLMs have capabilities to write other programming languages equally well before we rely on them too much.
  • bbkane 1 hour ago
    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...
  • croisillon 45 minutes ago
    fortunately the blog title police stepped in as soon as possible https://news.ycombinator.com/item?id=45426996
  • throwaway091025 58 minutes ago
    [dead]