Bun, Deno, Node.js? Recreating a JavaScript Runtime From Scratch

Rate this content
Bookmark

Bun, Deno, and many other JavaScript runtimes have been hype, but do you know why? Is it that easy to make a runtime from scratch?


I've been researching the secret behind Node.js' power and why there are so many new JavaScript runtimes coming up. Breaking down each key component used on Node.js I've come to interesting conclusions that many people used to say whereas in practice it works a bit differently.


In this talk, attendees will learn the concepts used to create a new JavaScript runtime. They're going to go through an example of how to make a JavaScript runtime by following what's behind the scenes on the Node.js project using C++. They'll learn the relationship between Chrome's V8 and Libuv and what makes one JavaScript runtime better than others.

FAQ

The speaker was motivated by a fear of being asked detailed questions about Node.js's inner workings at conferences and realized a gap in his knowledge. This led him to deeply explore and recreate Node.js to understand it better.

The tutorial and all related resources, including slides and links, are provided in the last slides of the presentation discussed in the talk.

In the reconstruction of Node.js, the main components used were JavaScript for scripting, the V8 engine for JavaScript interpretation, C++ as a bridge for connecting JavaScript with the operating system, and libuv for managing event loops and asynchronous operations.

The speaker suggests extending the V8 engine by implementing custom functions in C++ and linking them to JavaScript calls, effectively adding new functionalities like 'print' and 'setTimeout' to the V8 global context.

The speaker faced significant challenges, including the complexity of understanding and implementing the various components of Node.js, coordinating with experts, and the time-intensive nature of compiling and managing the required environments and libraries.

The speaker encourages taking pictures and mentioning the event on social media to help promote their work and extend the reach of the event, aiding in community building and recognition.

The key takeaway was the realization that Node.js extends functionalities by linking JavaScript with C++ operations, demonstrating that much of what seems complex is manageable with the right understanding and tools.

The speaker mentions an upcoming project to recreate React Native, indicating plans to explore and understand another complex framework by breaking it down into its fundamental components.

Erick Wendel
Erick Wendel
28 min
01 Jun, 2023

Comments

Sign in or register to post your comment.

Video Summary and Transcription

This Talk explores the journey of learning and recreating Node.js from scratch, highlighting the main components and experimentation involved. It delves into implementing functions in V8 and setTimeout in Node.js, as well as the execution pipeline and the event loop. The collaboration between different JavaScript runtimes and the continuing evolution of Node.js are also discussed. The speaker shares their experience of exploring Node.js and writing a book, and hints at future projects involving React Native.

1. Introduction to Node.js and My Journey of Learning

Short description:

Hello, everyone. We're gonna make some crazy experiments today. I tried recreating Node.js from scratch and I'm going to tell you all the step-by-step. First of all, all the slides, all the links, references and even a tutorial for you to follow after this conference I put on the last slides. Mention me, mention the event because this is how you can push our job further. Well, all this talk is about, do I really know Node.js? So I start researching a lot of things and start making questions. I've been creating a bunch of videos doing the same ideas. But this talk, I already have a tutorial there and here today I'm going to show you some highlights, and I even wrote a blog post for you later to extend.

Hello, everyone. How's it been? Yay! Let's try again. How's it been? Whoo! Energy, yes! We're gonna make some crazy experiments today. This is something I love doing, like learning new stuff, and I love doing it by trying it, right?

So I tried recreating Node.js from scratch and I'm going to tell you all the step-by-step in how I've been doing this. First of all, all the slides, all the links, references and even a tutorial for you to follow after this conference I put on the last slides. So not just listen to me here, try at home because you can get a lot of cool other insights. And for sure, take as many pictures as you can because this helps us a lot. Mention me, mention the event because this is how you can push our job further, right?

Well, all this talk is about, I start myself asking myself, do I really know Node.js? So I was looking, I became part of the Node.js car team there and I was so afraid of being in some conference and people asking me questions of how Node.js was working behind the scenes. And I figure, well, I don't know as much as I wish or as much as I thought I would. So I start researching a lot of things and I start making questions and chat dpt has helped a lot to answer those questions. But I've been creating a bunch of videos doing the same ideas. So if you like more math science projects, I've re-implemented the web socket protocol from scratch using binary code, a bunch of cool stuff, and other, creating your code coverage. But this talk, I already have a tutorial there and here today I'm going to show you some highlights, and I even wrote a blog post for you later to extend, because it's just 20 minutes here so you can follow along.

2. Introduction to Node.js and My Journey

Short description:

I'm not a C++ developer, but I'm curious and eager to learn. This research is my own, and I had to reach out to Google for help. Shout-out to Ben, Dino, Node.js, and the creators for their amazing job. They abstract the complexity, allowing us to create powerful applications. Let's do some magic!

Well, just before we go on, I just want to let you know that I'm not a C++ developer, okay? Some C++ developers on the back are going to see bad practices here, but I'm just a curious person trying to learn something on the hard way, okay? Well, this is part of my own research, so this content you aren't going to see anything on the internet. So it was really hard for me, I had to schedule some calls with people from Google, and if they said, I've never done this in my life, so try it yourself. It was crazy. And just a shout-out for Ben, Dino, Node.js, and all the creators from this runtime. You are going to figure out today how nice and how crazy is their job. Because they are abstracting all the complexity for us so we can use an accessible language to create powerful applications. And let's do some magic, I love this game!

QnA

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

A Framework for Managing Technical Debt
TechLead Conference 2023TechLead Conference 2023
35 min
A Framework for Managing Technical Debt
Top Content
Let’s face it: technical debt is inevitable and rewriting your code every 6 months is not an option. Refactoring is a complex topic that doesn't have a one-size-fits-all solution. Frontend applications are particularly sensitive because of frequent requirements and user flows changes. New abstractions, updated patterns and cleaning up those old functions - it all sounds great on paper, but it often fails in practice: todos accumulate, tickets end up rotting in the backlog and legacy code crops up in every corner of your codebase. So a process of continuous refactoring is the only weapon you have against tech debt.In the past three years, I’ve been exploring different strategies and processes for refactoring code. In this talk I will describe the key components of a framework for tackling refactoring and I will share some of the learnings accumulated along the way. Hopefully, this will help you in your quest of improving the code quality of your codebases.

Debugging JS
React Summit 2023React Summit 2023
24 min
Debugging JS
Top Content
As developers, we spend much of our time debugging apps - often code we didn't even write. Sadly, few developers have ever been taught how to approach debugging - it's something most of us learn through painful experience.  The good news is you _can_ learn how to debug effectively, and there's several key techniques and tools you can use for debugging JS and React apps.
It's a Jungle Out There: What's Really Going on Inside Your Node_Modules Folder
Node Congress 2022Node Congress 2022
26 min
It's a Jungle Out There: What's Really Going on Inside Your Node_Modules Folder
Top Content
Do you know what’s really going on in your node_modules folder? Software supply chain attacks have exploded over the past 12 months and they’re only accelerating in 2022 and beyond. We’ll dive into examples of recent supply chain attacks and what concrete steps you can take to protect your team from this emerging threat.
You can check the slides for Feross' talk here.
Building a Voice-Enabled AI Assistant With Javascript
JSNation 2023JSNation 2023
21 min
Building a Voice-Enabled AI Assistant With Javascript
Top Content
In this talk, we'll build our own Jarvis using Web APIs and langchain. There will be live coding.
Power Fixing React Performance Woes
React Advanced Conference 2023React Advanced Conference 2023
22 min
Power Fixing React Performance Woes
Top Content
Next.js and other wrapping React frameworks provide great power in building larger applications. But with great power comes great performance responsibility - and if you don’t pay attention, it’s easy to add multiple seconds of loading penalty on all of your pages. Eek! Let’s walk through a case study of how a few hours of performance debugging improved both load and parse times for the Centered app by several hundred percent each. We’ll learn not just why those performance problems happen, but how to diagnose and fix them. Hooray, performance! ⚡️
Monolith to Micro-Frontends
React Advanced Conference 2022React Advanced Conference 2022
22 min
Monolith to Micro-Frontends
Top Content
Many companies worldwide are considering adopting Micro-Frontends to improve business agility and scale, however, there are many unknowns when it comes to what the migration path looks like in practice. In this talk, I will discuss the steps required to successfully migrate a monolithic React Application into a more modular decoupled frontend architecture.

Workshops on related topic

Node.js Masterclass
Node Congress 2023Node Congress 2023
109 min
Node.js Masterclass
Top Content
Workshop
Matteo Collina
Matteo Collina
Have you ever struggled with designing and structuring your Node.js applications? Building applications that are well organised, testable and extendable is not always easy. It can often turn out to be a lot more complicated than you expect it to be. In this live event Matteo will show you how he builds Node.js applications from scratch. You’ll learn how he approaches application design, and the philosophies that he applies to create modular, maintainable and effective applications.

Level: intermediate
Building a Shopify App with React & Node
React Summit Remote Edition 2021React Summit Remote Edition 2021
87 min
Building a Shopify App with React & Node
Top Content
WorkshopFree
Jennifer Gray
Hanna Chen
2 authors
Shopify merchants have a diverse set of needs, and developers have a unique opportunity to meet those needs building apps. Building an app can be tough work but Shopify has created a set of tools and resources to help you build out a seamless app experience as quickly as possible. Get hands on experience building an embedded Shopify app using the Shopify App CLI, Polaris and Shopify App Bridge.We’ll show you how to create an app that accesses information from a development store and can run in your local environment.
Build and Deploy a Backend With Fastify & Platformatic
JSNation 2023JSNation 2023
104 min
Build and Deploy a Backend With Fastify & Platformatic
WorkshopFree
Matteo Collina
Matteo Collina
Platformatic allows you to rapidly develop GraphQL and REST APIs with minimal effort. The best part is that it also allows you to unleash the full potential of Node.js and Fastify whenever you need to. You can fully customise a Platformatic application by writing your own additional features and plugins. In the workshop, we’ll cover both our Open Source modules and our Cloud offering:- Platformatic OSS (open-source software) — Tools and libraries for rapidly building robust applications with Node.js (https://oss.platformatic.dev/).- Platformatic Cloud (currently in beta) — Our hosting platform that includes features such as preview apps, built-in metrics and integration with your Git flow (https://platformatic.dev/). 
In this workshop you'll learn how to develop APIs with Fastify and deploy them to the Platformatic Cloud.
0 to Auth in an Hour Using NodeJS SDK
Node Congress 2023Node Congress 2023
63 min
0 to Auth in an Hour Using NodeJS SDK
WorkshopFree
Asaf Shen
Asaf Shen
Passwordless authentication may seem complex, but it is simple to add it to any app using the right tool.
We will enhance a full-stack JS application (Node.JS backend + React frontend) to authenticate users with OAuth (social login) and One Time Passwords (email), including:- User authentication - Managing user interactions, returning session / refresh JWTs- Session management and validation - Storing the session for subsequent client requests, validating / refreshing sessions
At the end of the workshop, we will also touch on another approach to code authentication using frontend Descope Flows (drag-and-drop workflows), while keeping only session validation in the backend. With this, we will also show how easy it is to enable biometrics and other passwordless authentication methods.
Table of contents- A quick intro to core authentication concepts- Coding- Why passwordless matters
Prerequisites- IDE for your choice- Node 18 or higher
Building a Hyper Fast Web Server with Deno
JSNation Live 2021JSNation Live 2021
156 min
Building a Hyper Fast Web Server with Deno
WorkshopFree
Matt Landers
Will Johnston
2 authors
Deno 1.9 introduced a new web server API that takes advantage of Hyper, a fast and correct HTTP implementation for Rust. Using this API instead of the std/http implementation increases performance and provides support for HTTP2. In this workshop, learn how to create a web server utilizing Hyper under the hood and boost the performance for your web apps.
Build a chat room with Appwrite and React
JSNation 2022JSNation 2022
41 min
Build a chat room with Appwrite and React
WorkshopFree
Wess Cope
Wess Cope
API's/Backends are difficult and we need websockets. You will be using VS Code as your editor, Parcel.js, Chakra-ui, React, React Icons, and Appwrite. By the end of this workshop, you will have the knowledge to build a real-time app using Appwrite and zero API development. Follow along and you'll have an awesome chat app to show off!