Skip to main content

about 4 years ago Syntax Podcast

What is Bun? The New JS Runtime

Wes Bos

Wes Bos Host

Scott Tolinski

Scott Tolinski Host

Topic 0 18:27

Bun has a public roadmap

Wes Bos

like a database server locally. You can just have an SQLite a file in your folder and you can save and whatnot. And it's pretty cool. I'm a big fan of Escuelite, and it looks like they have written their own. I think it's called the ORM, One neat thing that Bun has out of the box is the ability to run a web server, and that is something that does exist with, That cold start is is really important, Implementing What do you call that? A driver or ORM?

Scott Tolinski

where they're at with many of these things because there is a whole lot of stuff. Like, for instance, the web compatibility

Wes Bos

One other thing they have here is they have,

Scott Tolinski

a lot a lot here. Oh, here's Node. Js, And a tool chain for maintaining robust,

Wes Bos

literally anywhere. And SQLite is very, very popular in, like, desktop applications because Why doesn't it just work? You know, I don't wanna have to do all this sort of overhead. And it's interesting that that just is built right in. They say it's batteries included. Yeah. Batteries included is something that I I like to hear more and more.

Wes Bos

in

Wes Bos

compiling with Node as well. However, in most cases, looking really, really interesting.

Wes Bos

That's more to a framework than an environment. Yeah.

Wes Bos

Like, this seems like the whole batteries included, except for the, like, obvious parts of, like, authentication Very excited about bun here. I I like all things buns, ham buns. Yeah. Buns buns. Yeah. Buns buns. And the button, I like it. JavaScript environment, you name it. So bunnies, pretty exciting. Like bunnies. Bunnies. I do like bunnies. Yeah. Yep.

Wes Bos

on your system, and you can you can just keep that file in

Scott Tolinski

should be used

Scott Tolinski

compatibility.

Wes Bos

essentially have a database just as a file if you have a .env file,

Wes Bos

and apparently is very fast. So I'm wondering, like, they're doing everything here. TypeScript

Scott Tolinski

This is a big old project, and I think it's one we're gonna be seeing a lot of for the time to come here. So here's a question is

Scott Tolinski

Gotta love that.

Scott Tolinski

or any of that stuff. So there is a lot Welcome to Syntax. In this Monday, hasty treat, we're gonna be talking about bun,

Wes Bos

JavaScript runtime.

Wes Bos

if your your desktop app wants to store some data, You don't need to go to an external server. You don't want to run a,

Wes Bos

an SQL SQLite,

Wes Bos

and image processing. That's more

Scott Tolinski

section,

Scott Tolinski

Crypto polyfill It. You pay for the services you actually use, not the number of the people on your team, which is important because you can scale your incident response team without adding to your bill. You get intelligent on call scheduling and escalations.

Scott Tolinski

Should use hard so it seems like they have a crypto polyfill west. Crypto polyfill should use hardware accelerator,

Topic 1 10:58

Bun supports async code

Wes Bos

It supports FS and Path right now, and then other APIs For the longest time, we've had Node as our JavaScript environment. And then a couple of years ago, we got Deno, which is sort of

Scott Tolinski

a a SvelteKit

Scott Tolinski

as well, CommonJS and text as well as ESM. So you're not gonna have to worry about,

Scott Tolinski

It. You know, I think it's interesting that, IO briefly.

Scott Tolinski

to replace your node command with the bun command, and it should run your thing. So instead of saying, like, node index dot j s, you would just say bun index dot j s, and that will run bun. Now it for, I believe, a potluck episode. Get ready.

Scott Tolinski

I'm interested about, like, the section in their docs that say, it. Like, what's not implemented yet? Have you checked that out at all, Wes? No. I haven't. What what do they have there? So not implemented yet. Web streams via the fetch API, web streams via HTML Rewriter, web, the socket server, package hoisting that matches NPM's behavior, source maps, more recently, we haven't really had a lot of different server node run or JavaScript runtime. So It is interesting how this world's kind of changing a little bit now, and we are seeing,

Scott Tolinski

and basically attempts

Wes Bos

Node API. They call it NAPI,

Scott Tolinski

is shorter than the word node. So you're gonna say 1 letter typing, and you're gonna get speed games on top of that. Yeah. So I'm just reading it here. It supports the

Wes Bos

Although there's web crypto, so probably not.

Wes Bos

Like sort of polyfill them, I guess, so that if you want to use like, oh, I would love to move it upon, but

Wes Bos

them, That will be how you handle it. So if you've ever used a serverless function

Wes Bos

We're using this one like Chihuahua JS, and that uses us internally, it uses a node a native API, and we we just can't

Scott Tolinski

We've talked a little bit about what what this thing is and and maybe, like, why you might wanna use it. But, like, can you use it? I guess this is a whole another topic. So, like, can you use this thing today? I don't have to be changing out which bundler I'm using every single month just to get some big perf gains or something. So

Scott Tolinski

you know, until

Wes Bos

A lot of these modules will be built not just as node modules, but they'll be built as Like, why would you want to use JavaScript on the server? What a joke.

Scott Tolinski

already

Scott Tolinski

I'm under of the understanding that it should mostly just work. There are some APIs that aren't implemented yet, which we'll talk about. But I did even see, You know, there's it's nice. I like TOML,

Wes Bos

Like, they could even be written in Dart or something like that. So to surface that to Node, they have this thing called the Node API, the n API, tool. So it's And here we are, what, like 12, 13 years later, And now we can use them

Scott Tolinski

I I saw that this supports CommonJS Yeah. We had Tom on the show, the creator of Tomo. Tom's obvious minimal language.

Scott Tolinski

So, I mean, I think it seems like from their intention, you should be able to start, like, applying this to real projects and seeing essentially free games. And and you you gotta love free games from doing nothing really other than just changing a word. In fact,

Scott Tolinski

I so, you know,

Scott Tolinski

I was like, did I get the right one? I I think so. You know, that's it's so funny without that word. It it it's always

Wes Bos

probably crypto,

Scott Tolinski

adapter for BUN. There's people. There's a whole section on using Next. Js with BUN in BUN's documentation.

Wes Bos

like node native APIs, which is like the FS API, the path API, in nodelan will work in BUN. And then you also have,

Scott Tolinski

is this just, like, the newer features? It seems like like you mentioned a lot of stuff.

Wes Bos

Server JavaScript modules, and they'll be they'll be built in such a way that you can at least you can run them in all the different environments ideally. That's what I see happening. Yeah. It's wild how, how this landscape has changed. I mean, for so long, we had JavaScript or Node, and then we had You can rewrite it. So you could you could do something as as

Wes Bos

Eventually, they will be all supported, so you'll be able to bring those things in. And what I The sort of what I see for the ecosystem in general is long term.

Wes Bos

and that is for another JavaScript environment? Isn't this just Like like, it seems like we're getting excited about

Scott Tolinski

characters pop up and play here.

Wes Bos

Any modules that are native, meaning that there's lots of modules in Node land that are not written in JavaScript. They're written in c, or c plus plus or something, and they're compiled.

Wes Bos

In in order to surface the functionality of those modules

Topic 2 17:10

Bun uses TOML for config

Scott Tolinski

so it's kind of interesting.

Wes Bos

And it is. It's

Wes Bos

and and whatnot. So it's interesting that they did not just go for JSON five, which Like, Versus Code went all in on JSON five, where any time you are writing a JSON config in Versus Code, you can do comments and and whatnot. But I wonder if there's features of TOML They're focused on performance, but they are also, Like buffer process,

Wes Bos

where, like so that should you need to use any packages and they just include them in the language itself. And for the long This time, we had browser APIs and then we had node APIs and things like fetch didn't exist in node.

Wes Bos

JSON five For

Scott Tolinski

Yes. Yeah. He's a fan of it. This equals that. This equals that. And here's some brackets. Yeah. Don't have to worry about not having comments like you mentioned. But, Yeah. I think it's just nice. There's also a road map here that will link into the show notes so you can kind of see where they're going. They have this over in the issues, but it's an it. It's a road map. I I love road maps, especially when they're they have checkboxes because this says 17 of a 133

Wes Bos

because of one of the problems with, package. Json is that it's a regular JSON,

Scott Tolinski

tasks complete.

Wes Bos

and you can't do things like comments and you have to have a trailing comma

Topic 3 23:06

Conclusion and call to try Bun

Wes Bos

Catch you then. Peace. Peace.

Scott Tolinski

or drop a review if you like this show.

Scott Tolinski

for a full archive of all of our shows, Head on over to syntax.fm

Scott Tolinski

and don't forget to subscribe in your podcast player You can see exactly what's complete, what's not complete, what's coming down the line, what's not,

Topic 4 03:32

What is Bun?

Wes Bos

a bundler. It looks like it even has test.

Wes Bos

a package manager, a TypeScript needs We don't have time to refactor that out.

Wes Bos

Which means that it's, like, kind of the 1st version out there,

Scott Tolinski

What is BUN? b u n. Bun JavaScript minifier, CSS minifier, You can get the full context on your service health, active alerts, and who's on call. LightStep incident response immediately pinpoints issues Like, I'll I'll just trust. I'll default to whatever whatever you said at the time because I don't wanna have to think about it.

Scott Tolinski

Wes,

Wes Bos

To focus on, now there's a new one called Bun,

Wes Bos

Yeah. So we talked about this A couple times on the podcast here or there, and, recently, it was just, like, released as well, was it 1.0 or environmental variables. And And it's a vote of comments for JavaScript in general, so always bet on JS.

Wes Bos

starting fast. This has an edge in mind. New levels of performance of going fast as heck, having a Script environment that runs extremely fast and starts extremely fast.

Wes Bos

it is aiming to be on the same level as Node and Deno, But also be just works.

Scott Tolinski

let's get into BUN.

Wes Bos

0.1, Express or one of those connect

Topic 5 15:13

APIs not yet implemented in Bun

Wes Bos

Automatically add a alt tag or any. You can do literally anything you want as it's streaming in. I always thought that was a really cool the config JSX those are not implemented just yet. And the same thing with Deno is that over time, we saw Yeah. It's I'm curious that they didn't choose transpiler,

Wes Bos

It's interesting how Yeah.

Scott Tolinski

TypeScript decorators,

Scott Tolinski

There's also a config file, of course, because we gotta love config files. There is an interesting enough. Did you notice,

Scott Tolinski

No. No. I didn't. Yeah. So not YAML, but Tomo. Tomo.

Wes Bos

API,

Scott Tolinski

j s s JSX pragma. I don't know what JSX pragma is, but it sounds kind of like a Love a monster or something. Rag.

Scott Tolinski

that the It's it's just going to work, which you gotta love that. Right? You gotta love just being able to use TypeScript.

Wes Bos

And maybe that signals that they will be implementing

Scott Tolinski

Extends, or how the workspaces and monorepo stuff exists inside of BUN. But so far, it really feels like if you go down the list of all of the things that it is, It's kind of, an all encompassing.

Scott Tolinski

for both CSS and JavaScript And the answer is really yes. It's it's not I don't wanna say it's It's not done or anything like that. There's certainly we'll talk a little bit about what's not implemented and what the road map is. But as far as installing and getting it to try to use this thing, you could It's all bun today

Wes Bos

You just said HTML Rewriter, they don't support yet. And I just was like, hey. Isn't that that's a CloudFlare Worker thing. Web streams with HTML Rewriter. Yeah. Just streams. Yeah. Okay. Because HTML rewriters are pretty cool Cloudflare thing where you can intercept a request and as you are streaming it in,

Wes Bos

silly as replace Scott with Scotty Specify the port that you want. Specify a fetch method. And then inside of that fetch method,

Scott Tolinski

CSS parser, extends in TypeScript TS config dot JSON, so that might be a problem with your SvelteKit sites. You need that. Well, you don't need that, but they use TS, it.

Scott Tolinski

like, their bundler config file is a TOML file?

Wes Bos

In button, which is which would be really sweet. Nice. Yeah. That'd be pretty cool.

Topic 6 04:22

Comparing Bun to Node and Deno

Wes Bos

included, which also Node just that people can try. And it's a new JavaScript environment And that is fully supported, meaning that any of these modules that are native

Wes Bos

A different JavaScript environment. It still runs JavaScript, but the API is slightly different.

Wes Bos

and it's

Wes Bos

It's kind of cool because like, trying to support the whole node API

Wes Bos

rolled that out as well. So it's kinda interesting because

Wes Bos

are only node only. It it will work. So I don't think it's necessarily going to try to replace node,

Wes Bos

But I think it's going to try as we start to move towards more serverless and edge functions, You're gonna wanna use this if you are running a small business, a large business. You're just sending out a couple invoices. This is the one that you wanna do. You're gonna get paid faster.

Wes Bos

That,

Wes Bos

Flare has its own runtime.

Topic 7 08:17

Bun builds on Zig language

Scott Tolinski

JavaScript esque, dare I say, in some ways. Yeah.

Scott Tolinski

But it's supposed to be very, very fast, and it's supposed to be

Scott Tolinski

Zig It is it's a language that you may not have heard of. It's its own programming language. It's it's a general purpose language,

Scott Tolinski

and it's a smaller community.

Scott Tolinski

optimal, and reusable software. And Zig is kind of its Own interesting topic if we wanted to dive into Zig sometime, but Zig is a it's a tone language. And,

Scott Tolinski

I don't know. It seems seems like, as far as These types of languages go whether you have, like, a Rust or or, you know, c or or Java or any of that stuff. It seems like it It's way more readable than many of those languages that I've tried to read before. It does feel

Topic 8 06:47

Bun implements common APIs

Wes Bos

Yeah. And,

Wes Bos

other things like the dotenv You're gonna get paid faster. 30 day free trial. Thank you FreshBooks for sponsoring.

Wes Bos

Right across the board without having to do any polyfills,

Wes Bos

readable stream.

Wes Bos

and run it right.

Wes Bos

And this is just built right into BUN. So Some of those just like easy, easy to use things. Dino had this as well where it's like, oh, yeah. Like all of us are doing this. Lots of us are using TypeScript. Lots of us are using JSX.

Wes Bos

All of these are standard JavaScript APIs, CS. FreshBooks is the cloud accounting service for your small business.

Wes Bos

Web APIs as well. And so we talked about this with Deno as well where they take a fetch, WebSocket,

Scott Tolinski

JavaScript ecosystem.

Wes Bos

So, like, pretty much every application that you build a node who else has their own runtime?

Scott Tolinski

The older the older I get and the more things that I build, I don't want to have to build everything from scratch all the time, and I don't wanna have to pick all of these things. Now one of the interesting things they say, why you know, why is it so fast? And the answer is that they just built in Zig.

Wes Bos

this this just looks really good because it takes a lot of the, like, My clients love FreshBooks because they're able to just log in And see it. Like, I have people send me invoices via FreshBooks, and it's great because I can just log in and see exactly how much I owe, What's been paid? What's not been paid? There's no hemming and hawing. You can pay right online. You can hook it up with their payment processor. You can hook it up with Stripe or PayPal.

Topic 9 00:00

Transcript

Announcer

the craziest,

Announcer

CSD.

Announcer

Monday. Monday. Monday.

Announcer

Open wide dev fans, get ready to stuff your face with JavaScript, CSS, node modules, barbecue tips, get workflows, breakdancing, soft skill, web development, the hastiest,

Announcer

Boss and Scott

Announcer

the tastiest web development treats coming again hot. Here is Wes Barracuda

Topic 10 20:23

Why do we need another JS runtime?

Scott Tolinski

Bun, So, you're you're saving some time because the word bun And what we're seeing here is more tools that promise to do more things In more parts of the platform, whether that is, you can get exactly into you can see when that support for HTML rewrite is coming companies.

Scott Tolinski

have something that's fast here, And it solves a bunch of the annoyances. I I would imagine,

Wes Bos

Most serverless functions are done in JavaScript. So huge vote of confidence for JavaScript. And

Wes Bos

multiple JavaScript environments. And Escalate is pretty cool. You can

Wes Bos

incompatibility

Wes Bos

In the browser, you have to use JavaScript.

Wes Bos

and we kind of answered this, but, like, maybe people are asking, like, look, why do we need

Wes Bos

on the server in general A test runner,

Wes Bos

across multiple. Do you have any thoughts on that? I think,

Scott Tolinski

If you wanna check it out, we'll have some links for you, Ben. It's a good Ben. If you wanna check it out, check out those links in the show notes, And, give it a try. I I'm personally gonna be giving this a try. At least nothing nothing else. Just, you know, firing up a basic HTTP server and saying, alright. I did it. That's pretty cool. And, yeah, give it a try. So that's it for Bun. We will see you on Wednesday But other than that, like, We want we want the community and the type of support that other languages have had for so long. You know, there's something so nice about Rust having a built in package manager Speed, man. I think it's both I I think it's just both an opportunity to, other tools like we have Roam. That is one of those ones that's out there that wants to do everything as well. Yeah. Like, it seems like different different

Scott Tolinski

And so I would imagine Jared Jared Seems like his influence for this was just kind of frustration with the current platform.

Scott Tolinski

It seems to me like this is just a a way to step forward and a way to kind of fill in some of the gaps and and take control over your entire application build And at the same time, get some sick perf gains. Yeah. If anything, this is like, what a vote of confidence for JavaScript you know, this is something before it. I had before I learned about BUN, I would assume that it's it's kind of similar to most people. But before I'd I'd heard of BUN, I had not heard of Zig. And then BUN came out, And then all of a sudden, I'm I'm sure once bun hit Zig's homepage got a ton of traffic because it's it's a newer language, tree shaking,

Scott Tolinski

I should say this is I don't know if we we if you mentioned that this was created by Jared's summoner.

Wes Bos

and we're starting to see like belly rolling.

Scott Tolinski

and test runner and bundler and all that stuff. You don't have to worry about it. I don't have to

Scott Tolinski

I think it's just

Scott Tolinski

when Jared created

Wes Bos

the way to code for the Edge is in JavaScript.

Topic 11 06:04

Bun has batteries included

Scott Tolinski

You'll have bundling baked in. You'll have all that task runner stuff baked in the stuff that we have a note with package. Json. But then they they also promised, you know, the 20%

Scott Tolinski

You could say it's like a steamed bun wrapped around the entire is the latest and greatest in the JavaScript world. It's a new JS runtime and more. We're gonna be talking all about what BUN is and why you should have it on your radar.

Scott Tolinski

same, NPM compatible anything that you know and love. I'll I'll be interested to see how that compares to, like, CSPM,

Scott Tolinski

faster package installs Via the

Scott Tolinski

So, you know, with this, you'll have better TypeScript integration because The always bet on JS. Yeah. That is very true. Well, this has been BUN.

Topic 12 05:34

Bun focuses on performance

Scott Tolinski

built in that Node. Js for the longest time just has not had built in, and then you go to land for these things. The next thing you know, there's

Scott Tolinski

really talked about a whole ton, but, you know, so many other

Scott Tolinski

excited to see that this is coming out. Yeah. I'm excited too because, like, we we haven't

Scott Tolinski

8 different versions of them available.

Wes Bos

Is something that people are going to be looking for, so I am pretty or, or or every image On the server, you can use literally anything you want. And when when they first rolled out Node. Js, people People are laughing Bloomberg folks have their own runtime. We did a whole show on So

Topic 13 01:08

Sponsors

Scott Tolinski

and you'll get a free 30 day trial.

Scott Tolinski

Listeners of Syntax will also Hardware accelerated crypto.

Scott Tolinski

This episode is also sponsored today by LightStep incident response. The all in one incident response languages have all of these features

Scott Tolinski

and groups alerts with machine learning, reducing your time to respond. And this means less noise and more personalization for precise notifications where you can take control

Wes Bos

You can send late payment reminders. You name it, they got it. Check it out. Freshbooks.comforward/syntax.

Scott Tolinski

LightStep Incident Response is the intelligent on call scheduling and escalation, as well as FreshBooks, Books, the amazing cloud accounting software that you know and love. Let's talk about one of our sponsors, FreshBooks.

Scott Tolinski

LightStep instant response is built on the ServiceNow platform, which is used by over 6,000

Scott Tolinski

on declaring incidents automatically notifying the right teams. And you can get unified incident response by seamlessly orchestrating alerts and incident triage with on call scheduling across Slack, Teams, Zoom, desktop, and mobile. So what you'll want to do is head on over to lightstep.comforward/syntax, So it seems like if they're referencing the crypto polyfill, then they probably have a polyfill for it. Yeah. Yeah.

Scott Tolinski

receive a free LightStep incident response t shirt after firing an alert or incident. So check it out. Are you in need of incident response? Check out lightstep.comforward/syntax.

Scott Tolinski

Gotta love all that stuff. It. This episode is sponsored by 2 amazing companies.

Scott Tolinski

form for DevOps and SREs.

Topic 14 09:36

Bun supports web server out of the box

Wes Bos

You can just export default curly brackets, you have to Like, do the require dotenv because And just being like a a fully complete

Wes Bos

those things have been standardized, and they work in Deno, and now they also work in Bun. It's kind of cool because you can just make a file,

Wes Bos

because we now have web standards that are request and response, that are not available in JSON or if, they just don't like JSON. I think it's just nice.

Wes Bos

and right from that, you can export a config object. And if That config object has a fetch request on it.

Wes Bos

similar to like that. So you want to Just quickly whip up a quick little script that has a web server in it.

Wes Bos

And you can return a response and you can do literally anything else you want inside of there asynchronously.

Wes Bos

people don't just use the built in HTTP dot create server in Node. They usually reach for

Wes Bos

servers. So

Wes Bos

or a Cloudflare Worker or any of these different varieties is very much If anything, then you might be saying, oh, my gosh. Another thing. This is a huge vote of confidence both for web standards. It's implementing standard stuff. They're not rolling out their own APIs.

Wes Bos

you can create you get the request,

Wes Bos

Yeah. Or yeah. Asynchronously. Yeah. Okay.

Share

Empowering developers for over 286197068516 milliseconds!