BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Node.js Alternative Bun Now Generally Available

Node.js Alternative Bun Now Generally Available

The release 1.0 of the JavaScript toolkit Bun has been recently announced. Aiming to be a drop-in replacement for Node.js, Bun is garnering attention from the JavaScript and serverless communities for its speed and ease of use.

Bun is designed to be a fast toolkit for running, building, testing, and debugging JavaScript and TypeScript, competing with Node.js and Rust-based Deno. Announcing the general availability, Jarred Sumner, creator of Bun and CEO of Oven, explains the goal of the project:

Since Node.js debuted 14 years ago, layers and layers of tooling have accumulated on top of each other. And like any system that grows and evolves without centralized planning, JavaScript tooling has become slow and complex. (...) Bun's goal is simple: eliminate slowness and complexity without throwing away everything that's great about JavaScript. Your favorite libraries and frameworks should still work, and you shouldn't need to unlearn the conventions you're familiar with.

Written in Zig, Bun includes a runtime, a package manager, a test runner, a bundler, and a package runner. It provides built-in support for Node APIs, including built-in modules like fs, path, and net, globals like __dirname and process, and the Node.js module resolution algorithm (node_modules).

Multiple Reddit threads discuss the performances of Bun, comparing it with Rust, Deno, and Node.js. While some developers on Hacker News question if the GA is premature, others acknowledge the fast package installation, build times, and performances. Matteo Collina, co-founder and CTO at Platformatic and core contributor of Node.js, writes:

I really like what Jarred Sumner is building with Bun, but I'm a bit frustrated by their compatibility claim with Node.js. In my experience, it's not a drop-in replacement and many inner details differ (...) I would have preferred if they waited for calling a 1.0.

While some developers question the compatibility with Node.js, Christian Kjær, director of engineering at Famly, comments:

Just ported a massive 10-year-old frontend monolith to it with what amounts to a couple of line changes, and several smaller backend services which required no changes.

According to Sumner, Bun was tested against test suites of the most popular Node.js packages on npm, and supports different server frameworks including Express, Koa, and Hono. Highlighting instead how Bun does not currently support modules like Fastify or Pino, Collina adds:

Bun did not care about backward compatibility with a significant portion of the npm ecosystem. They made things fast and are working to preserve backward compatibility as an after-fact: this is how you approach building fast software.

The possibility of a runtime faster than Node.js attracts the attention of serverless developers, with Jeremy Daly, CEO and founder of Ampt, writing:

Bun seems very cool and the early benchmarks are impressive. What does this have to do with serverless, you ask? Well, lots of folks are wondering if Bun’s exceptional speed (and tooling, testing, etc.) would outperform the Node.js runtime on AWS Lambda. It’s an interesting proposition.

In the article "Serverless Bun vs Node: Benchmarking on AWS Lambda", Mitchell Kossoris, senior software development engineer at AWS, performs some initial benchmarks and concludes that Node has fewer cold starts but Bun is 50% faster in API Gateway response time. Kossoris writes:

I think Bun has a real chance of overtaking Node as the industry default runtime for JavaScript and TypeScript development, and I’ll personally be rooting for it. Also, AWS Lambda (...) considers supporting Bun as a native runtime.

Bun is MIT-licensed and aims for complete Node.js API compatibility.

 

About the Author

Rate this Article

Adoption
Style

BT