Rust Beyond Systems Programming

The case that Rust is a good choice for ordinary applications — tools, services, desktop software — and not only for systems work.

14 parts published so far.

Parts

  1. Write like TypeScript, deploy like Go

    I learned Rust by building a bank in it, having never written a line of it before, while the corridor explained that Rust needs PhD-level programmers. What actually changed was not safety. It was relief: I stopped spending my day avoiding mistakes and got to spend it solving the problem.

  2. Put it next to what you already write

    The things you actually like about TypeScript, Java, Python and Go — unions, Optional, streams, lambdas, promises, channels, one command that builds everything — and where every one of them lives in Rust. No complaints in this one. Just the shape of an ordinary working day.

  3. The errors you are never going to see again

    NullPointerException. Cannot read properties of undefined. ConcurrentModificationException. Segmentation fault. A tour of the failures that have nowhere left to happen once the types stop evaporating — and an honest account of the ones that stay.

  4. A converter is a small compiler

    An empty directory becomes a Rust project: why a file-to-file converter is shaped like a compiler, a library and a binary in one package, modules and who can see them, a manifest with no dependencies in it, two lines that let the build refuse undocumented and unsafe code, and CI on three operating systems from the very first commit.

  5. Arguments, without writing a parser

    postres learns to listen, and we write no parser to make it happen: the command line described as a struct, a macro that writes the parser from it — help screen and typo suggestions included — and what structs, attributes and macros are, and why they make Rust feel like a high-level language.

  6. Optional for the user, not for us

    Some and None turn out to be an enum — and not the kind Java has. Tagged unions, an Option that cannot pass for the value it might hold, inputs kept apart from the domain, and a Config the rest of postres can trust: private, settled once built, and named even when the user does not name it.

  7. Is that name right?

    postres picks a default output name, and one run showed it can be wrong. Tests that say what right means, a regular expression that fails them twice, the fix that was in the standard library all along — and a rule that would have found it first.

  8. Now, later, or only in tests

    Three ways to hand code around — a block that runs now, a closure that runs later, a function with a name — and how to choose. Tests that become a table. And conditional compilation: code decided before the program runs, and why that is safer than deciding it while it runs.

  9. Threads, told in a kitchen

    What a thread is, told in a kitchen that cooks for weddings. Why a bigger kitchen alone is no faster, why running a program twice does not help one order, and a mountain of potatoes peeled three and a half times sooner — measured.

  10. Sharing the kitchen

    Threads that share: salt added twice because nobody agreed on anything, six cooks slower than one, two cooks waiting for each other forever — measured, and the one of them Rust will not let you compile.

  11. A log that does not block

    Why printing a line makes a program wait, what a non-blocking writer does about it, what that costs when you actually measure it — four lines in five, silently — and what happens to the lines still waiting when the program exits.

  12. A one-character mistake

    Three small things in a logging setup — standard error, colours only on a terminal, and a level picked by counting -v — and then one character that throws away every log line, which the compiler itself recommends, and the lint that refuses it.

  13. Flattening, and back

    What serialization is, and why formats that every language can read won over formats only one can. Why a Postman collection is two things at once — JSON, the format, and the schema, what it means — read three ways, with a look at the code serde writes for us at compile time, and at how other languages do the same job while the program runs.

  14. Reading the collection

    postres reads a Postman collection at last. Seven fields of our own turn into the whole schema, which gets tedious fast, so we use a crate somebody already wrote — I knew it existed, and had sent it fixes. Data with several shapes as enums, two rungs of the ladder in one crate, and the price paid in error messages.

  15. Where a String lives

    Not published yet

    The stack, the heap, and two kinds of text: a String that owns its letters and a &str that only looks at them. Measured, with the compiler explaining every handover — and why a struct cannot contain itself.

  16. Saying what went wrong

    Not published yet

    An error type the program can name, Result end to end, and the difference between a failure you can explain and one you can only report.

  17. Methods and traits

    Not published yet

    A string arrives and has to become something the program cannot get wrong. Traits where another language would reach for inheritance.

  18. The request and its builder

    Not published yet

    A value assembled in stages, the builder written by hand and then derived — and the story of a fork, a rejected pull request, and the better answer the maintainer gave.

  19. Bodies

    Not published yet

    One thing that is several shapes, each with its own optional parts: pattern matching and destructuring on data that genuinely varies.

  20. The output has nowhere to live

    Not published yet

    The program understands a request and still cannot produce anything, because nothing can hold the result. A tree with parents in it, and what it costs.

  21. Lowering

    Not published yet

    Turning one model into another without copying everything and without the compiler refusing the program. Borrowing, lifetimes, and clone as a legitimate first answer.

  22. Walking the tree

    Not published yet

    Every later step needs to visit every request. Implementing Iterator by hand, and then iterators in general on a structure that is not a list of numbers.

  23. Passes, and writing the file

    Not published yet

    Inherited settings, composed names, and then the writer. The first time the program produces output, four years after it was started.

  24. Shipping

    Not published yet

    A tool nobody can install is not a tool. Binaries for three platforms, one command to install it, and the closing measurement.