hmc_site_source/content/english/operation2030/appendix/c-is-evil-so-what.md

4.0 KiB
Raw Blame History

+++ title="C is Evil" mediatype="extra" conference="seattle-2022" date="2022-11-16T12:00:00-08:00" description="So what?" thumbnail=""

videos title="Memory Strategies" embed="https://player.vimeo.com/video/774890907" service="vimeo" download_link="https://player.vimeo.com/progressive_redirect/playback/774890907/rendition/720p/file.mp4?loc=external&oauth2_token_id=1777364455&signature=3c443137144bf46966f5607ab00f818dfa5f98e1ac7643e62160f55e0bb27792"

speakers name="Abner Coimbre" bio="" image="" +++

Prev (Objectives) | Contents | Next

So What?

In early 2025, File Pilot launched to widespread acclaim, stunning the industry with unfathomable performance and breathtaking design (we dont use those words lightly.) Mainstream articles and big YouTube reviewers praise it as being orders of magnitude cleaner than the default file explorer experience for Windows 11.

This is the power of the Handmade ethos: a single indie dev shipped something vastly superior than what a trillion-dollar corporation could deliver. Thats a serious wake-up call by the way; it's not something to shrug off or accept as remotely normal.

When you dig into File Pilot, youll find its author wrote the entire thing in pure C. The loudest Rust enthusiasts might call him evil, but Handmade Cities response is simple: ... and?

Abner pokes fun at Rustaceans too. For example while extending microui to support growable command lists (to queue up more draw commands per frame) he went straight for the jugular:

function __attribute__((nonnull)) void mu_grow_command_list(mu_Context *ctx, int capacity) {
    expect(capacity > ctx->command_list.capacity);

    char *old_base = ctx->command_list.items;

    ctx->command_list.items = TC_REALLOC(ctx->command_list.items, capacity);
    ctx->command_list.capacity = capacity;

    /* patch up pointers (Rust enthusiasts: avert your eyes!) */
    ptrdiff_t offset =  ctx->command_list.items - old_base;

    // jump commands
    mu_Command *cmd = (mu_Command*) ctx->command_list.items;
    while ((char*)cmd < ctx->command_list.items + ctx->command_list.idx) {
        if (cmd->type == MU_COMMAND_JUMP)
            cmd->jump.dst += offset;
        cmd = (mu_Command*)((char*)cmd + cmd->base.size);
    }

    // root containers
    for (int i = 0; i < ctx->root_list.idx; ++i) {
        mu_Container *cnt = ctx->root_list.items[i];
        cnt->head = (mu_Command *)((char*)cnt->head + offset);
        cnt->tail = (mu_Command *)((char*)cnt->tail + offset);
    }
}

Similarly, NASA repudiates Rust in many areas too, as discussed in our interview with Billy Basso (creator of Animal Well). Timestamped recording below:

That said, Handmade Cities welcomes Rust with open arms. We do love fast Rust software like ripgrep. But if you pester us to stop using C, Zig, Odin, or Jai well laugh you out of the room. Dont let yourself become a caricature of the Evangelism Strikeforce.

Rust is, for most Handmade devs, too restrictive—a straightjacket limiting the absolute freedom needed to experiment rapidly. Rust is important for many use cases (even preferable. We'll take a Rust web server any day.) But for the kind of Formula 1 race car driving defining our ethos, its usually not the right fit.

This isnt a reactionary stance at all; weve thought deeply about these issues. If you'd like a more sophisticated discussion on the merits of being memory unsafe, with representatives on both sides, check out our podcast from Handmade Seattle 2022. Its as relevant in 2025 as it was then:

{{< vimeo 774890907 >}}