Author: Andy Balaam
-
Mini-rust in Rust 025: Parsing let mut
Continuing trying to get the simplest bit of real code we could think of to work, we need to finish off less-than-or-equals, and also make let mut work. You can find the source code at codeberg.org/andybalaam/milk and more of my stuff at artificialwor…
-
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 023: Refactor to share structure of the syntax tree
We are repeating ourselves with the SyntaxTree and TypedSyntaxTree enums. I thought the solution would be too complex, but on reflection it’s fine, so let’s share that code. You can find the source code at codeberg.org/andybalaam/milk and more of my s…
-
Rust tracing basic setup
I spent ages yesterday trying to figure out how to use Rust’s tracing library (and tracing-subscriber) for a very simple logging use-case. I wanted to use tracing because a) it’s rapidly becoming standard everywhere and b) I was using libraries that us…
-
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 021: Including type information in our syntax tree
We realised last time that our type checker needs to move on from just saying “yes” or “no” for whether our program is OK: we need to keep hold of the type information we work out, so we can use it for error messages and possibly even within the evalua…
-
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 018: Type checking, the happy path
This is it: we’re going to do some actual type-checking. We want to be able to identify that let x: i32 = 3.0; is wrong, but for now we’re going to check some things that are right. Type-checking this kind of thing is way easier than the full type infe…
-
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 015: Parsing a typed assignment
We want to have a go at some type-checking, so the first step is to write some code that causes a type error. We are going for let x: i32 = 3.0;. To do that, we need to be able to lex and parse the : i32 part… You can find the source code at codeber…
-
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 013: Fixing a bug in our lexer
We have been putting up with a weird problem with our lexer: up to now it requires white space between each token. But, last time we created a backtracking iterator that we can use to fix this problem, so let’s go ahead and do it. You can find the sou…
-
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 008: Refactoring our parser
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…
-
Message order in Matrix: right now, we are deliberately inconsistent
After lots of conversations with Element colleagues about message order in Matrix, and lots of surprises for me, I wanted to write down what I had learned before I forgot, and also write down some principles I think we should try to follow. A lot of th…
-
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 004: Refactoring our lexer
Refactoring our lexer, so all the awful things we did to make the tests pass are behind us. 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
-
Mini-rust in Rust 001: Lexing an int
Introducing my new series: writing a little Rust-like language in Rust. It will be an interpreted language, and (for now at least) it will try to work as much like real Rust as possible. Maybe one day it will be a useful language, but for now it’s pure…
-
Mini-rust in Rust 001: Lexing an int
Introducing my new series: writing a little Rust-like language in Rust. It will be an interpreted language, and (for now at least) it will try to work as much like real Rust as possible. Maybe one day it will be a useful language, but for now it’s pure…
-
Rust 101 – 53: Exercises for module G (q4)
Creating a custom Python extension in Rust. Series: Language basics, More syntax, Traits and generics, Building applications, Concurrency and parallelism, Trait objects, Async, Unsafe, FFI This section (FFI): 49: FFI, 50: Exercise 1, 51: Exercise 2, 5…
-
Rust 101 – 52: Exercises for module G (q3)
Using cargo-bindgen to generate bindings, automating what we need to do to use existing C code inside a Rust project. Series: Language basics, More syntax, Traits and generics, Building applications, Concurrency and parallelism, Trait objects, Async, …
-
Rust 101 – 51: Exercises for module G (q2)
Trying out calling Rust code from with a C program (should help with calling Rust from any compiled-to-native language too). Series: Language basics, More syntax, Traits and generics, Building applications, Concurrency and parallelism, Trait objects, …
-
Rust 101 – 50: Exercises for module G (q1)
Calling C code from Rust, Rust code from C-family languages, using cargo-bindgen, and creating Python extensions. Series: Language basics, More syntax, Traits and generics, Building applications, Concurrency and parallelism, Trait objects, Async, Unsa…
-
Rust 101 – 49: Foreign function interfaces (interacting with other languages)
Calling C code from Rust, Rust code from C-family languages, using cargo-bindgen, and creating Python extensions. Series: Language basics, More syntax, Traits and generics, Building applications, Concurrency and parallelism, Trait objects, Async, Unsa…
-
19 years of blogging
As you may have noticed, I recently upgraded my blog from WordPress to Zola. This means that my home computer does the work of rendering the pages to HTML once, and my web server only has to provide the rendered HTML to your browser. This should mean t…
-
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 – 48: Exercises for module F (q3)
Implementing our own Result type that has a specific memory layout, so it can be used by Roc code. Series: Language basics, More syntax, Traits and generics, Building applications, Concurrency and parallelism, Trait objects, Async, Unsafe This section…
-
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…
-
Heads-up: moving away from WordPress
This is an early warning: I am actively working to move this blog away from WordPress, to a static site created using Zola. I am planning to keep as many URLs working as humanly possible, and the RSS feed URL should be unchanged. (With any luck, the pe…
-
Heads-up: moving away from WordPress
This is an early warning: I am actively working to move this blog away from WordPress, to a static site created using Zola. I am planning to keep as many URLs working as humanly possible, and the RSS feed URL should be unchanged. (With any luck, the permalinks inside will also be unchanged, but I … Continue reading Heads-up: moving away from WordPress
-
Rust 101 – 46: Exercises for module F (q1)
Coding up a linked list based on raw pointers in Rust. 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 un…
-
Rust 101 – 46: Exercises for module F (q1)
Coding up a linked list based on raw pointers in Rust. 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: Undefined behaviour, 45: Unsafe types, 46: Exercise 1 Links: Slides: Rust 101 – module F Exercises: … Continue reading Rust 101 – 46: Exercises for module F (q1)
-
Rust 101 – 45: Unsafe types and examples
Looking through some of the types of code you will be working with if you’re doing unsafe Rust, and some of the unsafe types you might want to use. Series: Language basics, More syntax, Traits and generics, Building applications, Concurrency and paral…
-
Rust 101 – 45: Unsafe types and examples
Looking through some of the types of code you will be working with if you’re doing unsafe Rust, and some of the unsafe types you might want to use. 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 … Continue reading Rust 101 – 45: Unsafe types and examples
-
Rust 101 – 44: Undefined behaviour
If you write unsafe Rust, you need to reason about “undefined behaviour”. We talk through what that means, and try to develop an intuition about why we can’t predict how our program will behave if we don’t follow the rules. Series: Language basics, Mo…
-
Rust 101 – 44: Undefined behaviour
If you write unsafe Rust, you need to reason about “undefined behaviour”. We talk through what that means, and try to develop an intuition about why we can’t predict how our program will behave if we don’t follow the rules. Series: Language basics, More syntax, Traits and generics, Building applications, Concurrency and parallelism, Trait objects, … Continue reading Rust 101 – 44: Undefined behaviour
-
Rust 101 – 43: The two meanings of “unsafe” in Rust
The unsafe keyword in Rust means two things: “You must read the docs!” or “I promise I read the docs and followed the rules!”. Series: Language basics, More syntax, Traits and generics, Building applications, Concurrency and parallelism, Trait objects…
-
Rust 101 – 43: The two meanings of “unsafe” in Rust
The `unsafe` keyword in Rust means two things: “You must read the docs!” or “I promise I read the docs and followed the rules!”. 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 Links: Slides: Rust 101 … Continue reading Rust 101 – 43: The two meanings of “unsafe” in Rust
-
Rust 101 – 42: Why do we need unsafe?
There is a special mode in Rust programs called unsafe – why do we need it? Series: Language basics, More syntax, Traits and generics, Building applications, Concurrency and parallelism, Trait objects, Async, Unsafe This section (Async): 42: Why unsaf…
-
Rust 101 – 42: Why do we need unsafe?
There is a special mode in Rust programs called unsafe – why do we need it? Series: Language basics, More syntax, Traits and generics, Building applications, Concurrency and parallelism, Trait objects, Async, Unsafe This section (Async): 42: Why unsafe? Links: Slides: Rust 101 – module F Exercises: artificialworlds.net/presentations/rust-101/exercises/F-safe-unsafe/mod.html The course materials for this series are … Continue reading Rust 101 – 42: Why do we need unsafe?
-
Rust 101 – 41: Exercises for module E (q2b)
Writing a mini client to connect to our async Rust chat server. Series: Language basics, More syntax, Traits and generics, Building applications, Concurrency and parallelism, Trait objects, Async, Unsafe This section (Async): 34: What is async?, 35: F…
-
Rust 101 – 41: Exercises for module E (q2b)
Writing a mini client to connect to our async Rust chat server. Series: Language basics, More syntax, Traits and generics, Building applications, Concurrency and parallelism, Trait objects, Async This section (Async): 34: What is async?, 35: Futures, 36: async/await, 37: Runtimes, 38: Exercise E1a, 39: Exercise E1b, 40: Exercise E2a, 41: Exercise E2b Links: Slides: … Continue reading Rust 101 – 41: Exercises for module E (q2b)
-
Rust 101 – 40: Exercises for module E (q2a)
Writing a little chat server in async Rust. Series: Language basics, More syntax, Traits and generics, Building applications, Concurrency and parallelism, Trait objects, Async, Unsafe This section (Async): 34: What is async?, 35: Futures, 36: async/aw…
-
Rust 101 – 40: Exercises for module E (q2a)
Writing a little chat server in async Rust. Series: Language basics, More syntax, Traits and generics, Building applications, Concurrency and parallelism, Trait objects, Async This section (Async): 34: What is async?, 35: Futures, 36: async/await, 37: Runtimes, 38: Exercise E1a, 39: Exercise E1b, 40: Exercise E2a, 41: Exercise E2b Links: Slides: Rust 101 – module … Continue reading Rust 101 – 40: Exercises for module E (q2a)
-
Rust 101 – 39: Exercises for module E (q1b)
Writing a one-shot queue using async Rust, this time with a little less help. Series: Language basics, More syntax, Traits and generics, Building applications, Concurrency and parallelism, Trait objects, Async, Unsafe This section (Async): 34: What is…
-
Rust 101 – 39: Exercises for module E (q1b)
Writing a one-shot queue using async Rust, this time with a little less help. Series: Language basics, More syntax, Traits and generics, Building applications, Concurrency and parallelism, Trait objects, Async This section (Async): 34: What is async?, 35: Futures, 36: async/await, 37: Runtimes, 38: Exercise E1a, 39: Exercise E1b, 40: Exercise E2a, 41: Exercise E2b … Continue reading Rust 101 – 39: Exercises for module E (q1b)
-
Rust 101 – 38: Exercises for module E (q1a)
Writing our own multi-producer-single-consumer (MPSC) queue using async Rust. Series: Language basics, More syntax, Traits and generics, Building applications, Concurrency and parallelism, Trait objects, Async, Unsafe This section (Async): 34: What is…
-
Rust 101 – 38: Exercises for module E (q1a)
Writing our own multi-producer-single-consumer (MPSC) queue using async Rust. Series: Language basics, More syntax, Traits and generics, Building applications, Concurrency and parallelism, Trait objects, Async This section (Async): 34: What is async?, 35: Futures, 36: async/await, 37: Runtimes, 38: Exercise E1a, 39: Exercise E1b, 40: Exercise E2a, 41: Exercise E2b Links: Slides: Rust 101 – … Continue reading Rust 101 – 38: Exercises for module E (q1a)
-
Rust 101 – 37: Async runtimes
We talked about how Futures have poll methods, but who calls them? That is the job of the runtime. We talk about how to launch your async code and how to choose the right runtime, and then we have a very brief look at some Web frameworks that are based…
-
Rust 101 – 37: Async runtimes
We talked about how Futures have poll methods, but who calls them? That is the job of the runtime. We talk about how to launch your async code and how to choose the right runtime, and then we have a very brief look at some Web frameworks that are based on async Rust. Series: Language … Continue reading Rust 101 – 37: Async runtimes
-
Rust 101 – 36: What async and await really do
Attempting to explain as slowly as possible what actually happens when the compiler finds an async function containing awaits: it writes a poll method for you to create something that implements Future. The generated poll method polls the Futures you a…
-
Rust 101 – 36: What async and await really do
Attempting to explain as slowly as possible what actually happens when the compiler finds an async function containing awaits: it writes a poll method for you to create something that implements Future. The generated poll method polls the Futures you asked to await, in order. The interesting bit is that this generated thing that implements … Continue reading Rust 101 – 36: What async and await really do
-
Rust 101 – 35: Futures
Exploring what a Future is in async Rust and how we could manually write code that polls futures. Normally, we avoid this manual work by using the async and await keywords, but looking into this helps us understand what those keywords really do. Serie…
-
Rust 101 – 35: Futures
Exploring what a Future is in async Rust and how we could manually write code that polls futures. Normally, we avoid this manual work by using the `async` and `await` keywords, but looking into this helps us understand what those keywords really do. Series: Language basics, More syntax, Traits and generics, Building applications, Concurrency and … Continue reading Rust 101 – 35: Futures
-
Rust 101 – 34: What is async?
What async programming is and what it looks like in Rust. Series: Language basics, More syntax, Traits and generics, Building applications, Concurrency and parallelism, Trait objects, Async, Unsafe This section (Async): 34: What is async?, 35: Futures…
-
Rust 101 – 34: What is async?
What async programming is and what it looks like in Rust. Series: Language basics, More syntax, Traits and generics, Building applications, Concurrency and parallelism, Trait objects, Async This section (Async): 34: What is async?, 35: Futures, 36: async/await, 37: Runtimes, 38: Exercise E1a, 39: Exercise E1b, 40: Exercise E2a, 41: Exercise E2b Links: Slides: Rust … Continue reading Rust 101 – 34: What is async?
-
Rust 101 – 33: Exercises for module D (q3)
Following through an exercise using a trait object with dynamic dispatch to choose different behaviour at runtime. Series: Language basics, More syntax, Traits and generics, Building applications, Concurrency and parallelism, Trait objects, Async, Uns…
-
Rust 101 – 33: Exercises for module D (q3)
Following through an exercise using a trait object with dynamic dispatch to choose different behaviour at runtime. Series: Language basics, More syntax, Traits and generics, Building applications, Concurrency and parallelism, Trait objects, Async This section (Trait objects): 28: Dynamic dispatch, 29: Object safety, 30: Patterns, 31: Exercise D1, 32: Exercise D2, 33: Exercise D3 Links: … Continue reading Rust 101 – 33: Exercises for module D (q3)
-
Elected to the Matrix Foundation Governing Board!
I am really excited to say I was elected to the Governing Board of the Matrix Foundation! I was really surprised because there were lots of people standing, and the quality of the candidates was very high, but I am one of the lucky ones. I hope I can d…
-
Elected to the Matrix Foundation Governing Board!
I am really excited to say I was elected to the Governing Board of the Matrix Foundation! I was really surprised because there were lots of people standing, and the quality of the candidates was very high, but I am one of the lucky ones. I hope I can do a decent job of helping … Continue reading Elected to the Matrix Foundation Governing Board!
-
Rust 101 – 32: Exercises for module D (q2)
Trying out the typestate pattern by tracking the state of a 3D printer by changing our type instead of updating a variable whenever it changes. Series: Language basics, More syntax, Traits and generics, Building applications, Concurrency and paralleli…
-
Rust 101 – 31: Exercises for module D (q1)
Some good patterns to follow in your code e.g. “newtype”, “typestate” and one to avoid. Series: Language basics, More syntax, Traits and generics, Building applications, Concurrency and parallelism, Trait objects, Async, Unsafe This section (Trait obj…
-
Rust 101 – 30: Good patterns and not so good
Some good patterns to follow in your code e.g. “newtype”, “typestate” and one to avoid. Series: Language basics, More syntax, Traits and generics, Building applications, Concurrency and parallelism, Trait objects, Async, Unsafe This section (Trait obj…
-
Rust 101 – 29: Trait objects and object safety
Trying to explain why the rules for object safety are the way they are, and how to create and use a trait objects. Series: Language basics, More syntax, Traits and generics, Building applications, Concurrency and parallelism, Trait objects, Async, Uns…
-
Rust 101 – 28: Dynamic dispatch
Explaining how to hold on to something even when we don’t know its exact type, just what trait it implements. Series: Language basics, More syntax, Traits and generics, Building applications, Concurrency and parallelism, Trait objects, Async, Unsafe T…
-
New home for my videos: video.infosec.exchange
Huge thanks to Micah Scott for hosting my videos on diode.zone until recently. My videos are moving to video.infosec.exchange/a/andybalaam – please update all your feeds. (Thanks to Jerry Bell for running that – please donate!) You can follow this blog…
-
Why I won’t link to AI resources
I received a very kind email today from someone who had found my page Resources for year 6 teachers on coding and programming helpful, and wanted to suggest another link for me to add, about AI resources. I’m sure it was a helpful and useful link, but …
-
Rust 101 – 27: Exercises for module C (q2)
Implementing a simplified form of Mutex. Series: Language basics, More syntax, Traits and generics, Building applications, Concurrency and parallelism, Trait objects, Async, Unsafe This section (Concurrency and parallelism): 24: Parallelism, 25: Threa…
-
Rust 101 – 26: Exercises for module C (q1)
Searching across multiple documents in parallel with Rayon. Series: Language basics, More syntax, Traits and generics, Building applications, Concurrency and parallelism, Trait objects, Async, Unsafe This section (Concurrency and parallelism): 24: Par…
-
Choosing who to vote for in the 2024 UK General Election
Update: I just discussed this with my son and I really want to emphasise: It does make a difference who is in power. The previous Labour government significantly improved primary education and many other public services. Don’t lose hope! Here are the c…
-
Rust 101 – 25: Threads, Mutexes, channels, Send and Sync
How to spawn threads and deal with lifetimes, how to send or share state across threads, and what Send and Sync mean. Series: Language basics, More syntax, Traits and generics, Building applications, Concurrency and parallelism, Trait objects, Async, …
-
Rust 101 – 24: Parallelism and Rayon
What concurrency and parallelism are, a brief intro to Rayon, and a quick note on closures. Series: Language basics, More syntax, Traits and generics, Building applications, Concurrency and parallelism, Trait objects, Async, Unsafe This section (Concu…
-
Rust 101 – 23 Exercises for module B (q3)
Testing, benchmarking and optimising a small program that plays FizzBuzz. Series: Language basics, More syntax, Traits and generics, Building applications, Concurrency and parallelism, Trait objects, Async, Unsafe This section (Building applications):…
-
Rust 101 – 22 Exercises for module B (q2)
Building a command-line quiz application to bed in our knowledge about crates, modules and serialisation. All done using test-driven development. Series: Language basics, More syntax, Traits and generics, Building applications, Concurrency and paralle…
-
Rust 101 – 21 Exercises for module B (q1)
Going through an exercise on serialization with serde. Series: Language basics, More syntax, Traits and generics, Building applications, Concurrency and parallelism, Trait objects, Async, Unsafe This section (Building applications): 18: Dependencies, …
-
Rust 101 – 20: Unit, integration and benchmark tests
How to write unit tests in your Rust code, and some quick pointers on writing integration and benchmark tests. Series: Language basics, More syntax, Traits and generics, Building applications, Concurrency and parallelism, Trait objects, Async, Unsafe …
-
Standing for the Matrix Governing Board
I have decided to stand for election to the Matrix Governing Board, which is a brand new body which advises and oversees the work of the Matrix Foundation. I will stand as an Individual Member, not representing a company or project. Contents: Purpose …
-
Rust 101 – 19: Creating a nice API
Tips and rules for writing good APIs that are easy for other people to use. Try to make them Unsurprising, Flexible, and Obvious. Series: Language basics, More syntax, Traits and generics, Building applications, Concurrency and parallelism, Trait obje…
-
Rust 101 – 18: Dependencies and Cargo.toml
How to describe details of your Rust project with a Cargo.toml file, and how to find and add dependencies (other people’s code). Series: Language basics, More syntax, Traits and generics, Building applications, Concurrency and parallelism, Trait objec…
-
Rust 101 – 17: Exercises for module A3 (part 2)
Finishing off the exercises on Rust traits, designing a customised version of Vec. Series: Language basics, More syntax, Traits and generics, Building applications, Concurrency and parallelism, Trait objects, Async, Unsafe This section (Traits and gen…
-
Automated backups from Signal to Nextcloud
DON’T DO THIS: the Signal app has the ability to make daily backups of your messages, and when you choose a folder to backup into, you can choose “Nextcloud” as the device, then choose a Nextcloud folder to back up to. Don’t do that. Although the above…
-
Rust 101 – 16: Exercises for module A3 (part 1)
Going through some exercises on Rust traits, designing a customised version of Vec. Series: Language basics, More syntax, Traits and generics, Building applications, Concurrency and parallelism, Trait objects, Async, Unsafe This section (Traits and ge…
-
One import per line is best
Rust has a feature where if you import two things from the same module you can abbreviate it like this: use mypkg::{MyStruct1, MyStruct2}; If you prefer, you can keep them separate, like this: use mypkg::MyStruct1; use mypkg::MyStruct2; I do prefer. St…
-
Rust 101 – 15: Lifetime bounds
This time we tackle one of the most tricky areas for a new Rust programmer: lifetimes. The key point is that when we add lifetime bounds (‘a or similar) to a function signature, this is not to help Rust compile our function: it’s to help Rust understan…
-
Rust 101 – 14: Some standard library traits
A tour of some of the most interesting traits in the standard library including Add etc. to overload operators, Sized, Sync and Send for telling the compiler special things about your type, Clone and Copy for copying things, Into and From for convertin…
-
Rust 101 – 13: Type Parameters and Associated Types
Following on from video 12, looking at how to add type information to traits, to make them flexible enough to describe generic code with different types, for example how to add a u32 to a u64 and return a u128, without defining a whole new trait for ev…
-
Rust 101 – 12: Traits
Explaining what a trait is, and how to use it. A trait is a bit like an Interface in Java or Go, or an Abstract Base Class in C++ or Python, but it can be used to define behaviour at compile-time as well as at run-time. We go through an example of why …
-
Rust 101 – 11: Exercises for module A2
Going through some exercises on Rust ownership, references, slices and error handling. Series: Language basics, More syntax, Traits and generics, Building applications, Concurrency and parallelism, Trait objects, Async, Unsafe This section (More synta…
-
[Fixed in FF 123] Deleting an Indexed DB store can be incredibly slow on Firefox
Update: as confirmed in the bug I logged, this was fixed in Firefox 123! See also: Keep your Indexed DB keys and values small if you want good performance! and Don’t store arrays of numbers in Indexed DB – use base64 instead. We had performance problem…
-
Don’t store normal arrays of numbers in Indexed DB – use UInt8Array instead
Following on from Keep your Indexed DB keys and values small if you want good performance!, here is another thing I’ve learned about Indexed DB performance (in July 2024): Update: Thanks to richvdh, we now know UInt8Array is much better than base64! If…
-
Rust 101 – 10: Strings
What a String is in Rust, and how they differ from &str. Strings are resizeable arrays of bytes that are guaranteed to be in UTF-8 format. &strs are references to chunks of bytes that are also guaranteed to be in UTF-8 format. If you want to le…