Remix.run Logo
Show HN: Zedis – A Redis clone I'm writing in Zig(github.com)
68 points by barddoo 6 hours ago | 50 comments

Writing Redis from scratch in Zig.

jasonjmcghee 3 hours ago | parent | next [-]

I'm not really sure what it costs these days - i know certain projects not entirely free like they were a few years ago, but there's a pretty good "build your own redis" among other things.

It has little step-by-step tasks with automated tests. There are some other good ones like git and docker. It's pretty cool.

https://app.codecrafters.io/courses/redis/overview

nine_k 2 hours ago | parent | next [-]

It's easy to write a KV store, even a KV store with key expiration. But Redis is quite a bit more than that. Consider sharding and replication at least. Then lists, sets, zsets, bitfields, streams, geospatial indexes, hyperloglog / bloom filters, time series.

Something like LevelDB is relatively easy to write. Then you can build the rest of Redis on top of it.

barddoo 29 minutes ago | parent | prev [-]

Sounds pretty interesting.

johnisgood 4 hours ago | parent | prev | next [-]

Seems like LLMs are getting good at Zig (with some help, I presume).

mtlynch 4 hours ago | parent | next [-]

Is there anything about this project that seems LLM-generated?

I've found that LLMs are particularly bad at writing Zig because the language evolves quickly, so LLMs that are trained on Zig code from two years ago will write code that no longer compiles on modern Zig.

jasonjmcghee 2 hours ago | parent | next [-]

I skimmed, for me it was this: https://github.com/barddoo/zedis/blob/87321b04224b2e2e857b67...

There seems to be a fair amount of stigma around using llms. And many people that use them are uncomfortable talking about it.

It's a weird world. Depending on who is at the wheel, whether an llm is used _can_ make no difference.

But the problem is, you can have no idea what you're doing and make something that feels like it was carefully hand-crafted by someone - a really great project - but there are hidden things or outright lies about functionality, often to the surprise of the author. Like, they weren't trying to mislead, just didn't take them time to see if it did all of what the LLM said it did.

boredemployee 2 hours ago | parent [-]

3 months ago I was vibe coding an idea and for some reason (and luck) I went to check a less important part of the code and saw that the LLM changed the env variable of an API key and hard coded the key explictly in the code. That was scary. I'm glad I saw it before PR and shit like that.

5- 3 hours ago | parent | prev | next [-]

https://github.com/barddoo/zedis/blob/87321b04224b2e2e857b67...

these seem to occur only in college assignment projects, and in the output of text generators trained on those.

nine_k 3 hours ago | parent | next [-]

Has been doing this for years, even before LLMs were a thing. No, not in college assignments; by the time emoji appeared, I had long since walked out of my PhD program and went to the industry.

I put such emojis at the beginning of big headings, because my eyes detect compact shapes and colors faster than entire words and sentences. This helps me (and hopefully others) locate the right section easier.

In Slack, I put large emojis at the beginning of messages that need to stand out. These are few, and emojis work well in this capacity.

(Disclaimer: I may contain a large language model of some kind, but very definitely I cannot be reduced to it in any area of my activity.)

adastra22 3 hours ago | parent [-]

FWIW it is really confusing to me and others. What is this emoji supposed to mean? Heck if I know.

But the telltale signs are far more than just that. The whole document is exactly the kind of README produced by Claude.

WD-42 3 hours ago | parent | prev [-]

I will never place emojis in any of my readmes ever again.

chucky_z 3 hours ago | parent | next [-]

spell out 'development' with hammer emojis. bring ascii art back as emoji art.

(i actually do this in slack messages and folks find it funny and annoying, but more funny)

tayo42 3 hours ago | parent | prev [-]

People were doing this before llms, otherwise how did they learn it?

WD-42 3 hours ago | parent | next [-]

Sure, but llms absolutely love to do it for some reason.

tayo42 2 hours ago | parent [-]

I just took a look at a Readme I had cursor write a couple months ago and there's no emojis

adastra22 3 hours ago | parent | prev [-]

That's why he said "never again"

rmonvfer 3 hours ago | parent | prev [-]

As an avid Claude Code user, I can tell you with 99% probability, that README is LLM-generated. This exactly the same structure and wording used by Claude (of course, it has some human modification because otherwise I’d filled with emojis)

In my experience, when you work with something like agentic development tools, you describe your goals and give it some constraints like “use modern zig”, “always run tests”… and when you ask it to write a README, it will usually reproduce those constraints more or less verbatim.

The same thing happens with the features section, it reads like instructions for an LLM.

I might be wrong but I spend way too much time using Claude, Gemini, Codex… and IMHO it’s pretty obvious.

But hey, I don’t think it’s a problem! I write a lot of code using LLMs, mostly for learning (and… ejem, some of it might end up in production) and I’ve always found them great tools for learning (supposing you use the appropriate context engineering and make sure the agent has access to updated docs and all of that). For example, I wanted to learn Rust so I half-vibed a GPUI-based chat client for LLMs that works just fine and surprisingly enough, I actually learned and even had some fun.

adastra22 3 hours ago | parent [-]

I don't know why you're being downvoted. This follows the LLM-generated-README template perfectly. And yeah, it usually ends up being a dumping ground for the constraints you gave it, almost verbatim.

barddoo 3 hours ago | parent | prev [-]

Oh that’s nice of you. I take that as a compliment.

esafak 3 hours ago | parent | prev | next [-]

Consider adding support for vector search and sketching (https://www.sketchingbigdata.org/).

barddoo 25 minutes ago | parent [-]

I'll take a look. Thanks for the suggestion!

maleldil 2 hours ago | parent | prev | next [-]

From the README:

> Memory safety with RAII patterns

I'm curious to see how they achieve RAII in Zig, which doesn't have destructors. If they mean defer + deinit methods, that's not the same thing.

justinhj an hour ago | parent [-]

Zig is all about making things explicit. Destructors are hidden code. I presume there will be an application level tracking of lifetime.

pdntspa 4 hours ago | parent | prev | next [-]

Is zig lang stable enough now to start basing real projects on it?

pyrolistical 3 hours ago | parent | next [-]

Depends on your definition of stable. I would suspect most people would consider it unstable as they are still breaking the API for async. Wait for 1.0 if you really need true stability. But zig is just so good not to use now

barddoo 3 hours ago | parent | prev | next [-]

The standard library is changing too much to be honest. During the development of the library Zig 0.15 launched and changed the whole Io library.

justinhj 4 hours ago | parent | prev | next [-]

Check out Tigerbeetle and Ghostty

jrpelkonen 4 hours ago | parent | next [-]

Also bun

fishmicrowaver 3 hours ago | parent | prev [-]

I mean no offense but a billionaires vanity terminal and a database with an anime bug mascot are a bit different than a redis alternative

rvrb 2 hours ago | parent | next [-]

Good point, the database written in Zig with a bug mascot tells us nothing about writing a database in Zig without a bug mascot

throwawaymaths 39 minutes ago | parent [-]

im not sure i trust any hot takes from a person that doesn't know anything about anime

dpatterbee 3 hours ago | parent | prev | next [-]

Is software not real software if it's written by a billionaire? What is it about the bug mascot that detracts from the database's legitimacy?

justinhj an hour ago | parent | prev | next [-]

If all you know about Tigerbeetle is the mascot you should probably take another look before judging. Some very interesting db tech.

sroerick 25 minutes ago | parent [-]

Tigerbeetle is one of the most interesting projects I've seen in recent memory

aschobel 3 hours ago | parent | prev [-]

bun is real and spectacular. super loving using it

nitishr 2 hours ago | parent | prev | next [-]

it hasn't reached version 1.0

tonyhart7 3 hours ago | parent | prev [-]

"Is zig lang stable enough now to start basing real projects on it?"

only if you want to refactor/rewrite a lot

nitishr 2 hours ago | parent | prev | next [-]

Are you keeping it single threaded?

barddoo an hour ago | parent [-]

No, I wasn’t able to get it working with async io using io_uring/kqueue.

znpy an hour ago | parent | prev | next [-]

OT: Reminds me of the late 2000s when python was having its boom and it was a lot of pythis and pythat

barddoo 24 minutes ago | parent [-]

I just made it to learn Zig

BiraIgnacio an hour ago | parent | prev | next [-]

cool stuff, keep at it!

barddoo 21 minutes ago | parent [-]

Thanks! There are so many things to do still, authentication, glob-style keys search, json parsing.

tcfhgj 4 hours ago | parent | prev [-]

So riiR is now riiZ? ;)

nine_k 2 hours ago | parent [-]

"Rewrite it away from C (or C++)". Whether you choose Rust, Zig, Ada, D, Nim, even Pascal, it's likely going to become more secure. It will be supported on fewer platforms though, but still should run fine under Linux, macOS, Windows, *BSD, on x64, Arm64, and likely RISC-V, too.

maleldil 2 hours ago | parent [-]

Zig isn't memory safe, though. It's safer than C or C++, but not much.

ashikns an hour ago | parent | next [-]

This is what I have struggled to understand about Zig. It seems pretty much like C in a mental model aspect - you are responsible for everything. It's slightly better than C, but C already runs on everything on the planet and can be made secure even if painfully so. So what niche is Zig aiming to fill?

throwawaymaths 34 minutes ago | parent | next [-]

no, null pointers are enforced safe at the type level in zig, as are array bounds, this eliminates huge classes of errors, so you are not "responsible for everything". unlike c, you often (unless highly tuned performance is needed) do not have to resort to opaque void pointers, and the compiler gives you typesafety on that, another major footgun in c.

also operators and integer types are unambiguous, and there is no UB in safe compilation modes.

It's arguably much better than C, not "slightly better than C"

barddoo 23 minutes ago | parent | prev [-]

Zig detects memory leaks pretty well when you build it using -Doptimize=Debug.

throwawaymaths 38 minutes ago | parent | prev [-]

checked array bounds is memory safety.