8 ms·
I tried Gleam for Advent of Code
- marliechiller 10mo agoOne 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.
- armchairhacker 10mo agoGleam 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 10mo agoI 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 10mo agoThis was one of my bigger worries for LLM coding: we might develop path dependence on the largest tools and languages.
- c-hendricks 10mo agoI 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.
- whimsicalism 10mo agoit’s easy enough for them as soon as they have an RL environment for the language
- positron26 10mo agoThis is the answer. We need online learning for our own code bases and macros.
- bbatha 10mo agoI’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?
- epolanski 10mo agoLlms are already good at churning boilerplate, so the next step really is making them good as so they develop taste and architectural consistency imho.
- dugmartin 10mo agoI think as ai tools actually learn languages that functional languages will win out as they are much easier to reason about.
- torben-friis 10mo agoIf 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?
- macintux 10mo agoIf you're fortunate, you can find companies with a passion for good code who use lesser-known languages. Picking Erlang, or Haskell, or OCaml generally filters out candidates who don't share your interest in seeing what can be done outside the mainstream.
- epolanski 10mo agoIt's funny you mention Haskell, because it's one of those languages many love but can't find jobs in it even if they halved their salaries.
- ModernMech 10mo agoYes, 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.
- victorbjorklund 10mo agoI 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.
- stanmancan 10mo agoThere's certainly a lot more JS code out there to train on, but the quality of the Elixir code is likely overall much better.
- jszymborski 10mo agoI 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.
- dnautics 10mo agoi think it's pretty clear that some of "the things you expect to make an LLM good at a language" (like strong typing) are not actually the case. other things like "don't indirect your code by jumping to something unexpected" might be more important.
- manquer 10mo agoIf anything llms would be poorer in codegen for static languages because they are more verbose - More tokens to generate and use limited context windows parsing code. The advantage rather for llms in strongly typed languages is that compilers can catch errors early and give the model early automated feedback so you don’t have to. With weakly typed (and typically interpreted) languages they will need to run the code which maybe quite slow to do so or not realistic. Simply put agentic coding loops prefer stronger static analysis capabilities.
- dnautics 10mo agonot necessarily. if your refactoring loop requires too many cycles you'll fall off the attention context window. also, some nonstatic languages have a habit of having least surprise in their codebases -- it's often possible to effectively guess the types flowing through at the callsite. zero refactoring feedback necessary is better than even one.
- jedbrooke 10mo agowhere do you think the corpus of training data comes from?
- dragonwriter 10mo agoIts 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.
- thefaux 10mo agoIn 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.
- timeon 10mo agoSeems 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).
- dnautics 10mo agoclaude is really good at elixir. IME, It's really really good with a few "unofficial" tweaks to the language/frameworks, but this could be my bias. the LLM cutoff was a fear of mine, but i think it's actually the opposite. we know that as few as 250 documents can "poison" an LLM, i suspect that (for now) a small language with very higg quality examples can "poison" LLMs for the better.
- christophilus 10mo agoI recently built something in Hare (a very niche new language), and Claude Code was helpful. No where near as good as it is with TypeScript. But it was good enough that I don’t LLMs being in the top 5 reasons a language would fail to get adopted.
- epolanski 10mo agoOf course there is, especially if you believe that LLMs further improve on reasoning.
- isodev 10mo agoClaude reads and writes Gleam just fine. I think as long as the language syntax is well documented (with examples) and has meaningful diagnostics, LLMs can be useful. Gleam has both brilliant docs and diagnostics rivalling Rust. Gleam is also very well designed language wise, not many reserved words, very explicit APIs… also something that helps LLMs. Contrast with the likes of Swift - been around for years but it’s so bloated and obscure that coding agents (not just humans) have problems using it fully.
- kryptiskt 10mo agoOn the other hand, if you write a substantial amount of code in a niche languages, the LLMs will pick up your coding style as it's in a sizable chunk of the training corpus.
- perrygeo 10mo agoThe Gleam language, yes all of it, fits in a context window (https://tour.gleam.run/everything/ https://tour.gleam.run/everything/) I have similar concerns to you - how well a language works with LLMs is indeed an issue we have to consider. But why do you assume that it's the volume of training data that drives this advantage? Another assumption, equally if not more valid IMO, is that languages which have fewer, well-defined, simpler constructs are easier for LLMs to generate. Languages with sprawling complexity, where edge cases dominate dev time, all but require PBs of training data to be feasible. Languages that are simple (objectively), with a solid unwavering mental model, can match LLMs strengths - and completely leap-frog the competition in accurate code gen.
- lanthissa 10mo agothe flip side of that, right now ai coding agents try to generate code, not software. it seems semi intuitive to me that a typesafe, functional programming language with referential transparency would be ideal if you could decompose a program to small components and code those. once you have a referentially transparent function with input/out tests you can spin on that forever until its solved and then be sure that it works.
- bbkane 10mo agoI 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...
- threethirtytwo 10mo agoIt’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.
- torben-friis 10mo agoPerhaps this is a silly question but how do you do functional with no generics? Arent they pretty much required for map/reduce/filter?
- threethirtytwo 10mo agoSorry 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 10mo agoThere 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).
- lpil 10mo agoGleam does have generics.
- bnchrch 10mo agoGleam 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 10mo 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 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]"
- lpil 10mo agoHi, I’m the creator of Gleam! The comment you are replying to is correct, and you are incorrect. All OTP APIs are usable as normal within Gleam, the language is designed with it in mind, and there’s an additional set of Gleam specific additions to OTP (which you have linked there). Gleam does not have access to only a subset of OTP, and it does not have its own distinct OTP inspired OTP. It uses the OTP framework.
- tazjin 10mo ago(I know Erlang well, but haven't used Gleam) The library the parent links to says this: > Not all Erlang/OTP functionality is included in this library. Some is not possible to represent in a type safe way, so it is not included. Does this mean in practice that you can use all parts of OTP, but you might lose type checking for the parts the library doesn't cover?
- throwaway091025 10mo ago[dead]
- scuff3d 10mo agoGleam 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.
- tempest_ 10mo agoAs 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.
- styluss 10mo agoWhich conflicts? Gleam seems to be released often?
- OtomotO 10mo agoThe elm drama
- rapind 10mo ago> all the conflict with the creator Just so no one misunderstands this. The creator (Evan) didn't get into, or start, any drama himself that I ever noticed. I'd argue he's a very chill and nice dude. 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.
- deleted 10mo ago[deleted]
- scuff3d 10mo agoYeah I'm not a front end dev but I do kind of keep track of what's going on in that space. From what I saw it seemed Elm was all but dead. Maybe that's not true, but that was the impression from the outside looking in.
- theThree 10mo agoI don't know if I'm the only one experiencing this: It's too hard to find the download link from their website.
- zelphirkalt 10mo agoI think most people will use package managers to install it, or will use docker images to run code in.
- croisillon 10mo agofortunately the blog title police stepped in as soon as possible https://news.ycombinator.com/item?id=45426996 https://news.ycombinator.com/item?id=45426996
- deleted 10mo ago[deleted]
- periodjet 10mo agoRuined by ligatures. Use them in your own private coding time, not when trying to communicate with others. It obfuscates rather than clarifies.
- huflungdung 10mo ago[dead]
- tymscar 10mo agoI actually agree. I don’t even use them in my private code. I will look into removing them from my blog!
- seritools 10mo agoFor a quick fix: `font-variant-ligatures: none;` on body or similar.
- bmacho 10mo agoFor users: paste the following in console document.body.style.setProperty('font-variant-ligatures','none','important');
- Phelinofist 10mo agoI use NoScript and only got them after enabling JS for the blog page
- toastal 10mo agoI have this as !important in a global userStyle for code, pre, kbd, samp elements.
- jphoward 10mo ago'Ruined' is a bit strong, isn't it?
- mono442 10mo agoI'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?
- stuartaxelowen 10mo agoThe answer I’ve seen is “just pass structs of functions around”, which is just one step more explicit than the implicit version we’re all use to, but honestly I kinda like it to free ourselves of all the ceremony around generics.
- lpil 10mo agoIt’s discouraged to pass around structs of functions to replicate type classes in Gleam. Instead the preference is to not type class style patterns in your projects, favouring a concrete style instead.
- stuartaxelowen 10mo agoDoes that mean pass every needed function as a parameter? Or just don’t write generic functionality?
- lpil 10mo agoYes, one would use higher order functions, as is common in Erlang, Elixir, OCaml, Elm, etc.
- shirogane86x 10mo agoAt least half of those languages (Elixir and OCaml) have some sort of mechanism for ad hoc polymorphism (elixir has behaviors and protocols, OCaml has higher order modules) so I feel like the comparison doesn't work that well personally
- 10mo ago
- WJW 10mo agoGleam 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.
- vips7L 10mo ago> 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. I did it in F# this year and this was my feeling as well. All of the List.map and Seq.filter would have just been better to be called off of the actual list or Seq. Not having the functions attached to the objects really hurts discoverability too.
- titanomachy 10mo agoI don’t know gleam, but surely list.map(fn(line) { line |> calculate_instruction }) Could be written list.map(calculate_instruction) ?
- WJW 10mo agoThat is correct.
- tymscar 10mo agoYou're right, but loads of times I just left that there because I probably did something more involved in the map that I ended up deleting later without realising.
- deleted 10mo ago[deleted]
- Hasnep 10mo agoThis sounds like the kind of situation where the LSP could suggest the simpler code, I'll see if there's an issue for it already and suggest it if not.
- pdimitar 10mo agoElixir has one opinionated formatter -- Quokka -- that will rewrite the code above properly. It can also reuse linting rules as rewrite policies. Love using it.
- jsmo 10mo agoNice, 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?
- tymscar 10mo agoThank you! I have not played around with Elixir just yet, sadly, so I can't help there, I'm afraid.
- zelphirkalt 10mo agoI 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.
- sprkv5 10mo agoIf you like ML-ness try ReScript v12. It occupies a nice middle-ground between OCaml and Gleam.
- tasuki 10mo agoHeh, similar thoughts! The main difference that I only used Scheme for SICP, and I've used a bit of Haskell. I like Haskell in theory, but: just to get a hello world takes a lot of CPU and disk space. The standard library is full of exceptions (you can use a different prelude, that opens a whole different can of worms). The ergonomics of converting between the thousand different string types are awful. So, you being basically me, I have some recommendations: Idris (2): good stdlib, has dependent types. A beautiful language. The compiler is self-hosted and bootstrapped by lisp - very elegant! The ecosystem is basically nonexistent though. PureScript: also improves on Haskell in many ways. But, it's more of a frontend language, and though you can do backend, you're stuck with JavaScript runtime. Oh well.
- tasuki 10mo ago> 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!
- socalgal2 10mo agoThe `echo` part seemed interesting but it made me think, debuggers need this as a built in feature. If I have array .slice(0, 10) .filter(s => s[0].toLowerCase() < 'm') // a<->l .map(s => s.toUpperCase()); It seems like it should be a common feature to be able to view between each array operation in a debugger without having to augment the code with `echo` The out of bounds handling didn't seem all that good to me. Sure you can filter out undefined. You could also just make a function that returns an empty array if out of bounds, or array of 1 element if not. // JS function getElemFromGrid(grid, x, y) { return (x < 0 || x >= grid.width || y < 0 || y >= grid.height) ? [] : [grid.elems[y][x]] } ... neighbors = [ ...getElemFromGrid(grid, x + 1, y + 0), ...getElemFromGrid(grid, x + 1, y + 1), ...getElemFromGrid(grid, x + 0, y + 1), ...getElemFromGrid(grid, x - 1, y + 1), ...getElemFromGrid(grid, x - 1, y + 0), ...getElemFromGrid(grid, x - 1, y - 1), ...getElemFromGrid(grid, x + 0, y - 1), ...getElemFromGrid(grid, x + 1, y - 1), ] I also find grids made of 2 dimensional array to be code small. An array of arrays is NOT A GRID as there is nothing enforcing the inner arrays to be the same length as each other. Also, in efficienct code it would be better to provide a 1 dimensional array and bounds. Now, out of bounds checks based on accessing outside the array won't work. You need to check actual bounds. Again giving preference using a helper
- lysecret 10mo agoWhen I was debugging through f# code they definitely had that.
- nick4 10mo agoSomething I really hope Gleam figures out is a way to streamline the Elm architecture. We see the Elm architecture mostly in web apps, but I think that model is a really good idea for a lot of applications! But I think two things really hold it back: * it's verbose. * they compose awkwardly. Neither of these are showstoppers, but I think fixing these problems--maybe with something like syntax-level support--could really lead to a beautiful programming language.
- phplovesong 10mo agoGleam should add Go as an target. That would have a huge potentital, as the Go runtime is second to none, and its ecosystem is enormous.
- jgerrish 10mo agoI haven't explored the BEAM ecosystem much. And this post actually got me motivated enough to try it out. The more programming languages we play with, the better we become as engineers. We learn the different design decisions that go into each language. And we learn the language of Computer Science itself. Plus, Advent of Code! So I finally got everything installed. But then I realized there are no easily accessible offline docs. I don't have Internet service at home. So I have to grab service when I can make it out. So it looks like mix can download offline hexdocs, but I don't have elixir installed. And there's a hexdocs_offline dev package for Gleam. But it errors out on "gleam/dynamic does not have a 'from' value. Maybe it's a "teaching moment" about the basics of the language. But I have to run out to another appointment now, so these teaching moments don't always help. Anyways, I guess I'll dive in after the holidays and just wget the tour or get some well regarded projects for reference. I'm actually still really excited with all the functional features.
- tymscar 10mo agoHonestly it’s very much worth it! Look into this https://hexdocs.pm/hexdocs_offline/index.html https://hexdocs.pm/hexdocs_offline/index.html