I decided to try out Erlang for this year. I’ve avoided trying to learn a language through AoC up to now, but since last year I managed to get to the end without dropping out halfway through I’m confident enough that I’ll make it this year too. Erlang is also in a particular spot where I find it somewhat familiar (the functional style, pattern matching) but also foreign enough (the concurrency model) to make it an interesting choice. I also don’t have any particularly good ideas of what I could make with it so I think it’ll be a good chance to get acquainted with it.


      I used Elixir last year and I think there were some things in the Erlang stdlib that let you use mutable arrays. It might be helpful if you hit a wall with immutability. (On the elixir forum there was much groaning on some days.)

      ** EDIT **

      It was atomics. Man, that was a rough day…



        Yeah, I ended up using mutable data structures in last year’s F# fairly often. Some problems just aren’t suited for (usual) immutable data structures. I’m sure there’s some exotic data structures out there that would make performance acceptable but I don’t know if the trade-off is worth it.

        Thank you for the tip about atomics, though I think I’ll just retreat to Ruby or OCaml/F# if I’m having too much trouble!


      If I had never written Lisp and I wanted to attempt this in a Lisp-language which one would you suggest? Ideally I want something that I can learn quickly (the basics to solve some problems at least) and is batteries-included enough to let me parse strings or whatever without too much of a hassle.

      1. 5

        Personally I’d choose a Scheme variant if I was trying something Lisp-like for the first time. Probably Racket? https://racket-lang.org/

        Or you could go minimal and choose one of the R5RS schemes like Chicken. But Racket has nice tool support.


          Seconding racket. Massive standard library, maybe the most popular lisp these days alongside clojure.


          Racket is quite user friendly and has good docs. The standard library is massive too, it comes with a pretty good GUI library and an IDE written with it in its default distribution.


            I used Janet last year, and had a great time with it.


              I completed the advent in Clojure last year, and found it very suitable to the task.

              The standard library is comprehensive, but small; the batteries-included (persistent) data-structures are a real treat; and the sequence-processing primitives are well suited to the advent problems.

              Clojure was my first lisp, and I’ve enjoyed every minute of it.

            1. 2

              MDN says

              The Symbol.isConcatSpreadable well-known symbol is used to configure if an object should be flattened to its array elements when using the Array.prototype.concat() method.

              I was like: “‘well-known’? I’ve never heard of this”. Then I went to the spec

              Well-known symbols are built-in Symbol values that are explicitly referenced by algorithms of this specification

              So, uhh, not probably most people’s definition of “well-known”, but it didn’t answer my real question: why does this exist? Who needs this? It just seems like a good source of surprising behaviour. Has anyone here ever had cause to use this symbol?

              1. 2

                If I had to guess, it’s probably an obscure part of the spec that was implemented in V8 just for completeness and the reason why it’s implemented so sloppily is exactly because it’s not well known in the literal sense. Maybe other JS engines implement it per-object rather than globally.

                1. 1

                  FWIW “well-known” has a technical meaning in a few other places (e.g. “well-known” URLs are a subset of URLs that have certain implications if present, as used in domain validation for example) so it isn’t like the spec made that definition up.

                1. 1

                  Yesterday night I saw Death Stranding was on sale for lower than I remember it being and since I’ve been wanting to play it for a while and I’ve also been feeling like picking up one of these long games to dive into for a while, I picked it up. I think that’ll cover a big part of the weekend.

                  I’ll also write yet another parser combinator in typescript covering the types of parsers I wrote about in the post I submitted here a few days ago and I’ll use it to parse the Kamaitachi ni Yoru game files. I’ll have to figure out the output format, that’ll be fun.

                  1. 7

                    I caught a bit of this talk while it was live. I liked it a lot because it’s advice you can apply to anything you’re doing, you don’t necessarily have to be working in the videogames industry or use C/C++ or use SIMD intrinsics to trim whitespace as he does at some point, but you can still get big performance wins by not using generic tools and specializing your code for the problem at hand, instead of trying to solve a more general problem.

                    One thing I find interesting about how videogame programmers talk about code is the implication that code is cheap, and that you can and you should dump it and rewrite it when the problem changes. It’s a notion that seems to go against many “best practices”, but honestly not so much; one of the definitions of what “good code” constitutes that I prefer is code that is easy to delete.

                    1. 5

                      This is the repo containing the code for the parser: https://github.com/jhjourdan/C11parser

                      1. 4

                        And, just like you have types of parser combinators for composite or primitive data types, you can also have a type of parser combinators for … parser combinators. You’ll find a nice exposition of this idea in:

                        “Even higher-order functions for parsing or Why would anyone ever want to use a sixth-order function?” in JFP ’98 by Chris Okasaki

                        On the pragmatic side of things, that type of parser combinator is also the key approach behind coarsely and generically parsing many kinds of language syntax in comby (disclaimer: I’m the author of said tool).

                        1. 1

                          That’s definitely an interesting idea! Just thinking about functions of that sort of order is a mental workout. I haven’t read it carefully yet so maybe I don’t fully understand the consequences of using success and failure continuations, but wouldn’t using a mutable lazy type like OCaml’s Lazy.t be a bit more pragmatic? I never thought about using it for backtracking but I’ve implemented a lazy list to use as input for a streaming XML parser, maybe something similar could be used for backtracking too.

                          Edit: I’ve heard about comby before but never ended up looking into it, it looks very nice! I’ll try using it for refactoring some code at work.

                        1. 1

                          Usually this involves consuming less-structured input and producing more-structured output. This is called parsing…

                          Per this definition, how is e.g. the object indexing example parsing?

                          >> const getNestedItem = (o) => o?.a?.b?.c;
                          >> getNestedItem({ a: { b: { c: 1 } } })
                          <- 1
                          >> getNestedItem({})
                          <- undefined

                          What does “less structured” and “more structured” mean in this context?

                          1. 1

                            What I meant by that is more like “turning unknown data into known”, and IMO that example fits the definition because the nested item may or may not be there, depending on the object. In general though that’s more of a building block for constructing more useful parsers, and when you’re using some parser combinators along with it you could also decide to transform the data that it returns, or if it fails you could switch to parsing a different field or a different kind of object.

                          1. 1

                            and Meijer’s paper](https://www.cs.nott.ac.uk/~pszgmh/monparsing.pdf) about parser combinators also mentions that we might want to return more than one result in cases where it makes sense, but but let’s keep things simple here.

                            You’ve got a broken link/markdown there in the last paragraph.

                            1. 1

                              Whoops, thank you. Thought I was putting a footnote there but it turns out this markdown library doesn’t support them.

                            1. 2

                              I’ll be doing some big-ish rewrite. On the orange page I came across the idea of implementing something twice: first to understand the problem and the second as the more polished solution. Well, the codebase of my project works, but the more I work in it the less I want to… it has slowly becoming a hot fragile mess! So the rational is simple, I believe it would take less time to rewrite the whole thing and add new features than adding new features on the current state it is.

                              We’ll see how that goes :-D

                              1. 2

                                IMO that’s the point of a prototype, it’s something you make to figure out if your idea for how to do something is viable and figure out the things you might have failed to consider at the beginning, and then you use it as a model for writing the actual thing. You have to be careful to avoid the Second system effect when rewriting something that already works though.

                              1. 1

                                Parsing the game files of the iOS versions of Kamaitachi no Yoru, one of the first sound novels. It’s a sort of CYOA game accompanied by some graphics and music/sounds.

                                The files are just HTML pages with the game text and choices and a script tag that do stuff like setting the page’s background, the brightness, the music etc. I basically want to parse that logic into a declarative format so I can have better control over it, write a nice frontend, and then distribute the compiler that turns the app bundle into this web app.

                                There’s good libraries for parsing HTML and JS in TypeScript, and it would be really nice to do it using some pattern matching but I found no good solutions for that in JS… TypeScript has ts-pattern but that doesn’t support more than a certain level of nesting, otherwise the compiler gives up due to too much nesting.

                                The other option would be to use Rescript and create bindings to @babel/types, but I’d have to either rewrite the whole AST in Rescript (not doing that) or generate it from whatever @babel/types is using to generate that file. Maybe I’ll just do it in plain TypeScript.

                                1. 1

                                  and a script tag that do stuff like setting the page’s background, the brightness, the music etc.

                                  That’s cool— l wrote a short story with stuff like that[0] (albeit non-interactively) somewhat recently but the thought of adding music in never crossed my mind! I might do that next time if I can get a friend to help or something.

                                  ^0 I don’t really publish them, but you can poke me if you wanna read it.

                                1. 1

                                  Got some motivation to work on a sort of ML-but-C compiler I’ve been thinking about for a while, maybe I’ll do some work on that. But then again I need to go shopping for some clothes and do some housework so maybe I won’t.

                                  1. 5

                                    I’ve been simply doing

                                    nixos-rebuild switch --flake ~/Documents/dotfiles#machine-1 --target-host machine-1 --build-host localhost

                                    For building on my local machine, and deploying/upgrading other 4 machines (to save on bandwidth mostly) without a problem for several months. What benefit do nixops provide over the above? The article emphasises on “build in local deploy on remote”, but that don’t seem to be an issue with nixos-rebuild itself.

                                    I am kinda new to Nix, so if I need to do some reading to understand this I’ll appreciate some links (as opposed to dig into nixops head first; skimming through the first few pages of docs didn’t englighten me much).

                                    1. 1

                                      Probably nothing? I’m not great at Nix myself and you probably just have a better understanding of it :)

                                    1. 6

                                      Thanks for sharing. Similarly, I’ve been using deploy-rs to deploy Flake-based configurations to my own low powered devices (PCEngines APU, RPi). Works really well!

                                      1. 2

                                        Nice, thank you! I haven’t taken the time to grok flakes yet but I’ll be sure to take a look at deploy-rs when I do. It might take me a while though…

                                        1. 1

                                          I only spent an afternoon or two with deploy-rs (had been quite new to Nix in general), and enjoyed it, but didn’t need multiple profiles and found it to be a bit slow. Secret management did not seem to be included either, so that would require an extra tool and while hacking on that, I found https://github.com/zhaofengli/colmena which I am using since. It’s still a prototype officially but works well for me

                                          1. 0

                                            For secrets management agenix (or rangenix) seems to be the best option for me since I can push the secrets to the public repository. Still, it’d be nice to have features of both agenix and deploy-rs in a standard tool like NixOps.

                                            1. 2

                                              colmena has support for secrets included. One can even specify custom commands, which use together with pass with great pleasure :)

                                              1. 0

                                                That’s neat. I assume that keyCommand is executed on the local machine instead of the deployment target (though I couldn’t find it in the docs). Agenix, on the other hand, decrypts secrets using the target’s SSH host key at activation time. Both approaches make sense, I’m just more conformable with agenix way—“stateless” encrypted secrets in the Nix store so I can rollback secrets along with the system configuration.

                                                I also like that deploy-rs uses flake’s nixosConfigurations output, meaning that I can use plain nix for local deployments. Is it possible to do something similar with colmena-based configuration?

                                                1. 1

                                                  Yes, key command is executed locally - which i personally prefer for my use case but does not allow for unattended reboots - that could be regarded as a limitation or a feature depending on the project.

                                                  Is it possible to do something similar with colmena-based configuration?

                                                  Yes, colmena uses NixOS modules like anything else, but does not use nixosConfigurations, so one needs a smallish wrapper to support both, nixosConfigurations and colmena in the same flake. I could try to polish mine a bit and publish it, but haven’t done so yet because I am still new to nix so there might be better ways to do so ;)

                                                  1. 1

                                                    Ouch, doesn’t look like colmena supports automatic rollbacks for borked configurations. https://reddit.com/comments/kgj6ir/_/gggcmyo

                                                    That’s an absolute deal breaker for me since I tend to tinker with network configs way more than I probably should.

                                          1. 2

                                            I wonder how many community ISPs we could have if we just made them and ignored the regulations?

                                            1. 2

                                              I think a network like this is mostly possible because everybody lives in a single building. It’d get much harder when you start having to cross roads and connect several buildings together.

                                              Still, there are some examples out in the wild; Cuba has its own intranet(s?) that was built mostly to play online games, this is a good video about it: https://www.youtube.com/watch?v=lEplzHraw3c

                                            1. 10

                                              I don’t like that they call it “the first speakable programing language” because this is basically a derivative of AppleScript, which in turn I think borrows from HyperTalk. They even tagged the repo with #apple-script!

                                              I do think it’s interesting that it’s designed to be written by speech recognition. There’s other interesting methods you could use to achieve the same result but this looks like one of the more accessible ones in terms of stuff you have to learn if you were to start writing code by voice.

                                              1. 14

                                                Yes, the mandate for AppleScript was that it be based on HyperTalk. (I worked on it, though not on the syntax.)

                                                The problem with “English-like” languages I’ve seen is that they’re still based on a fairly rigid grammar, while natural language is much more flexible and tolerant of ambiguity or mistakes. So AppleScript ended up a sort of “read-only” language: it reads pretty clearly, but to write it you have to follow the one way it expects a statement to be phrased. To me it felt harder to remember that than a typical programming syntax, a sort of uncanny-valley effect.

                                                1. 1

                                                  That’s been roughly my experience writing a little here and there.

                                                  I have wondered if part of the problem is just that I don’t use it often enough for its grammar to stick, but I’m inclined to take your sense that it is more fundamental, since I imagine you were reading and writing it regularly.

                                                  1. 1

                                                    What do you make of an approach like at story.ai where the language doesn’t really need to follow a strict grammar since it’s semi-structural?

                                                    1. 1

                                                      I’m unfamiliar with it … from a glance at the home page, it’s unclear what the language is like. But I think something less rigid would be great, as long as there are good ways to resolve things the parser can’t make out. Perhaps by asking questions, like “by ‘it’, did you mean … or …?”, then updating the source code to incorporate the clarification.

                                                1. 2

                                                  Might get some work done on a simple single channel/server WebIRC client to use as chat for a stream me and a few friends are planning. We had to use kiwiirc in an iframe the other times which caused some issues with Firefox, and I just don’t like using an external service for this kind of stuff. So this time I’m looking into hosting kiwiirc’s webircgateway on our servers and doing the chat myself.

                                                  Other than that, hiking and eating some polenta in a mountain refuge, and finishing my playthrough of all 2D Metroid games (except for Dread). Maybe I’ll start Metroid Prime too.

                                                  1. 23

                                                    I love the attitude: you probably shouldn’t take it apart, but it’s your hardware, so here is instruction how to do this correctly.

                                                    1. 18

                                                      That’s the sort of attitude that IMO has made Steam basically the least-evil software distribution store. Not a high bar, unfortunately, but it’s something.

                                                      1. 9

                                                        They’re doing some pretty good work with Proton too, they claim the whole Steam library will be playable on the Steam Deck when it releases. Maybe the day I can switch my gaming PC to Linux isn’t too far off.

                                                        1. 7

                                                          Yep, and it coincidentally started happening just around the time that Microsoft was saying that the MS Store would become the only way to install programs on Windows 10. Somehow, Microsoft eventually decided that was a bad move once Valve started putting serious work into Linux compat and helping game developers port their games.

                                                          Though it also means that about half my own game library works pretty darn well on Linux, so, can’t complain too much.

                                                          1. 4

                                                            Obviously it’s in their own self-interest to do it, and they’ve been pushing it so that they don’t have to pay Microsoft to preinstall Windows on their consoles, but it’s still a good thing overall.

                                                            1. 2

                                                              Yeah, I believe this is part of the reason Valve has embraced Linux since so long ago. Basically a bit of insurance against the dominance of Windows. I imagine they were well aware of the extreme dependence on MS playing nice (or whatever). I feel like I’ve read more about this very subject, will see if I can dig up any links or anything…

                                                            2. 6

                                                              Apparently they are getting anti-cheat software to be work in Linux too (EAC for example) which I thought I would never see happen in my lifetime.

                                                              1. 2

                                                                I’m really curious about this. The closest any of these kernel-mode anticheats has come to Linux before is EAC, where they had an extremely basic version briefly for the game Rust, and were also working on a version that worked in WIne. Those were cancelled the moment Epic Games bought them though, so I’m unsure if they’ve managed to build limited support for the drivers into Proton, or whether they’ve made a deal with Epic to get that wine version going again.

                                                            3. 5

                                                              GoG is [almost] DRM-free, so I try to buy most games there. I wonder how to balance all of the evils against one another to choose the “least-evil”.

                                                            4. 8

                                                              All things considered, it’s quite amazing that it just takes 8 screws to open the unit and 3 more to replace the thumbstick. Replacing the internal SSD takes 4 more screws but they strongly discourage people from changing it just because they claim that the one that comes installed on it is selected for (1) power consumption and (2) minimal interference with the wifi module (but they also upcharge for more storage, so maybe they just don’t want people to buy the cheap version and swap the ssd on the side).

                                                              It seems that they put some thought on trying to make the steam deck as serviceable as possible given its form factor.

                                                            1. 2

                                                              Having to learn how to handle a project myself at work. Kinda scary and being a person who doesn’t normally like to bother people for help too much it’s making me push my comfort zone. I should also try to set up code review for another project probably. I feel like I haven’t had much time to just spend at home chilling since like… the start of August and I’ve been feeling out of whack for a while now, so now that things have calmed down I’m looking forward to getting some good sleep.

                                                              1. 13

                                                                I have a fun story about this. One of the criteria to determine the kosherness of food baked in an oven outside of your own home is that the oven should be lit by a Rabbi, so for food coming out of a processing plant to be kosher there has to be a Rabbi touring all the industrial ovens and lighting them up. With the coming of COVID and increased safety regulations a client reached out to develop a system that would allow them to perform this process remotely, and finding a solution that works for both the company and the OU has been very hard… We had to come up with a lot of ideas and developed and released an app with a process that we thought was gonna work, but of course you can’t tell people anything and after seeing the full version there were concerns raised on both sides and the whole thing ended up getting scrapped in favor of just having the plant operator and the Rabbi videocall each other.