Node.js Runtime: How It Works and How It's Different From Bun


If you’ve ever wondered what actually happens when you run node index.js
, you’re in the right place. I recently dove into how the Node.js runtime works thanks to 100xDev’s awesome resources, and thought it’d be fun to turn my learnings into a blog post. So, let’s unpack how Node.js runs our JavaScript and how it compares with the newer kid on the block—Bun.
🧠 So... What Is a JavaScript Runtime?
At its core, a JavaScript runtime lets you run JavaScript code. The browser has its own runtime (hello, Chrome’s V8), but when you want to run JavaScript outside the browser—say, on your server—that's where Node.js or Bun comes in.
Node.js gives you access to things like the file system, network, and more, all through JavaScript. It’s like giving JavaScript superpowers it didn’t have in the browser.
🏗️ What Makes Up the Node.js Runtime?
Let’s break this down a bit. The Node.js runtime isn’t just one magical thing—it’s a combo of several components working together:
1. V8 Engine
This is Google’s high-performance JavaScript engine that also powers Chrome. V8 takes your JS code and compiles it into machine code that your system can understand. It’s fast, optimized, and battle-tested.
2. Libuv
This little C library is what makes Node asynchronous. It gives Node its non-blocking I/O capabilities and manages the event loop, file system, and threading under the hood.
3. The Event Loop
This is where the magic happens. It keeps your application alive, waiting for tasks (like reading files or handling requests) to finish. Instead of getting stuck waiting on slow tasks, the event loop just moves on and checks back later.
4. Node.js Core APIs
These include things like fs
for file system operations, http
for creating servers, and so on. They're written in C++, wrapped in JavaScript, and exposed to developers in a nice JS interface.
🔄 What Happens When You Run a Node.js Script?
Let’s say you write a simple script:
console.log("Hello, world!");
Here’s a rough breakdown of what happens:
The JS file is passed to the V8 engine.
V8 compiles it into machine code.
Node’s runtime hooks into system-level APIs if needed (e.g., timers, file I/O).
It runs the code and exits when everything’s done (unless there’s an ongoing operation).
If your app has async operations (like a server), the event loop keeps it running, checking if there’s more work to do.
🔥 Enter Bun: Node’s Flashy New Rival
Now, Bun is a newer runtime that’s been getting a lot of attention. It was built from scratch with performance in mind, and it comes packed with modern dev features out of the box.
Here’s how Bun stacks up:
✅ Uses JavaScriptCore instead of V8
Bun is built on WebKit’s JavaScriptCore engine—the one used in Safari. It’s also fast, and Bun claims it outperforms Node in many benchmarks.
✅ Built-in Bundler, Transpiler, and Package Manager
Bun doesn’t just run your code—it bundles it, transpiles it (like Babel or esbuild), and manages packages (yes, no npm install
needed!).
✅ Native TypeScript Support
Want to run .ts
files directly? Bun does that out of the box. No need for separate compilers or configs.
🥊 Node.js vs. Bun: A Quick Comparison
Feature | Node.js | Bun |
JS Engine | V8 | JavaScriptCore |
TypeScript Support | Needs setup (e.g., ts-node) | Native |
Package Manager | npm | Built-in |
Bundler | External (e.g., webpack) | Built-in |
Performance | Fast | Even faster (in many cases) |
Maturity | Very mature | New but growing fast |
💭 My Take
Node.js is still my go-to for building production-ready backends, especially because of the massive ecosystem and stability. But I’ve been experimenting with Bun for fun projects, and I’ve gotta say—it’s really fast and developer-friendly.
It feels like Bun was made for today’s workflows: TypeScript-first, minimal setup, and performance-focused. That said, it’s still relatively new, so I’m watching how it evolves.
🚀 Final Thoughts
Understanding the runtime you’re building on is essential, especially as more options like Bun enter the scene. Whether you’re building a REST API or a CLI tool, knowing how the engine under the hood works helps you write better, faster, and more efficient code.
Let me know if you've tried Bun or if you’re sticking with good old Node.js—I’d love to hear your take!
Thanks for reading 🙌
Subscribe to my newsletter
Read articles from Tanmay Bansal directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Tanmay Bansal
Tanmay Bansal
build. ship, publish