JavaScript just got way faster

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments

Gotta love Fireship 🔥

👍︎︎ 1 👤︎︎ u/oh_jaimito 📅︎︎ Sep 05 2022 đź—«︎ replies
Captions
it is july 6 2022 and you're watching the code report one of the most profound quotes about the javascript ecosystem comes from an old british guy who said out of intense complexities intense simplicities emerge at the time nobody knew what the hell he was talking about but in 2022 it's clear he was prophesizing the rise of a new javascript runtime called bun that's right you no longer need node.js or dino so go ahead and uninstall those from your system right now bun just announced its first beta release and makes the claim that it's significantly faster than node or dino not just a little bit faster but orders of magnitude faster it's always a good idea to be skeptical about benchmarks provided by the creator of a tool but as you can see here it's about three times faster when server rendering react running database queries or executing native code with foreign functions impressive very nice but what i'm more excited about is what this tool can do to simplify your life as a developer we'll get into that in just a minute but first i know my mom is going to ask me what a javascript runtime is in the first place you can think of javascript like gasoline it's dangerous and bad for the environment and by itself isn't very useful to make javascript or gasoline useful it needs to run through an engine to convert it into raw energy or machine code for a cpu the most popular javascript engine is google's v8 which powers chrome node and dino and makes javascript execution extremely fast with just in time compilation now gasoline combined with an engine still isn't very useful the average person wants that engine in a car with user-friendly apis like wheels file system access subwoofers websockets automatic transmission and so on a javascript runtime is a complete car all you have to do is put a little bit of javascript in the tank and it will take you anywhere you want to go now that we're done with that ridiculous analogy let's talk about what makes bun special a big one is obviously performance but how does it actually go so fast well first of all it doesn't use the v8 engine but instead uses javascript core from webkit which is generally considered to be faster but more difficult to work with in addition it's written in a low level programming language called zig this is a relatively new language that's similar to c or rust and the creators of bun say the lack of hidden control flow makes it much simpler to write fast software it's fun to go fast but more importantly bun is an all-in-one runtime it has a native bundler to replace tools like webpack and also has a native transpiler so you can write typescript code out of the box with cool features like top level await an idea that's already been pioneered by dino but bun will also transpile your jsx files also like dino it prioritizes web apis like fetch while at the same time also supporting many node core modules as well as node api which will allow many npm packages to also work in bun in fact it implements node's module resolution algorithm which means you can install packages from npm into bun and those packages install 20 times faster it feels like magic another nice ergonomic feature is that environment variables load automatically it's not like node.js where you have to install env into every project it also comes with its own test runner similar to jess and as you might imagine it's fast some might even call it blazingly fast sounds awesome but keep in mind this project is in its infancy there will be bugs if you're on windows you'll have to use wsl and even that gave me some issues but overall my final analysis on bun is that this thing is bussin no cap for real this has been the code report thanks for watching and i will see you in the next one
Info
Channel: Fireship
Views: 697,924
Rating: undefined out of 5
Keywords: webdev, app development, lesson, tutorial
Id: FMhScnY0dME
Channel Id: undefined
Length: 3min 14sec (194 seconds)
Published: Wed Jul 06 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.