Syntax Video
SpaceTime DB 2.0 is 1000x Faster... (so they say) - and more! | 3 Devs - 3 Things
hello
Welcome to three devs, three things. Scott, Wes, and I all have something interesting that we found that we'd like to share with you. So, let's get right into it. Wes, uh, what do you got? Yeah, this is really crazy. So, Cloudflare rebuilt Nex.js in with with Vit. Um, and they did it with AI. So, essentially what they did is they took the entire Nex.js test suite. Um they took $1,100 worth of claw tokens and they said port this to Vit and apparently 800 open code instances and they basically rebuilt Nex.js their entire API most of it. I'll talk about that in a second using Vit instead of what what uh Nex.js uses is either Turboac or or Webpack. And this is kind of cool. So I I fired it up. I took the next faster app which is a like McMaster car style website and that that was built on Nex.js just to show how fast these websites can be and I I tried to port it over and I got it rendering. It
Cloudflare Rebuilt Next.js From Scratch
probably took me about an hour. So it was it was not just a drop in replacement. Not everything works. The there's a bunch of API endpoints don't work. There was commonjs issues out the wazoo which is another one of my complaints with Nex.js JS is that it's still CommonJS. You can use ESM with it, but it all just gets bundled into CommonJS at the end of the day. So, I mean, it worked kind of. Um, it loaded about the same speed as Turboac in dev mode. Um, but I think probably the more interesting thing here is not that they they did this. This was was clearly just like a publicity stunt. These two companies are have been like like taking shots at each other for for many years.
Yeah, the thing I'm most curious about is what was that AI setup that allowed them to iterate like that? Uh because I know when I'm working on this stuff, I'm constantly babysitting these things like to just let it rip on something and have it output something that is this usable. Granted, they have the test suite, but like I want to know what that AI said. The process started with a plan. I spent a couple hours going back and forth with Claude in open code to define the architecture, what to build, etc., etc. Um, from there, the workflow was straightforward. Define the task, let AI write all the implementations and the test, run the test suite if the if the test pass, etc. So basically it was just taking all of the tests and um setting up all these the shim with the router and whatnot that needs to happen and then just saying like hey just keep keep punching uh keys until the all of these tests pass which is crazy.
It sounds like there was a human sitting there waiting for each task to be done verifying and then going on to the next thing. So like this in a sense is human assisted. It's not fully AI. I don't know if we're there yet. I'm sure we'll get there at a certain point with agents and everything. Well, like with these like longunning agents, you can just say like like once you have your test suite in place, it can just kind of continually loop. You you still do need a human loop of course. Um and there was a lot of stuff broken with it as well. But I'm curious to see if they if this is just like a publicity thing or if this is actually going to like they they launched CIO.gov with it, right, as their like launch partner. I don't know if this will will be a long-term thing, but I'll tell you, I had a Nex.js website and I was using Open Nex.js and the way that that works is that they take the output bundle from Nex.js and then they just start like patching the bundled output, which is just a nightmare. I I tried using it for like a month and I ended up just being like, I'm moving over to to Wacku.
Yeah. So this is actually just really exciting to me because I I think it's a it is you're right it's a publicity stunt but the fact that they built on top of Vit opens up so many more opportunities like my my mind is just racing because personally I'm actually working on a framework myself and I had I had we're going to talk about it in the future stay tuned but I had written off Nex.js because of all of the baggage and everything. Um, but the fact that this is built on top of VIT makes it so that I can use the work that they did and build something even more interesting, but now it's all VTE powered. I can use the Vit ecosystem.
Um, it brings up the question of will projects move their test suites to be private. Um, because like that has to suck to like have spent your life's work on it like very smart people working on Nex.js and then these orange men come around and just try to reimplement the entire thing in in a week. I don't know if this is a joke or not, but Steve from TL Draw has opened up an issue on TL Draw to move all of his test suites private. So, no, someone can't do this to them. And the fact that I don't know if this is a joke or not is is kind of scaring me a little bit.
Yeah. And so u historically uh SQLite actually doesn't publish their their test suite and they they've done that before AI but oh in a sense it's it's kind of like it makes it really hard for someone else to create a like a fully compatible SQLite replacement because their test suite is uh is private. Now people have done it like there's lib SQL um but yeah it's an interesting way to go about it's a lot easier if you have all the edge cases all the way down because like Let me tell you like Nex.js has lots of edge cases, right? They have two different bundlers, you know, Turboac and Webpack and then they also have um like React server components. So there's a front end and a backend running and and it's in CommonJS, but some stuff is in ESM and there's also MDX. I had so many problems with with that type of stuff. So I guarantee if you have any sort of complex Nex.js, it's not going to be as easy as dropping this thing in.
Yeah. What I'm most excited about is that Nex.js JS users will finally get to experience what we've been experiencing uh for many many years that VIT is good. Vit is way better. V [laughter] is so much better than what you've been using. Yeah. Yes. All right, Scott. What do you got? Oh, I got something that has caused uh database CEOs all over the internet to start filling their diapers because my gosh, this is really uh sparked a lot of controversy for some reason. And what I'm bringing is space-time DB. Now, Spacetime DB is an interesting project.
SpaceTimeDB 2.0 Release
I gave this a rip a little bit, but I think the thing that has been causing the most amount of drama is from this YouTube video specifically. Anytime these companies start swinging with their graphs, I'm just like I didn't with the the Cloudflare stuff, I didn't even look at their like stats and graphs because, you know, they're picking whatever they like to show. So the reason why this has caused quite a bit of stir is because of these benchmarks which is how many transactions uh they can process per second. They have this magnifying glass for for convex which is honestly like that's very funny. There's the planet scale CEO saying if you can't tell these aren't comparative benchmarks you are a [ __ ] The Convex folks also had their chance with some snarky tweets calling them little bro. And then the founder of
Spacenuts DB. Uh so both Convex and Planet Scale, they're mad. They're big mad obviously. And and so let's talk about Spacetime DB. I I spun up a little spelt kit app with it. Uh this is just their their um their just little their spelt demo. And this is running spaceime locally on my machine. They have a cloud offering as well. Um, I I spun this up and I found it to be a pretty compelling API to work in. I found the code to be nice. Um, you know, there's some curious things about SpaceTime that, you know, because this started out as a video game database that there's some clear gaps in their knowledge of how like web stuff works. Like you won't find any SSR examples on their website. So, this is mostly SPA stuff that's going on. For the most part, you're defining reducers and those reducers are your API. they are your your connection to the database and everything else is done client side
the kind of way that you do in in convex or you know you use supabase but these things can be used server side rendering I'm sure that serverside rendering is possible with this but what makes spacetime different it's its own database it's its own database technology it has acid guarantees everything is atomic it's fully relational uh the the tech that makes it interesting is that the database itself is all in RAM. It's all stored in memory. So, uh everything is they say nancond lookups. Um but it persists to the the like the data store. So, you could think of it as kind of like a relational reddus with a sync to a a hard disk storing.
The entire database is in is needs to be loaded into memory, right? So you have a 300 gig database, you need 300 gigs of RAM, which is a great time to launch a RAM based database, right? [laughter] The prices of RAM right now, but it is compelling in terms of its use case. Uh I and it is fast as hell. When I I used it, it's great. And uh the the big gaps I think for me is like their O story is not like like I you can't can't use better o than this. You can't just use normal stuff. they're expecting you to use um you're they're expecting you to use like a thirdparty o service to then get you that JWT. So like if you want to just have your whole app existing in spacetime, it's going to be a bit of a pain unless you already have like an O server somewhere uh an ODB and O server or you're using just straight up OOTH from other things like that or you can use their product. Um you can self-host this so there's that u but you can't self-host the O part. So I I found it pretty compelling honestly. I I think
it's neat. I I I appreciate different use case and the fact that a lot of games are built using this tech or not like a lot of games but games are built using this tech effectively uh for real time MMOs and stuff like that. That's compelling to me. Yeah, it's a cool idea. I I'm I'm always hesitant of people writing their own database like why not like the way you described I'll have to look into it more but the way you described it I almost think you could build some kind of caching layer in front of Postgress or in front of my SQL.
That's what zero is. Yeah. Yeah. And like caching layer and get get a similar experience. Um so it's interesting that they went from scratch. Um but yeah, we'll have to I'll have to check it out. CJ, what do you got for us today? All right. Now for something completely different. This does not involve VCs or funding or [laughter] drama or drama. This is for the nerds. Um so this person Lyra implemented an x86 CPU purely in CSS. I'll talk about that what what that means in a second. But this page only has a tiny bit of JavaScript.
x86 CPU in Pure CSS
The only reason this JavaScript is here is to give it a more consistent clock cycle because a a CPU needs a ticking. And so the JavaScript gives that, but it can run without it as well. You can disable JavaScript and then it just uses CSS animations as the the clock, the tick in the actual uh computer itself.
So what you're looking at is this x86 program that they wrote is being rendered here with CSS and they're basically just using modern features of CSS to get this working. So this doesn't work across all browsers. It only works in Chrome. What you're seeing down here are like the memory registers. So essentially it's storing information in CSS variables and those are the registers. And I'll caveat it with they've implemented just a 16bit version of x86. So this doesn't run on on 64-bit. it's not 32-bit. Uh, essentially programs that were written for the Intel 8086. So, this was a chip that came out in 1978. So, like the uh the Tandee 1000 um or the NEC PC like these are older computers that any program written for them could basically run on CSS in the browser here. And so it has a way to provide input and if you press and hold uh that will run program number one and it'll start calculating the Fibonacci
sequence. Um and it's it's absolutely fascinating to look at the source of this page. So we've got our our clock, we've got our all of these custom properties and these are like memory registers. So I think like m each one of these is a register in memory. So all of these are there and then from there lots of functions that I could not explain but we also have calc right so lots of computation is happening using the calc keyword. So this is fascinating as you can see it's it's it's running it's doing its best job to calculate each number but this is uh how slow it would run because it can't just spit it all out. It's literally calculating each number based on the previous previous results.
Man, this is crazy. I love CSS. What the hell is going on here? Is this [laughter] I thought I was good at this stuff. What my favorite part of the read me is I just straight up wrote the CSS. It's handwritten in sublime text, but for the most repetitive parts, I wrote a Python script. What?
Yeah. [laughter] And they said they did not use AI and says, I don't think you could build a project like this with an LLM. This is also just another refreshing thing. It's like, you know, no AI involved here, just some pure engineering. Um, and I actually I got it running locally. So, um, I built a little, uh, C program that when it spins up, it says, "Hello, syntax FM."
And then, uh, it'll show us the, um, the inputs and then if you press one, it should say it again. I don't know if it loops. I didn't I don't know if I got looping working. Yeah, it doesn't loop. I was trying to get it to just say hello syntax forever. So you wrote the C program compiled it to what like 16 bit.
Yeah. So the way this works is I have this C program and it is built using this build IIA16 package and they actually have some Python scripts in the x86 CSS repo that helps with this. So this build C will actually compile your program into a binary and then build CSS will take that binary and turn it in to the actual CSS instructions and then all of that gets loaded onto the page.
itself to give you the the running program. So in terms of how all of the CSS features are being used, it uses variables to store the CPU state. So registers, instruction pointers, flags, memory, all of those are stored in CSS variables. Um it uses the at function keyword for reusable things. So it implements like ands and ors and exclusive ors. And then it uses if and style queries for conditional logic. So CSS, not in every browser, but currently in Chrome, CSS is not only touring complete, but you can literally build an entire computer inside [laughter] of inside of CSS.
Style queries enable so much cool stuff. We were just talking about them, man. Style queries are dope. You think you know CSS and like or you think you're up on on all the latest features, but then there's people that are just like, hm, I wonder if I could build a computer.
Unbelievable. All right, that's it for today. If you like the video, comment and share below. Let us know what you thought of it. I love when people tag us in things that we should be talking about. Keep doing it.
Quote it with credit and a link. Quoting Syntax