Yellow marks are automatic key passages. They aren’t personal saved highlights. Select a timestamp to follow along with the video.
Node.js, created in 2009 to bring event-driven I/O to server-side JavaScript, succeeded at first, but its creator later stepped back and came to see many of its design choices as mistakes, including the dropped promises, the missing security model, the GYP-based build system, and the sprawling module system built around package.json, node_modules, and implicit resolution. The talk then presents a prototype of a successor runtime, Deno, that is secure by default with explicit permissions, has a single entry point between a Go process and V8, bundles TypeScript in, imports modules by URL with caching, and uses a simpler build. The talk closes by inviting feedback and by acknowledging that the prototype is still early and not yet usable.
Opening and purpose of the talk
This talk was meant to cover different material, but that was not ready, so this make-up talk looks back on Node instead. Node has been around for some years now. It has stabilized and become a settled part of the ecosystem, moving in a clear direction. The talk opens with an apology for nervousness and a wavering voice.
Node's original goal
Node was created and managed through its initial development for a couple of years. Its central goal was event-driven I/O in JavaScript. In 2009, that focus was important for taking server-side JavaScript out from under a frowned-upon reputation. JavaScript is single-threaded, which made event-driven I/O a natural fit, and that design choice allowed Node to succeed.
Early I/O success
Node performed well in the I/O area. It supported protocols such as HTTP and HTTPS. It was ported to Windows using the native IOCP system calls, and it ran on Linux and Mac. The core was relatively small. It got somewhat out of hand over time, but it remained workable. The API was stable, npm had arrived, and people were adding modules.
A premature sense of completion
At that point the project seemed finished. In the creator's view, the verdict was badly wrong: 'This project is done now.' Keeping Node running on everyone's machines, keeping it updated alongside JavaScript, and fixing its issues has taken a tremendous effort from many contributors, several of whom are in the audience. Many important people are probably left out of this recap.
Stepping away and returning
The creator was personally done with Node and moved on to other work. Only in the last six months has Node been used heavily again. The return was largely prompted by Go, which arrived as the creator became interested in building fast servers. In the creator's view, Go is the better language for fast servers, so there was no need to use Node for that purpose.
Nuance on dynamic languages
Node still holds up, and JavaScript is quite nice. Dynamic languages have real strengths, and they suit some tasks better than others. For building a server where every aspect must be controlled, static typing is preferable. In scientific computing, by contrast, many one-off calculations happen in a Jupyter notebook, and a type error is the last thing wanted when just plotting something. Prototyping is another case where speed matters more than settling abstractions. In the creator's view, JavaScript is the best dynamic language, though many people may disagree.
Design mistakes that cannot be fixed
Using Node is at times frustrating. The creator sees bugs that were introduced, which in practice are no longer really bugs because they are simply how the system works, yet they remain bugs. These design mistakes cannot be corrected now because so much software depends on them. They offend the creator's sense of good design. Node could have been much nicer.
Regret over dropping promises
One regret is abandoning promises. Promises were added very early, and the creator removed them not long afterward, reasoning that Node should be minimal and that promises added an extra object to every callback. That reasoning made sense at the time. Had things gone differently, keeping promises might have sped up the development of async/await in the ecosystem, though that alternate history can never be known. Removing them may have been good, because it let the ecosystem build its own tools and find the right abstraction. Still, the creator has often wished promises had been kept, calling the decision a rash one.
Security as a missed opportunity
Another regret is security. JavaScript is a very secure sandbox in the browser, unlike Python. In Node, however, everything is open, and there is essentially zero security. A Node program has access to all sorts of system calls. This was a missed opportunity to build a server-side runtime that could be secured in certain situations. Granting disk access naturally lets programs exploit the disk. Still, there are cases where a program should run outside the browser without access to the disk or network. A linter is one example. It would be nice to download the massive codebase of a linter and run it without it taking over the computer, which it could.
The build system regret
The biggest regret may be the build system. Build systems are very difficult and very important to building projects, and Node's is a real pain. Node uses GYP. A module that links to a C library uses GYP to compile that library and link it into Node. Chrome used GYP too, but it abandoned GYP for another tool, GN, several years later. That could not have been predicted, but that is what happens. Many years on, Node is the sole remaining user of GYP. Its interface is a JSON file, but the tool is written in Python, and it is a terrible experience. Node has several wrappers around it, including node-gyp, which adds layers of unnecessary complexity.
Leadership failures and the path forward
V8 no longer builds with GYP. It has a GYP wrapper to support Node, which adds more unnecessary technology. In the creator's view, this is one of the biggest failures of Node's technical leadership, and it should be dealt with. The right direction is not clear. It is a difficult problem, given how much software must be supported.
Compiling extensions versus a foreign function interface
The creator made a rash decision in thinking that everyone should compile their extension modules. A foreign function interface could have been a more natural and easier option for people who want to link to system libraries. It does not necessarily require compiling, though the dependencies must still be present. Bryan Cantrell suggested this approach, but the creator ignored that advice. libuv also moved to autotools, which the creator considers unacceptable and regrettable. That decision was made by someone else, and the audience laughed at the attribution.
The origins of package.json and npm
package.json is now the lifeblood of JavaScript, but that was not always so. Isaac of npm fame more or less defined it, though some sort of specification may have existed. The creator largely sanctioned it and made it popular by letting require in Node follow semantics that look into package.json and through its files. That made package.json necessary for Node programs where it was not before. The creator ultimately included npm in Node, which made npm the standard Node distribution service.
How linking to a package works
When a JavaScript program requires a module, the require call does not completely specify what that module is. The module must also be defined in package.json, which is part of the resolution algorithm. It determines which version to install and related details. A node_modules folder also handles module resolution. Linking to a package therefore requires many systems and components working together.
Modules as directories
The creator's problem with package.json is that it gives rise to a concept of a module as a directory of files, which was not really a concept before. Earlier, there were only JavaScript files. On the web, they could be included with script tags all over the place. In the creator's view, there is no module package in that sense, and it is not a necessary abstraction. package.json carries unnecessary noise. Filling it out feels like bookkeeping when all that is needed is to link to a library. Relative URLs will be addressed later.
Vendoring and the size of node_modules
node_modules gets very big because it vendors modules by default, installing them locally into each project folder. With multiple projects, the folders grow large. The creator regrets this idea, which was the creator's own. The algorithm for resolving module names is also wildly complex, and it has been added to over time in ways that are regrettable.
Good intentions with vendoring
Vendoring by default had good intentions. It was meant to make explicit exactly what is being linked to. In practice, a path-style mechanism, like a NODE_PATH or PYTHONPATH setting through an environment variable, would have worked. The current approach deviates greatly from how browsers do things. The creator takes responsibility for this. It is impossible to undo now.
Omitting extensions and index.js
Requiring modules without their file extensions is another questionable choice. It is needlessly non-explicit, forcing the runtime to probe the file system for possibilities such as .js or .ts. Writing the extension out would be clearer. Some people prefer the extension-less style as cleaner, and there is still debate about it. The audience applauded in agreement with the creator's view. index.js was also a cute addition, modeled on index.html, so that including a directory looks up index.js. It was needlessly introduced.
Lessons about cute features
The creator has learned, now that the creator is getting older, that when designing a program, features that seem cute to add are often regretted later. Unnecessary features that are simply cute should be avoided.
Node's I/O versus its module system
The creator's problems with Node are not mainly about I/O. The creator likes Node and finds it relatively nice to program in. Node has a Unix-like feel, but the main problems lie in the module system and how it manages user code. This is largely because, when Node was being built, the focus was on I/O. The creator was deep into epoll, and the module system was an afterthought added as users needed it. That shows in how Node works now.
Why this talk offers alternatives
The talk first seemed negative. Complaining in front of people without offering a solution felt unfair. So the talk offers at least a prototype of how things might be different, or how Node might look if it were designed today. The code shown is very unusable at the moment and does not do anything. Unless someone is well versed in LLDB, building it is not advised. The example referenced is Deno, described as a secure TypeScript runtime on V8. It is about a month old, though the creator is not sure it counts as new software. This is a riff on what a good server-side runtime might be these days.
Security by default and explicit permissions
Event-driven I/O is now taken for granted, and that is something that has to be done. Security is what matters next. It would be nice to take advantage of JavaScript being a sandbox. By default there would be no write access, and users could opt into various kinds of access. To allow network access, a user would pass --allow-network. So, if you want to allow it to access the network, you do dash dash allow network. This
Security through a JavaScript sandbox
By default, the runtime has no write access, and users opt into specific permissions. Network access, for example, requires the flag --allow-network. This suits situations where some code needs to run without being given much access to the system it runs on. It works because JavaScript is itself a runtime: the runtime does not bind into or reach through to the operating system. All system calls go through a message-passing channel.
Architecture: Go process, V8 and protobuf messages
Other designs scatter system access through many entry points, which makes it very difficult to keep track of what is happening and has caused many problems. Here there is a single entry point. The author has long thought such a design would be nice. The architecture is a Deno process, currently written in Go (though the author is still debating whether Go is the right choice), with V8 running inside it. Send and receive calls are bound into V8 and exchange protobuf messages as array buffers. A dispatcher routes messages to various modules, so the modules on both sides of the privileged and unprivileged boundary can sync up. The Go side handles system calls, such as turning a request for a set timeout into a sleep, and V8 has a similar module system on its side.
Built-in TypeScript
The TypeScript compiler is built into the executable inside V8. The author loves TypeScript, regards it as the best thing, and finds the work by the Microsoft team pragmatic, well done and approachable. One of its strengths is that a project can start as plain JavaScript and be built up slowly. That was also a goal of Dart, which, in the author's words, was a total failure: very good intentions and cool, but obviously a failure at this point. TypeScript took a completely different approach, working entirely in JavaScript, and solved the problem in a way that satisfies many people. Anyone who has not used TypeScript is encouraged to check it out. The author wants this runtime to support TypeScript because they like it.
A simpler module system: import by URL
The module system is meant to be simpler, dropping the way Node modules work. Compatibility with Node is not possible, because otherwise the result would just be Node, and there is no attempt at compatibility with existing software; this is mostly a thought experiment. The idea is to import code by where the source came from, as on the web: link to a source file and it is linked into the program. Relative includes work too, and an extension should be provided. The worry that remote source code might change out from under a program does not apply. The first time a URL is used, the file is downloaded and cached somewhere, and it is never updated again, so later runs use the same code. A --reload flag, modeled on a browser's hard reload (the Ctrl+R gesture), reloads all cached files. Vendoring is possible by choosing a different location for the downloaded files. The author thinks this is viable.
Start-up time and snapshots
TypeScript works out of the box, and JavaScript does too, trivially, since TypeScript is a superset of it. Start-up time is currently slow, at one second, which is completely unacceptable. The plan is to use V8 snapshots to snapshot the entire compiler, along with other optimisations, and the author is confident start-up can be improved greatly.
A single executable and a simpler build
Shipping many files is something the author hates. The runtime should be a single executable that links to few things, so that it can be downloaded and run. It should also take advantage of the fact that we are in the future now. Node's build process involves a complicated setup of defining require and bundling the required files. With Parcel, which the author calls really great, the internals of Deno can be written as a normal Node program structure and bundled by Parcel, using Node's module resolution, into one JavaScript file that is dumped into V8. This makes building the whole thing much simpler.
Leaning on native infrastructure
Great native-code infrastructure now exists. Part of building Node was writing a web server, and a lot of time went into the HTTP parser. That work is done and does not need repeating. If the runtime stays in Go, it can link to Go's very good HTTP routines; Rust or C++ are alternatives, and linking into high-level native code is easy these days. That eases the job considerably.
Miscellaneous design choices and browser compatibility
Several smaller choices follow. The process should die immediately on an unhandled promise rejection: nobody really wants to add a catch handler later and keep running, so it should die as soon as an error occurs. Top-level await should be supported, which is not hard. The runtime should also be browser compatible. In Node, the author remembers thinking that window is a really dumb variable name for the global scope, since it is not a window and should be called global. That was a mistake, because it created an incompatibility with the browser. Where Deno overlaps with the browser, it should use browser semantics and browser functions.
Closing remarks
This is a prototype, and the author is mildly happy with it so far. Comments and questions are welcome by email, since they cannot be asked live. The first person to implement an HTTP server gets a star. With three minutes left, the talk closes with thanks for the invitation.
Turn your watchlist into a reading routine
Bring your YouTube videos together, read summaries with key passages marked, and explore the full transcript. Save your own highlights with Pro.
Start with 5 free batteries. Each covers up to 30 minutes of a new summary.
New summaries depend on video availability and demand; processing may take time or require retry.