subhafx

subhafx

Posted on July 16, 2022

Meet BUN !!

Bun logo

I am a fast all-in-one JavaScript runtime.

What is a Javascript runtime?
A JavaScript runtime environment provides access to built-in libraries and objects that are available to a program so that it can interact with the outside world and make the code work.

What is BUN?
Bun is a javascript runtime created by Jarred Sumner a few days ago. It is built on Javascript Core from WebKit. Not like Bun, other runtime like node and Deno are built on V8.Bun also have the potential to replace node.js and become the number one runtime.

Why BUN?
Bun can do almost everything node.js can do the only difference is Bun is faster than node.js. Being fast is pretty cool but the best part is that Bun is an all-in-one runtime It has a native module bundler which means that you can get rid of tools like webpack and also have a native transpiler that can allow you to write typescript and JSX out of the box. It also have the ability to download most npm 20 times fast.

LET'S DISCUSS ITS PERFORMANCE โšก
Instead of the V8 engine, which is usually regarded as being quicker, JavaScript Core from WebKit is used. Additionally, the author of Bun stated that ZIG, a low-level programming language comparable to C or Rust, lacks concealed control flow, making it considerably easier to build quick applications.

Comparision of Bun with other JS Engines

STARTING OUT WITH BUN:
Run this install script in your terminal to install bun. From GitHub, Bun is downloaded.
curl https://bun.sh/install | bash

Bun's HTTP server is built on web standards like Request and Response

// http.js
export default {
  port: 3000,
  fetch(request) {
    return new Response("Welcome to Bun!");
  },
};
Enter fullscreen mode Exit fullscreen mode

Run it with Bun:

$ bun run http.js

Then, in your browser, navigate to localhost:3000.

Bun CLI

$ bun run
The same command for running JavaScript & TypeScript files with bun's JavaScript runtime also runs package.json "scripts".

Replace npm run with bun run and save 160ms on every run.

bun runs package.json scripts 30x faster than npm run

$ bun install
bun install is an npm-compatible package manager. You probably will be surprised by how much faster copying files can get.

Replace yarn with bun install and get 20x faster package installs.

bun install uses the fastest system calls available to copy files.

$ bun wiptest
A Jest-like test runner for JavaScript & TypeScript projects builtin to bun

In short
Bun is an alternative to Node and Deno, that is written in Zig. Bun is currently in early access but is already up to 14x faster than its competitors.

Will Bunn kill deno and node?

In my opinion, a tool to watch out for because itโ€™s going to revolutionize the way we bundle our JavaScript together!

Bun is still in experimental mode.

References:
Official Website: https://bun.sh/
Github Repo: https://github.com/oven-sh/bun
Creator: https://twitter.com/jarredsumner

Follow me on Linkedin @subhadipfx

๐Ÿ’– ๐Ÿ’ช ๐Ÿ™… ๐Ÿšฉ
subhafx
subhafx

Posted on July 16, 2022

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

ยฉ TheLazy.dev

About