The Third Age of JavaScript

The way we write JavaScript in 2030 will be completely different than in 2020. Here's why: the slow death of IE11 and rollout of ES Modules will converge toward a new generation of JavaScript tooling. These tools are faster, typesafer, and polyglot, leading to both a better developer and user experience. Change is afoot!


Transcript


Intro


Hi everyone. My name is Shawn, also known as Swyx on the Internet. And I'm here to present this idea, this decade long thesis that I have, that's called The Third Age of JavaScript.

So what's the story so far? You can break JavaScript's periods up into two or three different ages. The first age was from 1997 to 2007. There was a lot that was happening in 2008. There was a world crisis going on. So you could vaguely start picking things up again in 2009, going onto 2019. 2020 was another random mix of events, but there were still a lot of news going on. And now we're well into the 2020s. And I want to talk about that. I want to try to categorize things in a neat little bow. Obviously, history is never as neat as historians put it. But, we can actually talk about different themes and speculate on what themes are to come.


Ages of JavaScript


[01:13] So the rough table of contents that we're going to cover today, we're going to cover the first age, the second age, and then the two components of the third age I really would like to talk about, which is ES modules and the death of IE11, as well as polyglot tooling, and collapsing layers of tooling. And then the death of JavaScript. Potentially what comes after the third age of JavaScript because the story doesn't end there. But, maybe it transitions into a different story.


The First Age


So the first age of JavaScript, 1997 to 2007. For those who want to know more about the origins of the JavaScript, you should actually hear it straight from the horse's mouth from Brendan Eich. He gave this really great talk at Dot Conf on a brief history of JavaScript. And the real insight here is that JavaScript was based on a lie. Netscape actually attracted him to build JavaScript telling him that he could build scheme in the browser. And when he arrived, they told him, no, you actually have to build a Java like clone that really isn't Java at all.

[02:17] So it's a very interesting period in JavaScript's history, which is a very formative period, as well. So there was this very hot period of formalization. So I marked the start a JavaScript in 1987, technically went back a few years before that, but ECMAScript 1, 2, and 3 were pumped out in fairly short order. And then there was a long period of silence where, essentially, there was a civil war where we didn't really agree on the direction of ECMAScript 3.1 or ECMAScript 4.

And, essentially, the way that the community started dealing with it was to have two tracks. So one was, they started building compile to JS dialects of Java. So, there's some straight up forks like ActionScript Qt, JScript, or a WMLScript.

[03:05] These are not compatible with JavaScript at all. Or you could stay within the bounds of JavaScript and just modify the heck out of it. So you can have jQuery, dojo, and MooTools. Obviously, jQuery did end up winning in the end.

But I think 2008 was still a pivotal year, despite not being a gray zone in terms of the way that I view my time chronology. I really liked this idea of the Oslo Meeting, where, they actually, everyone who was prominent in JavaScript at the time got together in Norway and resolve this dispute between or the schism between ECMAScript 3.1 and ECMAScript 4. And had some kind of roadmap towards harmony, which is ECMAScript 5. So they said, all right, instead of this evolutionary approach of 3.1 or a revolutionary approach of 4, let's take the best of each world and just come to some kind of concession so that browsers can start making a step ahead again.

[04:05] If you want more details on this, you should check out the manuscripts of JavaScript: The First 20 Years. It's just kind of a book slash talk that was submitted for the proceedings of ECM on programming languages that was supposed to happen last year. And, it's 200 pages. So no one's read it. I've only skimmed it a little bit. But this is the story of JavaScript from the authoritative authors, Brendan, who made JavaScript and Alan Morris Bach, who was the principal editor for ES 5 and 6.


The Second Age


[04:37] Then we'll talk about the second age of JavaScript. So if the first age of JavaScript was about forming the language, the second age of JavaScript is about the community, the ecosystem. In 2009, all these things happened in the same year. We reach ECMAScript 5, the harmony specification, but then we also had this weirdly common JS syntax that was proposed that became the eventual dominant module syntax in Node.JS and in the browser. There was Node.JS itself was launched in 2009. And as well as npm was also launched in 2009. So all these things that we take for granted today was invented in the same year.

There are different sections to the community. So I'm going to break out a few of them. So the first was runtimes. You can track the gradual evolution of being able to run JS everywhere. You could run JS in a browser. Chrome OS was started in 2009, which is wild to think it's that young. Electron, you can run in a desktop, you can run it on phones, and then you can have specialized runtimes just for Android. And, that's a really interesting low-level engineering thing that's going on. Obviously, there's probably other runtimes that I don't even know about. So let me know in the comments, if there are, that you think I should touch on.

[05:49] The second part of the ecosystem I want to touch on is the emergence of build tools. So the way to help you compile and build and bundle your JavaScript. So Google Closure compiler and CoffeeScript both have emerged in 2009, as well. Very, very significant year for innovation. There was Grunt, Webpack and TypeScript round about the same time in 2012ish, 2011. Gulp and Traceur came out in 2014. And Rollup. And Babel replaced Traceur well as the newer versions of Bundler's Rollup, Parcel, and Bazel came out in the subsequent three years.


Forming the ecosystem: frameworks


[06:24] Frameworks also came out. So we had, before Angular and Backbone, we had a bunch of others. But, let's just call it the start of the second age of JavaScript with Angular and Backbone. Meteor came on and tried to be full stack with its own UI layer called Blaze. React and Vue came out 2013 and '14 and Svelte came out in 2017 but was essentially reinvented in 2019. That's the history. It's over 10 years of runtimes and build tools and frameworks.


The shift left in JS tooling


And there's one more trend, which I like to call out, which is this idea of a shift left in JavaScript tooling. I've done two separate talks on this. One on Svelte and The Great Space Elevator, talking about the evolution towards compile upfront, or compiler only frameworks, as well as growing a meta language, the importance of developer experience and developer tools for frameworks. So this was presented at React Rally 2020.


The Third Age


[07:23] So now we come to the third age where we basically do an rm -rf on legacy JavaScript. Some kind of leader actually did a nice mock image of this. I never played this game but I heard it's lots of fun. But, essentially the two assumptions here, that are going away, is that common JS, there's the build target for all of our tooling, which introduces a lot of bloat. So we're going to move to ESModules and it's going to be assisted the slow death of IE11. And I'll give you my updates on those trends. And then the second theme that we talk about is JavaScript tooling. That we start writing JavaScript tooling, not in JavaScript anymore. We now write it, most of it, in TypeScript, but also increasingly in Rust and Go, as well as the collapsing layers of the different jobs of the tool.


The Third Age: ES Modules


[08:14] So first I'll talk about the ESModules and the death of IE11. So for those who don't know, what is an ESModule, is really just to import and export syntax that you might be seeing in a lot of your code that you might not actually know is being compiled away Webpack. So Webpack is acting as a sort of interpreter into environments that don't actually have the import and export ESModule native language.

But, now both browsers and no JS have essentially this capability unflagged. There's still some nuances like using MJS, the Michael Jackson script, if you want to specify that you're working in modules. And there's some kinks to work out there. But and large, this ecosystem is moving over. If you want to read a really good primer on this, you should check out the MDN docs on ESModules. And I think the V8 team also has a really good document on ESModules, according to them, as well.

[09:18] So there's some nuance here and there's some more development to be done. But it's coming along and it's looking really good. So there are limitations that people should be aware of. For example, you can't really just build a ESModules and ship them in production in any of significant size. Even the VA team recommends that there's a bottleneck of a loading pipeline when you're loading 300 modules in. So, if you start building any significant kind of app, you probably don't want to do this. But it probably will be fine for a website. But you can still use a dev only, un-bundler, like Snowpack or Vite, or WMR. And I think that's also a really good solution. So that's something that you see refreshing a lot of the tooling in JavaScript, now, today. That you don't have to bundle for development so your development refresh cycles can be a lot faster. It can be constant time refresh instead of having to rebuild the entire projects every single time you save.

The one hurdle with this, of course, is IE11, the elephant in the room. There's support across the board for the ESModules native spec, but not for IE11. So part of the adoption of IE11 is very contingent on the death of IE11. So on the top left, this is a screenshot of analytics.gov.us. And the key number to watch is the percentage visits from Internet Explorer. The US digital service has actually identified the 2% mark as the critical benchmark level where they support browsers. It used to be 3.6% in November 2020 when I first started writing about this thesis. It is now fallen to 2%. So it's fallen steadily and we're probably at about the time. And I think that the US government could drop IE11 this year. And I think that's a very big deal because that's a catalyst to say that, okay, if the US government has dropped IE11, we can drop it now at work. Obviously, a lot of other people in the ecosystem have gone ahead and agreed with that decision. So the Vue ecosystem has agreed to drop IE11 support. Agular has agreed to drop IE11 support as well as a bunch of other peer companies like Skillshare, Twitter, GoDaddy, WordPress, Drupal, Daily Motion, LinkedIn, and of course, Microsoft itself. It's also really helps this setting an edge. So the new Microsoft Edge where they have IE11 compatibility mode. So even if your app needs to be running IE11, you don't have to visit IE11, you don't have to use IE11 most of the time.

[12:03] And I think that's a really big catalyst for adoption as this gets rolled out across some of the larger enterprises that require all these IE11 apps and don't have the budget to rewrite all those things just to upgrade browsers.

So adoption is slowly happening for ESModules, both in the browser. So here's a screenshot of some stats from browser adoption of ESModules. It tripled in 2020. And I think it's going to do very well in 2021, as well. As well as in Node.js because it's mostly driven Sindre Sorhus who authors half of the ecosystem in Node.js, where he's just going to just transition all of his libraries over to ESModules. So if you want to use his stuff, you have to use ESModules inside of node. And I think it's happening in a coordinated fashion because everyone senses that the time is now. It's been a long, long time coming, ever since the first idea of standardization was floated in whenever this picture was taken with Addy Osmani. But, it's coming. It's really coming.


Third Age: New tooling


[13:09] Okay. The next part of the third age of JavaScript is the change in tooling. So Brandon Dail, used to be from Facebook, called it, in 2018, saying that in less than five years, most popular JavaScript tooling will not be written in JavaScript. And I think this is mostly come to pass, but in different degrees. So the two assumptions that were being cleared right now is that JavaScript tools should be written for JS developers JS developers so that they can contribute. The reality is that they do not. So we should optimize for hot paths and speed rather than ease of contribution people who don't actually end up contributing. And the other assumption is that of the Unix philosophy. Each tool should do one thing well.

So let's talk about those in turn. So the first is that whether we should only write JavaScript. The easy answer is most people have just opted into writing TypeScript. So here's an example of how much of the React ecosystem has switched over to TypeScript. I've been monitoring it. So React router, Next.js, Yarn, Storybook, Apollo, Gats as well, have all switched over to TypeScript. And yeah, these are the results from the state of JavaScript surveys. And, the adoption of TypeScript has been extremely strong. You can basically say that TypeScript has won at this point. But TypeScript is, design, very JavaScript like.

[14:32] So what about the other languages that we want to optimize even further? Here's ESBuild benchmark. ESBuild is a Webpack competitor. And it's about a hundred times faster than the next fastest alternative, according to their own benchmarks. So take it with a grain of salt. But, it is somewhat faster, for sure. And, that basically comes from having a compiled language at its core.

And that's a very interesting observation because you also see that in Rust. You see that being adopted in Deno, in Relay, and in Volta. And these all have significant Rust percentages in their code base. And I think what's happening is this idea that we should explore polyglot tooling. So we used to have this concept of pure tooling, where you will write the external API in JavaScript, and you write the core JavaScript, as well. But it doesn't make sense to write the core in JavaScript because it's a hot path that gets executed again and again. And no matter how much optimization you can do, you can probably do better compiling it to binaries or you can also do stronger type checking. So, it's more stable core. So whatever it is, you can switch over your core tool to a systems language and benefit from optimization there. But you still leave your external API in a scripting language like JavaScript. So this idea, I call systems core scripting shell, I think this is the pattern that we're going to move towards for a lot of our core tooling. That we're going to have Goal, Rust or maybe TypeScript if we have to, and then a JavaScript exterior.

[16:04] If this sounds like heresy to you, I think it's because we're changing our concept of what exactly a tool, one tool, for one job means. So, this is a really good blog post that I found from Benedict Evans on platforms and bundling, where when word processors came out, they actually had different functionality and different plugins for word counts, footnotes, and charts. These are all separate products from separate companies that you have to go out and buy for 50 to $100 each. Can you imagine buying a word processor today and not having word counts and not having footnotes? No. So today it just comes all bundled. How many plugins and how many different little tooling do you want in a word counter? I think the definition of what the one job is changes over time. And that's what we're seeing happening in JavaScript today.

So when you look at all these tools that we're so used to putting together, why are they all different tools? And why do they have different plugins for each of them? Why do I have eslint, Babel, Prettier, TypeScript plug in, instead of just having one set of ecosystem tooling that just works well together and has single EST passes and all that optimization that can happen if you have a holistic view of what the job of JavaScript bundling is. So that's a little bit of what happens.

[17:25] So our first reaction for this was actually very simple. This is something I covered in a previous talk called Creating Create React App, which is that we just swept everything under a rug. We will say, sitting on Webpack is too hard to make a React App. So let's just sweep everything under a single dependency. And then you would just install Create React App. And, that's a magical improvement in developer experience, but we just swept the complexity under the rug. The moment we need to deviate from it, you had to eject and now you're left with all that complexity again on that configuration.

I think that's continuing to happen. This is my other thesis called React Distros, swyx.io/react-distros, if you read that blog post. But we're continuing to do that. We're sweeping that complexity under more rugs. So Create React App does that, NextGen and Gats does that for routing. And then Blitz.js And RedwoodJS does that including other custom components and state and data frameworks. But, we're starting to build on top of React as a stable boundary, rather than trying to reinvent frameworks all the time.

[18:29] As we're collapsing tooling, I think this pitch is actually really cool. This is another blog post that I have, but essentially if you look at Rome's investor slide deck, you can see the exact same chart of why all these different tools. Let's just combine them into one tool. And you can see this in Deno as well, which tries to collapse that into the no JS layer, which I think is a super interesting approach.

These two, I think it's no coincidence, that these two are now venture capital funded. And I think that's another interesting innovation as well. In the first and second age of JavaScript, it was very independent, open source, volunteer movement. But, now in the third age of JavaScript, I think there is some sense that we need a sustainable business model for great open source to be built. And I think the money is there to back it up. So if you want to start at third age of JS developer tool project, talk to me, I can put you in touch with everyone and I would be interested in funding you myself.


The death of JS?


[19:26] Finally, we'll talk a little bit about the death of JavaScript because what happens after the third age of JavaScript? And I think the best source on this is actually a joke talk Gary Bernhardt on the birth and death of JavaScript, which is an excellent, excellent exploration of what happens after JavaScript, essentially. I think that's something that Brendan Nike started to talk about as well. I had this conversation with him about what the universal virtual machine could be. And he says, it's probably WebAssembly. He has started, instead of saying always better JavaScript, he started saying, always better JavaScript and WebAssembly.

And you're starting to see that it's some of the tools that we push out. But WebAssembly is also not a magic pixie dust. I don't think it will completely do away with JavaScript forever. But it is very appropriate for some use cases. And I think it's worth exploring for large apps like Figma.

[20:24] So that's the overall thesis. This is a very short talk, but hopefully it's given you some perspective on where we've been, what we're going through right now, and hopefully where we'll end up. So I love your comments and questions. So I will be in the chat for this conference. And if you want to learn more about how to spot trends and also bet on technologies for your career, you can check out my book at learningpublic.org. Thanks very much for having me and enjoy the rest of the conference.


Questions


[20:51] Liz Parody: The first one is to speak in standups, meetups, and conference with 36%. One, you can practice those just applying to a conference like this. JS Nation, Git Nation, React Conference. You can apply to conference. That's a good way to improve that skill. Self care and prioritization. Very important, too. Writing, blogging, documentation, design, and docs. That's one of the skills I want to improve. And negotiation is the last one with 12%. It seems that there's a lot of good negotiators watching this conference. So, that's really good. The number one is speaking. Now, let's see some of the questions. One is Brian Hough: How do you master technical blog writing? I find it's hard to balance the high level versus the technical. What do you define as a technical blog post? Shawn?

[21:50] Shawn Swyx Wang: That's an interesting question. I don't think you ever master it. Just do it a lot and try to be better than you were yesterday. And after a few years of doing it, you'll be really good. Why are you trying to be perfect or master it? Just do it better than you were before.

[22:12] Liz Parody: Yeah, that's, that's a great answer. Practicing, everything you get better and improving. Another question from Stark Anderson is: Keeping your code smaller in terms of file size can keep decrease the loading times. How do you balance between keeping your code short and keeping it actually readable?

[22:31] Shawn Swyx Wang: I see. I love this question. So I think the React core team's answer of composability really resonates with me here. You should be able to break down your code into logical code blocks. And if it's too long, then you have too much going on in your head. So you should be able to abstract things into reusable functions. Actually, you don't even need to reuse them. You can just take chunks of code out and separate them so that you can abstract them into a single function that you don't have to break that obstruction nicely until you need to look into the implementation detail. Composability of code is my answer of keeping code short and readable.

[23:14] Liz Parody: That's a good answer. Composability. Now, you know. What's actually the conclusion of the death of JavaScript composer?

[23:34] Shawn Swyx Wang: There is none. It's just an observation. I view myself as a JavaScript journalist. And the goal of a journalist is to write the first draft of history in the sense that, when we look at our web dev careers, 20, 30 years down the road, when we're retired and we're sick of programming anymore, what are we going to say about the 2020s? This 10 year period from 2020 to 2030. We can already see some hints of what's going on. And I think my role here is just as call out. I think there some trends that are very interesting. And these are things that I would invest in personally. So I would just share them. And if you agree, then that's great. If you disagree, let me know and we can have a conversation about it. I'm not trying to push some conclusion onto you.

[24:17] Liz Parody: Okay. Thank you. Leah Cheek, ask: Thank you. Very interesting. When do you get feedback in early stage of plugin?

[24:27] Shawn Swyx Wang: Where do you get... Oh, okay. Twitter is a big source of my feedback. I prototype a lot of blog ideas on Twitter. And, if I see some traction, then I flesh a tweet into a full blog post. But, sometimes a lot of people have questions on where to start if you don't have any followers. And this is called the cold start problem. I would say you can join blogging accountability groups. Together with my book, I have a community that, where we support each other with our learning in public and our writing efforts. You can join a community, whether it's a paid community or a free community just among your friends to share a feedback.

The other thing I encourage people is to, I have this essay called pickup what they put down, which means if you want other people to care about what you write, then make sure you're writing about something that they care about. And one way to guarantee that they care about stuff is just look at something that they've just released. Let's say the React core team, yesterday, just released their roadmap for React Suspense. If you want to write something, they'll probably read it and they'll probably give you feedback on it. So, that's a way just to respond quickly to something that someone else wrote. And you have a much higher chance of feedback than if you just publish some random document that nobody really was looking for, asking for.

[25:50] Liz Parody: Thank you. That was a really great answer. Daniel Burch ask: How can you improve... Sorry. How can you improve explaining complicated technical ideas during daily meetings of code reviews?

[26:05] Shawn Swyx Wang: Oh wow. That's interesting. I don't really know if I have figured that out. I think the venue of a daily meeting, or a daily standup, is not the right place to explain complicated ideas. I really like the Amazon way of having a one pager or a six pager to write down the full narrative of a concept. And before what we, I worked at Amazon, we would call this a business review meeting. We would actually sit down and have 10 minutes of just reading that writeup. Basically, try to write it down instead of just coming up with it off the cuff because when you write things down, you really get to organize your thoughts.

[26:48] Liz Parody: Thank you. Buto asks: How do you balance DX and UX? Tools, providing great DX, but default, they lack of optimization in production that Gats and Next can provide. But Next and Gats are default slower than Vite and so the whole DX is diluted due to the lack of speed. How would you balance it?

[27:13] Shawn Swyx Wang: This is a more complex question than that post. Actually Gats and Next are going to move on top of the next generation build tools, like third age of JavaScript. Tools like Vite. So they'll eventually get there. We are just in a phase of transitioning tools because of this new age of JavaScript. The way I think about it is that we create better DX to create better UX. And these tools are always changing and they're always different teams trying to improve it.

[27:29] Liz Parody: Thank you. And the last question will be from Pedro Flores, who asks: Do you feel once we'll get enough traction to eventually replace JavaScript?

[28:00] Shawn Swyx Wang: Yeah. The final piece of the talk was about this question. I think the answer is, basically, no. JavaScript will always have a place. But WebAssembly will replace some of the jobs that we are using JavaScript to do. And primarily, first, it's going to be used to port over code written in other languages. But, eventually we're also going to find ways to optimize the hot paths of code that we're running in JavaScript. But ultimately, the layer around what we can do for users and to interact with the DOM is still probably going to be owned JavaScript. So eventually you'll probably have to learn a JS language. And then compile to JS language to do your work. And yeah, I think that's the natural state of things. I don't think WebAssembly will kill JavaScript.

[28:50] Liz Parody: Thank you, Shawn, for this great talk and for all these great answers. Now you have to pick your favorite questions to give the book. Thank you very much.

[29:02] Shawn Swyx Wang: I want to give a shout out to Brian Hough, I think, the first question for breaking the ice and asking a really good question. I want to answer it in more detail actually, but we don't have time.

[29:14] Liz Parody: Okay, Brian, you have a book. Yay. Thank you very much.

[29:18] Shawn Swyx Wang: We'll get in touch and I'll send you the book. Thank you so much for asking all the great questions.

Liz Parody: Thank you, Shawn.

Shawn Swyx Wang
30 min

Check out more articles and videos

Workshops on related topic