Bun 1.0:All-in-One Toolkit
JavaScript has always been a dynamic language with a vibrant ecosystem. Over the years, we've seen a plethora of tools designed to make JavaScript development easier, faster, and more efficient.
Currently, there is a new development: Bun 1.0, which serves as a runtime, package manager, test runner, and bundler for JavaScript and TypeScript.
To test it I am using
Node - v20.6.1
Bun - v1.0.0
I am using this code to test performance
console.time('test');
for (let i = 0; i < 10000; i++) console.log(i)
console.timeEnd("test");
I have created a node file by npm init
Running the index.js script
I am getting around 154.889ms.
To create in bun, we will use bun init
Running the same index.js script
I am getting around 61.35ms⚡.
I have changed console logs to create difference between node and bun
We will run same commands in npx and bunx to measure creating time.
I created react project using create-react-app
$npx create-react-app node-text-react
$bun x create-react bun-text-react
Both are adding same number of packages(1455) but npx does it in 35s whereas bunx(bun x
) does it in 19s⚡.
After CRA, I tried in vite project
$npm create vite@latest
$bun x create-vite vite-project-bun
Both added 262 pakages but node does it in 11s whereas bunx(bun x
) does it in 1.2s⚡.
Then I tried creating next app with bun and node
$bun x create-next-app
$npx create-next-app@latest
Bun installed 321 packages in 7.85s⚡ where as node installed 325 packages in 22s.
Bun is very fast as compared with node and yarn, node, deno (according to documentation). It is based on Javascript Core Engine and Zig. Still there are some disadvantages like it can't run on Windows machine and also bugs as it is first stable release. With the introduction of Bun as a new contender in the Node ecosystem, developers now have viable alternatives to Node.
Hope you found this post helpful.
Happy Coding!