# I built a fast RSS reader in Zig

Well, I certainly tried. I had to, because it has a certain quirk inspired by "digital minimalism." The quirk is that it only allows you to fetch new articles once per day (or X days). Why? Let me explain... I want my internet content to be like a boring newspaper. You get it in the morning, and yo…

- **Page:** https://magpie.gallery/i/i-built-a-fast-rss-reader-in-zig-hcpm
- **Type:** Link to an idea elsewhere
- **Category:** Media & reading
- **Tags:** rss, reader, minimalism, zig, feeds

## Source

Web · superstarryeyes: I built a fast RSS reader in Zig

- **Original:** https://news.ycombinator.com/item?id=46293564

> Well, I certainly tried. I had to, because it has a certain quirk inspired by "digital minimalism." The quirk is that it only allows you to fetch new articles once per day (or X days). Why? Let me explain... I want my internet content to be like a boring newspaper. You get it in the morning, and you read the whole thing while sipping your morning coffee, and then you're done! No more new information for today. No pings, no alerts, peace, quiet, zen, etc. But with that, I needed it to be able to fetch all articles from my hundreds of feeds in one sitting. This is where Zig and curl optimisations come in. I tried to do all the tricks in the book. If I missed something, let me know! First off, I'm using curl multi for the network layer. The cool thing is it automatically does HTTP/2 multiplexing, which means if your feeds are hosted on the same CDN it reuses the same connection. I've got it configured to handle 50 connections total with up to 6 per host, which seems to be the sweet spot before servers start getting suspicious. Also, conditional GETs. If a feed hasn't changed since last time, the server just says "Not Modified" and we bail immediately. While curl is downloading feeds, I wouldn't want CPU just being idle so the moment curl finishes downloading a single feed, it fires a callback that immediately throws the XML into a worker thread pool for parsing. The main thread keeps managing all the network stuff while worker threads are chewing through XML in parallel. Zig's memory model is perfect for this. Each feed gets its own ArenaAllocator, which is basically a playground where you can allocate strings during parsing, then when we're done, we just nuke the entire arena in one go. For parsing itself, I'm using libexpat because it doesn't load the entire XML into memory like a DOM parser would. This matters because some podcast feeds especially are like 10MB+ of XML. So with smart truncation we download the first few X mb's (configurable), scan backwards to find

## GitHub projects

- https://github.com/superstarryeyes/hys

## Rules for reuse

- Build your own version: don't copy another product's code, look, icons, colours or copy.
- The original belongs to its author; Magpie only links to it.
- The original content's copyright belongs to its creator. Magpie doesn't download or re-upload it; we only show the link and the official preview.
