Home›Steve Klabnik›Article

Does unsafe undermine Rust's guarantees?

Mar 17, 2025

AI summary AI-generated, may contain mistakes

The article argues that Rust's `unsafe` keyword does not undermine Rust's memory safety guarantees, because a language's semantics are distinct from the implementation code that carries them out, just as Ruby remains memory safe despite possible segfaults caused by interpreter bugs or C extensions. Every memory safe language necessarily relies on a small amount of trusted code—implementations interacting with hardware and foreign function interfaces—whose bugs fall outside the language's guarantees, whereas unsafe languages require trusting a large amount of code. Drawing on syllogisms, Hoare Logic, and Separation Logic, the author shows that assuming some code is safe is foundational to how we prove properties of programs, making Rust's small, explicit trusted code acceptable on a deep, not merely practical, level.

When people first hear about unsafe in Rust, they often have questions. A very normal thing to ask is, “wait a minute, doesn’t this defeat the purpose?” And while it’s a perfectly reasonable question, the answer is both straightforward and has a lot of nuance. So let’s talk about it.

(The straightforward answer is “no”, by the way.)

Memory safe languages and their implementations

Keep reading

Out of respect for the author only the opening is shown here. Read the rest on the original site, or in HorizonReader with highlights, notes and AI help.

More from Steve Klabnik

Arguing about arguments

AI summaryThe article surveys argument-related language features—named parameters, optional/default arguments, and function overloading—and explains why the author, a former Ruby programmer turned Rust enthusiast, has long opposed adding them to Rust, citing the intertwined complexity and obscurity they introduce at call sites. However, the author now tentatively supports named parameters alone, arguing that AI coding agents shift the cost-benefit analysis: verbosity no longer matters much when agents write the code, while the inline clarity benefits both humans and agents. They still reject optional/default arguments because they hide what is actually being passed in, and note that many practical implementation concerns remain for adding named parameters to Rust.

So, what happened to my Claude Code series?

AI summaryThe author explains that his Claude Code series stalled because he has been extremely busy and the AI landscape has been changing so rapidly that keeping the documentation up to date became infeasible. With new releases like Claude Fable and OpenAI's upcoming Astra making the series feel increasingly outdated, he has decided to officially end it, though he still believes his earlier posts are valuable for getting started. He stresses that this decision doesn't reflect skepticism about AI—which he believes is here to stay and transforming how people work—but simply a lack of time for this specific project.

Too many words about DIDs

AI summaryThis article by Steve Klabnik explains how Decentralized Identifiers (DIDs) function in the atproto protocol that underlies Bluesky, describing how DIDs are resolved into DID Documents containing cryptographic keys and service endpoints. It compares the did:web method, which depends on DNS and self-hosted servers, with Bluesky's did:plc method, which uses the plc.directory service and remains stable even if domain names change, while discussing the trust trade-offs of each approach. The author concludes that while Bluesky initially generates and controls users' keys, did:plc's key rotation feature allows motivated users to run their own PDS and fully own their identity.

Compilers and AI 'cyber' defense

AI summarySteve Klabnik describes how new AI models (Sol and Fable) repeatedly refuse to help with his Rue compiler project because its safety layers flag the project's defensive testing practices—such as fuzzers, sanitizer hooks, and deliberate crash tests—as potential cybersecurity threats. While the AI itself confirms these are false positives stemming from the work's surface similarity to exploit development, Klabnik cannot bypass the guards. He expresses concern that such safety policies may leave individual developers unable to make their software as robust as that produced by large organizations.

The most important thing when working with LLMs

AI summaryThe article argues that the single most important practice when working with LLMs like Claude is giving them fast, objective ways to evaluate whether their work is correct, along with guidance pointing them in the right direction when it isn't. Drawing on lessons from teaching programming to children, the author notes that computers do what you say rather than what you mean, and applies Amdahl's law to show why optimizing the slow monitoring-and-approving step of the LLM development loop yields the biggest velocity gains. Practical techniques include letting Claude auto-run builds, tests, and commands, using informative compiler errors, and trimming verbose tool output so the model receives clear success signals and actionable failure feedback.