Most active commenters
  • barddoo(10)
  • johnisgood(5)
  • justinhj(3)
  • (3)
  • nine_k(3)
  • adastra22(3)
  • jasonjmcghee(3)
  • throwawaymaths(3)

99 points barddoo | 77 comments | | HN request time: 3.786s | source | bottom

Writing Redis from scratch in Zig.
1. pdntspa ◴[] No.45308007[source]
Is zig lang stable enough now to start basing real projects on it?
replies(6): >>45308038 #>>45308512 #>>45308547 #>>45308564 #>>45308957 #>>45311651 #
2. justinhj ◴[] No.45308038[source]
Check out Tigerbeetle and Ghostty
replies(2): >>45308281 #>>45308387 #
3. tcfhgj ◴[] No.45308065[source]
So riiR is now riiZ? ;)
replies(1): >>45308745 #
4. johnisgood ◴[] No.45308123[source]
Seems like LLMs are getting good at Zig (with some help, I presume).
replies(2): >>45308193 #>>45308553 #
5. mtlynch ◴[] No.45308193[source]
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.

replies(4): >>45308296 #>>45308429 #>>45308798 #>>45311161 #
6. jrpelkonen ◴[] No.45308281{3}[source]
Also bun
7. 5- ◴[] No.45308296{3}[source]
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.

replies(2): >>45308389 #>>45308685 #
8. fishmicrowaver ◴[] No.45308387{3}[source]
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
replies(4): >>45308492 #>>45308614 #>>45308834 #>>45309607 #
9. WD-42 ◴[] No.45308389{4}[source]
I will never place emojis in any of my readmes ever again.
replies(2): >>45308404 #>>45308424 #
10. chucky_z ◴[] No.45308404{5}[source]
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)

11. tayo42 ◴[] No.45308424{5}[source]
People were doing this before llms, otherwise how did they learn it?
replies(2): >>45308486 #>>45308701 #
12. rmonvfer ◴[] No.45308429{3}[source]
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.

replies(2): >>45308710 #>>45311137 #
13. WD-42 ◴[] No.45308486{6}[source]
Sure, but llms absolutely love to do it for some reason.
replies(1): >>45308842 #
14. dpatterbee ◴[] No.45308492{4}[source]
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?
replies(2): >>45308583 #>>45310592 #
15. tonyhart7 ◴[] No.45308512[source]
"Is zig lang stable enough now to start basing real projects on it?"

only if you want to refactor/rewrite a lot

16. barddoo ◴[] No.45308547[source]
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.
17. barddoo ◴[] No.45308553[source]
Oh that’s nice of you. I take that as a compliment.
replies(1): >>45311176 #
18. pyrolistical ◴[] No.45308564[source]
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
19. ◴[] No.45308583{5}[source]
20. aschobel ◴[] No.45308614{4}[source]
bun is real and spectacular. super loving using it
21. nine_k ◴[] No.45308685{4}[source]
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.)

replies(2): >>45308699 #>>45310502 #
22. adastra22 ◴[] No.45308699{5}[source]
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.

23. adastra22 ◴[] No.45308701{6}[source]
That's why he said "never again"
24. adastra22 ◴[] No.45308710{4}[source]
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.
25. esafak ◴[] No.45308717[source]
Consider adding support for vector search and sketching (https://www.sketchingbigdata.org/).
replies(1): >>45309919 #
26. jasonjmcghee ◴[] No.45308740[source]
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

replies(2): >>45308845 #>>45309901 #
27. nine_k ◴[] No.45308745[source]
"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.
replies(1): >>45309389 #
28. jasonjmcghee ◴[] No.45308798{3}[source]
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.

replies(3): >>45308978 #>>45310151 #>>45311116 #
29. rvrb ◴[] No.45308834{4}[source]
Good point, the database written in Zig with a bug mascot tells us nothing about writing a database in Zig without a bug mascot
replies(1): >>45309836 #
30. tayo42 ◴[] No.45308842{7}[source]
I just took a look at a Readme I had cursor write a couple months ago and there's no emojis
31. nine_k ◴[] No.45308845[source]
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.

32. nitishr ◴[] No.45308953[source]
Are you keeping it single threaded?
replies(1): >>45309584 #
33. nitishr ◴[] No.45308957[source]
it hasn't reached version 1.0
34. boredemployee ◴[] No.45308978{4}[source]
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.
35. maleldil ◴[] No.45309389{3}[source]
Zig isn't memory safe, though. It's safer than C or C++, but not much.
replies(2): >>45309760 #>>45309844 #
36. maleldil ◴[] No.45309397[source]
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.

replies(2): >>45309688 #>>45310719 #
37. BiraIgnacio ◴[] No.45309463[source]
cool stuff, keep at it!
replies(1): >>45309953 #
38. znpy ◴[] No.45309534[source]
OT: Reminds me of the late 2000s when python was having its boom and it was a lot of pythis and pythat
replies(1): >>45309930 #
39. barddoo ◴[] No.45309584[source]
No, I wasn’t able to get it working with async io using io_uring/kqueue.
40. justinhj ◴[] No.45309607{4}[source]
If all you know about Tigerbeetle is the mascot you should probably take another look before judging. Some very interesting db tech.
replies(2): >>45309842 #>>45309925 #
41. justinhj ◴[] No.45309688[source]
Zig is all about making things explicit. Destructors are hidden code. I presume there will be an application level tracking of lifetime.
replies(1): >>45310538 #
42. ashikns ◴[] No.45309760{4}[source]
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?
replies(2): >>45309865 #>>45309942 #
43. throwawaymaths ◴[] No.45309836{5}[source]
im not sure i trust any hot takes from a person that doesn't know anything about anime
44. throwawaymaths ◴[] No.45309844{4}[source]
checked array bounds is memory safety.
replies(1): >>45311001 #
45. throwawaymaths ◴[] No.45309865{5}[source]
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"

replies(2): >>45310566 #>>45310735 #
46. barddoo ◴[] No.45309901[source]
Sounds pretty interesting.
47. barddoo ◴[] No.45309919[source]
I'll take a look. Thanks for the suggestion!
48. sroerick ◴[] No.45309925{5}[source]
Tigerbeetle is one of the most interesting projects I've seen in recent memory
49. barddoo ◴[] No.45309930[source]
I just made it to learn Zig
50. barddoo ◴[] No.45309942{5}[source]
Zig detects memory leaks pretty well when you build it using -Doptimize=Debug.
51. barddoo ◴[] No.45309953[source]
Thanks! There are so many things to do still, authentication, glob-style keys search, json parsing.
52. barddoo ◴[] No.45310151{4}[source]
Agree. I used it mostly for getting ideas, the memory management for example, Gemini listed so many different ways of managing memory I didn’t even know existed. I know I wanted to pre allocate memory like tigerbeetle does, so the hybrid approach was perfect. Essentially it has 3 different allocators, a huge one for the cache, a arena allocator for context, intermediate state like pub/sub and temp one, for requests. It was 100% Gemini’s idea.
53. reenorap ◴[] No.45310286[source]
This 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.
replies(2): >>45310415 #>>45310671 #
54. saghm ◴[] No.45310415[source]
I 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?
55. k_bx ◴[] No.45310497[source]
Sorry 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 , 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.

replies(2): >>45310703 #>>45311050 #
56. MangoToupe ◴[] No.45310502{5}[source]
I had assumed they were referring to stuff like "Type-safe operations with compile-time guarantees". What a weird detail to add to a readme. And the whole section is like that. I wonder if that's part of a prompt leaking through.
57. ◴[] No.45310538{3}[source]
58. ◴[] No.45310566{6}[source]
59. garbagepatch ◴[] No.45310592{5}[source]
What's the problem with the mascot? PostgreSQL has an elephant and MySQL a dolphin. Is the bug too detailed for database software?
60. era37 ◴[] No.45310652[source]
Looks like a cool project; does the project aim to fix anything existing about Redis or is this just a fun side project? Thanks
61. thewisenerd ◴[] No.45310671[source]
i 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)

62. jasonjmcghee ◴[] No.45310703[source]
fwiw redis has persistence https://redis.io/docs/latest/operate/oss_and_stack/managemen...
replies(1): >>45310837 #
63. teo_zero ◴[] No.45310719[source]
> If they mean defer + deinit methods, that's not the same thing.

No? It's the first thing that came to my mind when I've read RAII.

64. uecker ◴[] No.45310735{6}[source]
If you write a modern style of C, you can have bounds checked code and do not need to use void pointers. I usually find that people overestimate the advantages of newer languages compared to using C by comparing to old and badly written C.
65. lyu07282 ◴[] No.45310837{3}[source]
That just makes it durable, the entire dataset still has to fit in memory.
66. didip ◴[] No.45310990[source]
What about calling it Zigdisk and make it save to disk?
67. lyu07282 ◴[] No.45311001{5}[source]
Runtime bounds checking, but only in Debug/ReleaseSafe builds, besides there are many other types of memory safety issues left unaddressed.
68. Szpadel ◴[] No.45311050[source]
Redis 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.

replies(1): >>45311124 #
69. mawadev ◴[] No.45311056[source]
This is a very cool project. I wish it could do the same stuff as RedisJson at some point!
70. johnisgood ◴[] No.45311116{4}[source]
I generally do not think it is a bad thing. I use LLMs too and I know what I am doing, so I do not know if it could be qualified as vibe coding.

I think it is not inherently a bad thing to use LLMs, only if you have absolutely no clue about what you are doing, but even then, if the project is usable and as-is advertised, why not? shrugs

As for the link, that is exactly the same code that caught my eye, besides the README.md itself. The LRU eviction thing is what GPT (and possibly other LLMs) always comes up with according to my experiences, and he could have just had it properly implemented then. :D

Edit: I am glad author confirmed the use of an LLM. :P

71. k_bx ◴[] No.45311124{3}[source]
Most projects need to start with something and know that they will "be good". Many will hit RAM limitations earlier than kvrocks latencies or single-threaded CPU limitations (if they will – usually author doesn't need advice). Most would benefit from "moving fast" (in terms of development).

Redis-compatible protocol guarantees that you can think about the things you've mentioned later. If project is successful – you'll find money to pay for RAM and move to pure Redis. If it's CPU-bound – you'll find multi-threaded alternatives.

So this is a pretty nice niche IMO actually.

replies(1): >>45311537 #
72. johnisgood ◴[] No.45311137{4}[source]
> 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.

As I wrote in another comment, it is not inherently a bad thing. I use LLMs too (while knowing what I am doing), and if the project works, why not?

73. johnisgood ◴[] No.45311161{3}[source]
Fair enough, but I have made a couple of projects in Odin using Claude, and Odin is evolving too, and it is much more obscure than Zig. I made these projects successfully by feeding the LLM the documentation of Odin and gave it example projects... thus, if I could create Odin projects (with some reiterations and hand-holding, true), then Zig should be even better.
74. johnisgood ◴[] No.45311176{3}[source]
It was not intended to be a criticism. I care about the end result, not the process. I use LLMs myself, too.
75. Karrot_Kream ◴[] No.45311537{4}[source]
Why not use a managed Redis or a large memory instance and run Redis yourself then? They aren't that much more expensive if you need to move fast.
76. ozgrakkurt ◴[] No.45311651[source]
Probably not for you if you are asking this and waiting for an answer.

If you know what you are doing then you already know the answer.

It is ok if you are fine with updating things every once in a while and you don’t use stdlib except maybe hashmap, hash functions, crypto etc.