What Makes Bun.sh Formidable with Node.js?

What Makes Bun.sh Formidable with Node.js?

Daily short news for you
  • Privacy Guides is a non-profit project aimed at providing users with insights into privacy rights, while also recommending best practices or tools to help reclaim privacy in the world of the Internet.

    There are many great articles here, and I will take the example of three concepts that are often confused or misrepresented: Privacy, Security, and Anonymity. While many people who oppose privacy argue that a person does not need privacy if they have 'nothing to hide.' 'This is a dangerous misconception, as it creates the impression that those who demand privacy must be deviant, criminal, or wrongdoers.' - Why Privacy Matters.

    » Read more
  • There is a wonderful place to learn, or if you're stuck in the thought that there's nothing left to learn, then the comments over at Hacker News are just for you.

    Y Combinator - the company behind Hacker News focuses on venture capital investments for startups in Silicon Valley, so it’s no surprise that there are many brilliant minds commenting here. But their casual discussions provide us with keywords that can open up many new insights.

    Don't believe it? Just scroll a bit, click on a post that matches your interests, check out the comments, and don’t forget to grab a cup of coffee next to you ☕️

    » Read more
  • Just got played by my buddy Turso. The server suddenly crashed, and checking the logs revealed a lot of errors:

    Operation was blocked LibsqlError: PROXY_ERROR: error executing a request on the primary

    Suspicious, I went to the Turso admin panel and saw the statistics showing that I had executed over 500 million write commands!? At that moment, I was like, "What the heck? Am I being DDoSed? But there's no way I could have written 500 million."

    Turso offers users free monthly limits of 1 billion read requests and 25 million write requests, yet I had written over 500 million. Does that seem unreasonable to everyone? 😆. But the server was down, and should I really spend money to get it back online? Roughly calculating, 500M would cost about $500.

    After that, I went to the Discord channel seeking help, and very quickly someone came in to assist me, and just a few minutes later they informed me that the error was on their side and had restored the service for me. Truly, in the midst of misfortune, there’s good fortune; what I love most about this service is the quick support like this 🙏

    » Read more

The Issue

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.

What is Bun.sh?

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.

What's new and different about Bun.sh compared to Node.js?

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.

Why is Bun.sh formidable compared to Node.js?

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.

Bun.sh benchmarks

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?

Conclusion

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.

Premium
Hello

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!

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!

View all

Subscribe to receive new article notifications

or
* The summary newsletter is sent every 1-2 weeks, cancel anytime.

Comments (0)

Leave a comment...