16 ms·
Show HN: Zedis – A Redis clone I'm writing in Zig
Writing Redis from scratch in Zig.
- pdntspa 1y agoIs zig lang stable enough now to start basing real projects on it?
- justinhj 1y agoCheck out Tigerbeetle and Ghostty
- jrpelkonen 1y agoAlso bun
- fishmicrowaver 1y agoI mean no offense but a billionaires vanity terminal and a database with an anime bug mascot are a bit different than a redis alternative
- dpatterbee 1y agoIs 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?
- deleted 1y ago[deleted]
- garbagepatch 1y agoWhat's the problem with the mascot? PostgreSQL has an elephant and MySQL a dolphin. Is the bug too detailed for database software?
- nickmonad 1y agoWhy would we want a literal BUG as a mascot?? /s
- aschobel 1y agobun is real and spectacular. super loving using it
- rvrb 1y agoGood point, the database written in Zig with a bug mascot tells us nothing about writing a database in Zig without a bug mascot
- throwawaymaths 1y agoim not sure i trust any hot takes from a person that doesn't know anything about anime
- justinhj 1y agoIf all you know about Tigerbeetle is the mascot you should probably take another look before judging. Some very interesting db tech.
- tonyhart7 1y ago"Is zig lang stable enough now to start basing real projects on it?" only if you want to refactor/rewrite a lot
- barddoo 1y agoThe 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.
- pyrolistical 1y agoDepends 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
- nitishr 1y agoit hasn't reached version 1.0
- deleted 1y ago[deleted]
- tcfhgj 1y agoSo riiR is now riiZ? ;)
- nine_k 1y ago"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 1y agoZig isn't memory safe, though. It's safer than C or C++, but not much.
- ashikns 1y agoThis 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 1y agono, 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"
- deleted 1y ago[deleted]
- 1y ago
- johnisgood 1y agoSeems like LLMs are getting good at Zig (with some help, I presume).
- mtlynch 1y agoIs 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.
- 5- 1y agohttps://github.com/barddoo/zedis/blob/87321b04224b2e2e857b6704926952b47abf01cc/README.md#project-structure 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.
- WD-42 1y agoI will never place emojis in any of my readmes ever again.
- chucky_z 1y agospell 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 1y agoPeople were doing this before llms, otherwise how did they learn it?
- WD-42 1y agoSure, but llms absolutely love to do it for some reason.
- esafak 1y agoConsider adding support for vector search and sketching (https://www.sketchingbigdata.org/ https://www.sketchingbigdata.org/).
- barddoo 1y agoI'll take a look. Thanks for the suggestion!
- jasonjmcghee 1y agoI'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 https://app.codecrafters.io/courses/redis/overview
- nine_k 1y agoIt'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.
- johnisgood 1y ago> Then lists, sets, zsets, bitfields, streams, geospatial indexes, hyperloglog / bloom filters, time series. I mean, I have my own C libraries for most of these!
- dns_snek 1y agoIn Redis those operations are performed server-side, on a shared dataset, and concurrently by many clients.
- barddoo 1y agoSounds pretty interesting.
- nitishr 1y agoAre you keeping it single threaded?
- barddoo 1y agoNo, I wasn’t able to get it working with async io using io_uring/kqueue.
- maleldil 1y agoFrom 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 1y agoZig is all about making things explicit. Destructors are hidden code. I presume there will be an application level tracking of lifetime.
- deleted 1y ago[deleted]
- maleldil 1y agoYes, which is why Zig can't have RAII. Zig initialisation and destruction are fundamentally different to how RAII works in other languages. That's not a negative point; it's just how Zig is. But it's not RAII.
- justinhj 1y agoYou are right. It seems the developer agrees and has changed the README
- cakealert 1y agoIt's explicit opt in RAII, you opt in by using a defer.
- ioasuncvinvaer 1y agofree is an explicit opt-in garbage collector.
- lenkite 1y agoRAII, which stands for Resource Acquisition Is Initialization, is a programming technique in which a resource's lifetime is tied to an object's lifespan. An explicit defer does not fit this paradigm.
- BiraIgnacio 1y agocool stuff, keep at it!
- barddoo 1y agoThanks! There are so many things to do still, authentication, glob-style keys search, json parsing.
- znpy 1y agoOT: Reminds me of the late 2000s when python was having its boom and it was a lot of pythis and pythat
- reenorap 1y agoThis is an interesting project but a poorly chosen name because it can easily be considered trademark infringement for being confusingly-similar to "Redis", especially since it's a self-admitted clone. I would change it now before you are forced to change your name and you lose time confusing people and wasting time renaming everything.
- saghm 1y agoI don't think it's particularly confusing. I wouldn't expect something official to have a name that changes the first letter. Would you honestly be confused about whether a search engine called Boogle, a laptop called a Yacbook, or a browser called Tirefox was an official product by Google, Apple, or Mozilla?
- thewisenerd 1y agoi think “$proj - implements the redis protocol” are going to be as ubiquitous as the things which claim to be “S3 compatible” idk if redis labs (the organization aka big bad) are going to patent the “protocol” to disallow clones (or they’d be going after valkey first)
- barddoo 1y agoThat’s a good point, I should had renamed it. You can’t trust these big corp
- jiehong 1y agoI’d see it in swift and then being called "Swedish" for giggles. Naming is famously difficult in this world!
- k_bx 1y agoSorry if somewhat off-topic, but might help with getting more users. Redis is actually good enough and easy to install for most projects, but it has downside that it's "memory-only" (needs to fit in ram), and if you're in a tight container/vm – you'd better not rely on it solely. So, there's another project – called kvrocks https://github.com/apache/kvrocks https://github.com/apache/kvrocks , which is for people which don't need in-memory perf of redis but would like to use its protocol and be still very performant. However, its devs never packaged a release in deb and other formats. So, if you were to implement something similar ^ which will implement the protocol, have ability to grow on disk, and be available in distro repos (ideally) – would definitely hold a niche of many little projects which benefit from redis-like thing I've done.
- jasonjmcghee 1y agofwiw redis has persistence https://redis.io/docs/latest/operate/oss_and_stack/management/persistence/ https://redis.io/docs/latest/operate/oss_and_stack/managemen...
- Szpadel 1y agoRedis is for high frequency cache, disk latencies would slow it too much. Maybe putting something that would normally be evicted to disk could be valid compromise. another major drawbacks of Redis is that It is single threaded and sync. you need expensive high frequency CPU if you need more performance. something that could benefit from multi core system and if you would want to use disk cache async is a must. single threading also affects scripts running on Redis side, when they execute whole Redis is waiting and is unable to fulfil other requests. another place for improvement would be proper easier to use HA, and maybe also auto scaling.
- era37 1y agoLooks like a cool project; does the project aim to fix anything existing about Redis or is this just a fun side project? Thanks
- barddoo 1y agoRedis dynamically allocates memory, the idea of the project is to pre allocate everything, so it’s by principle faster than Redis.
- didip 1y agoWhat about calling it Zigdisk and make it save to disk?
- mawadev 1y agoThis is a very cool project. I wish it could do the same stuff as RedisJson at some point!
- barddoo 1y agoI definitely plan to do that in the future
- montyanderson 1y agorelated: https://github.com/montyanderson/kavy https://github.com/montyanderson/kavy
- gkorland 1y agoDid you try to run redis-benchmark? (Compared to Redis)
- destroycom 1y ago> Written in Zig for optimal performance and memory safety Ironic to see this, as even a cursory glance over the code shows a lot of memory bugs, such as dangling pointers, data races, some potential bugs like double free, etc. It is good that the OP is learning things, but I would caution against relying on LLMs and taking on a bigger project like this, before the basics are well understood. Personally, this is one of the reasons I dislike the LLM hype, people are enabled to produce much more code, code that they aren't qualified to support or even understand. While the project linked is clearly designated as strictly for "learning purposes", the applications we will get in the large will be of no better quality. The difference being, before LLMs, those, who didn't have qualification, wouldn't even approach problems like this, now they can vibecode something that works on a lucky run, but is otherwise completely inadequate.
- glouwbug 1y agoI think this is the most apt summary of LLMs I’ve seen to date