Deno vs Node
While Deno is obviously an upgrade over Node (it's made by the same person after all) and has many interesting improvements, there has been a lot of hesitancy about moving over due to various reasons. Deno is fairly new (ver 1.0 came out in May of 2020) so it hasn't been that battle tested yet, and it has a much smaller community, so third party packages are way less abundant and most importantly while it is an improvement over Node in a lot of aspects, it still is often in the same ballpark performance-wise. That will obviously probably change as Deno becomes more mature and if things go well it might even replace Node. But what if I told you that you don't have to wait for that anymore and its no longer just a two horse race?
Can this really challenge Node and Deno?
Well the big selling point for Bun is performance, it's not just faster by a bit in this or that use case, it's faster by whole orders of magnitude. Sure it's always good to take measurements you get from the creators with a grain of salt, but in this case we can easily find various tests done by a number of people all pretty much confirming the same thing: it's blazingly fast. Going by Bun’s official benchmarks:
- bun.serve: 3 times faster when server rendering react
- bun:sqlite: almost 3 times faster when running database queries
- bun:ffi: almost twice as fast when executing native code with foreign functions
Speed has been the main focus since that is the thing that jumps out at you first and that justifiably has fueled a lot of the hype Bun has gotten over the past couple of weeks. But Bun also has a number of quite enticing features related to dev experience and some neat quality of life solutions. It also uses a bit of a best of both worlds approach. Like Deno it has top-level await and prioritizes WebAPI’s like
ReadableStream. As for Node it supports a lot of Node core modules already and has a Node API which will support a number of npm packages as well. It also uses Node’s module resolution algorithm so you can install from npm and do it a lot faster as well. And that's not all:
- native bundler instead of relying on something like Webpack
- native transpiler for built-in TypeScript support and auto transpiling JSX
- native test runner like Jest which runs really fast
- automatic loading of environment variables from .env files so no more
Great things have small beginnings
Bun started out as a side project simply because its creator Jarred Sumner thought Next.js was just too slow. The idea behind it is clear, max performance and better dev experience to work both faster and with less hassle. It blew up and its scope is now quite a bit bigger. It's obvious Bun is not production ready just yet, it's just version 0.1 after all and its creator freely admits there’s a lot of bugs and he just wanted to get it out before he ran out of steam. But there is really a lot worth checking out here and the hype is definitely justified. I think a lot of people jumped at it simply because the whole Node vs Deno debate got a bit stale and they got bored of waiting for some kind of resolution. Bun on the other hand is something to be excited about already as it brings a lot of new stuff to the table and offers taking a big leap instead of taking gradual steps in terms of improvements, especially if we’re looking at performance. Obviously I wouldn't assume Node and Deno are dead just yet, but it's worth it to check out Bun just to get some idea of all the possibilities it has just opened.
Check it out on GitHub: https://github.com/oven-sh/bun