Skip to main content

Command Palette

Search for a command to run...

Rust for Longevity

Updated
3 min read
Rust for Longevity

Rust, C, Python… all of these languages have something in common. They all have cult-like followings for one thing or another. C for speed and it being the low-level king. Python for it’s extensive libraries especially with the massive trend in machine learning & LLM going around. Rust known for memory safety and essentially the better C.

Now before I get hate for saying Rust is the better C, let me break down why I think it is better than both Python and C.

Why is Python so popular? I think anyone with the knack for programming or someone whose knowledgeable in syntax simplicity can agree that Python is easy to learn. It’s simple structure for create functions like:

def greet(name):
    return f"Hello, {name}!"

message = greet("World")
print(message)

OR simple if else:

def auth(code):
    if code == 'areallysecurecode123':
        return True
    else:
        return False

But, honestly, the real reason Python is so popular is it's extensive libraries. Everyone who is creating machine learning models leans towards Python because of that. Pandas, Tensor all essential to operations and with new ones like PufferLib rising as well for some applications no wonder people choose it.

What about C? C is the OG. The grandfather of modern programming languages. It's been around since 1972 and it still powers operating systems, embedded systems, and performance-critical applications. When people say "close to the metal," they mean C. Here's how those same functions look:

#include <stdio.h>
#include <string.h>

void greet(const char *name) {
    printf("Hello, %s!\n", name);
}

int main() {
    greet("World");
    return 0;
}

And the auth function:

#include <stdbool.h>
#include <string.h>

bool auth(const char *code) {
    if (strcmp(code, "areallysecurecode123") == 0)
        return true;
    else
        return false;
}

See what I mean about low-level? You're manually managing strings, dealing with pointers, and including headers for basic functionality. The power is undeniable, C gives you direct memory access and blazing speed. But that power comes with responsibility. One wrong pointer and you've got segfaults, buffer overflows, or worse: silent memory corruption that haunts you in production.

Well, how is Rust better than both? With Rust you get C-level performance without the footguns. No garbage collector slowing you down like Python. No manual memory management nightmares like C. The Rust compiler enforces memory safety at compile time through its ownership system. You literally cannot compile code with data races or null pointer dereferences.

fn greet(name: &str) -> String {
    format!("Hello, {}!", name)
}

fn main() {
    let message = greet("World");
    println!("{}", message);
}

And auth:

fn auth(code: &str) -> bool {
    code == "areallysecurecode123"
}

Clean, right? Almost as readable as Python, but with C's speed. So why are companies eyeing Rust for ML? Speed without sacrifice. Hugging Face built their tokenizers library in Rust (with Python bindings). We're talking up to 100x faster than pure Python. Their candle framework is bringing native Rust ML inference. Discord rewrote critical services in Rust and slashed resource usage. Cloudflare runs Rust at the edge.

When you're running inference on millions of requests, Python's GIL and interpreter overhead become bottlenecks. C could do it faster, but one memory bug in production ML infrastructure? Catastrophic. Rust gives you that performance ceiling with a safety net built into the language itself. Rust's ecosystem isn't as large as Python's, but that is changing. The learning curve is steep and the borrow checker will humble you. But once it clicks, you'll wonder how you ever trusted yourself with malloc().

Technical Tuesday

Part 2 of 3

This is a series where I will get more technical by discussing systems, tools, and real-world projects that are interesting.

Up next

How Vector Databases and RAG Solve AI Hallucination Problems

Using Semantic Search and External Context to Rein in Generative Models