Re:I Tried Gleam for Advent of Code, and I Get the Hype
by miki123211 on Saturday December 13, 2025 @04:14PM
(#46258143)
I understand your point, and I agree with it in most contexts! However, for the specific use case where one assumes that the client and server are running the exact same code (and the client auto-refreshes if this isn't the case), and where serialization is only used for synchronizing between the two, decoupling the state from it's representation on the wire doesn't really make sense.
Re:I Tried Gleam for Advent of Code, and I Get the Hype
by lpil on Saturday December 13, 2025 @05:35PM
(#46258878)
Totally. This is where I would generate them.
Re:I Tried Gleam for Advent of Code, and I Get the Hype
by premek on Saturday December 13, 2025 @06:10PM
(#46259135)
>You can generate those conversions, most people do.
Hi, what do people use to generate them, I found gserde (edit: and glerd-json)
Re:I Tried Gleam for Advent of Code, and I Get the Hype
by okkdev on Saturday December 13, 2025 @08:18PM
(#46259966)
The language server code action :)
Re:I Tried Gleam for Advent of Code, and I Get the Hype
by lpil on Sunday December 14, 2025 @04:03AM
(#46261783)
There’s several options, depending on what you want. The most commonly used option is the language server.
Re:I Tried Gleam for Advent of Code, and I Get the Hype
by premek on Sunday December 14, 2025 @11:14AM
(#46264102)
Oh nice, didn't know about it. (I have migrated from vim to neovim and half of it doesn't work for me yet)
I wonder why this is preferred over codegen (during build), possibly using some kind of annotations?
Re:I Tried Gleam for Advent of Code, and I Get the Hype
by lpil on Sunday December 14, 2025 @12:48PM
(#46265060)
We've not had any proposals for a design like that. We are open to proposals though! I wrote a blog post detailing the process here: https://lpil.uk/blog/how-to-add-metaprogramming-to-gleam/
But also, you shouldn’t think of it as writing the same type twice! If you couple your external API and your internal data model you are greatly restricting your domain modelling cability. Even in languages where JSON serialisation works with reflection I would recommend having a distinct definition for the internal and external structure so you can have the optimal structure for each context, dodging the “lowest common decimator” problem.