Like, and also all of the APIs are, like, based on an existing thing. So, like, the actual API interface here is pretty much the same as Postgres.js. This Redis client is mostly similar to Ioredis. It's not 100% mapping, but pretty close. And that also de-risks some of this, because it's like, okay, part of the challenge, there's, like, what APIs should BUN have, and then also which of those APIs look like. And generally, the thing about a runtime is that you basically can't have breaking changes ever, because it's also just not really worth the time to deal with breaking changes from, like, the user's perspective.
So it's much less risky for us if we base whatever API we add on some existing common pattern in the ecosystem, and we try hard to, like, not invent new things. And then we optimize a lot of it. Like, for example, the Redis client, every time you do any network activity on it, any of the commands, it doesn't send them immediately. It uses what we call a deferred task queue. Basically, it batches all of the network calls to be after all the microtasks are drained, but before the next tick of the event loop. And that means that we can then combine all the network calls to send to, which is the system call it uses, automatically without the user having to do anything themselves. And that makes it a lot faster.
We also have a built-in file API, button.file. We do not yet have a directory API, which is kind of silly. We also have a built-in S3 API, and the S3 API and the file API are basically the same thing. And that's because, like, S3 is generally what servers use for production, like, file systems. So ideally, the remote file system API is pretty much the same as your local. So that way it's easy to test between the two. It also just makes it really easy to, like, read a file as JSON. This is such a common thing. It should be really easy. We also have a bunch of random, kind of, like, they're not random, but like, basically, when there's a package that has tens of millions or more of weekly downloads at npm, and they're, like, really small, with, like, a very clear use case that's probably never going to go away.
Comments