Live data from Hacker News

I tried Gleam for Advent of Code

blog.tymscar.com

141–150 of 223 posts

Re: I tried Gleam for Advent of Code

#141

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 . To me it felt less elegant than Scheme (GNU Guile) which I usually use (with nice…

If you like ML-ness try ReScript v12. It occupies a nice middle-ground between OCaml and Gleam.

Re: I tried Gleam for Advent of Code

#142
post #72

I don’t know gleam, but surely list.map(fn(line) { line |> calculate_instruction }) Could be written list.map(calculate_instruction) ?

You'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.

This 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.

Re: I tried Gleam for Advent of Code

#143
post #8

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 Gle…

i just implemented a project in elixir with LLM support and would never have considered that before. (i had never used elixir before) - So who knows maybe it will help adoption?

Re: I tried Gleam for Advent of Code

#144
post #8

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 Gle…

> what I wish Elixir would become (re:typing).

Elixir is slowly rolling out set-theoretic typing: https://hexdocs.pm/elixir/main/gradual-set-theoretic-types.h...

Re: I tried Gleam for Advent of Code

#145
post #139

Earlier quoted context omitted.

There's a flywheel where programmers choose languages that LLMs already understand, but LLMs can only learn languages that programmers write a sufficient amount of code in. Because LLMs make it that much faster to develop software, any potential advantage you may get from adopting a very niche language is overshadowed by the fact that you can't use it with an LLM. This makes it that much harder for your new language…

I don't think this is actually true. LLMs have an impressive amount of ability to do knowledge-transfer between domains, it only makes sense that that would also apply to programming languages, since the basic underlying concepts (functions, data structures, etc.) exist nearly everywhere. If this does appear to become a problem, is it not hard to apply the same RLHF infrastructure that's used to get LLMs effective at…

> LLMs have an impressive amount of ability to do knowledge-transfer between domains, it only makes sense that that would also apply to programming languages, since the basic underlying concepts (functions, data structures, etc.) exist nearly everywhere.

That would make sense if LLMs understood the domains and the concepts. They don't. They need a lot of training data to "map" the "knowledge transfer".

Personal anecdote: Claude stopped writing Java-like Elixir only some time around summer this year (Elixir is 13 years old), and is still incapable of writing "modern HEEX" which changed some of the templaring syntax in Phoenix almost two years ago.

Re: I tried Gleam for Advent of Code

#146
post #52

Earlier quoted context omitted.

Gleam has first class functions, so it has dynamic dispatch. Both of type classes and interfaces desugar to high order functions, so anything you write with them can be written with first class functions, though with a less concise API.

What you are saying is: no, it doesn't. Of course dynamic dispatch can be implemented in almost every language. The Linux kernel uses dynamic dispatch with C! But that's a hack, not a language feature.

It's not a "hack" because many language DO NOT let you store functions with state. Gleam does, I write PHP, and that does as well.

PHP has interfaces and whatnot, but a lot of the time I do polymorphism by just having a class that has Closure members. When you can arbitrarily pass around functions like that, it's basically equivalent to an interface or abstract class, with a bit more flexibility.

Re: I tried Gleam for Advent of Code

#147
post #14

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.

I looked at lustre for a recent project and it seems very nice. But the ecosystem is pretty small yet (I could find no examples of auth, for one), so I ended up going with liveview.

I'm hoping it succeeds and gets bigger because I really like its ergonomics.

Re: I tried Gleam for Advent of Code

#148
post #44

Earlier quoted context omitted.

That’s the worse is better philosophy which maybe doesn’t matter as much anymore especially with AI

What do you mean?

I think he means maybe AI can get around languages lacking features - like how codegen was used for a long time.

Codegen is more and more rare these days, because languages have so many tools to help you write less code - like generics. LLMs could, theoretically, help you crank out similar repetitive implementations of things.

Re: I tried Gleam for Advent of Code

#149
post #65

Earlier quoted context omitted.

The 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.

It’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.

Does that mean pass every needed function as a parameter? Or just don’t write generic functionality?

Re: I tried Gleam for Advent of Code

#150
post #57

Earlier quoted context omitted.

Hi, 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.

> Hi, I’m the creator of Gleam! What's the state of Gleam's JSON parsing / serialization capabilities right now? I find it to be a lovely little language, but having to essentially write every type three times (once for the type definition, once for the serializer, once for the deserializer) isn't something I'm looking forward to. A functional language that can run both on the backend (Beam) and frontend (JS) lets on…

Also. The lisp cam now generate serialisers and deserializers for some types iirc.
Post reply on HN