Category: Uncategorized

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