Category: Uncategorized

  • Coding JezzBall in Rust+WASM

    I wrote a game framework a while back and this is the second game I’ve written with it. It’s based on “JezzBall”, which was one name for the classic game where you draw walls to trap in bouncing balls. The code is at https://codeberg.org/andybalaam/je…

  • LLMs produce plausible noise

    I know everyone and their dog is writing about LLMs, and since I refuse to use them you probably shouldn’t listen to me, but I have recently solidified some of my thinking about them and thought it might be useful to share. None of this makes any diffe…

  • Parsing SGF files for fun

    SGF files describe a board game like Go, including all the possible variations someone wants to talk about. Let’s write Rust to parse one of these files! They look something like this: (;FF[4]GM[1]SZ[19];B[aa];W[bb];B[cc];W[dd];B[ad];W[bd]) Follow me …

  • Keep the faith

    This is mainly a message to myself. I have spent the last few weeks feeling more and more depressed about “the tech industry”. I am sad that social media companies are manipulating us, making us angry and ignorant. I am sad that AI is becoming more per…

  • A full (slow) solution to the Billion Row Challenge

    We’ve been picking off small sub-tasks of the Billion Row Challenge, which asks us to summarise a large amount of data as quickly as we can. This time we complete the whole challenge, but in a slow way, to make sure we understand it. In future videos w…

  • The billion row challenge: do we have a bug?

    A couple of people contacted me with feedback about the SIMD implementation we used to find newlines in the billion-row file. One suggested a possible bug (shock!) and one suggested a way that might be more efficient. We’ll take a look at both, obvious…

  • Building a Rust commandline tool: a towncrier clone

    Enthusiastically embracing test-driven development as always, we attempt to write a minimal clone of a useful tool, towncrier, which allows us to build changelogs out of individual “newsfragment” files. By the end we have the outline of a decent soluti…

  • The billion row challenge: splitting lines using SIMD in Rust

    I was scared to do it, but it was actually fine! This time we look at the quickest way to split up massive text files into separate lines, first by implementing our own zero-copy version of BufReader::lines and later using SIMD, which allows us to proc…

  • Rust: reading very large files for the billion row challenge

    Checking out whether memmap can help us read very large files as fast as possible, and wondering how wc manages to be so fast. This is the next bit of the Billion Row Challenge, and probably the closest part to black magic. Follow me on mastodon: @and…

  • Parsing whole lines of the Billion Row Challenge

    Excitingly, our temperature parser can be trivially extended to find the start of the temperature, so we can use it to parse the whole line! Follow me on mastodon: @andybalaam@mastodon.social

  • Improving our billion-row parsers and benchmarks

    Improving the benchmarks of our Billion Row Challenge, and playing with some improved implementations. Follow me on mastodon: @andybalaam@mastodon.social

  • Making our own String type in Rust

    Implementing our own versions of standard types can help us understand how they work a bit better. This time we’ll make a new string type called AsciiString, and make it handle all its memory itself. Lots of unsafe, and probably lots of bugs! Follow m…

  • Writing a Snake game in Rust/WASM

    Last time we did the hard work, so this time we can focus directly on writing a fun game of Snake using pure Rust, running in a browser canvas via WASM. Follow me on mastodon: @andybalaam@mastodon.social

  • Talking to localhost from inside an Android emulator

    If you’re developing an Android application that talks to a server, you may well want to run the server locally and talk to it from your Android emulator. If you point at localhost, this means the Android device itself, not the server running on your c…

  • Rust: compiling to WASM to make a browser-based game using canvas

    I love writing Rust, and I love writing simple games, so let’s combine the two by showing how to make a tiny game framework with these properties: 99% of the code is Rust, compiled to WASM the game runs in any non-ancient Web browser the screen drawin…

  • Billion row challenge: parsing temperatures fast(ish)

    I watched Jon Gjengset taking on the one billion row challenge and got interested in one small corner of it: parsing temperatures, and in particular parsing temperatures in a “branchless” style – with no if statements – to help the CPU run the code as …

  • Rust: building arbitrary precision integers (badly)

    I thought it might be quite straightforward to show the basics of how we could design a “BigInt” type of struct. It turns out it was more involved than I thought it would be, but we got a little way into it. Maybe we can continue in a later video? Fol…

  • FizzBuzz 2: FizzBuzz Harder

    I implemented FizzBuzz before, but in retrospect I don’t like what I did. I especially don’t like my tests. So let’s try to do better, and talk about why it’s better. Follow me on mastodon: @andybalaam@mastodon.social

  • Turning it off and on again

    You probably shouldn’t read this post. It breaks several of the top rules in blog post content authorship: apologising for not posting in a while, explaining why, and promising to post more in the future. So if that sounds dull, you can (and should)…

  • Mini-rust in Rust 039: Spans should be ranges

    We’ve been tracking the location of a token in the file using a pair of numbers, but Rust has a better way: a Range. After some debate and wandering, we make the code a little better with this change. The interlude music is Blood, Collateral, & Oth…

  • Mini-rust in Rust 038: Avoiding a String allocation for each token

    Last time I described what I tried to do with removing the extra String stored in each Token. This time, having figured out a workaround, we go ahead and remove them. Of course, it’s more complicated than we expected. You can find the source code at c…

  • Mini-rust in Rust 037: Complex expressions in mutation statements

    We left a lot of gaps while we were building towards some working code. The first to tackle is allowing complex expressions on the right-hand side of mutation statements. You can find the source code at codeberg.org/andybalaam/milk and more of my stuf…

  • Mini-rust in Rust 036: Evaluating code blocks

    Blocks of code surrounded by braces are valid statements in Rust – it’s just a small change to our existing code to be able to evaluate them. You can find the source code at codeberg.org/andybalaam/milk and more of my stuff at artificialworlds.net

  • Mini-rust in Rust 034: Our first program, actually working

    It’s finally here – our mini-program to calculate factorials, featuring a while loop and mutable variables, is working! You can find the source code at codeberg.org/andybalaam/milk and more of my stuff at artificialworlds.net

  • Mini-rust in Rust 033: Evaluating operators like plusequals and timesequals

    Our while loop is close … first we need to be actually calculate new values for variables when we see a += or *= operator. You can find the source code at codeberg.org/andybalaam/milk and more of my stuff at artificialworlds.net

  • Mini-rust in Rust 032: Supporting a Unit type and type checking mutations

    We’ve been putting off creating a Unit type, (), and we need our type checker to be OK with += etc. We are getting excitingly close to having a working while loop! You can find the source code at codeberg.org/andybalaam/milk and more of my stuff at ar…

  • Mini-rust in Rust 029: Parsing plus-equals

    This is the first time we are handling modifying variables, so our current “assignment” parser, which looks for a let keyword is no help – we need a new bit of parsing for modification statements. You can find the source code at codeberg.org/andybalaa…

  • Standing again for the Matrix Governing Board

    I am standing for re-election to the Matrix Governing Board (see the election announcement). The Governing Board advises and oversees the work of the Matrix Foundation. I will stand as an Individual Member again, not representing a company or project. …

  • Testing nonexistence

    Testing that something is not there can be unreliable Today I am writing a test that something does not happen, like this: Given that the A setting is "off" When I start the app Then the warning about A being on IS NOT displayed It’s quite…

  • Mini-rust in Rust 026: Parsing an empty while loop

    The little real-world snippet we are trying to get working includes a while loop – let’s try to get it to parse. For now, only if the actual loop body is empty. You can find the source code at codeberg.org/andybalaam/milk and more of my stuff at artif…

  • Mini-rust in Rust 024: Lexing the <= sign

    Now we’re going to try and get a little code snippet that calculates factorials to work. First up: lexing the <= sign! You can find the source code at codeberg.org/andybalaam/milk and more of my stuff at artificialworlds.net

  • Mini-rust in Rust 022: Stop lying about types in errors

    Now that we have the types we calculated in our syntax tree, use them to stop faking it in error messages – replace a hard-coded “integer” with the actual type of the expression we are talking about. You can find the source code at codeberg.org/andyba…

  • Mini-rust in Rust 020: Gaps in our type checker

    The type checker is passing our unit tests, but it’s stopping our language from actually working. Time to fill in the gaps. You can find the source code at codeberg.org/andybalaam/milk and more of my stuff at artificialworlds.net

  • Mini-rust in Rust 019: Type checking an actual type error

    We have a plan for what error message we should get when we try to write code like let x: i32 = 3.0;. Let’s try to make it a reality! You can find the source code at codeberg.org/andybalaam/milk and more of my stuff at artificialworlds.net

  • Mini-rust in Rust 017: Handling float literals

    We’re still on a mission to do some type-checking, and our plan is to allow writing let x: i32 = 3.0;, then produce a type error because 3.0 is not an integer that can be stored in an i32. The last piece of the puzzle is to be able to handle the 3.0 bi…

  • Mini-rust in Rust 016: Tidying our parser

    We left our parser in an awful mess after the last video, so we’re going to tidy it up a bit and make it easier to understand. You can find the source code at codeberg.org/andybalaam/milk and more of my stuff at artificialworlds.net

  • Mini-rust in Rust 014: Evaluating an assignment

    Finally, we are going to execute a real piece of code that actually looks like a programming language! We are setting a variable to a value, and then using that variable later on… You can find the source code at codeberg.org/andybalaam/milk and more…

  • Mini-rust in Rust 012: Parsing with backtracking

    We’ve built a toy parser, but it’s not going to last us. We need to make it a bit more proper. Specifically, we need to be able to look ahead, and then backtrack. You can find the source code at codeberg.org/andybalaam/milk and more of my stuff at art…

  • Mini-rust in Rust 011: Parsing an assignment plus expression

    Last time we lexed an assignment statement. This time: parsing it, so we’re ready to execute it! You can find the source code at codeberg.org/andybalaam/milk and more of my stuff at artificialworlds.net

  • Mini-rust in Rust 010: Lexing an assignment

    We’re ready to lex a proper statement: specifically a “let” statement that will give a variable its value. You can find the source code at codeberg.org/andybalaam/milk and more of my stuff at artificialworlds.net

  • Mini-rust in Rust 009: Handling parsing errors

    Our parser kinda works, but it needs some work to be less terrible. We’ve realised we did a few things in awkward or wrong ways, so let’s fix them before they get out of hand. You can find the source code at codeberg.org/andybalaam/milk and more of my…

  • Mini-rust in Rust 007: Evaluating an operation

    Now that we can parse things, let’s evaluate them. By the end of this, we should be able to use our little language as a mini-calculator (only for adding up so far though). You can find the source code at codeberg.org/andybalaam/milk and more of my st…

  • Mini-rust in Rust 006: Parsing an operation

    We’re finally ready to parse things! Our lexer can do almost enough to allow us to handle “3 + 5”, so we’ll make that ready, and then parse that expression into a syntax tree. You can find the source code at codeberg.org/andybalaam/milk and more of my…

  • Mini-rust in Rust 005: Making our lexer an iterator

    Our lex function returns an iterator, but in the implementation we were faking it. Let’s do it properly. You can find the source code at codeberg.org/andybalaam/milk and more of my stuff at artificialworlds.net

  • Mini-rust in Rust 003: Much prettier errors

    More of the very basic structure of our interpreter: making the error messages from the lexer point at the exact line of code, in a pretty way. You can find the source code at codeberg.org/andybalaam/milk and more of my stuff at artificialworlds.net

  • Mini-rust in Rust 002: Errors while lexing

    Continuing writing our mini-rust in Rust. Figuring out how to throw an error when lexing goes wrong. You can find the source code at codeberg.org/andybalaam/milk and more of my stuff at artificialworlds.net

  • Deployment is important

    I just evaluated and installed software for providing comments and statistics for this blog. Here are my experiences of the deployment process: A Python comment system. Uses one of the 17 outdated installer/packaging systems for Python (none of which…

  • Rust 101 – 47: Exercises for module F (q2)

    Wrapping a C function with safe Rust code. Series: Language basics, More syntax, Traits and generics, Building applications, Concurrency and parallelism, Trait objects, Async, Unsafe This section (Async): 42: Why unsafe?, 43: Meaning of unsafe, 44: Un…