loading...
Cover image for 10 Things I Regret About Node.js

10 Things I Regret About Node.js

nickytonline profile image Nick Taylor (he/him) Updated on ・1 min read

Photo courtesy of flickr user Trygve Lie.

The creator of Node JS, Ryan Dahl, recently gave a talk at JSConf EU 2018 titled "10 Things I Regret About Node.js"

It's a great talk about Node and he also goes into some details about his new project Deno, a secure TypeScript runtime on V8.

Here's some of the things he regrets:

  • dynamic languages are great for certain things. In a server though, you want things to be statically typed. (Probably why he wrote Deno in TypeScript and Go)
  • design mistakes:
    • didn't stick with Promises in Node (in the beginning), keeping them could have sped up async/await development.
    • security
    • Build system (GYP)
    • package.json

Even Brendan Eich chimed in

Give it a watch. I'm curious what everyone's thoughts are.

Posted on by:

nickytonline profile

Nick Taylor (he/him)

@nickytonline

Senior software engineer at DEV/Forem. Caught the live coding bug on Twitch at livecoding.ca

Discussion

pic
Editor guide
 

The goal of Node was event driven HTTP servers.

5:04
1 Regret: Not sticking with Promises.
* I added promises to Node in June 2009 but foolishly removed them in February 2010.
* Promises are the necessary abstraction for async/await.
* It's possible unified usage of promises in Node would have sped the delivery of the eventual standartization and async/await.
* Today Node's many async APIs are aging baldly due to this.

6:02
2 Regret: Security
* V8 by itself is a very good security sandbox
* Had I put more thought into how that could be maintained for certain applications, Node could have had some nice security guarantees not available in any other language.
* Example: Your linter shouldn't get complete access to your computer and network.

7:01
3 Regret: The Build System (GYP)
* Build systems are very difficult and very important.
* V8 (via Chrome) started using GYP and I switched Node over in tow.
* Later Chrome dropped GYP for GN. Leaving Node the sole GYP user.
* GYP is not an ugly internal interface either - it is exposed to anyone who's trying to bind to V8.
* It's an awful experience for users. It's this non-JSON, Python adaptation of JSON.
* The continued usage of GYP is the probably largest failure of Node core.
* Instead of guiding users to write C++ bindings to V8, I should have provided a core foreign function interface (FFI)
* Many people, early on, suggested moving to an FFI (namely Cantrill) and regrettably I ignored them.
* (And I am extremely displeased that libuv adopted autotools.)

9:52
4 Regret: package.json
* Isaac, in NPM, invented package.json (for the most part)
* But I sanctioned it by allowing Nod's require() to inspect package.json files for "main"
* Ultimately I included NPM in the Node distribution, which much made it the defacto standard.
* It's unfortunate that there is centralized (privately controlled even) repository for modules.
* Allowing package.json gave rise to the concept of a "module" as a directory of files.
* This is no a stictly necessary abstraction - and one that doesn't exist on the web.
* package.json now includes all sorts of unnecessary information. License? Repository? Description? It's boilerplate noise.
* If only relative files and URLs were used when importing, the path defines the version. There is no need to list dependencies.

12:35
5 Regret: node_modules
* It massively complicates the module resolution algorithm.
* vendored-by-default has good intentios, but in practice just using $NODE_PATH wouldn't have precluded that.
* Deviates greatly from browser semantics
* It's my fault and I'm very sorry.
* Unfortunately it's impossible to undo now.

14:00
6 Regret: require("module") without the extension ".js"
* Needlessly less explicit.
* Not how browser javascript works. You cannot omit the ".js" in a script tag src attribute.
* The module loader has to query the file system at multiple locations trying to guess what the user intended.

14:40
7 Regret: index.js
* I thought it was cute, because there was index.html
* It needlessly complicated the module loading system.
* It became especially unnecessary after require supported package.json

15:28 Talks about Deno.

 

From someone who often forgets his headphones you sir are awesome.

 

His slide deck.

Edit: Fix my markdown 😛.

 

Thanks for the notes. tinyclouds.org/jsconf2018.pdf works, but the URL you have when you click on it is not that. Just FYI.

 

I just noticed "de-no" ↔︎ "no-de"

 
 
'node'.split('').sort().join('')
 

I have an odd question born of lazyness I admit: would you mind summarizing or listing the 10 points in your post?

I've never used Node.js but I'm still curious and this might help the conversation :D

 

I'll summarize it later tonight my lazy friend ;)

 

Posted a few of the items he mentioned during my coffee break. Gotta give it a second listen to gather the rest.

 
 

I think every software developer can learn a lot from this video. It's pretty inspiring to see someone as big in the industry as him admitting his mistakes. These were not on the lines of "yeah, that was a small mistake it doesn't matter", but he totally meant "I screwed up, big time".

 

I rarely have a conflict with Build System but when I do. Damn that GYP! #REBUILD

 

What I took from this video is that node.js is destined to be replaced by competitor that solves a lot of the issues that node does not currently do well, because they were added as afterthoughts. I don't know of such a competitor that currently exists (aside from the presenter's attempt), but it is only a matter of time.

 

it has happened already github.com/stealify/stealify

A Framework for graaljs a nodejs compatible runtime :) powerd by Oracle GraalVM :)

 

I'm excited to see where the Deno project goes as I'm a big fan of TypeScript.

 

Deno is the future 👍

 

Deno is not the future github.com/stealify/stealify powered by Oracles NodeJS Compatible GraalVM is the future today!!!

 

Nothing that has the words Oracle in it will be the future outside of enterprises...

 

They also discuss Ryan's talk on JS Party episode 29: Node's survey, Ry's regrets, Microsoft's GitHub. If you're not already subscribed to this podcast, I highly recommend it.

 

One thing that I don't understand. Why did he created new kind of Node? Why not use another language instead?

 

I asked the same. I guess it's because he's a builder. Thanks to people like him, today we have many alternatives in the world of software.

 

When I asked the question I didn't watch the full talk.
After watching the talk, however, I know that the author really likes JavaScript. That is the reason he didn't choose another language.