What Makes Bun.sh Formidable with Node.js?

What Makes Bun.sh Formidable with Node.js?

Daily short news for you
  • These past few days, well not exactly, due to the recent WWDC event, Apple has been the subject of online discussions about where their AI features actually stand. While other companies are diving into bringing AI to their devices and software, Apple seems to be... not too concerned.

    Recently, Apple's researchers suggested that LLM models will "completely collapse in accuracy" when faced with extremely complex problems. By pointing out that reasoning is merely an illusion, many rebuttals to this research emerged immediately. Once again, it raises the question of what Apple is truly thinking regarding AI on their devices.

    I think it's quite simple, Apple seems to be struggling with creating AI for themselves. That is, they are facing difficulties right from the data collection stage for training. They always appear to respect user privacy, so would they really go online to scrape data from everywhere, or "steal" data from users' devices? Surely, they wouldn't want to provide more user data to third parties like OpenAI.

    However, perhaps these challenges will lead them to discover a new direction. If everyone chooses the easy path, who will share the hardships? 😁. Oh, I'm not an "Apple fan," I just use what suits me 🤓.

    » Read more
  • A "sensitive" person to markdown is someone who jumps right in to see what's new when they come across a library that creates a new editor. Milkdown/milkdown is one example.

    Taking a look, it seems quite good, everyone. I might try integrating it into opennotas to see how it goes. It's supposed to be a note-taking application that supports markdown, but the library tiptap doesn't seem to want to add markdown support 😩. Using an external library isn't quite satisfactory yet.

    » Read more
  • Everyone using Cloudflare Worker to call OpenAI's API should be careful, I've encountered the error unsupported_country_region_territory these past few days. It's likely that the Worker server is calling from a region that OpenAI does not support.

    It's strange because this error has only occurred recently 🤔

    » 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

5 profound lessons

Every product comes with stories. The success of others is an inspiration for many to follow. 5 lessons learned have changed me forever. How about you? Click now!

Every product comes with stories. The success of others is an inspiration for many to follow. 5 lessons learned have changed me forever. How about you? 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...