Author: Andy Balaam
-
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 permalinks inside will also be unchanged, but I … Continue reading Heads-up: moving away from WordPress
-
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…
-
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 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 – 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 – 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 – 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 – 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 on async Rust. Series: Language … Continue reading Rust 101 – 37: Async runtimes
-
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 – 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. Series: Language basics, More syntax, Traits and generics, Building applications, Concurrency and … Continue reading Rust 101 – 35: Futures
-
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 – 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 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)
-
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…
-
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!
-
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…
-
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…
-
Keep your Indexed DB keys and values small if you want good performance!
In our work recently on Element Web (specifically attempting to replace our encryption code with our cross-platform Rust implementation) we’ve noticed some strange behaviour with the performance of our Indexed DB queries. We’ve been aware of some slowd…
-
Rust 101 – 9: Vecs, Boxes and slices
Explanation of some of the most commonly used types in Rust: Vecs, which store lists of items, Boxes that allow us to own things that we keep on the heap, and slices that are a way of referring to parts of Vecs or arrays without owning them. Series: L…
-
Rust 101 – 8: Writing methods using impl blocks
This time we discuss how to add methods to structs and enums, using impl blocks. Methods work similarly to other languages, but it might be a surprise that they can be defined inside separate blocks, and in fact they can be defined in multiple differen…
-
Rust 101 – 7: Error handling with panic and Result
We learnt about enums and generics last time, which means we’re ready to talk about Result, which is a really nice way of handling errors in Rust, that allows you to be very explicit about what went wrong, but also with a very compact syntax using the …
-
Letter to my MP: using starvation as a weapon
Dear Ben Spencer, The behaviour of Hamas on 7th October and afterwards is inexcusable, and is rightly condemned by our government. I believe that the ongoing behaviour of the Israeli government in response to these attacks is inexcusable, and should be…
-
Santa Circles 0.3 is out!
Santa Circles 0.3 is all new and shiny! santacircles.artificialworlds.net (It’s a secret-santa-style gift exchange web site.) Don’t worry, it looks exactly how it did last year, except there is a tiny “Forgot password?” link you can click if you need …
-
Follow this blog on the fediverse!
If I’ve set it up right, you can now follow this blog on Mastodon and other fediverse platforms! Search for this user: @blog@www.artificialworlds.net
-
Rust 101 – 6: Structs and Enums
Continuing our review of the things you need in Rust to write programs – grouping together data using structs, and allowing multiple possibilities with enums. We look at how to decide which thing you’ve got with the match keyword, and review a very pop…
-
Rust 101 – 5: References
Starting some more advanced Rust programming ideas by looking at references – the ability to “borrow” values and refer to them without taking ownership. We look at mutable and immutable references, and the rules about references that prevent us ever ha…
-
Rust 101 – 4: Exercises for module A1
Going through some exercises on basic Rust syntax and ownership. Series: Language basics, More syntax, Traits and generics, Building applications, Concurrency and parallelism, Trait objects, Async, Unsafe This section (Language basics): 1: Intro, 2: L…
-
Rust 101 – 3: Memory and ownership
Continuing on Rust programming basics by looking at ownership and memory management, including the stack and the heap: what they are, how they differ, and why you need to care. For more help on ownership and the stack and the heap, try Chapter 4 of th…
-
Rust 101 – 2: Language basics
An introduction to the Rust language basics. Series: Language basics, More syntax, Traits and generics, Building applications, Concurrency and parallelism, Trait objects, Async, Unsafe This section (Language basics): 1: Intro, 2: Language basics, 3: M…
-
Rust 101 – 1: Course intro
Introducing the Rust 101 series and how to install Rust. Series: Language basics, More syntax, Traits and generics, Building applications, Concurrency and parallelism, Trait objects, Async, Unsafe This section (Language basics): 1: Intro, 2: Language …
-
Combining two function types with & (ampersand) in TypeScript (intersection)
Combining interfaces/objects with & When you combine two types in TypeScript with & (ampersand), it is called an Intersection Type. For example: interface Particle { mass: number; } interface Wave { wavelength: number; } type Both = P…
-
Accessing services on the host from a Docker container or a Podman one
I use Podman to provide Docker-like stuff on my dev machine without effectively being root. Talking to the container host in Docker There is a little trick for accessing HTTP services on the container host in Docker: you add –add-host host.docker.inte…
-
Why I’m voting tactically against you – letter to my Conservative MP
Here’s the letter I just sent to my MP. Feel free to use it in full or in part. Dear Ben Wallace, Last night I made the decision to vote tactically against you at the next election, and I felt I owed you an explanation. I now feel that any of the likel…
-
Rust WASM hello world – no need for webpack!
Up to now I’ve been following the official guide and using webpack to package my Rust+WASM code to run in a browser. But today I found out there is no need for webpack at all! This makes development much faster, with many fewer dependencies. Setup Befo…
-
Estimating software tasks and stories: avoid time-based estimates
I was recently asked what I thought of using time-based estimates when tracking software tasks. TLDR: I think it’s a terrible idea that can hurt your software by introducing bugs and burning out developers. I think using time-based estimates is pretty …