Steve Klabnik

“The most violent element in society is ignorance.” - Emma Goldman

Page 3

WebAssembly is more than the web

While WebAssembly was given its name for good reason, I also think it’s quite the misnomer. When you hear about WebAssembly, don’t just think of the web: think bigger.

Many programmers know that WebAssembly is a technology that lets you run non-JavaScript code in the browser. That is true, but there’s a lot more to it. You see, the spec is written in a very interesting way: there’s the core, what WebAssembly actually is. Here’s the opening section:

To support the embedding of WebAssembly into different environments, its specification is split into layers that are specified in separate documents.

  • Core specification - Defines the semantics of WebAssembly modules and its instruction set, independent from a concrete embedding.

  • API specifications - Define application programming interfaces enabling the use of WebAssembly modules in concrete embedding environments.

It goes on to say:


Continue reading →

“The Expressive C++17 Coding Challenge (in Rust)” Revisited

In October of last year, I wrote a post, “The Expressive C++17 Coding Challenge (in Rust)”. For various reasons, it got brought up again in the D world, and seb has written a new post. It’s good, you should check it out!

However, it links to my gist, not my blog post. As I said back then:

I held myself to the same constraints as the original contest; no external packages is a bit painful in Rust, but it’s not too bad. Mostly it would let me eliminate boilerplate while also improving correctness, and making the code a bit shorter.

So, that got me thinking: What would this look like if I could use external packages? I took about an hour, and knocked it out. I have two versions to show you today, one where I pay no attention to allocations, and one where it’s zero-allocation.

First, the “whatever just allocate” version:

extern crate csv;
extern crate serde_derive;

Continue reading →


As someone who has significantly different beliefs than Peter Thiel, today is likely my second-to-last power of two years alive.

Two years ago, I wrote a post about turning 30, and I pretty much feel the same way. Never enough time, tick tock, tick tock. I have today off (thanks Mozilla!), but am still considering working anyway, because I really care about what I’m working on, and am excited about it. We’ll see.

I feel like I have more to say here, but also don’t. So maybe let’s leave it at that.

View →

Looking back at Rust in 2018

A careful reader will note the date of this post; it’s fundamentally in response to this call for blog posts, with a rhetorical device of looking backwards as if my personal plans for Rust came true. If you’re reading this in 2019 or beyond, this may be a work of fiction.

It’s been an exciting year for Rust. Well, it depends on what you mean by “exciting”, exactly. In a word, this year has been about polish. I find this kind of thing exciting! It’s a very different kind of exciting than the “new and shiny” exciting. It’s “take what we have and make it shiny.”

Let’s recap the major achievements of the year.

Rust 2018

First of all, we shipped our first epoch! If you type cargo new today, you’ll see a new shiny entry in your Cargo.toml:

name = "new-program"
version = "0.1.0"
authors = ["steveklabnik <[email protected]>"]

epoch = "2018"


What does this...

Continue reading →

Five years with Rust

Today is five years since I first heard of Rust. I wrote a post last year about it. This year, I have something slightly different in mind.

Five years is a long time in tech. It’s also a long time for me to be focused on one specific thing; other than the pizza job I held in high school and college, I’ve never stayed in a single job for five years. (This is true today as well; it’s not like I got a job with Rust the first day I learned of its existence.) I started with Ruby and Rails in 2008/2009, and my final commits to Rails were in August/September of 2013. So at this point, my career has basically been split in half, rather than dominated by Ruby.

Five years ago tomorrow, I registered

Yesterday, I had lunch with someone I’m very honored to call a friend. We talked about a lot of things, but also about Rust’s past, present, and future. One thing...

Continue reading →

User-Agent: moz://a

Every six months, Mozilla gets all of its employees from around the world together in one place, for a week. This morning was the plenary session, with Mozilla leadership talking about our successes this year, as well as plans for the future. I noticed a theme that, while not super overt, I find very interesting, and bodes well for Mozilla’s future.

The words “user agent” kept coming up in various aspects of the plenary. The User-Agent header has a… shall we say storied history. When most people hear the term “user agent”, they mostly think of the “user agent string”. This is passed through the User-Agent header to identify which browser you’re using.

Well, that’s how most people think of it, but that’s not the whole story. If it is supposed to identify which browser you’re using, why is it not the Browser header? What is this “user agent” term anyway?

The concept is a bit more broad...

Continue reading →

The Expressive C++17 Coding Challenge (in Rust)

A few weeks ago, two C++ bloggers initiated a challenge (here and here): use the shiny new features of C++17 to write a small program that manipulates CSV files. The link is to the results; you can see the examples people came up with.

I’ve written a follow-up post too!

I decided to implement it in Rust for fun. You should give it a try, in whatever language you use, it’s a nice sample problem. I held myself to the same constraints as the original contest; no external packages is a bit painful in Rust, but it’s not too bad. Mostly it would let me eliminate boilerplate while also improving correctness, and making the code a bit shorter.

Anyway, here it is:

I implemented From for everything so I could use ?, but then main just has a ton of unwraps. I normally would remove those too, but the challenge does not...

Continue reading →

Want to join the Rust docs team?

One of Rust’s major goals this year is to provide mentoring at all levels of the project. This is a goal I’m very on-board with. There’s lots of ways to get involved with Rust, but I’d like to talk about the bit I’m most involved in: documentation.

There’s many ways to contribute to Rust’s docs. Some people contribute occasional PRs, some people end up contributing a lot. No matter what your interest, I’d like to help. But before I get into those details, why should someone get involved with documentation? I have my own reasons, but I also have a pitch for you:

Working on documentation is a fantastic way to learn something in a deeper way.

In order to document something, you have to understand it, even if only a little bit! It’s a good excuse to dig into the details. And I’ve found that many people are eager to help explain something to you in return for you writing that down and...

Continue reading →

An Overview of Macros in Rust

Rust has had a lot of stuff going on with “macros”. There are a few, interconnected aspects of these features, many different names for the same thing, and a lot of development work going on. This post will give an overview of the past, present, and future of macros in Rust.

Ultimately, macros allow you to write things like this:

let map = hashmap!{
    "a" => 1,
    "b" => 2,


[derive(Serialize, Deserialize)]
struct S {
    [serde(rename = "a")]
    f: i32,

That is, some macros look like functions: foo!, but allow you to write nearly arbitrary syntax inside of the ()s. Some let you control the ability to write custom attributes. Both generate some other kind of valid Rust code for the compiler to interpret. In the first case, the hashmap! macro will expand to a call to HashMap::new and a bunch of insert calls, and the second case, the Serialize and Deserialize traits will...

Continue reading →

Announcing Rust Contributors

When I was working with Ruby on Rails, someone once sent me this link:

In some ways, this link changed my life. You see, I respond really strongly to integers going upwards. I am a sucker for points, hits, whatever. That web page, however, puts that integer towards something useful: open source contributions. It’s fairly well known that open source contribution is a long tail, but that’s also perfect for this kind of gamification. One contribution, as of today, will put you in 2461th place. Your second? 1473! That’s almost a thousand places! Just one more contribution puts you at number 1114. Still three hundred spots. Your forth commit will let you get in the top 900, 893. You get the idea. (I ended up at 47.)

Today, I’m working on Rust. And one of the things that I do is write the release announcements, or at least, their first draft. And one...

Continue reading →