Node.js is famous for its role as a server-side JavaScript runtime environment. When talking about Node, we can't ignore the powerful JS processing capability of the V8 Engine, backed by the strength of C++, the language that creates it. Node.js is free, easy to install, and deploy. The strong and trustworthy community of Node users further contributes to its fame and trustworthiness.
However, recently another name has emerged as a "threat" to Node.js, and that is Bun.sh. So what is Bun.sh, and why does it make Node.js wary? Let's continue reading this article to find out.
First of all, Bun.sh is also a JavaScript runtime environment similar to Node.js. The goal of Bun is to run most JavaScript outside of the browser, bringing improvements in performance and complexity to future infrastructure, as well as enhancing the productivity of developers through a better, simpler tool.
Bun.sh doesn't use V8 as the JavaScript Engine like Node does. Instead, it uses the JavaScriptCore engine, which is the engine of the Safari browser. In addition, Bun is written in Ziglang, which they introduce as a low-level programming language with manual memory management. This helps reduce the resource usage cost of Bun and significantly increases its performance.
Bun.sh implements most things like JSX/TypeScript compiler, npm client, bundler, SQLite client, HTTP client, WebSocket client... And all of these are their own hand-developed tools.
In addition, Bun also implements Node's module resolution algorithm, including node_modules
, so you can install and use packages from npm just like in Node. ESM and CommonJS are both supported, but Bun uses ESM as the default.
Bun implements about 90% of Node's APIs (N-API), so almost all modules or native modules written for Node will work with Bun.
Bun becomes formidable because of its speed. Besides leveraging most of Node's features, Bun allows you to run almost all Node-written applications but with even better speed.
According to the Bun developer, using the bun run
command instead of npm run
saves 160ms for each run. bun install
is also 20 times faster than yarn
because Bun uses "the fastest system calls" implemented by themselves.
Additionally, some benchmark images compare the speed of Bun's HTTP requests with the two commonly used JS runtime environments, Node and Deno, and it also shows impressive numbers.
The limitation of Bun is that it is a new tool still in the development stage, without a stable release, so using Bun in a production environment can pose risks. However, with the benefits that Bun brings, it is definitely worth experiencing. Give Bun a try, and who knows, you might discover a valuable tool for yourself?
Although a new tool, Bun.sh has already gained attention in the Node.js development community. Hopefully, one day Bun will release a stable version while maintaining and even further improving its speed, to strengthen the growing community.
The secret stack of Blog
As a developer, are you curious about the technology secrets or the technical debts of this blog? All secrets will be revealed in the article below. What are you waiting for, click now!
Subscribe to receive new article notifications
Hello, my name is Hoai - a developer who tells stories through writing ✍️ and creating products 🚀. With many years of programming experience, I have contributed to various products that bring value to users at my workplace as well as to myself. My hobbies include reading, writing, and researching... I created this blog with the mission of delivering quality articles to the readers of 2coffee.dev.Follow me through these channels LinkedIn, Facebook, Instagram, Telegram.
Comments (0)