DEV Community

Cover image for Bun or Node.js in 2024?

Bun or Node.js in 2024?

Vedansh Sharma on April 03, 2024

Hey there, fellow developers! πŸ–₯️ Well, when it comes to web development, YOU'RE RIGHT! There are just so many tools! But the most popular option ...
Collapse
 
senthilbalajiganesan profile image
Senthilbalajiganesan • Edited

Hey, thank you for the fantastic article. I appreciate the insights shared.

I'd like to share my experience with Bun. While it's incredibly fast and has great features for real-world applications, I encountered several unfixed bugs when using it with sqlite3.

Some of these bugs that were working in previous versions. I believe it's best to use Bun for minimal scripts due to easier debugging and fixing.

As the ecosystem matures, using Bun over node.js makes more sense to me.

Collapse
 
vedansh0412 profile image
Vedansh Sharma

Ohh! Well yeah I think bun is relatively very new and needs much improvement that is why organisations still use node.

Collapse
 
chrisdrobison profile image
Chris Robison

If performance were really the most important metric, JavaScript would not even be considered. Bun is an experimental runtime written in an experimental language. I think it is too bleeding edge for production right now.

Collapse
 
vedansh0412 profile image
Vedansh Sharma

That’s an interesting point because before bun even started the performance metric I don’t think people even talked about it as there wasn’t much to compare with.

Collapse
 
miketalbot profile image
Mike Talbot ⭐

At the time Node was created, there was a lot of talk about performance - but this was down to the fact that most other server architectures were doing thread-based serving - effectively synchronous serving but on a thread. Turns out that the async / event loop approach was way more scalable for traffic that wasn't doing heavy calculations. These days you have the same principle in lots of other architectures and so those turn out to be more performant than JS in some circumstances.

Collapse
 
steeve profile image
Steeve

Bun looks promising, but Node provides performances that most people don't even reach. Take a look at Restana handling 79000 req/s:
github.com/BackendStack21/restana

Collapse
 
vedansh0412 profile image
Vedansh Sharma

Exactly Bun aims more towards simplicity and speed but Node is like the superpower with strength and capabilities.

Collapse
 
alaindet profile image
Alain D'Ettorre

Bun seems fast, but Node.js is king in any other relevant metric. It's far more likely that Node.js will evolve and get faster instead of Bun getting traction. At least for me.

Collapse
 
vedansh0412 profile image
Vedansh Sharma

Yes absolutely!

Collapse
 
rohiitbagal profile image
Rohit

it is very interesting but i think node is better because i never used bun ....if you used then can you tell what is it

Collapse
 
vedansh0412 profile image
Vedansh Sharma

I believe it all comes down to your requirements but yeah Nodejs is like evergreen.

Collapse
 
rohiitbagal profile image
Rohit

yes node is very exited ...if you know then can you tell about Bun

Thread Thread
 
vedansh0412 profile image
Vedansh Sharma

I would suggest you to go through the Bun’s official platform to get a better idea as it is kind of difficult to share everything over here.

Thread Thread
 
rohiitbagal profile image
Rohit

Ok.. thanks for supporting β™₯️

Thread Thread
 
vedansh0412 profile image
Vedansh Sharma

Anytime.

Collapse
 
dotennin profile image
Dotennin

If Bun can slove the pain points of Node, rather than just the performance, I'm sure it'll slowly get a higher share. on the contracry, nodejs is not really more of a performance issue right (web development)?. I think that more performance-orientaed scenarios will not consider nodejs.

Collapse
 
autumnlight profile image
Aykut AkgΓΌn

It does for me personally, installing things is faster with bun, running typescript directly, having a better inspector. Bun is nowhere perfect yet, but its really smexy to dev with it.

Collapse
 
vedansh0412 profile image
Vedansh Sharma

Absolutely! Good point

Collapse
 
cheikhnouha profile image
Cheikhnouha

interesting read

Collapse
 
vedansh0412 profile image
Vedansh Sharma

Thank you! Glad to hear it.

Collapse
 
kortizti12 profile image
Kevin

Hey there! β˜•οΈ Great breakdown on the differences between Node.js and Bun! Bun really does bring some refreshing updates to the sceneβ€”its all-in-one approach with built-in tools like a package manager, bundler, and test runner definitely simplifies setups. And as you mentioned, the use of JavaScriptCore and Zig gives it a speed edge in many scenarios.

Node.js, of course, remains a rock-solid option with its massive ecosystem and mature community, making it ideal for large, scalable projects. For anyone curious to dive deeper, I recently came across a detailed comparison that discusses both runtimes and when you might pick one over the other. Here’s the link if you’re interested: scalablepath.com/nodejs/bun-node-a...

Looking forward to seeing where Bun heads in 2025β€”more choices for devs is always a win!

Collapse
 
vedansh0412 profile image
Vedansh Sharma

Well said!
I really wanna see Bun reach new heights

Collapse
 
joenogo profile image
Joe

Just be careful, Bun isn't yet ready in all aspects. For example, all crypto functions (such as hashing, AES, etc) is around 10x slower than Node.js at the moment.

Collapse
 
autumnlight profile image
Aykut AkgΓΌn

Did they have a regression? I had done some tests where bun was 3x perf of node, (mainly uuid tests)

Collapse
 
joenogo profile image
Joe

No clue, I tried moving a crypto-heavy project of mine to Bun and my dev machine nearly died. When I investigated, I realised that it was all the crypto work that was slow. Btw when I say 10x slower, that's not an exaggeration - we're talking 2-3 seconds in Node vs 25-32 seconds in Bun for the same key strength. Everything else I tested was around 2x-6x faster in Bun.

Collapse
 
vedansh0412 profile image
Vedansh Sharma

Yes absolutely that is why I referred it as a new child.

Collapse
 
ezekiel_77 profile image
Ezekiel

Node

Choosing the one that stood the test of time

Collapse
 
vedansh0412 profile image
Vedansh Sharma

Great Choice! My own preference πŸ˜…

Collapse
 
eric42 profile image
Eric

Larger scale projects can still benefit from Bun locally or in continuous integration pipelines. Running tests faster and better local package management save time in the development life cycle.

Collapse
 
vedansh0412 profile image
Vedansh Sharma

Yes absolutely, but bun is also new and lacks in few things although the newer version sounds much more promising.

Collapse
 
pavelee profile image
PaweΕ‚ Ciosek

Great post! πŸ‘ keep it up! πŸ™

Collapse
 
vedansh0412 profile image
Vedansh Sharma

Thank you so much!

Collapse
 
rayyannafees profile image
Rayyan Nafees

Bruh.. Your bun code is wrong.. it doesnt even run

Image description

Collapse
 
vedansh0412 profile image
Vedansh Sharma

Thanks for pointing it out, but I believe this typescript error might get resolved if you run it from your shell.

Although this has been highlighted on Bun’s QuickStart guide.

Please try this code:
const server = Bun.serve({
port: 3000,
fetch(req) {
return new Response("Bun!");
},
});

console.log(Listening on http://localhost:${server.port} ...);

Hope this works for you.

Collapse
 
rayyannafees profile image
Rayyan Nafees

bun version 1.1.1

Collapse
 
vedansh0412 profile image
Vedansh Sharma

I have shared another code, please try it and let me know if you still face some errors, please share it with me and I would also like you to go through the QuickStart guide on official website.

Collapse
 
asmeet_singh_e91937f76050 profile image
Asmeet Singh

πŸ‘πŸΌ

Collapse
 
vedansh0412 profile image
Vedansh Sharma

Thank you!

Collapse
 
ed3899 profile image
Eduardo Casanova

Id wait till serious companies with serious money start using it :)

Collapse
 
vedansh0412 profile image
Vedansh Sharma

But don’t you think then again the situation of too much competition will be created and might lack behind if we start learning it late like happening with MERN stack.

Collapse
 
vineyrawat profile image
Viney Rawat

I'm using bun in development and it's fantastic saves a lot of time

Collapse
 
alxwnth profile image
Alex

I’ve played with Bun before and it looks really promising. Thanks for the post!

Collapse
 
shruti_gupta_ profile image
Shruti Gupta

Interesting!

Collapse
 
vedansh0412 profile image
Vedansh Sharma

Thank you!

Collapse
 
frankatron profile image
Frank

Unfortunately, Bun in not supported on a lot of cloud and PaaS providers. It's a bit of a catch22, but once more cloud providers support Bun then I could see it getting more wide use adoption.

Collapse
 
madhusaini22 profile image
Madhu Saini

nice article!!
Thanks for sharing

Collapse
 
vedansh0412 profile image
Vedansh Sharma

Glad to hear!

Collapse
 
610470416 profile image
NotFound404

simple solution: run on both.

Collapse
 
vedansh0412 profile image
Vedansh Sharma

Great πŸ˜‚

Collapse
 
brense profile image
Rense Bakker

What about Hono, which can be used in both nodejs and bun runtimes?

Collapse
 
vedansh0412 profile image
Vedansh Sharma

As far as I have heard it works better with bun but haven’t really tried it so can’t say for sure.

Collapse
 
krushndayshmookh profile image
Krushn Dayshmookh

Clickbait article.

Collapse
 
vedansh0412 profile image
Vedansh Sharma

Value your opinion!

Collapse
 
richardevcom profile image
richardevcom

Switched to Bun recently - the performance is incredible.

Collapse
 
vedansh0412 profile image
Vedansh Sharma

Yes it’s really fast.

Collapse
 
yeasin2002 profile image
Md Kawsar Islam Yeasin

I've been using Bun for the last few days and it's really fast.
I tested both of them and bun is faster then node or Deno.

Collapse
 
vedansh0412 profile image
Vedansh Sharma

Yes! Bun is faster but it is not yet designed to build large scale complex applications unlike node.

Collapse
 
ricardogesteves profile image
Ricardo Esteves

Nice article, thanks for sharing it!

Collapse
 
vedansh0412 profile image
Vedansh Sharma

Glad to hear!

Collapse
 
anusha_raghav_341c0b480a0 profile image
Anusha Raghav

This is such an interesting read!! Waiting for more such reads keep it up!!

Collapse
 
vedansh0412 profile image
Vedansh Sharma

Thank you so much!!!!

Collapse
 
shenandrei4 profile image
Andrei Shen

Hi, thank you for the great article.

Collapse
 
vedansh0412 profile image
Vedansh Sharma

Glad to hear!

Collapse
 
raddevus profile image
raddevus • Edited

It's YAJF! Yet Another JavaScript Framework

Why should you use it?

Because it's 10 minutes newer than the previous YAJF. πŸ€“

Who Will Use It?

New-new-devs who don't know about (or haven't tried) previous YAJFs.
They'll tout it as the greatest thing ever -- because they don't know about previous things ever.
πŸ€“
Am I funny yet? 😁

Collapse
 
mr0cket profile image
Milo Silva

@vedansh0412 Any relevant updates as of September 2024? πŸ˜ƒ

It seems like your conclusion is that node-js is still the way to go for production/enterprise grade solutions, correct?

Collapse
 
andyjessop profile image
Info Comment hidden by post author - thread only accessible via permalink
Andy Jessop

This article is littered with errors, not least of which is this:

this modern, lightweight framework built on Node.js

It is not built on Node, it's built from scratch with Zig.

Collapse
 
fateriddle profile image
FateRiddle

I don't get it... this is a day 1 comparison article in, ... 2024?

Collapse
 
vedansh0412 profile image
Vedansh Sharma

No sir, this actually is a comparison of what you can choose in 2024, based on data till the date this article was published, if that was your doubt.

Some comments have been hidden by the post's author - find out more