🍞 Bun, A Faster JavaScript Runtime
Tags: bunjs, node, webdev, javascript
Published: 2024-02-27 21:41:03

<Intro>

:warning: **Disclaimer: This article is for those who don't really know about Bun but want to understand it in a hurry**

A new challenger approaches in web development!

Bun has received a lot of attention in the past year. But what is it?

---
## What is Bun?

Bun is many things but to sum it up, Bun is:
- package manager
- test runner
- fast javascript runtime
- bundler
- so many more things...

Bun is basically, a smaller, faster Node.js replacement.

Do note that not all features of Node.js are currently available in Bun. Though they will be built out eventually as the community is actively pushing out new and improved features. 

Thankfully, the Bun team provides a compatibility table to show what features are implemented and what still needs work. You can check that out [here](https://bun.sh/docs/runtime/nodejs-apis). 

One neat thing about Bun is it's written in [Zig](https://en.wikipedia.org/wiki/Zig_(programming_language)). A programming language that first appeared in 2016 that is intended to be a successor to the C programming language.

Other languages on this level would be: [Go](https://en.wikipedia.org/wiki/Go_(programming_language)), [Rust](https://en.wikipedia.org/wiki/Rust_(programming_language)), and Google's new interoperability language for C++, [Carbon](https://en.wikipedia.org/wiki/Carbon_(programming_language)).

While Zig is "new" in terms of languages, it seems to hold up to what the Bun team is trying to do with it.

---
## Bun vs. Node

As mentioned before, Bun isn't quite a 1:1 comparison to Node. So I'd avoid swapping out your back-end for it right now. However, if the features you use are fully implemented within Bun, I'd highly recommend trying it out.

Why? Check out these metrics:


![HTTP Web Server Metrics](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3lq0tc70lcm5coj8gshp.png)

![WebSocket Metrics](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/870nwp1ds4kau88ghzn9.png)


![SQLite Metrics](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mgnkn0tjc7sxl1b0q5m3.png)


<section talking about metrics>
As you can see, the results look pretty promising :eyes:

Also, here's a thorough [breakdown article by Mayank Choubey](https://medium.com/deno-the-complete-reference/is-bun-really-much-faster-than-node-js-e5b15942a8e8) going over some non-biased performance metrics. The results will shock you!

If you want to test it out yourself, refer to [this page](https://bun.sh/docs/project/benchmarking) of their documentation.

And with that, there's also a bunch of applications we can construct with Bun. So many that there's a [guides section](https://bun.sh/guides/) on the bun site. 


---
## Awesome Bun Projects

With Bun reaching version 1.0, you bet that there's a ton of projects out there that use it. The makers of bun made a repository with a bunch of projects that use the tool, you can check that out [here](https://github.com/oven-sh/awesome-bun).


Most notable projects:
- [Express-like API](https://github.com/elysiajs/elysia)
- [Express-like Edge API](https://github.com/honojs/hono)
- [Web Framework](https://primatejs.com/)
- [GraphQL Yoga](https://github.com/dotansimha/graphql-yoga)
- [Webdev Game Things](https://github.com/RodrigoDornelles/npm-gamepadzilla/)

---
## Conclusion

Thanks for reading!!

This was a short one, next month should be a larger article with a demo. In the meantime, here's some links to other Bun-related resources.

[Bun Github](https://github.com/oven-sh/bun)

[More Bun Projects](https://github.com/oven-sh/awesome-bun)