A first look at Bun

I'm a full-stack developer from South Africa 🇿🇦. I love writing about JavaScript, HTML and CSS.
Search for a command to run...

I'm a full-stack developer from South Africa 🇿🇦. I love writing about JavaScript, HTML and CSS.
No comments yet. Be the first to comment.
Most of you know me for my consistency, a golden arrow in my blog series. I've written 1000 articles in 1008 days! Almost an article a day, and my honeymoon was the only holiday I ever took. I'm super proud of this achievement; it has been a fantasti...

It's not the first time I'll be talking about community. I think it's an essential aspect of any successful tool. This shows in my previous explorations of Astro, Medusa, and now Vendure as well. All these products thrive in a super open, welcoming, ...

The cool part about Vendure is how easy it is to set up and how abstract each layer is. Basically, we get the following elements: External database Server Worker Admin UI Frontend While this is amazing, it also brings a bit of complexity when it co...

The previous article looked at customizing Vendure on a data and process level. In this article, we'll look at customizing emails, as they are often a big part of a webshop system. We'll be looking at two different layers of customization for customi...

Even though Vendure is a pretty significant project out of the box, in some cases, we might want to go in and modify some elements to work to our specific use case. In this article, I'll take a high-level look at some elements we can customize within...

Since I heard about Bun, I've been super excited to try it. And that's precisely what this article will be about.
Before we dive into the nitty gritty of setting Bun up, let's take a moment to talk about what it is.
Bun is a brand new JavaScript runtime, much like you know Node and potentially Deno already. However, they build this one from scratch with speed in mind. The idea is that we can use Bun for our JavaScript and TypeScript apps.
It comes packed with 90% of the Node-API function, plus it comes with all the fantastic Web APIs like fetch, WebSockets, and so on.
I won't go into the details, but Bun is written on the JavaScriptCore engine instead of the V8 engine. They wrote the code in ZIG, which helps with memory management. The combination here is what makes it so fast!
Alright, I'm not one for long background stories and am eager to see how it works and performs. So let's get some applications up and running.
First, let's install Bun. Open up your terminal and run the following command.
curl -fsSL https://bun.sh/install | bash
Now create a folder, and inside add a http.js file with the following contents.
// http.js
export default {
port: 3000,
fetch(request) {
return new Response('Welcome to Bun!');
},
};
Now run the following command in this folder:
bun run http.js
And if we now visit http://localhost:3000/ we should see the welcome from Bun.

As Bun is still very much being developed and limited now, I wouldn't rush to migrate all your applications as some essentials still need to be developed.
However, getting a feel for it is good, as it might become the following big framework for runtimes.
Thank you for reading my blog. Feel free to subscribe to my email newsletter and connect on Facebook or Twitter