Posts in Rust (20 found)
Farid Zakaria Yesterday

Programming languages are for humans

tl;dr borrIR is a borrow checker, a zero-libc standard library ( ), and a bitcode package manager for raw LLVM IR. Try it live in the browser playground , and commit yourself to the agentic engineering way of life . Welcome AI disciples. This post is for you. We are just past the year mark when Opus 4.5 was released on November 24, 2025, when the way in which we craft and generate code changed overnight. We ushered in the era of agentic coding , where AI agents can autonomously generate, modify, and reason about code with minimal human intervention. Despite the loss of joy that comes with knowing the codebase inside and out or bickering with my friends about esoteric language features, there is no denying how much more prolific I have become by embracing the agentic engineering way of life . With the blindfolds on, the language du jour seems to be Rust for our dutiful clankers. Anthropic even made a large splash at how they rewrote their whole messaging system from Python to Rust [ cite ] for those sweet sweet performance gains. After numerous projects coded 100% by agents, where I have had 0 insight into the code itself: why are we even bothering with a language at all? Rust seems like a reasonable choice but it has its fair share of criticisms: complexity, slow compile times, and everyone seems to enjoy complaining about the generated build artifacts. Of course the popular opinion now is that the compile-time verification of Rust from the borrow-checker is what gives it the appeal. Coupling provable-verification with the stochastic reasoning of AI agents seems to be the current trend. Hear me out: a borrow checker does not require Rust. To commit to the agentic engineering way of life, we need the implementation to be so low-level that you are disuaded from even looking at it. We need the LLM agents to code directly in assembly, but not any ordinary assembly. We need a form of assembly that carries enough type information to allow the agents to reason about memory safety without human intervention. We need LLVM IR as our assembly language, with a borrow checker built on top of it . I built borrIR . It is a borrow checker for LLVM IR, designed to enforce memory safety at the assembly level. Check out the playground for an interactive demo. Wtf did I just build? 1 is a static analysis pass that sits in front of (assembler for LLVM IR). It parses textual LLVM IR (or disassembles bitcode via ), builds each function’s control-flow graph, tracks pointer provenance, and runs a forward fixed-point dataflow analysis to enforce affine ownership. All the fancy stuff Rust’s borrow checker does, but at the LLVM IR level. Here is the same use-after-move bug in Rust on the left and raw LLVM IR on the right: We can then run on the LLVM IR file and get a diagnostic equivalent to what Rust’s borrow checker would produce for the same use-after-move bug. Aside For those wanting the juicy compiler details: borrIR gets Non-Lexical Lifetimes (NLL) almost for free. In early Rust a borrow lasted until the closing of its scope, even if you never touched the reference again. Fixing that meant inventing MIR so the compiler could track where each reference was last used. LLVM IR has no scopes to begin with. Simplicity wins. As of the first release, the checker reports eight error classes ( – ) and one warning from use after move to laundering a pointer through . You can see the full list of error classes and the warning on the borrIR documentation . In the pursuit of pure blind agentic engineering zeal, I decided to abandon all libraries that might have been generated by higher-level languages and rely solely on our verified LLVM IR modules. includes a set of verified LLVM IR modules for common low-level operations, , such as memory allocation, I/O, and string manipulation, all of which pass the borrow checker itself. Think of these as the replacement for the standard libraries you would normally get from C or Rust: and friends. No , no , no dynamic linker. The binaries produced by this pipeline are fully static ELF executables, with no dependencies on or any other external libraries. They are incredibly small and self-contained, and the build process itself produces very little overhead or intermediate artifacts. Aside You actually have to ask LLVM to disable passes such as , otherwise LLVM will happily rewrite your hand-written loops into calls to standard library functions, which then fail to link if you don’t have . There is even a package-manager built into for handling pre-assembled packages, making it easier to share and reuse verified LLVM IR modules. Details are unimportant for this post but suffice it to say that we can build a complete ecosystem purely out of verified LLVM IR modules. This has been a nagging thought bugging me for the last few months as I have gotten more-and-more comfortable with having projects purely written by an LLM agent. I already trust the compiler to turn whatever language I write into correct, optimized assembly, and I never read that output. Having the agent write LLVM IR directly is the same trust, moved one layer up. The borrow checker is what makes that trust reasonable. It is a safety net for me and a feedback loop for the agent. Ownership is checked one function at a time, so the agent does not have to hold the whole program in its context to know who frees what. Try breaking the borrow checker in the live WebAssembly playground , or poke around the repo and run . Programming languages are for humans. Nobody asked the clankers if they wanted one. Yes, I am using I in the sense of “I, the author, built this tool.” even though it’s 100% LLM-generated code.  ↩ Yes, I am using I in the sense of “I, the author, built this tool.” even though it’s 100% LLM-generated code.  ↩

0 views
Max Woolf 2 days ago

Opus 5.5 and Fable 5.2 made my overoptimized Rust code even more overoptimized

I like fast software. I like very fast software. A couple months ago, I published a blog post titled Writing Rust code that’s faster than state-of-the-art libraries by asking agents to make the code faster in which I listed techniques for using agentic LLMs to speed up the runtime execution of Rust software—of course, with extensive checks and balances to ensure good code quality, avoid regressions, and mitigate cheating by the LLMs. After enough iterations, the resulting Rust libraries are faster than existing state-of-the-art implementations with the same or better capabilities, even against those already written in Rust. The main bottlenecks for me open-sourcing the resulting Rust crates are a) doing comprehensive real-world testing to ensure the code works as advertised and b) I don’t want to release the code and then have another model release immediately find another 2x-or-more speed boost because that would be embarrassing. I’m not satisfied with my code merely being faster than state-of-the-art: I want my code to push against hardware limits even for “fun” software that may not require maximum throughput. I don’t want my benchmarks to be measured in milliseconds, I want them measured in microseconds , dammit. Who knows if some application in the future will require submillisecond word clouds or submillisecond ASCII art generations? In that blog post, I mostly used OpenAI’s GPT models for this agentic iteration pipeline. The day after publication, Anthropic announced Claude Opus 5.5 , which was met with skepticism as Opus 5 was underwhelming…and then it quickly turned out that Opus 5.5 was a step-change increase in the capability of agents with the ability to complete difficult technical tasks that neither OpenAI’s nor Anthropic’s other models could complete. I spent the $20/mo to try out Opus 5.5 on my agentic iteration pipeline after observing the hype…and after only two days, the results were impressive enough that I paid the $100/mo to get more usage quota. Through more testing over the past couple months, I can confidently say Opus 5.5 and its subsequent Fable 5.2 sibling did in fact result in significant performance breakthroughs that indeed push my Rust software to its limits. Lest people think that this post is an undisclosed #ad for Anthropic, I had grievances with Claude Code prior to Opus 5.5 which were the primary reasons I switched to OpenAI’s Codex . One such example is Claude ignoring AGENTS.md in favor of CLAUDE.md ( until very recently ), which was honestly petty enough to tip the scales. The main grievance with using Claude Code is deciding which harness to use—or, rather, the lack of decision. Although I was fine with using Claude Code in the terminal back in the halcyon days of Opus 4.5, Codex’s ability to use any harness, such as Zed Agent which allows using the Codex subscription natively, made it more convenient to keep everything in one place. In contrast, Claude Code infamously blocks third-party harnesses and has closed workarounds used to access it regardless. Therefore, I had to consider workarounds for using Opus 5.5 in a way that doesn’t require significant changes to my agentic iteration pipeline. Zed Agent has a workaround to use Claude Code by following the Agent Client Protocol , but there was a problem due to how Claude operates: Opus 5.5 loves spinning up background tasks and working asynchronously, and Zed Agent had poor support for background tasks so I had little idea what the agent was actually doing. This was made worse by Opus 5.5 never editing code files using Edit tools; instead, Opus 5.5 likes to write Python files which surgically find/replace the code. I tried using the Claude Code terminal application again but that made the ergonomic issues above even more difficult to manage. Claude editing a Rust file by writing a Python script. That said, the async nature can save time when spinning up subagents (in this case Haiku 5.5) to review the changes made, as the main Opus 5.5 agent can write code or run long benchmarks while the subagents simultaneously do their nonblocking review work. Therefore, my main harness for my Opus 5.5 work was the standard desktop Claude app —which will likely eliminate all my AI engineering street cred, but it is what it is. In addition to clearly listing background tasks in progress, the native app also lists current session and weekly usage which was a pain to constantly check when using Zed Agent or CLIs. Background task sidebar in the Claude Code desktop app. There are also two more usability perks of using Claude Code within the desktop app: images always appear inline when the agent reads them so I can tell specifically what the agent is reading, and Remote Control is unexpectedly useful for letting hours-long prompts run while I’m doing other things such as job hunting and touching grass (but failing because I really wanted to know how well the code is running). At first, I fed Opus 5.5 my updated Ur-Prompt for agentic iteration—typically a prompt with an explicit directive to improve the speed at which the benchmarks run by at least a specified amount without either causing regressions or cheating the benchmark results. With this new model (and a few tweaks to my AGENTS.md to address some peculiarities with Claude), that approach indeed worked, and in a single pass, Opus 5.5 achieved 1.2x - 1.5x speedups on multiple distinct projects which had already been optimized with GPT 6.1 Astra. That said, there are a few quirks with how Opus 5.5 works such as prompt queueing: with Codex/Zed Agent, I could queue a prompt such as such that it would only be sent to the agent after it was done with the current prompt (important as it is deliberately asymmetric information as telling someone to do a breakthrough while they are still working is counterproductive), but with Claude Code it will send any queued message when idle, e.g. while it’s waiting on background tasks such as benchmarks and subagents. My silly workaround to this behavior was to put in a Markdown file in another folder outside of the current environment (so Claude can’t accidentally find it when it examines the environment), then add to the prompt: This works, and Opus 5.5 indeed does not cheat by reading ahead of time, and the breakthrough commands do result in actual breakthroughs. One issue I have with Opus 5.5 is that it definitely writes more lines of code than the GPT models: in the case of Rust that’s not necessarily bad performance-wise since it’s a compiled language but it adds more technical debt than I would like. For example, many of my Rust projects rely on PNG image encoding and decoding through Rust’s png crate. However, when Opus 5.5 was instructed to make improvements on benchmarks where PNG processing is on the hot path, it consistently creates its own bespoke PNG module from scratch (with parallelism/streaming better-aligned to how the base code processes the data) that does achieve the desired 1.2x - 1.5x speedups without causing any regressions, so I’ll begrudgingly accept it. I very frequently run maintenance passes and even then it struggles to do so. Another issue with agentic iteration work specifically is that Claude Code obfuscates how it runs benchmarks. When running benchmarks with criterion , instead of displaying the benchmark results as they come in, they’re piped to a temporary file so I can’t view intermediate progress. It also doesn’t return results from the benchmarks until after they’ve concluded, despite my prompting explicitly asking it to, so I have to twiddle my thumbs a bit (again, good for attempting to touch grass). Agentic LLMs have mostly become homogenized in terms of how they work through their turns, with the difference between certain LLMs coming down to benchmarks which may be gamed, or worse— vibes . Overall, I have to give more trust to Opus 5.5, which I have mixed feelings about. That said, the trust has been rewarded, particularly with new approaches I found where Opus 5.5 excels where GPT models did not. In my prompts, I always added a suggestion about leveraging process profiling that the GPT models mostly ignored: Opus 5.5, in contrast, is extremely eager about profiling with samply to find the areas where code spends most of its time executing and will often do so as its first task, including reprofiling after each change to find changed hot paths for further improvements. Opus 5.5 profiling a Rust crate with a somewhat inscrutable command. Opus 5.5 also spends more time running experiments whereas GPT models edit the code first then ask questions later; both approaches have their merit but I think Opus 5.5 is more productive at it. While working on making my Rust software super-fast, I never put much thought into how much system memory it utilized. I figured it was unnecessary since a) Rust is already extremely memory efficient and b) writing to RAM beyond what is needed causes wasted system overhead which would inevitably be caught by the existing prompts to make the software faster. I was wrong. Very wrong. If I could get a ~20% reduction in peak memory without much code complexity change, then maybe it’s worth pursuing. Therefore I gave Opus 5.5 a simpler-than-usual prompt because I was too apathetic to prompt engineer it: The results on a couple projects: Memory decreases on my Rust HDBSCAN /clustering crate after the prompt. Memory decreases on my Rust text search project (in-memory, not CLI). I immediately used the same prompt on all my projects and achieved similar significant peak memory reductions (doing a second pass with resulted in even stronger reductions). In general, it achieved this through the traditional tricks used to explicitly manage memory such as streaming data and smarter specification of sizes. That said, I had hoped that this approach would result in speed improvements (i.e. the agent discovers an algorithm has no viable memory improvements and therefore it implements a better algorithm) but significant speed improvements were rare. Another hyped aspect of Opus 5.5 is its ability to better handle visual design and avoid the typical “AI Slop” aesthetic when designing web applications. This capability may not intuitively translate toward maximizing the speed of my Rust software, but it’s crucially important to balancing both speed and quality for my applications that rely on visual design, as visual design isn’t always subjective and “it looks ugly” can be a legitimate software regression. In my initial post about agentic iteration, I described implementing a UMAP algorithm with this approach, as UMAP is a useful-for-me dimensionality reduction algorithm (among many) that when used to project to 2D, it can automatically create intuitive visual clusters. Images of Digits clustered via umap-learn. via umap-learn docs In my original post, I noted that the Python bindings of my Rust UMAP algorithm beat umap-learn by 4x - 15x after several agentic iterations. Although it excelled at all the typical quantitative benchmark metrics, my UMAP algorithm apparently failed the most important benchmark: vibes. The visual clusters in cases such as the famous MNIST dataset of digit images were not semantically distinct compared to existing implementations such as umap-learn, PaCMAP , and TriMap : The Python bindings of my UMAP crate (top-left) are indeed ~12x faster than but that doesn’t matter if it produces indistinct clusters. So I asked Opus 5.5 iterate specifically to improve cluster distinctiveness compared against for the known good implementations while minimizing the speed tradeoff, along with making more apples-to-apples fairness tweaks: Download the video . Opus 5.5 also made the head-to-head video, which is unexpectedly hypnotic. The speedup relative to fell to about 4x, but cluster quality is very comparable now and 4x is still a good speedup. Another visual-oriented project I’ve been working on since Opus 4.5 is the fast and accurate automatic conversion of images from raster files to vector (SVG) files that can scale to any size. This isn’t a new concept: tools such as Inkscape that convert images to vectors/SVGs have been around for awhile. Rust itself has vtracer and img2svg , but I wanted to see if I could beat them not only in speed, but also a) visual fidelity between the vector and raster and b) output SVG file size, which requires deriving fewer and more efficient SVG Paths and Bézier curves . Take for example, this image of a pelican riding a bicycle. That is what everyone talks about with AI, right? A 393KB vector-art-style image generated with ChatGPT Images 2.5. Don’t think too hard about its left leg. This test case is deliberately tricky for raster-to-vector algorithms as pelicans are very curvy. Running the image through with default settings results in a 153KB SVG that’s unusably blocky. Prior to Opus 5.5, running the image through my Rust crate that went through the GPT agentic iterative optimization pipeline resulted in much better output than / for my crate, but still had enough errors such as color blotches and jagged “staircases” that were easily identifiable and would make the output vector SVG unusable, so I shelved the project entirely. Opus 5.5 in contrast is eager to zoom into the image, find staircases, construct comparison grids and image diffs, fix the underlying algorithms, and repeat until it’s fixed. Opus 5.5 iteratively examining output SVGs by creating comparison matrices of test outputs. With the guardrails and repeated Opus 5.5 iterations, my approach to raster-to-vector finally beats the existing options by considerable margins. For this pelican example, my crate beats both and in all of speed, size, and error. Here’s the pelican SVG output from the crate, reduced from the stated 25KB to 14KB after passing it through a separate SVG compression/refinement tool I also created and optimized with Opus 5.5 using similar techniques: It’s not 100% perfect but you really need to zoom in to see the defects. This pipeline has worked well with my other test images, but it still needs more real-world tests before I will release it. Yes, we’re going there. The release of Opus 5.5 specifically led to a new age of reverse engineering software using LLMs, from Reverse Engineering Anything allowing reverse engineering anything (duh), to drastically speeding up decompiling games . For my work making software as fast as possible, I didn’t read too much into it until I randomly saw one of my reasoning traces run objdump to try and figure out why a change did not result in an expected speed increase. So as an experiment, I gave this as a part of a dedicated variant Ur-Prompt in its own pass (since Opus 5.5 may avoid disassembly unless you specifically constrain it): The effectiveness of this approach legitimately surprised me…but don’t ask me to explain what’s happening. Speedup after a disassembly optimization for a Rust graph network crate. Speedup after a disassembly optimization for the Rust UMAP crate (w/ the visual constraints persisting). Somehow, Opus 5.5 is smart enough to make Rust code changes that propagate through LLVM to the resulting binary with fewer instructions without causing regressions—I would have called that impossible a year ago. One potential weakness of this approach is that it may overfit to specific hardware (my M3 MacBook Pro / ARM architecture) but the diffs appear to be more architecture agnostic. At the very least, it intentionally doesn’t write custom CPU instructions in Rust itself because doing so requires . You may have noticed I haven’t talked about Fable 5.2 yet despite giving it equal billing with Opus 5.5 in the headline. Fable 5.2 was released a couple weeks ago and its benchmarks were…ok. Not much better than Opus 5.5 on paper especially below effort, but much more expensive. I had spare quota, so why not put Fable 5.2 (on effort) through the same paces I did for Opus 5.5? I fed it the Ur-Prompt (and bumped the research subagents to Opus 5.5), and Fable 5.2 did not achieve the 1.2x - 1.5x speedup consistent with each successive model release. Fable 5.2 instead achieved a 1.5x - 2.0x speedup on many of my projects. Massive speedups for my word cloud project in both text parsing and generation. Given the benchmark results, I don’t get it but I am very much not complaining. One tool I’ve been experimenting with (particularly in this very post) but never talked about due to potential accusations of heresy is a next-generation grep replacement that is faster than the beloved ripgrep , but with additional features; this new Rust crate named byteseek . ripgrep, itself written in Rust and optimized for over a decade, is tough to beat speedwise without shenanigans, however Fable 5.2 was able to find massive speedups on synthetic benchmarks in-memory. Also massive speedups for byteseek; this is after I told Fable 5.2 to . ripgrep itself uses real-world datasets to benchmark (Linux source tree and English+Russian OpenSubtitles; Russian tests UTF-8) and does the benchmarks via the CLI which has significant overhead from opening files for scanning not present with in-memory benchmarks, so I ran an apples-to-apples CLI benchmarks comparing the two on both synthetic and real data: byteseek particularly excels at alternation/multiple query terms and case-insensitive searches. BTW I am also developing a new scientific data visualization library in Rust and wanted an excuse to dogfood it. Given the likely skepticism about its performance, I am officially open-sourcing byteseek on GitHub early as a research preview to demonstrate just what this type of overoptimized Rust code looks like. Since I have the speed headroom to do so, I also added more features such as pretty-printing output for humans, jq -like JSON searching (plus YAML/TOML), fuzzy and predicate matching, and Python bindings which unexpectedly beat the optimized pyahocorasick and orjson . A ripgrep-like output with but with more information and more pretty . In all, this is my new agentic iteration pipeline: The Opus 5.5 pass Typically done using my updated Ur-Prompt , with various constraints tweaked depending on the problem. (e.g. the target metrics for optimization and regression mitigation) The Opus 5.5 peak memory reduction pass Simple prompt, if there is a significant speed increase that implies performance has not converged. The Opus 5.5 disassembly pass Done with a dedicated variant Ur-Prompt , if there is a significant memory reduction. The Fable 5.2 pass Same as the Opus 5.5 pass, although I bump the subagents to Opus 5.5 to better match the model’s power. The (optional) Fable 5.2 disassembly pass …if I have Claude Code quota to spare: Fable only being able to be used for half of the Claude Code weekly quota is a bummer. My Rust software that I had already optimized with GPT-6.1 Astra now achieves a cumulative 4x speedup on average with much lower memory utilization, and this was reproducible across multiple projects. My word cloud generator—where I was overly excited about hitting 1 millisecond generation—now generates in 374 microseconds. This also generalizes to projects where speed is more meaningful, such as my Rust statistical modeling library and my Rust data visualization library. Per Opus 5.5, the performance for most of my Rust projects have now have hit theoretical hardware limits. Therefore I have little reason to continue procrastinating as new models likely won’t make the code meaningfully faster, so I should hopefully be shipping more quickly. That said, marketing the Rust projects has become increasingly difficult since my original post for a number of reasons, but that’s a discussion for another blog post. In the meantime, I should learn how compiler optimization in Rust actually works as there are likely more significant code speedup opportunities there… The Opus 5.5 pass Typically done using my updated Ur-Prompt , with various constraints tweaked depending on the problem. (e.g. the target metrics for optimization and regression mitigation) The Opus 5.5 peak memory reduction pass Simple prompt, if there is a significant speed increase that implies performance has not converged. The Opus 5.5 disassembly pass Done with a dedicated variant Ur-Prompt , if there is a significant memory reduction. The Fable 5.2 pass Same as the Opus 5.5 pass, although I bump the subagents to Opus 5.5 to better match the model’s power. The (optional) Fable 5.2 disassembly pass …if I have Claude Code quota to spare: Fable only being able to be used for half of the Claude Code weekly quota is a bummer.

0 views
Jeff Geerling 4 days ago

Ansible Fails waiting for privilege escalation on Ubuntu 26

I've slowly been moving my servers from Ubuntu 22 and 24 to 26 this year, and noticed my Ansible automation starts failing if I have password protection for use: Apparently Ubuntu's been rewriting system utilities in Rust, and the version that ships on Ubuntu 26.04 has some incompatiblities with the I've used on servers for 20+ years.

0 views
Blog System/5 4 days ago

Entering the Geminispace

On May 1st, 2020, Project Gemini made the rounds for the first time via a Hacker News discussion thread . I remember seeing the announcement back then, barely a month after the Covid 19 worldwide lockdown, and thinking it was a cool gimmick. But that was that. However, I’ve recently been seeing a few links here and there as footers in hand-crafted blogs, and I nerd-snipped myself to export this blog as a Gemini capsule that you can find at . The process has been fun, and I actually quite like the extreme minimalism of the resulting site. So what else would you expect from me? I had to write about it—hence this post. Today we’ll learn a little bit about what Gemini is, how I approached the blog export to its native gemtext format, and I’ll confess a couple of… sins I committed along the way. A terrible name, that is. Looking for information about Gemini these days is extremely hard, thanks to Google polluting the namespace with its own AI offering. Of course that’s not Project Gemini’s fault because Google’s thing came after them, but still, good luck finding stuff about this network. Joking aside, let’s look at Project Gemini’s barebones front page: Project Gemini's front page, displayed in the Lagrange browser. … and break down the introductory and only paragraph: Gemini is a new internet technology supporting an electronic library of interconnected text documents. You can think of Gemini as a way to access a bunch of text-only pages, with links among them, so you can find information and follow links to additional resources. Instead of using or URL prefixes, you use instead. That’s not a new idea, but it’s not old fashioned either. Exactly. Gemini is like the WWW , or “the web” in more colloquial/modern parlance. In fact, Gemini is a parallel community to the web. Obviously, that’s not a new idea because the web dates back to 1989, and we are now 37 years after that. The idea is not unique either because Gopher , a much lesser-known option, exists as well. Surprisingly to me, I realized that Gopher came after the web in 1991 while researching this article. I had always assumed Gopher was first and that the web came to replace it because of Gopher’s rigidness. But that’s not quite what happened. It’s timeless, and deserves tools which treat it as a first class concept, not a vestigial corner case. Humans have shared written documents since around 3400–3100 BCE (roughly 5,100–5,400 years ago) in ancient Mesopotamia and Egypt, and that’s probably (hopefully?) not going away. It’s true, though, that at this point, text sharing is not the primary thing that the web does, as you well know. We have morphed the web from a document distribution tool into an app platform, for better or worse. A little confession: I worked at Google for 12 years, starting right at the time they published Google Wave (2009), which to me marked the start of truly interactive web apps—more so than Gmail (2004) did. In the back of my mind, I knew I was helping turn the web into how we run apps, destroying the traditional desktop paradigm—a feeling I never liked. And… it happened. Obviously, it’d have happened without me, a little pawn in the game, but it bothered me regardless. Gemini isn’t about innovation or disruption, it’s about providing some respite for those who feel the internet has been disrupted enough already. (That comma splice hurts.) As we have established earlier, Gemini’s ideas are not new, so it’s indeed not innovative. And seeing how little people read these days, or even how unable to pay attention to long-form text they are, it’s not going to disrupt anything either. But respite is key: having a separate place where you know you’ll only find some sort of counter-culture sounds entertaining. Fun fact: I wasn’t quite sure what respite meant and originally took it to be similar to spite. That meaning would have worked equally well here, if not better? We’re not out to change the world or destroy other technologies. We are out to build a lightweight online space where documents are just documents, in the interests of every reader’s privacy, attention and bandwidth. Here is the interesting thing. Gemini claims that it has been designed to minimize the chances of becoming bloated, and I’m not exactly sure how you can prevent that. For example: articles can provide links to images, but images are not auto-loaded. OK, says who? The auto-loading part is something the client browser controls, and it’d be trivial to create a Gemini browser, or modify an existing one, to auto-load and render images. That’d go against the spirit of Gemini, but if enough people wanted it, it’d happen. Same story as the browser wars . And that’s the key: “enough people”. As long as Gemini stays under the radar and only like-minded people gravitate towards it, these properties will be maintained. But if for any reason it becomes more mainstream… unwanted changes will happen. Enjoying so far? Please take a moment to show me by subscribing to Blog System/5. It’s free! Gemtext is the native format of documents stored in the Gemini network, with a MIME type of and a extension. Gemtext documents are typically grouped in capsules —which is just another name for “website”. The format itself is like a super-diluted version of Markdown, supporting just these features: Three levels of headings. Paragraphs. Links as standalone lines, not as inline text. Preformatted text blocks, also not as inline text. Unordered lists. Blockquotes. Workable for sure, but weak. In my opinion, Gemini missed the boat of creating a truly semantical web, but for that you need additional primitives to represent more concepts. In any case, you can read through the long FAQ to know that this was discussed and eventually ruled against, so know that a lot of thought was put into its design. Yet another fun fact: just two days ago, I stumbled upon “Good morning and welcome to my idea of a new web” : the proposal of a “browser” that just renders Markdown documents. This feels quite similar to the idea behind Gemini, but using a better (not a great) format with more markup abilities. And I say fun fact because, as I was learning about Gemini, I was imagining developing this exact alternate idea. One curious bit is that Gemtext is also the format for subscription feeds. Sure, you can offer an RSS feed for your capsule, but RSS is a monster spec that feels out of place in a minimalistic network like Gemini’s. So you can abuse Gemtext to create a feed by creating a page that’s primarily links with a de-facto format. Again, it’s simple, and it works. The big benefit of Gemtext’s simplicity is that clients can also be super-simple. You can rest assured that all clients will be able to display the same content, consistently. So far I’ve tried Elpher within Emacs , Lagrange on the desktop , and Buran on my Android phone . All are simple. All display text in the same way. I definitely do not recommend using the Gemtext format to persist your original content, but that doesn’t mean you have to write in Gemtext. Which brings us to Markdown again. All of the content you are reading in this blog is authored and stored as Markdown documents. Like many other people who still maintain a blog in this day and age, I started with a hosted platform (Blogger) and then experimented with Medium. But as soon as Medium became riddled with noise, I ran away. Unfortunately, escaping was difficult: the format that Medium spit out was frigging awful—almost as if it were designed to provide the illusion that you could export content, even if the content was nearly useless after the fact. It was at that point that I committed to converting my golden copies to Markdown even though authoring in Markdown was more inconvenient. And believe me: it is inconvenient, especially when having to insert images. But now I own my content in a format that’ll survive for years to come. Which brings us back to Gemtext. The thought that crossed my mind when I stumbled upon Project Gemini again three weeks ago and that triggered this whole thing was: can I write a script to convert my Markdown docs into a capsule? And with “I” I really mean AI, because this is the kind of experiment I was not going to code myself. And of course I could. After just one simple prompt, I had a converted site that I could browse. Granted: the conversion Python script was literally awful, and the converted format was not great either, but having something I could play with inspired me to try harder. A run of my blog-to-capsule exporter. So I threw everything away and started over, again with AI, to write a conversion tool for my blog (codenamed for now) that takes the existing Hugo layout and spits out a capsule end-to-end in just 300 milliseconds while processing 1000 documents. The tool is obviously written in Rust, and by now supports enough configurable features that I’m increasingly tempted to throw Hugo away for the web version and create my own static site generator too. Because, you know, while Hugo works, it isn’t the greatest in usability and its recurrent incompatible changes are annoying. I’ll resist the urge to do that for now… I think. Let’s dive a tiny bit into . First of all, this second iteration is still entirely vibecoded. Oops, first sin. I have not looked at the code because it’s working for what I need it to do, it’s fast, and it’s not going to be used by anyone else… unless you want it, but then I’d probably rewrite it once more now that I know what the final feature set looks like. Now, for this second iteration, I was so close to running out of my $20 weekly OpenAI quota that I pivoted from my favorite GPT 6.1 Sol model to GPT 6 Luna to see how far I could go. Luna is so cheap that you can do a ton with it, and I actually got to work well enough within just a few iterations. But oh dear. Luna is cheap, but it’s also kind of crap for coding. It stops half-way. It doesn’t think through enough corner cases. It doesn’t produce enough tests. The plans it produces are very vague. You have to be extremely prescriptive when asking it to do things and even that leads to mixed results. Out of curiosity, when my weekly cap was reset, I asked Sol to review what Luna did, and oh boy did it have things to say. From design problems to important missing tests, passing through outright bugs. I let it fix those issues, and I continued building with Sol. Right now, I’m actually pretty happy with the results of . I can configure the mapping of pages to templates in a much more explicit way than in Hugo. I can use MiniJinja for templating. I can specify cross-site links. I can handle inline links, figures, and even tables. I can generate archives/feeds for the site, for each year, for each month. I can process blog posts, and also standalone pages. All in all, the results are very satisfactory given the close-to-zero effort I put into it. With the site exported to Gemtext, I needed a server. There are a lot of options out there, but the one that piqued my interest was Agate : a minimalistic Gemini server written, of course, in Rust. You run the binary pointing it at the directory containing the generated site and, voila, it works. Agate even takes care of auto-generating SSL certificates because all Gemini traffic is TLS-protected, and the fact that it’s automated is a relief because dealing with certificates is a pain. My new Gemini capsule shown by a Surface Go 2 running Lagrange. Artwork courtesy of Eva Merino. But running Agate once, interactively, and making it serve in the background are different stories. I am running FreeBSD on my server and I could have used the prebuilt package, but then I encountered a crashing bug and wanted to add a feature, so I had to pivot to building from source. And, as you can imagine, Cargo leaves a lot to be desired if you want to install the resulting product to a running system. Now, of course you can copy the built binary to, say, , but there is typically much more than a binary in a distribution: think about documents, examples and, for a server program in particular, startup scripts. Mind you, Agate’s source tree does include a FreeBSD rc.d script, but it was buggy, insufficient, and it also required manual copying. So I created a PR to revamp the installation system based on earlier experience with setting up similar infrastructure in other Rust services I run. I mentioned briefly above that I wanted to add a feature to Agate and that it was the reason I had to build from source. And that feature is… analytics, which are the second sin right there. “Oh no, ah-nah-ly-tics! Privacy enemy number one! How dare you add analytics to something in the Gemini network!?!” But wait a second. What are analytics? You do realize that Agate prints and saves a log of incoming connections (with IPs redacted by default), right? That’s par for the course for any Internet server out there, because in order to serve requests… well, the server actually needs to know what those requests are and where to send the responses to. So you can always analyze the log to gain some insights on traffic. And that’s pretty much what I did. I just wired this exact same information to my own analytics service for visualization. The only thing I see are the pages that are being downloaded, when they are downloaded, and the originating country (computed from the requester’s IP after truncating the last octet to mask it). Essentially… good old page counters from the 1990s. Live page views graph showing both https:// and gemini:// visits at once. The way I implemented this is generic though: I extended Agate to add optional support for an SSI-style URL inclusion primitive and then added such a call to the capsule-wide footer template given to my Gemtext generator. As a high-level primitive, it can serve other purposes, like sourcing comments for each page by making the footer download a pre-rendered chunk. I haven’t implemented that yet in my comments service, but it should be pretty easy. Sounds interesting? I might try to contribute this SSI feature upstream to Agate, but I predict that this collides with the goal of a lightweight server and that it’ll be rejected. But I’ll try anyway. I want to get the FreeBSD-related bug fixes and related improvements merged first, because those are helpful to everyone, I hope. That’s about it! If you are in the U.S. you are about to have 4 days off, so spend that time falling into the Gemini rathole. And if you are elsewhere, do the same! It’s entertaining. From now on, remember that you can also read this blog via gemini://capsule.jmmv.dev/ if you want a super-fast, distraction-free experience. To get started, visit the Gemini software page for a long list of clients to choose from and install. (Content also available at: ) Project Gemini's front page, displayed in the Lagrange browser. … and break down the introductory and only paragraph: Gemini is a new internet technology supporting an electronic library of interconnected text documents. You can think of Gemini as a way to access a bunch of text-only pages, with links among them, so you can find information and follow links to additional resources. Instead of using or URL prefixes, you use instead. That’s not a new idea, but it’s not old fashioned either. Exactly. Gemini is like the WWW , or “the web” in more colloquial/modern parlance. In fact, Gemini is a parallel community to the web. Obviously, that’s not a new idea because the web dates back to 1989, and we are now 37 years after that. The idea is not unique either because Gopher , a much lesser-known option, exists as well. Surprisingly to me, I realized that Gopher came after the web in 1991 while researching this article. I had always assumed Gopher was first and that the web came to replace it because of Gopher’s rigidness. But that’s not quite what happened. It’s timeless, and deserves tools which treat it as a first class concept, not a vestigial corner case. Humans have shared written documents since around 3400–3100 BCE (roughly 5,100–5,400 years ago) in ancient Mesopotamia and Egypt, and that’s probably (hopefully?) not going away. It’s true, though, that at this point, text sharing is not the primary thing that the web does, as you well know. We have morphed the web from a document distribution tool into an app platform, for better or worse. A little confession: I worked at Google for 12 years, starting right at the time they published Google Wave (2009), which to me marked the start of truly interactive web apps—more so than Gmail (2004) did. In the back of my mind, I knew I was helping turn the web into how we run apps, destroying the traditional desktop paradigm—a feeling I never liked. And… it happened. Obviously, it’d have happened without me, a little pawn in the game, but it bothered me regardless. Gemini isn’t about innovation or disruption, it’s about providing some respite for those who feel the internet has been disrupted enough already. (That comma splice hurts.) As we have established earlier, Gemini’s ideas are not new, so it’s indeed not innovative. And seeing how little people read these days, or even how unable to pay attention to long-form text they are, it’s not going to disrupt anything either. But respite is key: having a separate place where you know you’ll only find some sort of counter-culture sounds entertaining. Fun fact: I wasn’t quite sure what respite meant and originally took it to be similar to spite. That meaning would have worked equally well here, if not better? We’re not out to change the world or destroy other technologies. We are out to build a lightweight online space where documents are just documents, in the interests of every reader’s privacy, attention and bandwidth. Here is the interesting thing. Gemini claims that it has been designed to minimize the chances of becoming bloated, and I’m not exactly sure how you can prevent that. For example: articles can provide links to images, but images are not auto-loaded. OK, says who? The auto-loading part is something the client browser controls, and it’d be trivial to create a Gemini browser, or modify an existing one, to auto-load and render images. That’d go against the spirit of Gemini, but if enough people wanted it, it’d happen. Same story as the browser wars . And that’s the key: “enough people”. As long as Gemini stays under the radar and only like-minded people gravitate towards it, these properties will be maintained. But if for any reason it becomes more mainstream… unwanted changes will happen. Enjoying so far? Please take a moment to show me by subscribing to Blog System/5. It’s free! Gemtext Gemtext is the native format of documents stored in the Gemini network, with a MIME type of and a extension. Gemtext documents are typically grouped in capsules —which is just another name for “website”. The format itself is like a super-diluted version of Markdown, supporting just these features: Three levels of headings. Paragraphs. Links as standalone lines, not as inline text. Preformatted text blocks, also not as inline text. Unordered lists. Blockquotes.

0 views
Armin Ronacher 5 days ago

Abolish Lock Poisoning

Rust has a curious feature that I don’t think the language would land today, if it was not there for a long time: mutex poisoning. When some Rust code panics while holding a , the mutex is poisoned . That means that any further call to returns a . The motivation for this feature is that an object might have some internal invariants that need to be upheld and panicking in the wrong moment might invalidate reasonable at and leave an object behind in a broken state. Personally I absolutely hate this feature as it has bitten me so many times and I cannot once remember it helping me. The libs team is discussing making the non-poisoning locks the default in the next edition but entirely expectedly it has caused quite a few people to jump to the defence of the feature. In this post I want to make my personal case why poisoned locks should either be entirely removed or be made the exception. Primarily this is because I have yet to come across code in the wild that handles a poisoned lock correctly. On the other hand I have come across enough code that mishandles it and as a result behaves worse than a parking_lot lock would which does not support poisoning. Josh Triplett put it quite strongly in a hackernews comment: “In the entire history of the standard library, we have never once seen a single report of anyone attempting to recover from poison.” When a panic happens with a lock held, there are two reasonable reactions: shut the process down, or carry on and ignore the flag. With you get the former and poisoning never comes up. From all the evidence I have seen, with unwinding, the idiomatic picks the worst option of all. That’s because it neither stops the process nor lets it continue as it will turn every further lock into a panic with sometimes disastrous effects. But that is not the only issue with the system today. So here I want to share some of the issues and with some references to real world code of how people got bitten. One subtle aspect to the poisoning is that the needs to hold the guard. That’s because in order to ignore the poison flag, you need to fetch the guard from the error object. Holding on to the error means holding on to the lock! That can cause common code that does error wrapping / error conversions into a deadlock hazard. The innocent looking in a function returning or similar keeps the mutex locked for as long as the error lives ( #159930 ). This can also happen with if let. For instance in cc-switch you can see that they had a test hung because a fallback locked the same mutex again while the unnamed from the condition still owned the guard. PC-AI had the same bug in a arm. Another case can be found in ox-embed-server . Deviously poisoning does not fail fast and done wrong, it fails forever. The original panic happens once, on one thread, often somewhere unrelated from future failures. Every later on that lock now however panics as well, and because so much Rust code survives panics (thread pools, request handlers, tokio tasks, FFI boundaries), the process stays up and becomes useless: While not live services, test suites show the same general issue. One failing test poisons a shared static and every test after it fails with . This problem showed up for cargo , deno , polars and rustc itself. If you recover with , the flag stays set and every later access takes the recovery path again. And remember that for the first nine years of Rust after the poisoning feature landed, you could not even clear it as arrived only in 1.77. Not clearing the flag means that potentially expensive side effects will happen from that point onwards: goose-in-a-pond rebuilt its decoder state on every transcription after a single panic, librefang logged the same warning on every access, and a pool threw its model away on every return. So who is handling poisonings? I’m really not sure, definitely not the standard library. Every place where the standard library’s own code ignores it. Standard I/O has done so since March 2015 , two months before 1.0, because “any poison must have been the result of user code which the lock isn’t protecting”. A common issue with a lot of poisoning errors that never had anything to do with the mutex that was held. Same with the panic output capture , the backtrace lock and the WASI environment lock . They all do the same and unsurprisingly there is an open PR to move std’s internal mutexes to . And I would argue the ecosystem has largely come to the same conclusion. Tokio’s own locks don’t poison. Internally it wraps the std one in an adapter that removes poison . When it landed Carl Lerche remarked “ I rather pretend lock poisoning isn’t a thing .” In one case Eliza Weisman needed to unlink a waiter during drop, or “we’ll leave the list with a potentially dangling pointer”. I want to point to this in particular because this is a case where poisoning stood in the way of memory safety which is commonly argued as a reason you want poisoning. Wasmtime, crossbeam-channel, tracing-subscriber always ignores lock poisoning. rust-analyzer switched to parking_lot after cancellation poisoned its solver like RLS did before. The parking_lot maintainer described it as an anti-feature that hurts usability and reliability to which I strongly concur. Another aspect here is why this is done on but not on . Surely if the case for poisoning is that some code temporarily breaks an invariant, panics, and someone else observes the broken state, then this should apply to more cases. Take the usual example that argues in favor of poisoning and replace with , and you have exactly the same problem . Threads are not needed at all and this is not hypothetical either as tokio catches every task panic. Paired with a the panic comes back as a , the next succeeds and reads a null pointer exactly like the mutex example from the issue. Given how much panic catching goes on in async code, much of which is for performance reasons, I’m not even convinced that panics get caught more often in multi-threaded code yet nobody asks for to poison. The standard library isn’t consistent with itself either as poisons for good, never poisons, poisons but lets you recover. Also remember that poisoning only tracks panics and a more common early return has the same issue. The operator (as well as the macro before) that returns early from the middle of a critical section leaves the same broken invariant behind an unpoisoned lock. Note also that the coupling of poisoning of mutexes is historical and an explicit type would allow you to opt into this for any interior mutability wrapper. Personally I hope the rust team stabilizes , have resolve to it by default . If someone wants poisoning add that separate wrapper then anyone who believes they need and can handle it, can opt into it for any type including or tokio threads. What I think would be the worst of all outcomes is the counter-proposal is to keep poisoning but have panic instead of returning a . That would only fix the held guard lock semantics, and to a smaller degree the ergonomics, but it makes the slow outage the only option. That is what every does today, and the issues above should be plenty of evidence of this being a problematic behavior in light of the existence of . The post In defense of lock poisoning is the best argument for the other side and worth reading but I believe the evidence all points the other way, and most of what Oxide ships aborts on panic anyway which is also a reasonable behavior. In RLS a failed cargo build panicked with held which made any subsequent runs impossible . Mozilla’s application-services saw rise to rank 5 in crash stats and moved to parking_lot after they concluded they did not benefit of poisoning handling. A Neon safekeeper on staging failed every timeline lookup after a panic with a global lock held, and the original panic could not even be found in the logs.

0 views
Ankur Sethi 1 weeks ago

An experiment with SIMD in Rust using fearless_simd

SIMD is having a moment right now. I've always been vaguely aware of the existence of SIMD instructions, but it was Mitchell Hashimoto's Everyone Should Know SIMD that finally inspired me to try writing some code that uses SIMD myself. I decided to take a straightforward problem and try making it faster using SIMD instructions: count the number of occurrences of a byte inside a text file. Since I've been using Rust for writing pretty much everything these days, that's the language I picked for this task. I used as my test dataset. This is a file containing a gigabyte of text from the English language Wikipedia. All benchmark numbers are from my MacBook Pro with an M4 Pro and 48GB RAM. My Rust version is 1.100.0. Here's what the non-SIMD version of the code looks like: When I compiled this code with Rust's auto-vectorization turned off, it took 138.05ms to count the number of occurrences of the letter in the test dataset. With auto-vectorization enabled—which is the default behavior—it was marginally faster at 114.55ms. Here's the same code, this time using : This code took 30.35ms to to run on my computer. That's ~4.5 times faster than the scalar version with auto-vectorization disabled, and ~3.8 times faster than the scalar version with auto-vectorization enabled. Pretty damn good for a few extra lines of code! To make sure my numbers were accurate, I had to make sure Rust and LLVM weren't optimizing away the very code I was trying to benchmark. I recently inherited an old ASUS TUF Dash F15 from my brother. This computer comes with an 11th generation Intel Core i5 (11300H) and 24GB RAM. It's currently running Fedora 45. The benchmarks on this machine were a bit surprising: I don't understand why enabling auto-vectorization made the scalar version slower . I don't know enough about Rust, SIMD, Linux, benchmarking, or x86 assembly to explain this behavior. If anyone reading this understands why this happens, I would appreciate it if you could get in touch . If you want to try replicating these experiments, you can grab the code from my GitHub repo. You'll also have to download the test data from Matt Mahoney's website . Go added experimental SIMD support to their standard library. C++26 standardized (which hasn't been very well received ). Portable SIMD is available on nightly Rust via . The excellent cut a 1.0 release in September . It works on stable Rust. Other languages have already shipped portable SIMD APIs in their standard libraries for a few years. For example, in Zig and in Java . I made liberal use of to block certain common optimizations. I used to prevent inlining the scalar code ( might have been enough to ensure this, but I was in an overly cautious mood). I compiled the scalar version with and to disable auto-vectorization . Scalar version with auto-vectorization disabled: 240.48ms Scalar version with auto-vectorization enabled: 319.96ms SIMD version: 56.80ms

0 views
Jimmy Miller 1 weeks ago

The Magic of Partial Evaluation

There are certain ideas in software that are simply beautiful. It doesn't matter if they have any practical use. It doesn't matter that you will never convince your coworkers to consider them. There is just something captivating about the way some computational systems work. For me, the most beautiful pieces of software are those that reveal something about the nature of programming languages. Programming languages are my obsession. I have never met a problem that couldn't be solved by introducing yet another programming language. Solving a problem at the programming language level is about solving the meta problem. Instead of trying to solve a particular problem, we take a step back and ask how we can solve a whole class of problems at once. So when I find something that makes me rethink the nature of programming languages, I start rethinking computation as a whole. One of these incredibly beautiful but tricky concepts goes by the name partial evaluation. If you are fascinated by interpreters and compilers, partial evaluation will teach you how they are related, and how you can get a compiler for free. Partial evaluation has been a fascination of mine for a while. But this whole thing came up when James Long announced he had revived Meta's partial evaluator for JavaScript called prepack. When I first heard about prepack, I had some high hopes and expectations for the project, but was sadly let down. This revival brought to light those same dreams. But sadly, just as with the original aim, prepack was not designed for beauty, but for practicality. So I figured it was time to renew my own efforts. Yes, in some ways this is a post repping my own library I'm releasing. But I'm not doing this because I want it to be used. I'm doing this because it lets you play with the idea I find so beautiful. That is what this post is about. Consider the following code: As a person who reads code, you can think about how this code computes and what answer it will give. But you can do more than just give the answer. You can see the expanded form of this particular code for these particular calls. This code is spiritually the same as the following expression, once we expand it out. In this case, there is really nothing at all that this code needs to do at runtime. A sufficiently smart compiler will just run this code directly at compile time and give the answer. But this is a bit less clear if things come in at runtime. It might seem like we can't do anything here, but again, if you are used to thinking about how programs run, you can trace this out and realize this is just the same as: What we have done in both of these cases is called partial evaluation. In the first, it was a trivial case because everything was statically known. But in this latter case, we have reduced a program down into the essentials of its dynamic structure. There are no recursive function calls left. All of this has been expanded as far as it could till we get just the dynamic parts of the code remaining. This intuitive notion of partial evaluation is all you need to know to appreciate the beauty here. Partial evaluation just evaluates the part of the program we can evaluate at build time and leaves all the rest. When we do this with certain programs in certain combinations, we get some quite surprising, incredible behavior. Here we have a very simple interpreter for a language that just supports arithmetic. For the above expression, you should be able to think about how we could start "partially" evaluating it. (In this case, it can be a full evaluation.) If this kind of partial evaluation isn't quite clicking for you, I've put the steps below to hopefully help it make sense. This is a simple evaluation of the code. But what happens if we throw a value we don't know into the expression? Here we can see that clear partial evaluation difference. We don't know how to evaluate . We have no idea what the answer to that will be. But as part of this process, we do know some partial information about it. For example, when we get to we know that is indeed a number. So we can partially evaluate it further. Hopefully this is all making sense. But if you are like me, this all might seem a bit trivial and uninteresting. So let's look at a more complicated example. Here we have a brainfuck interpreter. And the example program we want to partially evaluate does not require any input at all (in brainfuck is the way you get input). So when we go to partially evaluate this, we will just get an answer. In this case, this program is actually brainfuck's "hello world". But what about a program with input? When we do our partial evaluation, we get the following: What is this? A compiled brainfuck program! This is the first incredible fact: when you take an interpreter and partially evaluate it with a program, you get the compiled program out! Now this particular exact form is an artifact of how my partial evaluator works. You could imagine slightly different code. But the key is that what we've done is remove the interpreter completely. What we've discovered here is the first of three so-called Futamura Projections. Our partial evaluator, when applied to an interpreter and given a program, can give us a compiled version of that program. Or to put it in pseudocode. Depending on your exposure to interpreters and compilers, this might seem miraculous or mundane. Writing an interpreter and writing a compiler can seem like significantly different undertakings. In the age of AI, perhaps less so, but I think even then many things still hold. It is quite easy to instrument an interpreter, quite a bit harder to do so for a compiler. Changing an interpreter to support new features is quite easy, less so for a compiler. But more than that, there are all sorts of things that can be thought of as interpreters, that we'd almost never write a compiler for. Consider this simple schema setup. This is code that can easily be partially evaled into something where we have created specialized functions for our particular schema. While not the most crucial code, this can give us a 5x performance boost when our objects start getting more complicated. You may think that we should just hand-write those functions. Or hand-write a compiler for these schemas. But what about those schemas that exist only at runtime? Now we either need to compile those on the fly, or we have to keep both a compiler and interpreter. Having a way to partial eval lowers this burden quite a bit. But if the Futamura projections stopped here, they would be exciting, but not quite the craziness they are. To understand how this can go further, we are going to take this a step beyond your raw intuition of what it means to partially evaluate something and give a different frame. We can think of partial evaluation as a process of "specializing" a program. What exactly is specializing a program? Well, it is taking a program that is generic and making a version that instead works for a single program. Let's think about a simple pattern matcher program like an overly simplified regex. This program is generic. It lets you match on many different patterns. That can be great if we need that flexibility. But if you don't have a bunch of patterns, it might be worth it to just make specialized code. Now, exactly what kind of specialized code? It might be that you only have this literal pattern; then you want to specialize very particularly. Or you just have as a pattern. For any bit of generic code, we can think of how to move our code to a more specialized form. Partial evaluation is a form of specialization that figures out what it should specialize on based on what input is static and what is dynamic. In many ways, a partial evaluator is a generic specializer. Given any program, we can make a specialized version of it for any input. What happens if we specialize an interpreter for a given input? We get back that interpreter for only exactly that one program. But what do we need then? Do we need all this generic dispatch? No, we know the full program. We don't need any operations we don't actually use. We can fully get rid of all the generic interpreter mechanism. But if the specializer can specialize any program, can it specialize itself? This leads us to the second Futamura projection. Put in our pseudo-code format, we get: Or, to put it in our specializer language, what if we make a special version of our generic specializer? What is it specialized for? A particular interpreter. Now we have a function that, given any program, will spit out newly specialized interpreters just for that program. Or, in Java speak, we have a specialized interpreter factory. Let's see a real example of one of these compilers to make this concrete. Here is the interpreter we are going to specialize. When we apply our second projection, we get out the following compiler: And if we compile one of these very simple programs, we can see the output: Now, of course, this is not a very interesting language. But hopefully you can see this general idea. Given an interpreter, we automatically derive a compiler! Pretty incredible. But we can't stop at the second projection. We have to push on and get to the final mind-bending projection. If you apply our specializer to itself as input, you get a compiler generator. So now we have a generic function that will spit out compilers for any interpreter we give it! I have implemented a reasonable, but still very limited partial evaluator for JavaScript in Rust. I have taken it further to try to make it work quite well for a number of different interpreters and interpreter-like programs in JavaScript. I've also tried to get limited versions of the second and third projections working. Go play with it, see what works, what doesn't, file issues, or better, use some of your tokens to help me make more cases work. But most of all, explore. This is such a rich space. Below are some papers, blogs, and projects about partial evaluation in some way, shape, or form. There has never been a better time to play with these kinds of crazy techniques for programming languages. Don't let what is practical stop you from exploring the cool, interesting aspects of programming. weval: the WebAssembly partial evaluator Compilation of JavaScript to Wasm, Part 3: Partial Evaluation — Chris Fallin A First Futamura Projection — Veit Heller Partial Evaluation in Truffle — Graal documentation Partial Evaluation of Computation Process—An Approach to a Compiler-Compiler — Yoshihiko Futamura (1971, original English translation) Partial Evaluation and Automatic Program Generation — Neil D. Jones, Carsten K. Gomard, and Peter Sestoft Tutorial on Online Partial Evaluation — William R. Cook and Ralf Lämmel

0 views
daniel.haxx.se 1 weeks ago

Actual curl rewrites in rust

For a long time we have received repeated requests for, or questions about, a curl rewrite in rust. Often as a joke, but also seriously. A joke from years ago In this modern world of AIs, we have only been waiting for someone to prove it possible and now it seems we don’t have to wait anymore. This fall seems to be the time of the curl-in-rust takes as we first saw urlx appear a few months ago, claimed to be a memory-safe, from-scratch reimplementation of curl and libcurl and now in November curl, rewritten in Rust – a rewrite of curl and libcurl in Rust . This second one confusingly enough not even using a different name. This latter one claims to have spent 8,600 USD to make it happen. Writing code once was never the big deal with software and it still isn’t. Sure, it’s fascinating that you can make a set of agents accomplish this in only a few weeks but let’s face it: it could do this because all the AIs of the world have trained on curl code for years. curl is extremely well documented, there are hundreds of existing open source application using its API and there are thousands of test cases to verify the implementation. The C code sits there and all the AI needs to do is convert it to rust, then polish until the tests work. A know-it-all person’s comment from years ago curl is the result of time curl has come to be what it is thanks to many decisions, lots of time, many users, oceans of feedback and many iterations. Sure, recreating what curl is at any specific single moment in time is certainly doable. Doable, because we have made a perfect specification for that project. During the time these agents converted 185,000 lines of C code into 340,000 lines of Rust code (I counted), we merged over 300 commits in the actual curl project. We actually improved curl during these a little more than three weeks. A little over 200 bugfixes actually. 200 bugfixes that none of those rust rewrites have. We also fixed a few vulnerabilities. In another month we have done another 200 and maybe fixed a few more vulnerabilities. Will these clones keep up? The constant tweaking, fixing, improving and extending is what makes a software project live, what makes it attractive to users and what makes it able to compete with alternatives. That fixing, and occasional new feature, is a direct result of a working community of users, contributors and maintainers. That goes way beyond the source code or which language that is used. A primary reason it is hard to make a competing curl alternative is because of the development speed, the development team and the community around curl. It is not because of the chosen language it is implemented in. Only curl can boast decades of ABI and API stability and prove that we know this and can do it well – over time. An alternative that pops up today might be able to do it as well, and in a few decades we will know if they could . I know I’m repeating myself but: out of the 81 vulnerabilities we have confirmed in curl so far during 2026, 14 were the result of mistakes that most likely would have been avoided had we used a memory-safe language such as rust. That’s 17.3%. A Rust implementation of curl would thus still have had 67 of those vulnerabilities. I don’t believe in rewrites into any language. I believe in constant and never-ending polishing, iterating and refactoring. I should add that I have not been in contact with any of the people behind these rewrites, and if there are two I bet there are more that I just haven’t seen yet. I only know of them because people have pasted me links to their repositories. I don’t know what they will do with those projects going forward. Are they anything more than proof of concepts? I presume we will find out. They can of course follow along our commits and convert them to rust on the fly if they want – we only do about 11 commits per day on average. Or maybe they ignore the bugreports or maybe they take their projects in other directions? I wish them good luck whatever they decide! Several people asked me this. Imitation is the sincerest form of flattery that mediocrity can pay to greatness . / Someone I’m amused. A little puzzled. Fascinated. They spent their money and effort on that?

0 views
matduggan.com 2 weeks ago

So all software is free as in money now?

A few weeks ago I was up late in my kitchen. I've always been a bad sleeper, starting from when I was 10 and would spend whole nights reading books and watching the clock slowly wind it way to when I had to get up and go to school. Like most things, I hoped it would go away when I was older and instead has now become something I've just gotten used to. My friends all know this about me, so I'm typically who you call if you also can't sleep or have a sick baby and want to speak to another adult. It's whatever the opposite of a superpower is. It was during this period I got a text message from a friend with the line "someone has made the Adobe Suite with AI and it's free". Without any additional thought I proclaimed to my empty kitchen with its too-small European refrigerator "that's the stupidest fucking thing I've ever heard". There is frankly nothing worse than the endless cycle in tech of "we've cracked a hard problem in an easy low effort way". Every single time there is always a giant asterisks, something it doesn't do, something where the illusion falls away. Obviously I hadn't yet actually tried the software before I uttered this confident proclamation to my picture of a corgi as a dictator that I keep hanging on my kitchen wall. There was no way you could recreate what Adobe had made, right? When I graduated from college in 2008 and I watched in horror as my friends all moved back in with their parents, I decided I'd rather freeze to death in Chicago than suffer that fate. So I got a job that my childhood spent in local PC repair stores and college IT department helpdesks didn't really prepare me for by basically acting confidently. I was a corporate Mac IT contractor who wandered from skyscraper to skyscraper with my Manhattan Portage Messenger bag that had cost way too much money and hurt my shoulder with all the tools and spare 3.5 in hard drives I had to carry. The primary market for Macs at that time was college students and creative departments. Frankly, nobody else wanted them or had the budget for them. Creative departments inside of large corporations are a strange place to work. Often I would get escorted by security past rows and rows of cubicles (god remember when we thought cubicles were dehumanizing? We hadn't seen the unending horror of the open office plan yet). The creative department was usually the only place where even an attempt had been made to make the place less depressing. They often had like real books on shelves, art on the walls and the only employees in the entire place you would describe as "fashionable". The spaces were dominated by giant printers that would produce the full-size examples of "wraps" for buses or other large-scale advertisements. There were often a bank of color-calibrated monitors with hoods on them in a special area, which was always a thankless job. Color calibration was me attempting to prove with my little device that we were exactly on target with the Pantone colors on these specific monitors while the creative director would wander by, dressed like a college professor and confidently explain to me that "it's closer to Classic Green not Poison Green". They'd go get the Pantone color cards out of their office. From my perspective it seemed like a lot of people arguing a lot over whether to move rectangles in InDesign. There was no question that the tools they were using were Adobe tools. Nobody ever even asked if they really needed Adobe, in the same way that nobody ever asks "is water pressure actually important". The most reliable work I got was from a design studio in River North run by a woman named Donna. Donna was a life-long Chicagoan who seemed to liked me as an employee exclusively based on my willingness to walk and talk with her as she endlessly patrolled the upper level walkway. The pit area were all the designers and the upper ring was the senior staff. They did a lot of print advertisements and campaigns, which meant fonts. Fonts, for those unaware, need to be licensed to be used. Default fonts, at least for Donna, were basically trash not to be trusted as even placeholders. She was the keeper of the font licenses and the font license software, ensuring everything was paid for and allocated correctly. She liked to issue threats and then pretend they were a joke. "If a campaign ships with an unlicensed font, it'll be your ass! Anyway have a great day." She used to smoke in the alleyway behind the building in her pantsuits and a folded Wall Street Journal. I spent almost the rest of my time that wasn't spent on fonts troubleshooting problems with Adobe software. Teams would get legitimately nervous before updates to their core applications. Any changes to a shortcut would be met with a chorus of boos from the pit. The workflow was mostly ensuring that the local network share was up, backed up and performant. A lot of my day was ensuring the tape backups were working, shipping one set of backups to Iron Mountain for offsite storage which sounds cooler than it was. I was invited out to the temple of Adobe out in San Jose to chat with the folks there once. I don't remember the exact chain of events, but it was basically a large Adobe customer who wanted to ensure that they got some face time and I tagged along. I was horrified when you walked up to the building because at the time (around 2011) it basically looked like a bank. The lobby smelled like sorta old fabric and the offices were surprisingly run-down. Like as it turns out the nerve center for Photoshop was not quite as lux as that price tag would lead you to believe. It also didn't help that I never know how to dress for California weather. It's always colder than you think it would be? So after I tried and failed to find their parking garage, I ended up finding cheap(ish) parking like 5 blocks away and showed up to their office sweaty and flustered. But after spending the day with the folks there it was hard not to walk away with the impression that they cared deeply and truly about the sorts of creative problems their customers were trying to solve. They looked like the designers I was working with back in Chicago, with the same earrings and cool rolled up shirts. The demo stuff they were showing, I didn't really care about the software but I did care a lot about "is there maybe a way to shim a cheaper alternative to Adobe in there?" In short the people I met were very impressive and the answer was no. They had answers to every question I could imagine and every question my users had come up with. The software looked amazing and had just endless seas of options nested under options. I walked away with the complete confidence that regardless of what happened, unless they made a series of just catastrophic mistakes, they were entrenched forever in the creative space. Then they made a bunch of catastrophic mistakes. Originally creative software worked like....buying anything else expensive. It was a shrink-wrapped box that cost like an eye-watering amount, I think I remember $649 for Photoshop at some point. Then that turned into the Suite where it made sense to buy a license for the suite. This was kind of Adobe at the height of their powers, where it was cheaper to buy the whole rather than get the two parts you needed so then their file formats and patterns became just the default. Everyone needed one part of the suite so it was hard to kinda wedge yourself in there. If an upstart showed up they were typically acquired and then rolled into the Suite. Then Adobe watered down the value argument. I was still like vaguely involved with the entire ecosystem when the switch happened to Creative Cloud. It's kind of hard to...overstate how angry this made people. I don't think anyone has truly really measured the pure fucking fury that Adobe generated with this move. The combination of "there is no such thing as a perpetual license", the aggressive dark patterns for signup and the cancellation fees fundamentally changed the relationship Adobe had with its customers. Basically when Adobe retired perpetual license like a jersey, the vibes changed and the party was over. The best way I can describe it: some companies rely on the perception by their user that they have their best interest at heart. Apple is sorta like this. Adobe, I'd argue, was like this. The Microsoft Office team is maybe a bit like this as well. If Amazon screws you over well that's just them being their natural selves. Some greed is tolerated because they're cool and its understood to be a premium product. But if you cross sort of an invisible line of greed, the product is ruined in the minds of the consumers. For a lot of people, the butterfly keyboard Mac with no ports that broke a lot destroyed the entire concept of the Mac laptop for them. It was a shitty product that didn't work well that Apple didn't care enough to fix. There wasn't really a "coming back" for those users, because the illusion was shattered. Apple wasn't a cool group of creative California people they were assholes who were telling them to pound sand. Part of the mystique was killed and then you are left with a broken laptop and a trip to a dying strip mall. Microsoft Office was never the cheapest way to do a spreadsheet, word processing or slides, but it was pretty cheap and the file formats became the defacto standard. Then suddenly everyone collectively decided to cross the greed line at the same time. So I downloaded LightCraft as the primary Adobe software I use now is Lightroom. I've paid a subscription for...many moons for it. It works quite well, does exactly what I need. I had downloaded it expecting to hate it. Most LLM stuff looks nice and runs like shit, ending up being a giant waste of time. I also eye-rolled at "rewritten in Rust" which has become this new slang for "I didn't write any of it myself". At this rate nobody on earth will have ever hand-written Rust. The first sign something was good was how quickly it started. Adobe stuff opens slow, I assume to ensure that my paperwork is in order back at HQ. It also sipped RAM and CPU. As I went through my "workflow" which is a fancy way of saying "I take phone photos that suck very much and then try to make them slightly better", I was really impressed. The things weren't all in the same place, but more or less it worked as I expected it to. To be clear, I'm not suggesting these things are bulletproof. For instance, the Artcraft launcher is constantly telling me the launcher has an update. I'll hit update and it'll throw an error message. I'll quit the app and then it....seems to have applied the update? I also spent a few hours with DesignCraft which is their Adobe InDesign alternative and like we're still pretty far from that replacing InDesign as of right now. Great if you have some straight-forward needs for InDesign, but I think the Adobe moat is pretty strong there. InDesign people live or die by impossibly hard to detect errors. All that said, I was surprised how close a lot of the features got . Especially considering this is an LLM written clean-room implementation. Now to be clear I'm not a lawyer and that explanation makes no sense to me. I don't know why a "clean-room rewrite by an LLM" would be better than you making a Lightroom knockoff by hand. Feels like the clean-room part is making this sound a lot more scientific than it is. But as I spent hours clicking around and trying things out, I started to get a pit in my stomach. The best and worst thing about tech is that everything is constantly changing all the time. We've now gone from the moat being the price, distribution and shelf space to file formats, enterprise sales team to now the last remaining trickle of water being muscle memory and intellectual property. I was reading the interview in Ars with the folks behind this and the quote that popped out to me was "I one-shotted Photoshop. The whole thing". https://arstechnica.com/ai/2026/10/software-is-over-bold-ai-developer-takes-aim-at-adobe-with-open-source-clones/ That is a crazy sentence. If you aren't a developer, let me put it like this. Imagine if you read about the construction of Notre-Dame de Paris. Generations of workers, precise and hard to learn techniques, the whole thing. Some design elements we still don't fully understand today how they work. Then someone in Texas made a giant 3D printer that shot out a one to one copy in six months. Also there's a gift shop. I increasingly think the way we think about moats and barriers in software was always wrong. I think the actual moat was the goodwill built up over decades, the trust that these were professional tools and the people behind them wanted the best for you. Plus the 15+ years of muscle memory and just comfort in this ecosystem. You can 3D print software but you cannot really clean-room generate trust. But right now you don't need to, because every incumbent keeps giving their trust away, one dark pattern at a time. So what does this mean for software, if Adobe and Microsoft cannot keep the moat going? What if CADCraft does get good enough to threaten AutoCAD, a product with muscle memory older than some nations? Are we ever going to sell desktop software again, or is the future just an endless series of clones, produced by LLMs, with what specific features you want? I don't know. Meanwhile, the launcher has told me there's another update to the LLM Lightroom somehow. Right now the race feels weirdly inevitably, like watching a horse beat a car once and knowing in your heart that the car is gonna win in the end.

0 views
Blog System/5 3 weeks ago

Unattended reboots with encrypted disks

Do you run a small home server or NAS holding your precious photos and sensitive documents? If so, I suppose the drives are encrypted, right? But then… can you reboot the machine without manually entering a passphrase before being able to access your files again? If you answered yes to the questions above—which is common for convenience—that implies the encryption keys live in the machine which… kinda defeats the purpose of disk encryption, doesn’t it? A thief can break into your house, lift the whole box (they are small these days, huh), plug it in elsewhere, and gain free rein over your files. So, which one is it? Simplicity and reliability by allowing automatic reboots or data protection by keeping the key in your head? With ZKeys—a little new project I’m launching today—you can have your cake and eat it too. TL;DR ZKeys is a managed service that stores encryption passphrases off-site. Client machines fetch the encryption keys from the service and keep those keys alive (unlocked) via periodic keepalive messages. If the server stops receiving those messages for a long period of time (e.g. because it has been unplugged as part of theft), access to the key is automatically locked. You get automatic, passwordless reboots while keeping your data protected against real incidents. Did you know that, by subscribing to Blog System/5, you support the creation of this content and this software? About a year ago, I was reinstalling my FreeBSD home server to act as my NAS after a short stint with a Synology box . During that process, I decided to enable encryption for the ZFS data pool. But as I did that, I faced the question: how do I allow the machine to automatically serve my data after a reboot? I could put the key in a local file, which FreeBSD supports via the ZFS option, but that would render disk encryption pretty much useless. So I had an idea: what if I put the key on a different machine away from my house? I could then make the NAS fetch the key to mount the drives. And if someone stole the server, I could wipe the remote key and make the data unreadable before they could plug it back in. I did post this to Twitter and there was some interest in the idea: But… did you notice the problem with what I said above? Wiping the key by hand after noticing something is wrong is problematic because the gap between those two events may be large. What if I’m on a long vacation and I have no means of noticing that the machine has been stolen? Game over. So I refined the idea: what if I had a service that stored the key remotely and required the consuming machine to send it frequent pings to keep the key unlocked? This way, if the machine were stolen, it’d likely be offline for more than a few minutes and the service could automatically determine that something is wrong and lock the key from future accesses. And that’s precisely what ZKeys does. Before getting into details, it’s important to get something out of the way early on: ZKeys is designed so that a compromise of the server is insufficient to retrieve or reconstruct your keys. This is done in two ways: Split keys: The ZKeys server only stores half of the passphrase used to unlock a volume. The other half remains on the client machine. The client program combines both halves to produce the whole passphrase. Encryption at rest: The keys are encrypted at rest with a password that the client must supply for retrieval and which is securely transmitted over HTTPS. The password only lives in the server’s memory for a brief period of time. The tradeoff is, simply, that you MUST back up the full encryption keys in a third location of your own (a paper in a safe, a password manager, you name it). If ZKeys goes down or you lose your remote key password, there is absolutely nothing I can do to help you. You have been warned. The setup instructions later on will instruct you how to back the key up. The ZKeys service is available at https://zkeys.jmmv.dev/ and the open-source client—along with system integrations for FreeBSD and Fedora—is in my jmmv/zkeys repository. Disclaimer: ZKeys is offered to you for free. I make no promises about its reliability, availability, or anything else. I am giving you access because I expect that supporting a handful of extra users won’t be a big issue. But if support becomes a burden, or if load becomes unmanageable, I’ll have to re-evaluate my choices here. Which means that, for now, you have to use the limited code to get started! The basic idea to set ZKeys up is the following: Install the client CLI tool. Create a service account. Create a new key (or onboard an existing key). Configure the keep-alive service on the target machine. Change or add the filesystem encryption key to be the one stored in ZKeys. Configure the auto-mount service on the target machine. That’s all it takes, but the steps are quite manual at the moment because no upstream OSes provide packages. The service documentation covers several scenarios in detail for FreeBSD and Fedora, so I’m not going to repeat them here. Demo of the integration between ZKeys and Fedora 44 with a fully encrypted root volume: the video starts by showing a fully unattended boot, followed by a manual lock of a key that causes Fedora to refuse to reboot on its own, and finishes with another automatic reboot after the key has been unlocked again. Now for the nerdy details, because that’s what you’re here for: The CLI is Rust, of course, but it has to come with a bunch of shell scripts to integrate with FreeBSD’s rc.d system and Fedora’s systemd and dracut. These integration points are the trickiest part of the client package and the hardest to validate automatically, which is why I only provide support for the two systems I use on a daily basis. It should be possible to integrate ZKeys with any other Unix-like OS, though. The CLI package is a frankenmonster made up of Cargo and GNU Automake/Autoconf because of the above. I believe system-level tools should abide by de facto standard tooling even if such standard tooling is deficient, so GNU Autotools it is. I run two non-replicated instances of the service: one in US West and one in EU West, because I have machines in both locations and both rely on encryption. I strongly suggest you use the US instance as I’m seeing frequent power hiccups in my EU deployment. The frontend uses Bootstrap, straight from the 2010s. Does it look ugly? Maybe, but I kinda like it and, most importantly, it’s functional . Of course I could have asked AI to produce yet-another-dull-site full of gradients and slop, but I did not want to do that, so I stuck to what I already knew how to do by hand from previous services. The admin page is an SPA, yes. This is an intentional design choice that forces a very clear separation between the backend APIs and the frontend. Whatever the current web frontend can do any other client can do as well. For example: the current CLI tool does not offer administrative operations but it could trivially be made to support them, because the APIs are right there. The backend is built on my own III-IV framework which I’ve been building up over the last few years while implementing a couple of other services. I’ve had to add a lot more features to it to make this possible though. Oops, I know that’s the name of a different effort , but you really need to encrypt your local drives. With computers becoming smaller and lighter every day, it’s easier than ever to steal them, and unfortunately home break-ins are common in some parts of the world. Block-level encryption is cheap in CPU terms, so do it. ZKeys just makes this process less cumbersome for headless servers. Once again, head to: https://zkeys.jmmv.dev/ to get started and use code to create an account! And if you are interested in helping out, I’d appreciate the creation of packages for FreeBSD and Fedora, and integration scripts for other systems. TL;DR ZKeys is a managed service that stores encryption passphrases off-site. Client machines fetch the encryption keys from the service and keep those keys alive (unlocked) via periodic keepalive messages. If the server stops receiving those messages for a long period of time (e.g. because it has been unplugged as part of theft), access to the key is automatically locked. You get automatic, passwordless reboots while keeping your data protected against real incidents. Did you know that, by subscribing to Blog System/5, you support the creation of this content and this software? Storytime About a year ago, I was reinstalling my FreeBSD home server to act as my NAS after a short stint with a Synology box . During that process, I decided to enable encryption for the ZFS data pool. But as I did that, I faced the question: how do I allow the machine to automatically serve my data after a reboot? I could put the key in a local file, which FreeBSD supports via the ZFS option, but that would render disk encryption pretty much useless. So I had an idea: what if I put the key on a different machine away from my house? I could then make the NAS fetch the key to mount the drives. And if someone stole the server, I could wipe the remote key and make the data unreadable before they could plug it back in. I did post this to Twitter and there was some interest in the idea: But… did you notice the problem with what I said above? Wiping the key by hand after noticing something is wrong is problematic because the gap between those two events may be large. What if I’m on a long vacation and I have no means of noticing that the machine has been stolen? Game over. So I refined the idea: what if I had a service that stored the key remotely and required the consuming machine to send it frequent pings to keep the key unlocked? This way, if the machine were stolen, it’d likely be offline for more than a few minutes and the service could automatically determine that something is wrong and lock the key from future accesses. And that’s precisely what ZKeys does. Zero-knowledge protection Before getting into details, it’s important to get something out of the way early on: ZKeys is designed so that a compromise of the server is insufficient to retrieve or reconstruct your keys. This is done in two ways: Split keys: The ZKeys server only stores half of the passphrase used to unlock a volume. The other half remains on the client machine. The client program combines both halves to produce the whole passphrase. Encryption at rest: The keys are encrypted at rest with a password that the client must supply for retrieval and which is securely transmitted over HTTPS. The password only lives in the server’s memory for a brief period of time. Install the client CLI tool. Create a service account. Create a new key (or onboard an existing key). Configure the keep-alive service on the target machine. Change or add the filesystem encryption key to be the one stored in ZKeys. Configure the auto-mount service on the target machine. The CLI is Rust, of course, but it has to come with a bunch of shell scripts to integrate with FreeBSD’s rc.d system and Fedora’s systemd and dracut. These integration points are the trickiest part of the client package and the hardest to validate automatically, which is why I only provide support for the two systems I use on a daily basis. It should be possible to integrate ZKeys with any other Unix-like OS, though. The CLI package is a frankenmonster made up of Cargo and GNU Automake/Autoconf because of the above. I believe system-level tools should abide by de facto standard tooling even if such standard tooling is deficient, so GNU Autotools it is. I run two non-replicated instances of the service: one in US West and one in EU West, because I have machines in both locations and both rely on encryption. I strongly suggest you use the US instance as I’m seeing frequent power hiccups in my EU deployment. The frontend uses Bootstrap, straight from the 2010s. Does it look ugly? Maybe, but I kinda like it and, most importantly, it’s functional . Of course I could have asked AI to produce yet-another-dull-site full of gradients and slop, but I did not want to do that, so I stuck to what I already knew how to do by hand from previous services. The admin page is an SPA, yes. This is an intentional design choice that forces a very clear separation between the backend APIs and the frontend. Whatever the current web frontend can do any other client can do as well. For example: the current CLI tool does not offer administrative operations but it could trivially be made to support them, because the APIs are right there. The backend is built on my own III-IV framework which I’ve been building up over the last few years while implementing a couple of other services. I’ve had to add a lot more features to it to make this possible though.

0 views
Matthias Endler 3 weeks ago

Wrong Ways To Create Strings

I’m on my way back from RustLab 2026, where I gave a lightning talk about all the ways to create a in Rust that don’t involve . The talks were not recorded, so I decided to write it up as a blog post. Collect Some Characters One of the most obvious ways to create a string without calling is to collect some characters into a string: Alternatively, you can start with the UTF-8 bytes: Derive Debug If we derive for an enum, we can format a variant as a string. Note that debug output isn’t a stable serialization format, so this just happens to work for this particular string. Use a CString This is another very obvious one: we can use to create a string with a NUL terminator, then convert it back to a . Converting it back removes the terminator and checks that the remaining bytes are valid UTF-8. Use If we supply an invalid string to , it will return an error instead of panicking. We can abuse that fact and call on the result to get the error, which gives us the rejected bytes back . All we have to do now is remove the invalid NUL byte we added: Now we can convert each byte back to a character. is safe because every value (0–255) corresponds to a valid Unicode character. It does not decode UTF-8; it simply converts each byte into a Unicode code point. When collecting these characters into a , Rust automatically encodes them as valid UTF-8. Therefore, the conversion cannot fail, but the resulting text may be incorrect if the original bytes represented multibyte UTF-8 characters. Statically include some text with Create a file called containing exactly , without a trailing newline. In another Rust file, we can include that text at compile time: The extension doesn’t matter. embeds the file as UTF-8 text at compile time; it doesn’t try to parse it as Rust. Thread Shenanigans Threads can have names, and we can read the name of the current thread. We can abuse that to create a string by naming a thread and then reading its name from another thread. Then let it read its own name and send it back: The name is borrowed from the thread handle; that’s why we copy it into an owned string. Ask Another Process Instead of threads, you can also spawn a child process and read its output. The child prints the string and exits. The parent waits for it, checks its exit status, and converts the captured stdout into a . Store It in a Float Those bits, read as little-endian bytes, are . We can use to avoid the numeric conversion of these bytes. Now extract the characters and discard the two padding bytes: Note how I use and here. That’s because these are two separate variables, not characters. Using makes this independent of the machine’s byte order. All we have to do is format the variables back into a string. Assemble a String From Raw Parts A in Rust is just a pointer to a heap allocation, along with a length and capacity. We can manually create an instance of that type, but we have to be careful to get the layout, length, capacity, and UTF-8 validity right ourselves. gives up ownership without freeing the allocation. The takes over and will free it when dropped. Using the Type Name Every type in Rust has a name. We can use to get the name of a type as a string. So if we create a type with the string we want, we can get that string back from the type name. The name can include the module path, so we take the last component, then “parse” it as a string: Note that does not have a stable naming API, so the exact output is unspecified. Deliver It Through a Panic Maybe one of my favorite ways to create a string is to panic with it and catch the panic. That works because the panic carries an owned . Catching it gives us the payload, downcasting gives us a , and dereferencing moves the string out of the box. This requires unwinding . With , the process would just exit instead. Use Only Padding is one of the most powerful macros in the Rust standard library. It supports “format specifiers” that let you control how the output is formatted in exactly the way you want. One feature is , which right-aligns the output and pads it with a fill character. The character before in a format specifier is the fill character. The number is the minimum width: Knowing this, we can completely abuse specifiers to pad an empty string with each letter we need. Argument lets us reuse the same empty string: So we take an empty string and pad it with , then , then twice, then , then . I like how we use to get two s instead of writing twice like a peasant. That was fun! This little exercise is not completely useless. Trying to solve a familiar problem in an unfamiliar way can teach you something new. One more way I didn’t have the time to show in the talk is to use to extract random bytes from memory and hope they form the string you want. Apart from that, did I forget an interesting way to create a string? Let me know on Mastodon . You might also like my 2023 RustLab lightning talk on Printing Things The Wrong Way .

0 views
Stratechery 3 weeks ago

AI on the Ballot

Listen to this post : From Bloomberg this morning at 2 a.m. Central: Democrats won control of both chambers of the US Congress in a midterm election landslide that amounted to a rejection of President Donald Trump following widespread voter discontent with the economy and the war in Iran. Across the country, Democrats scored victories in GOP strongholds, flipping at least seven Senate seats and winning House races in districts Republicans easily carried in 2024. Several news organizations projected that Democrats would win the House, while Decision Desk HQ projected they took the Senate. I have no doubt that Iran and the economy played significant roles in this election; what stood out to me, however, was very much Stratechery fodder. Specifically, I watch a lot of sports, and particularly this fall, watched a lot of baseball. My Milwaukee Brewers — excuse me, my World Champion Milwaukee Brewers — demanded my full attention, which also meant I saw a lot of campaign ads, and by far the most common topic, at least here in Wisconsin, was data centers. Moreover, it was never entirely clear which way it cut politically: both parties were anti-data center, accusing their opponent of being the opposite. Meanwhile in Texas, from Yahoo Finance : A strong showing by Democrats in Texas swept Gina Hinojosa into office as the state’s first Democratic governor since 1990 in a contest closely watched by Big Tech companies. The state is considered a bellwether for government restrictions on AI data centers…Hinojosa, Texas’ first Latina governor, has pledged to impose a moratorium on data center construction in Texas, which accounts for more than 25% of planned US capacity by 2030. Republican incumbent Greg Abbott, I would note, already declared a moratorium on new data-center permits in September; that’s how much of a hot-button issue this is, including in the state that is the biggest opportunity and beneficiary of the data center buildout. So yeah, this is a Stratechery topic of concern. Earlier this year, while writing about data center opposition , I said: There really wasn’t widespread opposition to data centers when they were being built for the Internet generally; indeed, local governments would compete for them, eager for the economic benefits that came during their construction and the long-term tax benefits once they were operational. In other words, it seems pretty clear that the current wave of opposition can’t be divorced from AI — you know, the technology that in the best case scenario is going to take everyone’s jobs, and in the worst case scenario end the human race. I do not, I don’t think, need to explain to you why this is not a very compelling message, and, in the very long run, I do think that humans will have economic value . At the same time, it’s hard to explain the huge amount of investment that is going into AI, not just at the model level but also in terms of data centers, without admitting that a big part of the thesis is that AI can not just increase the top line for companies, but also increase the bottom line — i.e. replace the jobs of some number of humans. Again, I’m generally an optimist here, but this already happened with the first wave of IT . That leads to an interesting contrast to globalization: when companies were closing down American factories and laying off workers and moving operations to China, none of the affected towns or workers had a say. They just suddenly no longer had a job, and a huge number of cities across the Rust Belt no longer had a reason to exist. People simply had to move, or worse, retreat to things like alcohol or drugs. AI, however, is the opposite: building data centers requires permission, which is to say that people actually have a say. Again, I am not at all saying that these people are well informed about data centers, or about the economic impact on their communities, much less the economic impact of AI generally; what I am noting is that people who didn’t have a say in globalization are suddenly finding they do have a say about AI, and it’s not a surprise they are expressing their disapproval by blocking data centers. That message was loud and clear last spring; now it is deafening, and it’s tempting to say that tech, particularly the frontier labs, have no one to blame but themselves. In fact, however, some of the biggest culprits may, in the long run, be some of the biggest beneficiaries of the anti-data center wave. My thesis — driven not just by national results and the Texas governorship, but also the fact that, as this thread documents , nearly every relevant local ballot measure opposing data centers won or is winning ( the only exception so far was in North Dakota ) — is that the constraint on AI dispersion has shifted once again. First we were short on compute, but that ramped; now we are short on memory, but that will ramp; we were coming close to being short on power, but that will be rectified. The final constraint is political, and that may be the most imposing constraint of all. Not only is it harder to solve, but it actually interferes with solving the other constraints. Many of the theories about AI assume that it becomes a commodity; I think it’s just as likely we are looking at scarcity for much longer than we expected, which will have ripple effects on everything. To that end, here — with the caveat that nothing leads to hot takes you regret like an election — are ten perspectives on what a permanently impaired ability to build might mean. To be clear, I’m not declaring permanency — look at how our elections swing back and forth — but it’s worth considering what the implications might be if Americans don’t change their minds about data centers. The most obvious reason why the stock market has been rocky over the last few weeks is the tightening of credit markets, which I wrote about this summer . We are, needless to say, full on into the equity funding era (and while I’m here, I haven’t written about Anthropic’s updated S-1 , but it strongly affirms my initial analysis ). At the same time, it seems clear that this outcome is very bad for the AI trade in the short term, but much of the pain may have already been endured. The Neoclouds have been at the forefront of credit concerns, and from a certain perspective, being unable to build data centers has a silver lining in that they couldn’t get the money to pay for them anyways. Moreover, Neoclouds with facilities that are already permitted now have an asset that is going to be scarcer than expected. At the same time, it’s Neoclouds that need new sites and new permits, even as they are likely to have much less political sway than the hyperscalers — who already have more sites they can repurpose or rebuild. It was already getting harder to get capital, relative to the hyperscalers; now you have to layer on that it’s going to be harder to get permission, too. The downside for the neoclouds is upside for the hyperscalers, who are more likely to grow their share of AI compute than they were before. Moreover, investors may be pleased if the hyperscalers’ ambitions are somewhat curtailed; political opposition is an excuse to moderate spending, knowing that everyone else is in the same boat. Nvidia will almost certainly be a short-term loser. Fewer data centers mean fewer Nvidia chips generally, and a weakened Neocloud set is particularly harmful not only because Neoclouds almost exclusively use Nvidia full-rack systems, but also because Nvidia is back-stopping a huge number of them. It’s the hyperscalers, meanwhile, who are Nvidia’s biggest long-term threat, given their scale and ability to invest in their own chips. At the same time, a constrained world makes Nvidia’s offerings more compelling. CEO Jensen Huang actually spent an entire keynote making this point back in 2025; I wrote in an Update : When Huang says “iso power” he means that power is the constraint; the question is how many tokens can you generate given a fixed power envelope, and Blackwell can generate a lot more. These were the numbers Huang gave for a 100 MW data center: What this means is that the first order of business for an ASIC maker is to match that level of efficiency. That, though, means keeping up with Nvidia’s product development cadence; The Information has a post about Amazon offering instances using its latest Trainium ASIC at a significant discount to the H100. Huang, though, spent this keynote insulting the H100! You can almost hear him speaking to Amazon directly: you spent all this money, and are offering these huge discounts, just to entice developers to lock themselves into an inferior chip, even as reasoning models are going to swamp your available power generation… Huang is issuing a challenge to every cloud provider tempted to make an ASIC: do you really think that you can keep up with this, and risk running out of power capacity because your chips aren’t efficient enough? Don’t even try. A world without power or data center constraints is one where it is, in the very long run, very difficult to maintain Nvidia’s margins; once those constraints start to bite, however, an advantage in tokens/megawatt is worth a lot of money. Go back to my point about the hyperscalers: one way to generate more tokens is to build a new data center; another way is to rebuild a data center with new Nvidia chips. China is the inverse of the scenario that Huang laid out: the country has plenty of power and the ability to build a lot more, but they don’t have leading-edge chips. Some of the advantages of leading-edge chips, however, can be overcome by simply throwing tons of electricity at the problem. From a 2025 Update about the Huawei CloudMatrix 384 supercomputer: The CloudMatrix 384, which is a supercomputer consisting of 384 chips, takes up dramatically more space, uses dramatically more power, is almost certainly dramatically more expensive to make, and is dramatically more brittle than Nvidia’s NVL72; there is no one in the world who would choose the CloudMatrix 384 over the NVL72 if they had the choice. That’s the thing, though: China doesn’t have the choice, because of U.S. export controls. The country’s saving grace is that they are operating on different constraints than the U.S.…China — which actually builds power generation — is not iso power; they are iso compute: Huawei’s goal with the CloudMatrix 384 is to get as much compute as possible, power efficiency be damned. In the fullness of time — i.e. as China figures out leading-edge chips — this may be an insurmountable advantage. When SpaceX released their S-1, I explicitly pointed to political opposition to data centers as one of the company’s most significant upside scenarios: The third question about data centers in space is if there is a stick. Specifically, while I think that racks-in-space are both a lot more viable than people think, and a lot more relevant to agentic inference than current modes of compute, it is at the end of the day cheaper and easier to build on earth, all things being equal. All things are not equal, however: right now we are at the very beginning of the AI buildout and already one of the biggest constraints is not just power (expected), but zoning (unexpected). I wrote in an Update last week: I already posted the relevant excerpt above. Continuing: In that Update I made the case that data center builders — and by extension the companies that use them — should straight up pay people for permission to build data centers in their communities. At a minimum, however, that increases the costs of terrestrial data centers. What seems very plausible in the long run is that the demand for compute ends up being so large that there eventually is nowhere left to build, making the vast expanses of space not just an alternative but in fact the only choice. This is where I come back to my experience watching these campaign ads: this isn’t a partisan issue, where the pendulum will swing back in two years. Both parties see opposition to data centers as a winning cause, and not just nationally: that thread has multiple examples of local officials straight up recalled for approving data centers in their localities. Space will be incredibly difficult, but difficulty is all relative! Moreover, to the extent opposition is permanent, the more this actually reduces the risk of data centers in space, because investors will have more confidence in there being enduring demand. If the hyperscalers had a red queen problem , the frontier labs have it even worse: the biggest revelation from Anthropic’s S-1 was that their inference margins were very high (good!), which meant that their massive compute costs were actually in R&D; this is bad because that R&D spend is governed by competition with the other frontier labs, and absent constraints, that spend looked set to surpass revenue sooner rather than later. Now, however, it is the public that is effectively demanding that the frontier be paced, which is great for the frontier labs’ financial outlook. The upside goes further than that: the point about efficiency being more important in a world of constraints doesn’t just matter for chips, but also for models. Devoting limited compute to inefficient and costlier-to-serve Chinese models is a poor trade if there isn’t enough compute. Moreover, open models may be at greater regulatory risk, as Democrats seem much more likely to pass laws that ultimately favor the frontier labs. There are some counter-arguments. First, if compute is constrained, and thus more expensive, then that will increase the drive to right-size models for jobs, which is a big argument in favor of open models; the fact that compute won’t be a commodity means that the frontier labs’ lower cost to serve will never come to bear on the low end of the market. And, it’s worth noting, it will be harder for the frontier labs to build their own compute, leaving them dependent on the hyperscalers; big tech wins again. The most obvious advantage for Apple is that in a world of constrained compute, inference on the edge will be that much more important. Another advantage is that any slowdown in the dispersion of AI is good for a company that dominated the previous paradigm . The biggest advantage of all, however, is that any slowdown in the AI buildout offers hope that the memory crunch will ease. This will take a while, to be sure, but no company would be a bigger beneficiary of the world running out of places to put AI chips than Apple. AI has drawn a great many battle lines, not just in terms of data centers, but also within AI, and between AI and the rest of tech. Specifically, anything that strengthens the frontier labs is likely bad for the rest of the startup ecosystem. In a world with fewer data centers, startups will have less access to cheap compute, even as a slowdown in capabilities both means it takes longer to build compelling products and also gives the frontier labs time to actually build products that secure their ownership of the end user. One major fear that investors have had about the data center buildout is that there would be too much capacity, causing prices to plummet and investors and creditors to lose their shirts; that scenario, however, would be great for users, who would suddenly have access to incredibly cheap compute. Of course most users aren’t going to use AI directly; what they will miss out on is the equivalent of the Web 2.0 wave of free Internet services that were predicated on compute being free. Now there’s a good chance that AI is going to have meaningful marginal costs for a long time to come. At the same time, while I have been an optimist about humans in an AI future , there is no question that we were and are facing a wrenching change as intelligence becomes a commodity. It follows, however, that if it doesn’t become a commodity — or if that change takes longer than expected — that humanity will have more time to adapt. Maybe this is a break we needed; what is increasingly clear is it’s the break Americans wanted. That noted, there is a long history of citizens demanding the ends and opposing the means, and it’s the demand that wins in the end. The big difference today is that, unlike the first few waves of tech, the industry is going to need to do some convincing, and break the habit of assuming everything it does will get the benefit of the doubt. AI wasn’t technically on the ballot, but it was implicitly, and will be forevermore. Presented by I spend a lot of time trying to figure out what is happening to businesses on the internet. What I often find I’m missing is a view across the economy itself. With more than 1.7% of global GDP running on Stripe, working with them means I can bring some of what they’re seeing to Stratechery. They are, in a sense, a barometer of the economy. Take the “SaaSpocalypse”. Earlier this year, nearly a trillion dollars in enterprise software value disappeared amid fears of AI eating its lunch. Stock prices only tell us what investors think will happen, and not necessarily what is happening. In this case, Stripe recently built a SaaS Index using payments data from 72,000 non-AI SaaS businesses. Looking at their actual performance, we can see that while SaaS stocks were selling off, revenue growth was actually accelerating. Year-over-year growth is now over 30%, with some of the fastest growth coming from the youngest SaaS companies. I suspect there are a lot more interesting things hiding in Stripe’s data, and I’m excited about having an excuse to go look for them.

0 views
Corrode 4 weeks ago

Thinking in Traits

Rust favors composition over inheritance. I’m sure you’ve heard that before, but rarely does anyone take the time to explain what it means in practice. Also, why is this model the right choice for Rust? Let’s take a step back and look at an example: have you ever asked yourself why works the way it does? How does know to produce a here? To answer that, let’s first look at the signature of : Note how it doesn’t mention at all. In fact, it doesn’t “know” about any collection type or any other type, for that matter. The thing it does know is that whatever type you want must be capable of constructing itself from an iterator. And happens to be a type that does. Further note that we didn’t specify the element type of the vector. The compiler is clever enough to infer that from the context! The mechanism is the same for any other supported type, like hash maps, strings, or any custom collection type of your choosing as long as it implements for the iterator’s item type. And what “collecting” means is also defined by the type itself. A , for example, has the ability to collect characters: And a can collect key-value pairs: It’s only fair to mention that interfaces can also express shared contracts. Here, two independently defined implementations connect through a shared item type. This is “composition through contracts”: Here, a producer yields values of some type through the trait. On the other side, a collection implements to describe how it can build itself from those values. The shared item type connects the two contracts, and is the bridge between them. It requires only that the destination can be constructed from the items the iterator yields. In our first example, the annotation selects the destination type. Because implements , the compiler knows how to connect that destination to our iterator. is the glue that passes the iterator to that implementation, which creates and fills the vector. Note how neither side needs to know the concrete type on the other side. The iterator doesn’t need to know how a vector stores its elements. And the vector doesn’t need to know where the items came from, only how to iterate over them. That means we can extend either side independently. A new iterator can feed existing collections, and a new collection implementing can accept existing iterators yielding . We don’t need a separate conversion for every producer–collection pair. All we need is one implementation, and is the glue that brings it all together. In simple Rust pseudocode, we can expand the calls step by step: The value of an abstraction is the code that no longer needs to exist between its users. Class inheritance models “is-a” relationships. In Java, for example, an is a subclass of . An encrypted socket is still a socket, after all. But does every socket operation make sense for it? lets a TCP connection stop sending while continuing to receive, a feature called “half-closing.” Code using a socket might therefore do this: On Android API levels 21 through 23, the platform’s implementations rejected this operation with . This caused a real crash in OkHttp 5.2.0 . Modern OpenJDK supports TLS-aware shutdown , so this is a historical mismatch, not a universal limitation of TLS. Still, the type exposed an operation without telling callers whether that implementation supported it. With composition, a TLS connection can hold a socket internally without exposing every operation on it. It can provide reading and writing, with a separate capability for half-closing where supported. We can reuse the transport without inheriting its entire interface. Simply replacing inheritance with interfaces—or traits—doesn’t fix a poorly chosen contract. What’s important is that the contract matches the capabilities of its implementations . Rust makes trait-based composition central to code reuse. In Rust, we ask what a type can do , not what it is . In other words, traits describe capabilities, not taxonomies. Here are simplified versions of two central I/O traits from the standard library: Note how these are two independent traits. A type can implement , or , or both, or neither. You’re declaring which operations a type supports, without inheriting a bunch of unrelated methods. The capabilities are orthogonal. For example: The trait implementation belongs to the type , not to a concrete value. Take , for example. It implements both and , but a file opened in read-only mode will still fail at runtime if you try to write to it. Even a file opened for writing can fail when the disk fills up. The trait implementation is a promise that the type supports those operations, but what it can’t do is guarantee that every operation will succeed at runtime. If you want to distinguish read-only and writable handles at compile time, you could define a and a and only implement the appropriate traits for each. That rules out unsupported operations in your API, but it still doesn’t make I/O infallible. Rust can express that a container has a capability only when its contents do. For example, implements when implements . Thanks to this trick, we don’t end up with two different types, one cloneable and one not. Here’s the same pattern for a small wrapper you could define yourself: A is cloneable because is cloneable. A is not, since does not implement . If you were to call on that batch, the code wouldn’t compile. You can store non-cloneable items in a batch; you just can’t clone that batch. For this wrapper, you can use to generate the conditional implementation automatically. Note that the bound belongs on the implementation , not on itself. Making your type cloneable requires , but apart from that, is still a perfectly valid type for non-cloneable elements. The compiler works out which operations are available from the capabilities of the component types . A conditional implementation can also apply to every type that satisfies a trait bound as opposed to one particular wrapper. This is called a blanket implementation . For example, the standard library implements for every type that implements : All you have to do to get a method is implement for your type. The compiler automatically generates the implementation for you. The rule applies even to types written long after the standard library itself. This is an elegant way to express a reusable implication between capabilities: “If a type can be displayed, it can be turned into a string.” The same idea appears in conversions. You might know that implementing automatically provides through a blanket implementation. That’s why you normally implement rather than writing the corresponding implementation yourself. Conditional implementations also let us add behavior by wrapping one value in another. This is a different type of composition: “composition of values.” A wrapper holds another value and builds on its capabilities. Take our trait from earlier: So a parser accepting doesn’t need separate support for files, buffered files, and length-limited buffered files. It just reads bytes! We can add buffering and a byte limit without teaching the parser about either. The parser doesn’t need to understand how its input was assembled. This works because each wrapper preserves the contract that the next piece needs. A implements when does, and so does . The result of one composition becomes a building block for the next. You can see the same idea in iterator chains. Each type implements , so you can chain them. Writing your own iterator connects your type to this vast ecosystem of adapters. All you need is to provide the associated type and the method . , , , and already have default implementations, available when their additional bounds are satisfied. This is how you reuse code without a base class. Default methods provide behavior within a trait you implement; blanket implementations can make another trait apply automatically. But adapters don’t have to be limited to a single, rigid contract either. They can provide rich, additional capabilities, too. For example, implements when its input iterator does, and it does so with an appropriate trait bound on the mapping function: So because the adapter has a conditional implementation for , it preserves the ability to iterate backward through the input. We’re not limited to basic iteration. And since we know the concrete iterator types, the compiler can optimize and inline the entire chain of adapters into a single loop. Optimized iterator code can perform comparably to a hand-written loop . So fully embracing iterator patterns has no runtime cost. Hold on, Rust has another way to express “different kinds of things that are related”: enums! These are useful in situations where you know the full list of possibilities in advance. Enums are great if you almost always want to handle all of the variants in one place. Traits are the better model if different types implement the same behavior and you don’t know all of the types right now. In other words, enums are a closed set of variants while traits are an open set of implementations. You can’t add new variants to an enum without changing the enum definition. But traits enable the open/closed principle: you can add new implementations without modifying existing code. This allows other crates to extend your library without needing to modify your code. Imagine your library defines the and types, and you want to provide a way for users to fetch records from different sources. In your library, you implement for a and a . But now, users can implement it for their own or a . Heck, you don’t even need to know these types exist. And yet, your contract still holds: any type that implements can be used to fetch records. The reverse is also true: an external contributor can define an extension trait and implement it for your type without you knowing about it. You can even do that with types from the standard library: As long as the trait is in scope, you can call the method on a : No need to modify or derive a subclass. This implementation is allowed because we define in our crate. Rust’s coherence rules restrict implementations involving foreign traits and types. For example, we couldn’t implement the standard library’s trait directly for , since neither the trait nor the type is ours. This is composition at the level of behavior : we combine an existing type with an independently defined capability. The type and the trait don’t need to know about each other. The same type can implement other, unrelated traits, and each function can ask for just the capabilities it needs by means of trait bounds: This open-set/closed-set principle is a good way to think about when to use enums and when to use traits. But to be fair, the lines can blur a bit. An enum can also implement traits, and a library can restrict who implements a trait through a technique called a “sealed trait.” In application code, exhaustive enum checking can make refactoring easier because the compiler will tell you which statements need to be updated when you add a new variant. Introduce a trait instead when you have a good reason to share a contract across types . The more unrelated responsibilities a trait combines, the harder it becomes to implement and reuse. Every implementer has to account for operations it may not need. Consider this application context: Ask yourself: what concept does this trait capture? What contract does it enforce? It combines reading records, writing records, and running the application. Perhaps your application really needs one type to provide it all, but a function that copies records shouldn’t require its inputs to run an application. Let’s split the capabilities: Now a read-only source can implement , a write-only destination can implement , and the execution runtime is left out. Your functions don’t need to know about the runtime either, and you can compose the exact capabilities you need: Each of your types can implement either trait. Or both. This also explains how independent crates work with your types. Serde defines and ; your types implement them, often through derive macros. Serde’s serializers don’t need to know about your application’s structs in advance. They just use the shared contract: a type that implements can be serialized. Code becomes more composable as a consequence. If Serde decided to couple serialization and deserialization into a single trait, some use cases would be impossible to express. All of that is great for testing, too. We can test with a fake implementation and a fake implementation, without creating a runtime. The goal isn’t to make every trait contain exactly one method. has many methods, but they are all strictly related to the task of iterating over a sequence of values, and all but one ( ) have a default implementation. It’s fine to keep methods together when they describe the same contract, but if you’re unsure if callers need the independent capabilities, split your traits. Below are a couple of concrete tips around trait design. When you approach a problem, ask what your code needs a type to be able to do. Often, an existing trait already expresses that. Check the standard library and popular crates first. And sometimes a concrete type or an enum is enough. Write the code concretely first. If you find yourself copying similar implementations across different types, look for a shared contract. By then, you’ll have concrete examples to test your abstraction against. And when you do need a new trait, give it a contract you can explain in a single sentence. Abstraction has a cost for readers. They may need to follow bounds and implementations across several files to understand a call. Sometimes that indirection hides details they shouldn’t need to care about. Sometimes it hides an important detail they should. Trait-based abstractions in Rust often incur zero additional runtime overhead, but there is a compilation cost as well. The costs depend on how you use the trait. Generic code is usually monomorphized: the compiler generates code for the concrete types that use it. That permits static dispatch and inlining, but many instantiations can still increase compile time and binary size. For dyn-compatible traits , dynamic dispatch through lets the same caller operate on different implementations, but introduces indirection and can limit inlining. Not every trait supports this: , for example, is not dyn-compatible. Keep these trade-offs in mind when you introduce a trait. There is no free lunch. Let’s come back to our once more. So far, we’ve used the destination type to choose a collection. But it can also determine control flow. For example, we can decide to stop iterating on the first error or keep going and collect every result, including errors. I first learned about this from Karol Kuczmarski’s Iteration patterns for Result & Option , still one of my favorite Rust posts. Here it is in action: Note that in both cases, the iterator expressions are identical . The only thing that changes is the destination type: In the second case, is never parsed. If every parse succeeds, the second version returns containing the vector of values. This behavior comes from the standard library’s implementation for . Here’s a stub of that implementation: What this says is: An iterator of values can be collected into a , as long as can collect values of type . The bound means that could be a or any other type that can collect those values. itself doesn’t need to know any of this: it just calls the destination type’s implementation. See how all of those pieces fit together? That’s the real payoff when you think in traits. A single implementation can connect a type to an entire ecosystem of algorithms, adapters, and collections. A few carefully crafted capabilities can combine in ways their authors never imagined. That makes the whole greater than the sum of its parts. And that’s just great API design. A byte slice ( ) implements but not . The returned by implements but not . A implements both. A implements . Wrapping it in a adds buffering, and the result still implements . Calling on that reader limits how many bytes it yields, and the result still implements . produces a iterator that applies a function to each item of the underlying iterator . produces a iterator that yields only the items of that satisfy the predicate . produces a iterator that yields at most the first items of . When you approach a problem, ask what your code needs a type to be able to do. Often, an existing trait already expresses that. Check the standard library and popular crates first. And sometimes a concrete type or an enum is enough. Write the code concretely first. If you find yourself copying similar implementations across different types, look for a shared contract. By then, you’ll have concrete examples to test your abstraction against. And when you do need a new trait, give it a contract you can explain in a single sentence. Abstraction has a cost for readers. They may need to follow bounds and implementations across several files to understand a call. Sometimes that indirection hides details they shouldn’t need to care about. Sometimes it hides an important detail they should. Trait-based abstractions in Rust often incur zero additional runtime overhead, but there is a compilation cost as well. The costs depend on how you use the trait. Generic code is usually monomorphized: the compiler generates code for the concrete types that use it. That permits static dispatch and inlining, but many instantiations can still increase compile time and binary size. For dyn-compatible traits , dynamic dispatch through lets the same caller operate on different implementations, but introduces indirection and can limit inlining. Not every trait supports this: , for example, is not dyn-compatible. collects every parse result. returns the first error and stops advancing the iterator immediately.

0 views
Alex White's Blog 1 months ago

Unleashing agents inside the workshop

I recently learned of Ubuntu Workshops . In short, Workshops allow you to create an isolated development environment to safely work with AI agents. You get a configured (via YAML) sandbox where you can safely run an agent without the need for permission checks and guardrails. Workshops allow you to expose or block certain parts of your system as needed (for example, you can expose your GPU for local models or block access to your webcam). As an example, let's build a simple Rust app that converts images from the HEIC format (bane of my existence) to JPEG. We'll use Iced to provide a simple GUI that supports drag and drop. First, install the Workshops Snap from the Ubuntu App Store. I also had to install the LXD subsystem for virtualization : To setup the workshop, create an empty directory and run the following commands: This will give a workshop named "dev" with Codex and Rust ready to go. On first run, we'll need to login to Codex using the following: Next, we want to define an "auto-mode" for Codex so we don't have to deal with permission check prompts. We'll do this by defining an "action" in the file. We've added two actions, to define a non-interactive session, and for an interactive one. Both have the flag which bypasses permission checks. As an added benefit, actions make it easy to standardize how we pass instructions to agents. We could easily define a Claude action that accepts the same arguments as Codex. Now let's define our prompt, instructing the agent to build our Rust application. This could of course also be done interactively via the Codex TUI inside the workshop, or through a a AI software factory . For now, we'll create a file and add the following: Finally, we'll setup Git for version controlling. Time for the fun part! We'll use the command to build the application in the folder without needing any input from the user. The agent will now run completely autonomously with no need to press "enter" on permission checks. Our host system remains protected as the agent is sandboxed away from our filesystem and devices. In fact, you'll notice in the prompt we specified that the agent should not try running the application. This is because we didn't provide access to a Wayland or X11 display server, so the agent cannot run a GUI application. Here's what I got as a result: The UI isn't great, but it works and successfully converted some photos from my iPhone! After putting together this article and testing out workshops, I'd say it's definitely a tool worth using. Workshops add minimal overhead, provide a composable/reusable environment for development and safeguard your host system from agents going rogue. Between this and Myna , Canonical is doing a lot to support the new development workflows that are becoming common

0 views
Blargh 1 months ago

Inspecting RustRadio and GNU Radio streams dynamically

When building software defined radio flowgraphs it’s common to want to inspect the live data as it flows through various stages. In GNU Radio, and RustRadio, the handoff points are very clear. They are the streams between the blocks. In GNU Radio you can stop the graph, click a bit in gnuradio-companion, and have a new time sink (or whatever you need) added, and then start the graph up again. But it makes for a lot of stopping and starting. There’s also the drawback that it assumes that the GNU Radio flowgraph is graphical in the first place, and not running headless on a raspberry pi somewhere. And for large graphs, preemptively adding GUI elements for everything you may possibly want to read at runtime can clutter things up, and waste CPU processing and rendering data you’re not interested in. Another use case is if you have a constantly running RF sniff process using an SDR, to get a second reader of the same data, to help develop the next version without shutting down the one already running. So clearly, what you want is to be able to connect to the flowgraph over the network, and start streaming any and all streams in the flowgraph. I showed a screenshot of this in my previous post . After adding the ability to sniff streams it looks about the same, but instead of needing to tee off every stream that may be interesting, and wasting the CPU resources when the UI is not connected, I’ve now changed it to sniff the streams by name. RustRadio has a pretty easy way to sniff the streams by name using , and add other stream metadata. E.g. this is most of the receiver for my IKEA sparsnäs decoder : But I’m not restricted to using a fixed UI. The RustRadio UI crate has an example UI application that can connect to anything, and lets you show a waterfall of any I/Q stream. When I told a friend of mine about this he thought it was very cool. Then he got disappointed when I said it was just for RustRadio, not GNU Radio. Well, let’s see if an LLM can make it happen. Yup, a few tokens later it works on GNU Radio too. Now, the code is probably not suitable for merging at all , but it’s just a demo. It’s fine if it’s throwaway code. Note the “IQ Stream Server” block, which can be used for dedicated sinks, and can also “import” all streams in the whole graph. My demo does not let me add the true sample rate, though, so imported streams get a default fake sample rate. I can query the available streams at runtime: And I can use the same example I/Q waterfall UI to plot waterfalls from this graph: There are more streams in that dropdown than there are blocks. That’s because the Channel Model block is actually a GNU Radio Python hierarchical block, and we’re seeing all the underlying blocks’ streams. Video demo: This is built into RustRadio , with the WASM-based UI code in rustradio UI . The vibecoded changes to GNU Radio are in this hooks branch , and then the IQ streaming blocks using the hooks in the hooks branch of gr-iqstream .

0 views
./techtipsy 1 months ago

Restoring my Fiat 126 BIS

This is an ongoing project that will get continuously updated whenever I have made some progress. Check in once in a while for updates! You probably have a lot of questions. Let’s begin. It all started back in 2021. A guy from Australia that did videos about restoring and upgrading old iPods set up a car channel, and that was when I got introduced to the glorious Fiat 126. These videos really do feel like a few ol’ mates fixing a car together, and that got me hooked. You can get a more historically accurate version from Wikipedia or anyone in Poland that’s old enough to remember these, but long story short: these were produced in large numbers in Poland under a license from Fiat proper, and due to the affordability, got super popular in Poland. It’s the car that put Poland on wheels. The Fiat 126 is an absolute nugget. It’s loud, slow, and makes funny smells sometimes. It looks dorky. It weights about 600-620kg, depending on how rusted it is. Its electrical circuit diagram fits on a single A4 sheet of paper. It’s me, but in car form! And that’s why I love it. With the help of my brother, I was on the lookout for one in Estonia. Most variants that were on sale were usually a different color or outside of my pay range, about 2000-4000 EUR usually. There were no guarantees that they were in good condition either. Then there was one for sale for 800 EUR. Not started for 10 years, as it got stranded due to a mechanical failure. It has a gearbox leak. Lots of things that are probably not working due to the fact that it stood for 10 years. A proper project car. That was back in Spring of 2026. I didn’t jump on it yet, as I was quite tired already and didn’t feel like I had the time and energy for a project car. On 1st of August 2026, an event named “Retrokulgurite päevad” took place. A lot of people with old cars joined the event, and we went to check it out. It was nice, there were lots of unique cars there that you don’t see every day, and a whole trolley-bus that was fitted with a diesel-electric engine to generate power for it, with it being fully street legal. But it had no Fiat 126 models on display. Bunch of Audis and soviet era cars, sure, but no legendary nuggets. That was the tipping point. Soon after that, we checked out the 800 EUR option, and deemed it worthy of restoring. This model is different from most Fiat 126 models, as this one has modern features that the old ones don’t, such as ✨ water-cooling ✨ . The engine is still in the butt of the car, but lower, and more compact. This also means that you have a small amount of trunk space, and if you fold the unusably small rear seats down, you actually have a decent amount of space for luggage, making it ideal for a summer car trip with two people. Except during any kinds of warm weather, this thing does not have anything resembling air conditioning. The transport was quite convenient, as the guy helping with the sale offered to transport it near my home for a good price, as he had some family around here. My goal: take part in this event in 2027, including the parade, with a fully street-legal Fiat 126 BIS. I’m not a car guy. Whenever a mechanic explains what needs to be done or what the issue was, I nod, while not understanding a thing they say. I may use the wrong terminology, the wrong tools, and make mistakes. But that’s fine, this is a learning experience for me. I have some help along the way from family members who know cars. I’ll do my best with the legitimately dangerous things. We had a lot of work to do, but on a high level the plan is: The first job I took on were the brakes. The front wheels were absolutely seized, and that made it impossible to push around. The goal: take them all apart, observe the carnage, work on the easy known issues and figure out the next steps. After the first session, I also realized I am lacking tools and liquids, so I got myself a starter kit for doing car things, with all sorts of bits and two ratcheting thingies. I love ratchets. This was also the time to check around the car for surprises and to do the easy bits. This thing desperately needed new wipers. These ones have this bayonet-style end on it, flat surface, with a small circular bump actually holding things together. 330-350mm should be good enough for this car. The right door window was a known issue, it would not go up and down, and a replacement window regulator part was already ordered for the car and came with it. But that was not the only issue with it. Turns out that the frame that holds the window had broken due to corrosion. While fixing the window regulator, we found what these odd cables were that went to the door. Turns out someone had attempted the installation of central locks for this Fiat. Just one problem. Anyway, after that fun discovery I got help from a family member with a welder, and fixed the point where the window holder connects to the regulator cable. Worked like a charm. A solid amount of rust-proofing agent was applied to avoid a repeat of this issue. It will happen again at some point due to the seals around the window not really existing any longer after having disintegrated, but hopefully not in a few years. Around this time I was looking into assembling a big list of parts that I now need to order, and finding sites that specialize in these cars and comparing the results against more mainstream car parts stores. One thing that became very obvious is that you really need to check what you have first before ordering any parts. Your version may have modifications, different replacement parts, and sometimes you just don’t know what you need before you take a look at things. The latter makes parts shopping especially painful if you don’t want to keep making small orders and pay for shipping, but it’s a fact of life, I feel, when working on cars. Based on my research and my location in Estonia, here’s what I’ve more-or-less settled on. This does not serve as an endorsement, it’s just taken verbatim from my personal notes. Specialist shops: higher prices, but much easier to navigate and less chances of getting the wrong parts: For more common and generic parts, such as brakes, fuel hoses, batteries and tyres, just go with whatever you have locally. In Estonia, I’ve found these places to be cromulent for this: Somewhat surprisingly, Google AI mode and Claude were quite useless for making a proper list, and you had to rely on your own measurements, knowledge of the car, Polish Fiat 126 manuals, and specialty shop listings to get the right parts. Enough about that, the work must go on. After dealing with the carnage, the car finally rolled around with ease when pushing it manually. Again, only ~620kg, so I could do it alone. With brakes removed, it was clear that the parts list had to grow to include the hydraulic cylinders. The existing ones were stuck and full of gunk that was definitely not supposed to be there, plus the rubber bits were cracking and leaking brake fluid. I still had some time, so I started tackling some other items based on whatever I felt like doing. I finally also made progress on the window regulator, but annoyingly the new part seems to have an issue, the mechanism works, but it’s crunchy-feeling and makes odd clicks. But it works. We now had the opportunity to move the car under a shed, which is optimal in September weather and doing work on the car. My brother joined in for a day to evaluate the situation and to try to do something useful with the car. Equipped with some 15W40 engine oil, green G11 coolant, wire, an empty plastic canister, fuel hoses and a lot of hope, we got to work trying to get the car doing car noises. While that was going on, I installed new side mirrors. Bling-bling! Now we’re up to two, which is the correct number. Then we started it. Engine go brrrr! It was now time to approach the slightly annoying/scary work. It’s time to install new brake hydraulic bits, but first you need to get the old ones off. That proved to be tricky. It’s also the time I learned about flare-nut wrenches, never realized that these were a thing. So far, I have only managed to get one off, with the rusted brake line also snapping, so yeah, new brake lines have entered the to-do list. Since it was clear that brakes are a total pain, I did additional investigative work on the rear lights to check what’s the situation there. The rear brake lights work and stay on constantly, which is luckily just a sensor fix near the brake pedal, but the fog and reverse lights were iffier. With the reverse light, the reflector bit just fell to bits, so that will need to be renewed. Behind that, I found lots of corroded bits and wires whose metal connectors have snapped. That’s a problem. The plastic covers on the rear lights were screwed in using the plain old screws that had corroded, and when taking them off I learned why additional washers were used, as the screw holes in the plastic had worn and there wasn’t any plastic to attach to. Buying these parts new is also possible, but I may try to fix these properly. After getting very frustrated on that one nut that I simply could not get off, I got frustrated and decided to quickly paint the rusty drum brake covers on the outside with some anti-rust paint that I had bought for testing. There is no good reason to do this, I just did it for fun. At this point, life happened, and my other cars demanded attention as well, with things like broken rear window wiper arm and a slow leak in the front left tyre. With winter on the horizon, I suspect I won’t make too much progress, but that’s a good opportunity to start researching and ordering all the parts that I need now. get it moving so that we can push it in a shed fix the known issues look around for unknown issues get the engine running do all the tricky parts to get it street legal Axel Gerstl Fiat 500, 126, 600 spare parts, tuning and accessories Arnold Classic Shop Aero Motors Baltic Bolt (not to be confused with the other Bolt )

0 views
daniel.haxx.se 1 months ago

A UAF turned RCE

In the curl 8.23.0 release we shipped a fix for one of the worst vulnerabilities in curl in a long time. We grade it severity HIGH. It is known as CVE-2026-92392 with the title HTTP/2 upload Use-After-Free . This post explains the bug, what the problem can lead to, and something about why it happened and what we have done to make it harder to introduce a problem like this in curl again in the future. This is a much simplified explanation. Please refer to the original report for all the details and the full reproducible Docker image for all the low-level fun and education you could possibly want. I highly recommend doing that; the report and the reproducible are awesome. It is a use-after-free , which is a classic problem in memory-unsafe programming languages, like C, where we erroneously have a lingering pointer left, pointing to memory that is already freed, and yet we use that pointer and the memory it points to. This family of errors is especially bad when a malicious actor can affect the content that gets stored into that memory area that is still used even though it was freed. Tricking the program to do something unintended. This problem involves HTTP/2. HTTP/2 is a multiplexed protocol, meaning that it handles multiple logical transfers over the same physical connection. curl needs to keep track of a number of transfers at the same time, and when data arrives or is to be sent off, it needs to keep things apart appropriately. For every transfer done using libcurl, the application creates and sets up a dedicated handle . We call it an easy handle . This handle is kept around for as long as the transfer is in progress, and the application can close and free it once the operation is completed. When doing multiple transfers, multiple handles are used. libcurl also has multi handles , which is a super handle type that holds any amount of easy handles . This handle, and the corresponding multi interface, makes it possible to drive any amount of concurrent transfers. A transfer done with libcurl always has at least one multi handle and one easy handle. (Sometimes the multi handle is hiddenly used under the hood.) In order to trigger this problem, we need an application (such as the curl command line tool) to do an upload over HTTP/2 to a server. By default, libcurl negotiates HTTP/2 when a HTTPS:// URLs is used and the server agrees. When the upload has started, the server pauses the send by zeroing the HTTP/2 window size, returns a piece of the response and then it resets the stream, which shuts down the transfer – but not the connection. curl then correctly pulls down the entire transfer, but it accidentally leaves a lingering pointer to the involved easy handle . When the application finds out that the transfer completed (with an error), it subsequently frees the easy handle and then, and here comes the problematic part: cleans up the multi handle. At this point, the easy handle was just freed but there is still a reference to that handle. When libcurl shuts down the multi handle, it misunderstands the situation, allocates memory to download data into, finds the still dangling pointer and manages to download data from the server that ends up in the very same memory previously used for the easy handle. In this process, it sends off a request that leaks internal client details, which includes information about local addresses, which is crucial. Modern operating systems use Address Space Layout Randomization (ASLR), so a server needs this clue in order to generate a good attack payload. Subsequently, when libcurl deals with this received data (using the handle the dangling pointer points to) in the download buffer, it uses a function pointer that now has been modified by data just downloaded from the server, and then it runs remote code . Here’s a simplified 6-step illustration. Conditions to trigger In order to actually successfully execute remote code, lots of several specific conditions need to be met and we deem it extremely difficult to meet these requirements in the wild, which is why we decided this is “only” severity HIGH and not CRITICAL. The most likely outcome of an attempted attack is rather just a crash. We estimate that the chance for a successful attack is slim. This problem was found and reported by Luna Tong at Anthropic using their new OSS Scanner. Presumably this involves their AI models. In general we have over the last few years been working on reducing the amount of internal pointers to handles that needs to be correct, and instead we store transfer identifiers that we look-up on demand. While this is a tiny bit slower, it is more foolproof when there are logical mistakes like the one mentioned here. We also of course continue to add more tests and we verify the code with more tools and analyzers in order to find additional similar mistakes. Multiplexed protocols like HTTP/2 have this challenge that there are many concurrent transfers going and they all have different life-times and with memory-unsafe languages, dangling pointer mistakes can indeed be fatal. This is of course no guarantee that we do not have or will not introduce another use-after-free in the code now or later. libcurl is written in C – a memory unsafe language. With a memory-safe language, this mistake could probably have been avoided. We have worked on curl for almost thirty years, and have over this time manage to make a rather polished transfer engine. For the longest time there really was no memory-safe alternative that also allowed libcurl to be a low-level library available on hundreds of operating systems and several dozen CPU architectures. It even barely exist alternatives now. We do not rewrite curl. Not into another language but also not in C. We are set to iterate, polish, improve, refactor over and over until the end of time. Porting curl to another language (like rust) would be a monstrous undertaking that would be slow and introduce lots of new short to medium term problems. Not to mention that the existing curl team is not rust experts and that libcurl is currently portable to many more platforms and environments than rust itself is. When this vulnerability was confirmed by the curl security team just hours after it was submitted to us on September 15. We immediately realized the significance and decided to rush the pending next release. However, we still wanted to be careful, follow the procedures and not create any further problems or mistakes by stressing it too much. That’s how we ended up just shortening the release cycle with two weeks. Down from eight to six weeks from the previous release. This allowed us to also merge and fix many more vulnerabilities and general bugs in the same release. We never provide CVSS for our published vulnerabilities as we don’t think we can do a job there. Others will provide them even for our flaws. The victim needs to actually attempt to upload data to a malicious server, meaning that the server certificate must remain valid. The size of the upload needs to be roughly the right size (~135KB) The attacker needs to know curl’s architecture to generate and deliver the right code The attack requires a specific sequence of allocations and allocation sizes so that the data from the server ends up in the right place (from the attacker’s view). This pattern differs between Linux distros, libc versions/flavors, TLS certificate bundles, libcurl using applications and more. nghttp2 and OpenSSL/TLS 1.3 behavior, including allocation effects around session tickets The payload storage area is small (around 23 bytes)

0 views
baby steps 1 months ago

What agents mean for Rust (and vice versa)

As someone who has made a career of programming language design, I definitely have moments of existential dread about the rise of LLMs. I started coding in 5th grade on an x86 1 that ran at 5MHz, had something like a 5MB hard-disk and 512K of RAM 2 . Computers were really, really different back then. But honestly, programming wasn’t. For all the advances in IDEs and programming languages and so forth, the basic act of entering code into a file has remained surprisingly constant 3 – right up until a few years ago, when everything kinda turned on its head. That’s been exciting and empowering at times 4 but also scary and disorienting. Will my skills in programming matter? What about my skills in programming language design (such as they are)? This blog post is my attempt to answer those questions. So as not to keep you in suspense, let me just give you the conclusion. In short, yes, I believe there will still be a role for humans in programming . And yes, I think that programming language design is still relevant . And, naturally, I also happen to think Rust is a really good fit for agentic development – but that’s not to say we can’t make it a better fit . And that’s what this post is ultimately about: what makes Rust and agentic development work well, and where we could double down on those strengths. This is a kind of “blog post companion version” of a talk I gave this week at REBASE, part of SPLASH . You might also enjoy the slides from the talk I gave at IWACO, IWACO and Rust: hidden links revealed , which was a bit more of a retrospective (no soundtrack for those, though). In any case, this turned out to be a great conference! Jack Huey presented on the Rust Vision Doc and, quite to my surprise, Steve Klabnik and Dorian Scheidt presented “LLMs as Collaborators in Language Specification and Design” , talking about their process in building out Rue . It was fun to see Steve again. On top of that, there was a ton of great research presented at IWACO in particular. I was particularly taken by the work on Reachability Types and Information Borrowing . I also really liked learning about Hylo Lang , particularly their approach to projections. Clever and cool. Rust is popular right now. Very popular: Stratospheric among the breakout languages is TypeScript, cropped from the chart and sitting currently at +1200% growth from the prior year. [..] The second most rapid recent growth is in Rust. Meta engineers have written twice as much first-party Rust code so far this year than in the previous 9 years combined. — David Tolnay (emphasis mine) Some of that is because agents make it very easy to try out new things. And some of that is because Rust has a reputation for being performant and, if it’s just as easy to pick any language, why not pick one that will yield faster execution times? But I think Rust is popular for another reason: because Rust happens to be a really good fit for agentic coding 6 . Of course, I would, wouldn’t I? The point of this post is (1) to argue for why that is and then (2) to discuss what we might change about Rust to make it work even better. It seems to me that an effective “software factory” will have three pillars: None of these pillars are solved, but some have made more progress than others. Rust is designed to give “good performance by default”, making the idiomatic thing typically also be the fastest thing. But another key part of Rust is that you have the knobs to eke out better performance when you need it. You control when something is stack- or heap-allocated and where pointer indirection occurs. If you want to, you can force the layout of your structs to be done in a particular way, or decide where to introduce boxing into your async stack frames. In the limit, you can put in inline assembly. In the past, learning how to “tune the performance knobs” could be a bit of a black art: but agents are making that much easier. 7 It turns out that agents are really good at fine-tuning the performance of existing code. For example, people who work on super high-performance cryptographic algorithms used to do so by hand-tuning assembly code. But those people tell me that they are now turning to agents for that same job. More prosaicly, a lot of people building network services are finding that, using a profiler like dial9 , agents can quite effectively diagnose async performance pitfalls, like long polls or blocking. Therefore, I think the task for Rust is clear. We keep on with our goal of “low-level enough for a kernel, high level enough for a GUI” . If anything, I think the shift around agents means we can tolerate a bit more “noise” in the form of explicit calls to or – but not too much, since we still want the “happy path” of the code to be clear and evident 8 , even as we surface details that are important in specific scenarios (like tracking precisely how many clones you have of a channel endpoint). Combined with a profiler, you get an effective feedback loop to get your code running fast: As usual though, while a reputation for good performance is what brings people to Rust, what makes them want to stay is a sense that using Rust “just seems to work better”. The basic theory is that Rust’s type system and guardrails help keep agents on track : rust is a perfect language for agents, given that if it compiles it's ~correct I think there’s truth in that: languages like Rust, Ocaml, or Haskell all share this “if it compiles, it works” feeling, and I think that agents will benefit from that. Testing can show the presence of bugs, but not their absence. — Edsger W. Dijkstra, 1970 Writing tests has never been enough to show that your program is correct – but, with agents, it’s not even close. It happens so often that my first few tests seem great and then the next one goes completely bonkers. Usually bonkers in a way where I cannot even imagine how that bug could have come about. Then I dig in and I realize the agent completely missed the boat on the logic I was trying to express. 9 This is where a type systems really shines – particularly an advanced one like Rust. Type systems give you some guardrails that keep the agent on track. In Rust, those guardrails extend beyond simple stuff like “do all fields have the correct names” and to stuff like never having to close a socket . Type systems can show the absence of bugs, but not the presence of correctness. — Me, failing to coin a phrase of equal eloquence 10 , 2026 So yeah, type systems are helpful! But they have inherent limits. A type system is a simple set of rules that, if you follow them, make sure that you avoid (certain kinds of) mistakes. But they don’t tell you that you do the right thing – only that you don’t do (certain kinds of) wrong things . If you want to go further, you need a proof system – something that will let you show that richer properties are actively true, not just that you’re avoiding bugs. As it happens, there are a lot of interesting proof tools for Rust, like Verus , Creusot , Aeneas , and Kani . As a starting point, you can prove that your code is panic-free, which will eliminate a lot of bugs, though it is still fundamentally a “type-checker-like” property (i.e., you avoid doing things wrong). But you can also go further and add assertions that show your code is computing the results you expect. Deplying proofs is not just good for getting code right – it’s good for getting code fast . This is somewhat counterintuitive, but it’s true. Earlier I mentioned how optimized cryptographic algorithms were now being written by agents . Part of what makes that possible is that cryptographic algorithms have a very clear mathematical definition. This means that you can basically tell the agent “do whatever you want, as long as you can prove that the code still computes the correct result”. These proofs can be done with theorem provers like Lean or Rocq . The blog post “Why Lean is faster than Rust” makes the point quite well. For Rust, a good example of this would be around unsafe code. Right now, people are sometimes reluctant to deploy unsafe code even if it might make their code faster because it’s not worth the risk of getting it wrong. And I applaud that effort. But what if you could use a prover to show that your unsafe code is, in fact, safe (i.e., incapable of causing undefined behavior)? Then you’d be free to optimize to your heart’s content. You might wonder: if we’re deploying a proof system on our code, do we still need type systems? I think the answer is definitely yes. Type systems are infinitely simpler to work with, which is why they are much more popular. Using a type system lets you rule out all kinds of annoying bugs so that you can focus your “proof energy” only on the important stuff. As a simple example of this, consider the following Java code: Without seeing more code, it is impossible to prove whether this assertion is true or not! This is because there could be any number of other threads running around mutating . In contrast, the following Rust code must be true (at least, so long as the operator is reflexive for ): We know this because the type system of Rust guarantees that implies a unique reference. This is in fact exactly how Verus works. By trusting the Rust borrow checker to track uniqueness etc, it simplifies the job of the SMT solver, making proof checking must faster and more reliable than it would be otherwise. So my take is that Rust should double down on if it compiles, it works . As expressive as Rust’s type system is, there are plenty of things that it cannot capture. This includes fairly common things, like this method only reads one particular field or internal references , but also fancy things like “no logging of personally identifiable information”. We should work to lift those limits, giving agents room to prove more complex properties. We also need to improve the experience of integrating a proof tool by working towards an extensible compiler . As cool as the existing Rust-based proof tools are, using them is a janky experience involing annoying macros and pinned compiler versions. We can do better. I’d like to propose a north star for Rust: no more unsafe code . By that, I don’t mean that we never use the keyword . Rather, I mean that we have the power to prove that all the unsafe code we write is correct and cannot cause undefined behavior. Don’t get me wrong: knowing exactly what code needs to be vetted is a huge step forward, as is normalizing the idea that libraries need to be responsible for protecting their users from undefined behavior via safe API boundaries 11 . But given agents’ ability to find vulnerabilities, I think we need to up-our-game if we want to stop the steady stream of CVEs. 12 But before you go about proving things or optimizing them, you need to have a clear idea of what you are building. As far as I can tell the state of the art here is basically variations on “markdown-driven-development”, developing docs and hoping that agents pay attention. I don’t know how much of a role for Rust there is in this space. I think there are some steps we might wind up taking that could be helpful here – for example, having ways to separate out interface from implementation so that it’s easier to review the interface in isolation or to see when the agent made changes there. 13 Or perhaps just providing betters tools to review that. I also think there’s space for dedicated “modeling languages”, something that let you iterate quickly with agents on the high-level designs and invariants without having to get into the weeds and read the code. I have more thoughts on this but it merits many blog posts all of its own. For the moment, I’ll start by pointing you all at this post by Kari Wilhelm, “Principles of Anchor Engineering” , which I think does a nice job of describing what it means to pull out the key elements of a design and drive the coding from there. We covered a lot of ground here, so let me put this all together. What makes Rust a good choice for developing with agents? And what could make it better, from a language design perspective? Overall, I think it’s very similar to what we were doing, except that the way we weight the tradeoffs is tweaked to account for agents doing the code authoring, and humans focused more on code comprehension: As a final close, let me point you at this interesting article by Marc Brooker, “What’s easy now? What’s hard now?” . He posits that the more it is possible to clearly specify success criteria for a task, the easier it is, and that we may find that tasks we traditionally think of as ‘hard’ (e.g., building out an efficient implementation of a cryptographic algorithm) may soon become automated, whereas tasks that we have thoght of as ’easy’ (e.g., making a unique, compelling website) may become more valued. Looking at it from a PL point-of-view, I think Marc’s point reinforces my sense that the biggest action is going to come from design languages , things that let you capture the architecture and intended behavior at a very high-level. The goal would be to let humans intuitively specify a design that gets translated into effective guardrails, whether that’s type system checks, lints, or theorems to be proven. Agents would then take on the task of translating the design into code written in a traditional PL like Rust, with humans looking at it only rarely. This doesn’t make the design of traditional PLs less interesting, but it definitely makes the tradeoffs very different than they were before. Secretly I have always been jealous of people that coded using punchcards and stored things on gigantic rolls of tape or whatever. I just want to be world weary so badly! I am kinda delighted that I’m finally old enough that I can say things like “I remember when we had to edit CONFIG.SYS before we could play a computer game!” and younger programmers will gasp in horror. 5 But I still feel like I must sound like a silly kid to folks who were around “back in the day”.  ↩︎ I still remember when my dad told me he had bought me a 10MB disk and secretly he had bought a 40MB disk to surprise me. It seemed absurdly large. “I’ll never need a new disk again!”  ↩︎ I mean my god, we’re even using again! My first editor!  ↩︎ I built an electron app! And it was so easy to do! And reading weird papers and things is so much more accessible now that I can ask an LLM to translate all the math jargon for me.  ↩︎ I remember once trying to tell Alex Crichton how I used to “order shareware from a paper catalog by putting a check in the mail” and he was like “I do not understand any of the nouns in that sentence”. Highlight of my life, right after Rust 1.0. Oh, and maybe the birth of my child and getting married. I guess.  ↩︎ I’m not saying Rust is the only language that’s a good fit. I’m not even saying that the way that Rust is a good fit is the only way to be a good fit. I have heard for example that Go is a really good fit for agentic coding and I believe it: I think it hits a different sweet spot, one that helps agents iterate quickly (although I do suspect agents will let data races and subtle bugs slip through that Rust would have prevented).  ↩︎ The fact that agentic development makes more room for knobs is good for Rust performance, but it is quite likely an even better fit for performance in other languages. Tuning a GC has traditionally been a job that really requires a GC expert, but agents can likely fill that role pretty well these days.  ↩︎ On this pont, I’m even more convinced of the importance of ergonomic RC now that I work with agents. Agents are good at introducing the extra clones and things you need to deal with capturing around async tasks, but the resulting code is so annoying to read, it really hides what’s going on.  ↩︎ “Claude, this is not what we talked about!” – me, all too often.  ↩︎ So close though, right? I just .. couldn’t land the plane.  ↩︎ All too often, C++ libraries consider it adequate to tell users “you’re holding it wrong” – i.e., that they are responsible for causing undefined behavior by misusing the API. Rust takes a clear position that a safe API has to protect its users, no matter how much they abuse it.  ↩︎ To be fair, if Rust is encountering a stream of CVEs, other languages like C++ and Java are encountering a veritable flood, since they lack the protection of Rust’s type system. st takes a clear position that a safe API has to protect its users, no matter how much they abuse it.  ↩︎ The revenge of files?  ↩︎ Design: figure out and specify clearly what the code is supposed to do. Construction: author code that does what it is supposed to do. Optimization: optimize the code so that it runs efficiently. It offers good default perf (why pay more?) and, in conjunction with a profiler, can be tuned as much as you want. The type system gives stronger guardrails, and if you setup your agents right, you can strengthen those guardrails through techniques like new types. If it compiles, it works – our type system is our big advantage, we need to make it more expressive and more functional so that agents don’t get stuck trying to work around it! And as an adjunct, establish a North Star: Enable Unsafe code without unsafety by supporting proof, and see the most widely used Rust libraries proven sound. Low-level enough for a kernel, high-level enough for a GUI – make sure we expose the knobs needed to tune for performance, while also making the code’s intent clear (but don’t worry about golfing the code down to an absolute minimum number of characters). Extensible and versatile – one of Rust’s great strengths is that, with macros + our type system, we support DSLs and a wide variety of targets. We need to bring that spirit of extensibility into the compiler so we can target more styles of development (e.g., GPU, deep language interop, etc) and also integrate theorem provers and other tools that require more than just tokens. Secretly I have always been jealous of people that coded using punchcards and stored things on gigantic rolls of tape or whatever. I just want to be world weary so badly! I am kinda delighted that I’m finally old enough that I can say things like “I remember when we had to edit CONFIG.SYS before we could play a computer game!” and younger programmers will gasp in horror. 5 But I still feel like I must sound like a silly kid to folks who were around “back in the day”.  ↩︎ I still remember when my dad told me he had bought me a 10MB disk and secretly he had bought a 40MB disk to surprise me. It seemed absurdly large. “I’ll never need a new disk again!”  ↩︎ I mean my god, we’re even using again! My first editor!  ↩︎ I built an electron app! And it was so easy to do! And reading weird papers and things is so much more accessible now that I can ask an LLM to translate all the math jargon for me.  ↩︎ I remember once trying to tell Alex Crichton how I used to “order shareware from a paper catalog by putting a check in the mail” and he was like “I do not understand any of the nouns in that sentence”. Highlight of my life, right after Rust 1.0. Oh, and maybe the birth of my child and getting married. I guess.  ↩︎ I’m not saying Rust is the only language that’s a good fit. I’m not even saying that the way that Rust is a good fit is the only way to be a good fit. I have heard for example that Go is a really good fit for agentic coding and I believe it: I think it hits a different sweet spot, one that helps agents iterate quickly (although I do suspect agents will let data races and subtle bugs slip through that Rust would have prevented).  ↩︎ The fact that agentic development makes more room for knobs is good for Rust performance, but it is quite likely an even better fit for performance in other languages. Tuning a GC has traditionally been a job that really requires a GC expert, but agents can likely fill that role pretty well these days.  ↩︎ On this pont, I’m even more convinced of the importance of ergonomic RC now that I work with agents. Agents are good at introducing the extra clones and things you need to deal with capturing around async tasks, but the resulting code is so annoying to read, it really hides what’s going on.  ↩︎ “Claude, this is not what we talked about!” – me, all too often.  ↩︎ So close though, right? I just .. couldn’t land the plane.  ↩︎ All too often, C++ libraries consider it adequate to tell users “you’re holding it wrong” – i.e., that they are responsible for causing undefined behavior by misusing the API. Rust takes a clear position that a safe API has to protect its users, no matter how much they abuse it.  ↩︎ To be fair, if Rust is encountering a stream of CVEs, other languages like C++ and Java are encountering a veritable flood, since they lack the protection of Rust’s type system. st takes a clear position that a safe API has to protect its users, no matter how much they abuse it.  ↩︎ The revenge of files?  ↩︎

0 views
Langur Monkey 1 months ago

JPEG XL finally lands in Chrome!

Today, I was browsing Hacker News , when a particular item caught my eye: Hacker News post with the Chrome JPEG XL announcement . I opened it promptly and, indeed, it was not a prank. Finally, after years and years of bull**** from the Chrome team, they are shipping it. They are shipping a JPEG XL decoder. For those of you who don’t know, JPEG XL is a new image codec that includes most of, if not all, the features we’d want in the image codec of the future: This is awesome news for the codec . Whether we like it or not, Chrome is the dominant web browser, with ~66.5% of the market share , very far from its competitors (Safari, Edge, and Firefox, in that order). Now, I don’t use Chrome at all, but I still think that this was just the final piece of the puzzle needed to help the format go mainstream. So, what finally pushed them over the edge? If you read their announcement , they cite “consistent feedback and requests from web developers” and its massive popularity in the Interop 2026 project. Translated from corporate PR-speak: the community simply refused to let it go. Web developers, photographers, and open-source advocates kept pushing, complaining on bug trackers, and demanding a truly superior image format instead of settling for Google’s own WebP or the heavily pushed AVIF. The technical excuse the Chrome team used for years was that a C++ decoder was too much of an attack surface to run safely in the browser. Well, it has now been elegantly sidestepped. To bring JPEG XL to Chrome 155, they have integrated , a pure Rust reimplementation of the decoder. This tackles the memory safety issues head-on, eliminating the risk of out-of-bounds reads and use-after-free bugs of other decoders. And to make sure it doesn’t run sluggishly, they built a SIMD abstraction layer ( ) to maximize hardware performance without compromising Rust’s safety guarantees. This is a massive victory. Not just for JPEG XL, but for the open web. As I demonstrated in my comparison back in 2023 ,JXL has significant advantages over older formats and, in many cases, over AVIF as well, especially for high-fidelity photography, lossless compression, and progressive decoding. The fact that it allows lossless transcoding of existing JPEG files is of special importance. It means that we can finally upgrade our backlog of old images without losing a single pixel of quality, while saving a big chunk of disk space and/or bandwidth in the process. With Firefox adding it to Labs earlier this year, and Chrome finally capitulating, Safari is left as the major outlier with only partial support. The dark days of “Google kills JPEG XL” are officially over. It’s time to start converting your image libraries, updating your tags, and serving . The future of (high-quality) web imagery is finally here, and I’ll be ready for it. File size reduction by \(~20-60\%\) w.r.t JPEG. Lossless JPEG transcoding. Progressive decoding. Wide gamut, HDR and 32-bit support. Animations and transparency (alpha channel). Shines with high-fidelity photographic images. Fast-ish encoding and decoding. Royalty-free and FOSS. Support for super high-resolution images, of up to 1 terapixels ( \(2^{30}-1\) pixels per side).

0 views
Evan Schwartz 1 months ago

Scour - September Update

Hi friends, In September, Scour scoured 1.2 million articles (up from ~880,000 in August) from 28,568 feeds . Also, welcome to the 116 new users who signed up since my last product update email! Here's what's new in the product: You can now find all of your saved, loved, and liked posts, as well as your full reading history, in the Library section. Also, if you click Read on Scour for any article, that page now has tabs for the article's content, other posts that it cites and that cite it, and the feeds it was found in. Here's an example for a widely cited post. Scour now tries to determine the level of expertise each post assumes and infers the level of expertise you have per topic (based on the wording of your interest is and the types of articles you click on or like). At least for me, this means I'm seeing far fewer beginner Rust questions from Reddit showing up in my feed. (For those in tech, this is powered by Jev.) Scour's Search will now show you results for feeds and authors, in addition to posts that match your query. Relatedly, you can now follow individual authors as sources and Scour will try to show you their posts from any website they publish on. Scour now detects and hides more junk, ranging from sales pages and SEO garbage to uninformative link roundups and low-value discussion threads. You should see more high-quality content in your feeds. By my current count, about 1 in 10 posts being shown before was some kind of junk that Scour now hides. I continue to obsess over making Scour feel super fast and snappy. In September the slowest feed loads got about 7x faster (p99 went from 2.1 seconds to 282 milliseconds) and the median feed load time got 2x faster (p50 went from 90 ms to 40 ms). This is also while ranking about 1.4x as much content as the month before. Unfortunately Reddit announced their plan to turn off RSS feeds on November 13th . This is how Scour checks which discussions are happening on Reddit and finds articles posted on different subreddits. After November 13th you'll no longer see links to the Reddit discussions from Scour 😢. Here are some of my favorite articles I found on Scour in September: Happy Scouring! - Evan The biggest news in the tech / AI world was the release of TypeSafe's Jev model . These were some of the related articles that I found interesting: The Latent Space interview with TypeSafe's CEO, Jev: System One models for Prod, not God — with Diogo Almeida, CEO, TypeSafe AI . Fingerprints of Jev and Jev's Architecture Unmasked were interesting black box investigations into Jev's base model using the tokenizer and other externally visible properties. Sixteen Models Walk Into a Storefront gives a very nice breakdown of techniques that can be used to manipulate LLMs' assessments of which products to buy and how much to pay for products. Logo Design Trends in 2027 Favor Marks Someone Can Prove They Made . In the age of AI-generated glossy slop, this is no surprise, but it's a nice write-up. The engineering behind the US Strategic Petroleum Reserve . Quite random but an interesting read. I Judged My Mum for Overusing AI, Until I Caught Myself Doing Worse . I continue to appreciate Sid's commentary on the age of AI. This is very relatable.

0 views