Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Show HN: I built the fastest RSS reader in Zig (github.com/superstarryeyes)
25 points by superstarryeyes 1 day ago | hide | past | favorite | 8 comments
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 the last complete item tag, cut it there, and parse just that. Keeps memory usage sane even when feed sizes get massive.

And for the UI I just pipe everything to the system's "less" command. You get vim navigation, searching, and paging for free. Plus I'm using OSC 8 hyperlinks, so you can actually click links to open them on your browser. Zero TUI framework needed. I've also included OPML import/export and feed groups as additional features.

The result: content from hundreds of RSS feeds retrieved in matter of seconds, and peace of mind for the rest of the day.

The code is open source and MIT licensed. If you have ideas on how to make it even faster or better, comment below. Feature requests and other suggestions are also welcome, here or GitHub.





I think its cool that more people are building what I call "calm tech". More technology should try to serve a purpose quickly and then get out of the way instead of trying to artificially stay on your screen as long as possible.

Incidentally, I built my own calm RSS reader some time ago that has many similar ideas to yours: https://github.com/lukasknuth/briefly



nice! yeah, i agree. calm tech is a nice way to put it. the current big platforms are highly tuned to keep people engaged and enraged to the max, rss is kind antithesis of that. that's probably why big companies try to bury and hide it. youtube and reddit still give pretty good rss support though, which is nice.

Why MIT and not GPL3?

why not? isn't mit just objectively a better license for open source? i just hope rss would make a comeback to make the internet a little saner again, and if someone wants to use hys source code as a base for their own rss reader, whether commercial or not, great!

Explain what you mean by "objectively better"? Your response makes it sound like you don't know the difference and are doing it because everybody else does it. It also makes it sounds like you don't understand the difference between open source software and free software. Both are free licenses, open source is just one part of it.

The main difference is that GPL3 is a copyleft license, whereas MIT is not. Meaning that legally there is nothing in the license preventing a company from taking your code and using it for their purposes without having to contribute to improve the code.


i know the difference. i use gpl3 in my other project lue for example. i meant objectively better for the open source community. the spread of new ideas benefits from the mit license because the ideas in the code can travel farther.

the reason i picked mit is because rss is in a rough spot right now. the tech isn't mainstream, and big companies are trying to squash it since it doesn't drive engagement like the infinite scroll. anything that helps rss move forward is a win, and the mit license makes that easier.


Ok thank you for explaining.

> the reason i picked mit is because rss is in a rough spot right now.

I don't think another client is the solution, just saying. There's about three billion of them out there (though I don't dispute that yours might have something unique).




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: