Bun is a new runtime written from scratch. Optimized for performance, compatibility, and ease of use.
A few things that stood out after using Bun for a few hours. I'm not an expert but so far Bun has been stupid easy to use.
Using Bun feels faster. You have to try to appreciate the difference. It's like your computer feels lighter.
When you run a NodeJS script, it's fast. Hit enter and your script gets to work. No lag you'd complain about.
Then you run the same script with Bun and it's like omg what just happened? I barely finished hitting enter and it's done!? 🤯
I don't know about you, but seeing
Error [ERR_REQUIRE_ESM]: require() of ES Module makes me want to throw keyboards. You add a new library and the whole project blows up. (╯°□°）╯︵ ┻━┻
This is because a few years ago NodeJS decided to support modern imports.
import thing from 'file' instead of
const thing = require('file). Fantastic!
But they couldn't make both systems compatible. You have to choose between CommonJS (require) and Modules (import).
Some libraries have migrated. Many haven't. You'll find out which is which when your project blows up after you add a dependency 🙃
Bun doesn't have this problem. I don't know through what magic, but I like it. Everything just works.
file.ts run with
bun run file.ts.
file.js run with
bun run file.js.
No run-time support for types though. Jarred, creator of Bun, says that's not a goal either.
the right side and the left side will look a lot more similar in less than a year https://t.co/awZsr0GhDD— Jarred Sumner (@jarredsumner) October 11, 2023
Can't wait! The ease of going
bun add library and
bun run code.ts already feels amazing. Haven't looked for others yet.
This has been my favorite part. Bun aims to work as a drop-in replacement for NodeJS, which means full ecosystem compatibility.
APIs you're used to from NodeJS all work. I haven't bumped into anything broken, at least not in side-projects. Every library I've tried has also worked.
Means you don't have to learn anything new \o/
We all know how drop-in replacements work.
"Like Bun, it's a drop-in replacement" pic.twitter.com/IhXdmoMOTE— Swizec Teller (@Swizec) October 17, 2023
If you use private packages, you'll have to move registry configuration from
bunfig.toml. That's easy.
In larger projects, you're likely to find things that are broken. When I tried running work stuff in Bun, there was a cryptic error with no good way to debug. Later we figured out our Logger library, used everywhere, doesn't like Bun – an outdated dependency maybe.
Bun is new. Fantastic documentation, but if you run into a problem the documentation doesn't cover, you're likely one of the first people online to have this problem.
All in all, Bun is my new favorite way to write CLI scripts.
I write articles with real insight into the career and skills of a modern software engineer. "Raw and honest from the heart!" as one reader described them. Fueled by lessons learned over 20 years of building production code for side-projects, small businesses, and hyper growth startups. Both successful and not.
Subscribe below 👇
Join Swizec's Newsletter and get insightful emails 💌 on mindsets, tactics, and technical skills for your career. Real lessons from building production software. No bullshit.
"Man, love your simple writing! Yours is the only newsletter I open and only blog that I give a fuck to read & scroll till the end. And wow always take away lessons with me. Inspiring! And very relatable. 👌"
Senior Mindset Book
Get promoted, earn a bigger salary, work for top companiesLearn more
Have a burning question that you think I can answer? Hit me up on twitter and I'll do my best.
Who am I and who do I help? I'm Swizec Teller and I turn coders into engineers with "Raw and honest from the heart!" writing. No bullshit. Real insights into the career and skills of a modern software engineer.
Want to become a true senior engineer? Take ownership, have autonomy, and be a force multiplier on your team. The Senior Engineer Mindset ebook can help 👉 swizec.com/senior-mindset. These are the shifts in mindset that unlocked my career.
Curious about Serverless and the modern backend? Check out Serverless Handbook, for frontend engineers 👉 ServerlessHandbook.dev
Want to Stop copy pasting D3 examples and create data visualizations of your own? Learn how to build scalable dataviz React components your whole team can understand with React for Data Visualization
Did someone amazing share this letter with you? Wonderful! You can sign up for my weekly letters for software engineers on their path to greatness, here: swizec.com/blog
By the way, just in case no one has told you it yet today: I love and appreciate you for who you are ❤️