Skip to content
Babel with Henry Zhu episode artwork

Jun 21, 2018 1 hr

Babel with Henry Zhu

from Open Source Archives - Software Engineering Daily Hosted by SE Daily

Different browsers consume JavaScript in different ways. When a new version of JavaScript comes out, developers are eager to use the new functionality of that language version. But if you are writing frontend JavaScript code, that code needs to be interpretable by every browser that might consume it–whether the consumer is on an iPhone running The post Babel with Henry Zhu appeared first on Software Engineering Daily.

Episode details come from the podcast's RSS feed.

Embed this episode

Ready to play

Babel with Henry Zhu

0:00 1:00:27
of matches

Transcript Auto-generated, may contain errors

When you write a front-end application in JavaScript, you assume it will run on the user's browser. But different browsers are compatible with different versions of JavaScript. If you write an application in the most recent version of JavaScript, you might take advantage of new language features. A user who's running an old browser can only interpret the older features of JavaScript.

To solve this problem, JavaScript developers use a tool called Babel. Babel transpiles one version of JavaScript into another version of JavaScript, so that the code can run on a target browser that would otherwise be incompatible. Henry Zhu is a core maintainer of Babel, and he joins the show to describe how Babel works. Henry works on Babel full-time, and he's supported through Patreon and Open Collective.

This is a newer model for employment, and Henry describes in this episode how he ended up working on open source full-time, as well as the costs and the benefits of living that open source lifestyle. Before I start the show, we're looking for a videographer. We're also looking for writers and a couple other jobs. If you're interested in working with us, go to softwareengineeringdaily.com slash jobs.

And if you're interested in a lower commitment way of interacting with the Software Engineering Daily community, we have the open source ecosystem, which is available at github.com slash softwareengineeringdaily. We have open source apps for Android, iOS, as well as the web. The iOS app just got a major improvement with some added features of downloads and saving episodes offline, as well as a news feed within the app. So do check out that Software Engineering Daily app for iOS.

If you like the podcast, you might like the app. And we'd love to have you as part of the Software Engineering Daily open source community. So we hope you get involved. Henry Zhu is a core maintainer of Babel.

Maybe I should say the core maintainer. Henry, welcome to Software Engineering Daily. Thank you for having me. Babel is sometimes difficult to explain, but I think the place to start is the fact that different browsers are compatible with different versions of JavaScript.

Why is that, and why is it important? Yeah, I think the browser landscape is pretty unique. There are multiple implementations of the JavaScript, or what do we say, ECMAScript specification, unlike, say, more of a server-side name, or even though we have Python or C, everyone uses that thing, even though there might be multiple compilers. But with the browsers, each vendor, they try to implement the spec to the best they can, but they have different team sizes, different release schedules.

So you can't really know what they're supporting unless you look at their sites. And more importantly, you don't know what browser your users are using. So if you support all the major browsers, or even IE 11 or less, then you can't assume what they're allowed to do. And so Babel is this tool that lets you support the widest range of browsers, but also lets you write the latest syntax.

When you think about different versions of Java, for example, I think many of the advances that come with a newer version of Java, at least we talked about from Java 7 to Java 8, I think, were in the flavor of syntactic sugar, and Java 8 was comfortably backwards compatible with Java 7 and the versions that came before it. I don't think in the Java world you need something like Babel, where you have these transpiled different versions of Java that can port to different places. Why is it important to have a transpiled? Because that's what Babel is.

It allows different JavaScript versions to be compatible with another. And you can transpile a newer version of JavaScript into an older version of JavaScript. Why is that important? I think there are a few reasons.

So with Java, it's kind of like on your end to upgrade. So if your company is on Java 7, they want to go to 8 or 9, you just need to update all of your code to do that. But with JavaScript, you have no idea what browsers your users are doing. So you can update your own code to the latest version, but it doesn't mean that it will run on your user's browser.

So in order to do that, you have to kind of either wait until somehow you know that, but you can't really guarantee. So a tool like Babel lets you kind of standardize and not have to think about what browsers you're targeting. But also importantly, the reason why we have transpilers is there's twofold. One is this backwards compatibility story, but the other is that transpilers can actually help influence the language itself.

And I think that's the second more important role of Babel is that, unlike other languages where there's a committee of people, which there are for JavaScript as well, but instead of waiting for the implementers to do all this work in C++ land in browsers and then kind of show developers, and then at that point it's almost too late for like real feedback. With Babel, we can implement a plugin because Babel is written in JavaScript and users can test out ideas, give feedback, like this is not even a good approach at all or this is not intuitive. And that way we can kind of more like get the community's feedback at a faster pace or even just make sure we're on the right track. Yeah, and we'll talk about that role of Babel as a way for developers and standards bodies to interact with each other, but just to talk a little bit more about the developer side of things.

So Babel is a project that transforms newer JavaScript syntax into backwards compatible code. If I'm a JavaScript developer, how does Babel fit into my workflow? Yeah, so for most, at this point, you know, a lot of it is the fact that most people are already using Babel and a lot of times people don't know what the project is because it's so, it's kind of like infrastructure level now. It's like all the tools that you use are already using it, so you might not even know that you're using it because it's already like built into some framework or tooling that you're using.

So if you use like React, you might use something called Create React App or if you're using Vue, there's Vue, CLI, or Ember, CLI. All these tools kind of already have Babel built in. So one of the issues we kind of have as a project is that it's almost too ubiquitous, too successful in a way, quote successful, and so people don't realize it exists and it also means that they might assume that it's a company or a lot of people are working on it when it's just a few volunteers and crowdfunded. Yeah, so if I'm writing a React application, I get to use the nice world of React components and building in the React developer ergonomics that people love.

What developers don't often know is that part of the reason that that's such a nice experience is that under the hood, one of the things that the React compilation to JavaScript, because React itself is not JavaScript, it's writing stuff in JSX and then it gets translated into HTML and JavaScript, but one thing that's happening is that it's taking care of that cross-browser compatibility for you out of the box and it's doing that through Babel. Right, exactly, so JSX is not part of JavaScript and yeah, Babel will convert that into a function call. And you can not do it, but the point is that instead of doing it manually or not writing it at all, it lets you have this nice way of writing React, yeah. It's not completely necessary, it's just people are used to that and it's a nice way of doing it and it does it for you automatically.

You're also already going to compile JSX, so it's kind of like you get the JSX part for free. Babel generates the right version for the right browser at the right time, depending on what browser is consuming a given application and what version of the browser is running on the user's device. How does Babel do that? Does it translate the code into a bunch of different versions and then deploys all those versions or it somehow senses what the user agent is and gives the user the right version?

How does Babel generate the right version of JavaScript for the right browser at the right time? Yeah, so that thing is, it doesn't actually do that out of the box. It's more low level. You can specify what browsers you want to target and it will compile to that.

So you just kind of think of a spreadsheet of every possible browser version and also every different kind of syntax of if it's arrow function, is it supported by browser XYZ or version XYZ or classes or different syntax and then it will do the least common denominator of what you support. If you want to do what you were describing earlier, you kind of need a lot more tooling on top of all that. I'm not sure if a lot of people are attempting this but it's definitely been suggested and talked about a lot about should we read the user agent and do some kind of weird try-catch and eval where you try to see if the browser supports that syntax or do you do something completely different where you just, okay, I'm just going to assume that the baseline is IE and then you ship as much code as possible. But people are realizing, yeah, we shouldn't have to do that if we're able to detect certain things.

The problem with the whole user agent thing is, well, it's hard to know if that is actually accurate and even if you are, creating a different bundle for every single version can be kind of difficult in the sense, you know, now your builds might be longer because you support like 10 browsers weird codes and compile differently. So that just gets a little bit more complex. Maybe some people have a better way of doing that but that's my thoughts on that. Babel transpiles JavaScript from one version to another.

That term transpiler, how does that differ from the term compiler? Yeah, I think there's a lot of backshedding on that and a lot of people get into arguments over whether we should use... Sorry, bikeshedding? Yeah, just like whether, you know, should Babel be called compiler or not.

We actually changed all the documentation I think a while ago so that it just says Babel is a JavaScript compiler because it gets confusing. Because it's kind of a newer word anyway. It's like people say like source to source compiler or like it's in the same language so that's why we call it transpiler. Right now I just say it's a compiler.

It just happens to compile to JavaScript instead of like lower level language. But yeah, I don't think it's not necessarily that big a deal whether we say transpiler or not. But yeah, it still, you know, it changes a form of code into another form. Right, okay.

So this transformation or compilation or transpilation or whatever we want to call it, transforming, converting one piece of code into another piece of code, this takes three stages. There's the parsing stage, the transforming stage and the generation stage. Describe these three steps. Yeah, and so I think you put it well that there's in a high level there's only three steps.

A lot of people have a hard time grasping what a compiler is or what it does. I never took a compiler class or studied it formally or anything. I just kind of learned everything. You should be thankful.

Maybe that helps, right? At least my programming languages class, oh my, I can't believe I had to pay money for that. It was the most, I'm sorry, I hope the professor that taught me that out there is not listening but it was just abhorrent and so boring and so unapplied. Like I think compilers is why I'm kind of glad to have you on the show is because compilers I think has a reputation as being super academic, super dry, super uninteresting when in fact it's a very vibrant and highly applied area of computer science.

Yeah, I totally agree. I almost purposely didn't choose to do computer science as my major in college because of that and knowing that's going to be so boring even though I had a lot of interest in computer science and programming but I just wanted to like do like visualizations or just games, stuff like things that seem fun. What'd you study? I studied, I followed industrial and systems engineering so it was more like more math, statistics, queuing, transportation.

Right. Very different but also related to program in a way. Oh yeah, I know a lot of super creative engineering leaders actually that did industrial engineering it's one of those majors that you don't really hear about as much but you find all the time it's just sort of like you find people in power who were philosophy majors it's just like okay and it kind of surprises you sometimes but it sounds like a pretty interesting major there's a lot of cross-disciplinary coursework and that kind of thing. Yeah, you were able to take there were a few programming courses specifically you could take like whether it was databases or machine learning but yeah, I didn't have to it was fun because I was able to just choose electives that I liked just for fun outside of that but yeah, I hated the idea of wanting to learn about compilers and now ironically I work on one and I like it.

Okay, so parsing, transforming and generation the three stages of the compiler of Babel. Yeah, so the way I like to think about it is when you want to transform your code to do something you could do a simple find replace right like say I want to turn all of the variable names like A into B you know you could go through your editor of choice and then do like control F and then like find all the A's and change the B's but the problem is that you know you don't know if the A that you're looking for is a variable or is it in a string or is it in a comment and the point is that you want to semantically know if the A that you're using right now is a variable or a comment or a string or something else and so what we do is we use intermediate representation of the code so instead of a string we use what we call an abstract syntax tree in AST and an abstract syntax tree is just a separate form that lets you know what part of the code you're in and the way I think about it is kind of like in English or languages we have like that whole sentence grammar like tree structure where it's like oh this is a verb and this is a noun like parts of speech and all that stuff and in the same way we have that with code it's just defined more formally and so in the three stages you're just trying to convert the string into an AST and then so the parser is the piece of the tool that converts your first your file that reads the string and turns it into an AST and then the second step is the transformation phase it's just it's the part where you have that AST and you change the AST around and then the last step is the generator which you can just think of as a printer it takes the AST and then it spits it back into a string so like before with the file replace thing you're just taking a string and then making a string again but we have this intermediate step where we change the form of it into an AST change that and then print it out again and also an AST it sounds really like crazy abstract syntax tree but the way I think about it it's just kind of like JSON a lot of us use JSON to send data around we know that there are nodes and there's properties on these nodes and all we're doing is just moving the data in there because it's easier to manipulate that term abstract syntax tree I think we can break that down into what it is abstract it's a higher level easier to interpret from both the human point of view and the computer's point of view representation of computer code as it's going to be evaluated that's abstract the syntax is you're referring to something that's related to language it's a lingual structure and it's a tree that's a data structure you could represent this as a non-tree structure you could probably represent it as a hash map or a graph if you wanted to but this happens to be in a tree format so when you think about those terms abstract syntax tree it's actually not the most complicated thing in the world it's just a data structure that represents programming language code yeah I think that's a great summary for sure okay so the abstract syntax tree gets built when it gets built is there a place where the human needs to look at that abstract syntax tree and do something with it to manipulate it as a programmer if I'm a programmer that's building something let's say I'm a React programmer and I'm interfacing with the point in the React compilation code that uses Babel do I need to know how to manipulate that abstract syntax tree? well if you're just writing a web app then I guess in some sense you shouldn't need to know how any of it works sorry what I meant is let's say I'm a React core developer that is building code for that cross-browser compatibility actually even if you're a library author you wouldn't need to know it but if you're trying to make your own Babel plugin or change how it works then yes you definitely need to understand that part so React like JSX itself has its own spec and whatnot so it has different nodes and different names for all these parts so like if you have like a JSX element like a button right the capital B button and you have your less than sign then button then greater than sign and then that itself has a name right there's like JSX element and inside there's like JSX opening tag JSX closing tag and then there's like JSX attributes so there's different names for these things and when you're talking about what these things are it's a good way to at least use those terms but if you're trying to make the code that actually transforms that into JS then yeah you'll need to understand those terms what's a Babel plugin? yeah so a Babel plugin I would just say is one of the individual steps in the second part that we were talking about where we have the parser and then we have the transforms in the middle and then we have the generator so the plugins are just individual transforms so a plugin is just the fact that Babel is it doesn't really do anything by default and every plugin or every transformation of syntax can be its own plugin that you can even write yourself.

Even the core plugins are not any different from a plugin that you would write yourself. It's just the ones that we give to you that you can add. But you can import them. You can make your own plugins.

You can change whatever you need. But it's just JavaScript file that finds, yeah, it'll just convert syntax. And the way it actually works, too, we use this thing called a visitor pattern, which is a common thing that compilers do. Basically, when you're writing your plugin, I think of it like jQuery, actually.

jQuery, when you're using it, you have the dollar sign and put stuff inside of that function call. What you do is you select elements on the page in the DOM. And the same way we do that with Babel, but with the nodes in the AST. So when you're using jQuery, you might be like, oh, I want all the A tags or all the H ones.

And then I'm going to do something to that, right? But in Babel, it's like, oh, I want to find all the functions or all the classes or all the arrow functions specifically. And then I want to do something. So in the same way you're trying to find something, you visit, you quote, visit a node.

And then you either change it, or you just analyze it, or you can throw an error, stuff like that. You need to do this kind of changing to the AST in the event that maybe an old browser is going to react to, or actually, say, respond to disambiguate. In case an old browser is going to respond to some portion of my code in an unfriendly way, IE, it would just throw an error and be like, I don't know what the syntax is. So we would find all the arrow functions and then turn them into regular functions.

But also, I would say that you can use Babel for things that are not really about supporting old browsers. There are a lot of community plugins that people write, that you can do anything you want, right? You can change it and transform the code. So actually, let's go through a couple examples.

So in case somebody was a little bit confused by the Babel plugin example, give maybe two examples. So I want a more conventional example of the Babel usage where I'm a developer, I want to write a plugin that manipulates the abstract syntax tree in a specific way, and then maybe give an example of somebody who's doing something off the beaten path. I don't know if it's static analysis or something else that's not just transforming it for cross-browser compatibility. Yeah, so for a cross-browser thing, we can use the example of a class.

So in Java, there's classes, and in JavaScript, now there's also classes, and the syntax is just class, space, like A, and then open, curly, close, curly. And that won't work in all the browsers. It'll just throw an error, like, what's class? But if you Babel, then it'll actually convert it into the equivalent, and the equivalent is a function call.

And so we find all the classes in the AST, and we just convert that into functions. So that's the straightforward thing that Babel does. If you're trying to, you can do a lot of things with your own plugin. So one example could be, when you use React, it converts JSX into what we call a React.create element.

And if you use that JSX, you actually have to, because it converts, using JSX actually means you're using React. And so that means you have to require that at the top of your file. And so there's a plugin where it's like, every time I use JSX, it automatically adds import React from React at the top of your file for you. And that's just, it doesn't mean that everyone has to do that.

It's just something you could, just because they thought of it. The way I think about it is, do you want to do something at build time that you might have wanted to done at runtime, or something that's more of a, yeah, a developer-friendly thing? Like maybe I want, a lot of people write their own like battle plugin console things, where it's like, maybe they put a comment above a function and automatically add a console.log that this function got called, or a better debugging experience, or like only in development environment, maybe output more comments or make the code, you know, say something differently. Those can be really helpful.

There are plugins that help you do like code coverage. There's a Lodash plugin that I don't know if you need to use anymore, but it used to allow you to, or it still allows you to import from the Lodash namespace, like package, but then when you use it, it only, it transforms it, so it only uses a specific function that you use. So if you only use like pick, then it will transform the regular import, like Lodash import pick from Lodash to like import pick from Lodash slash function slash pick, or whatever the namespace is. You can also do stuff like in production, maybe you don't need all this extra code, so like strip that away, or maybe optimize certain things in production.

Yeah, I think there's a lot of different things. And you can just have fun too, like someone, Sebastian is a creator about, he made a plugin a while ago, called like Babel plugin Emojify or something, and it turned all the variable names into emojis, just because you can. So you can do a lot of stuff. I want to give people a chance to catch up for, again, if they missed some of the ideas of what Babel was that you explained.

So let's take again the example of, I've got a React application that I've written, and at some point that React application is going to turn into raw JavaScript and HTML. It's written in JSX, it's going to get translated into JavaScript and HTML. I believe, it's been a while since I wrote a React application, or also since I did a show about it, I think React related, I think. But I think there's this notion of you can have server-side rendering as well as client-side rendering, so you can just ship the React code to the client browser and have React be imported to the client's browser, and then the client's browser is responsible for translating the React from JSX into HTML and JavaScript and CSS, and then it gets rendered on the page, but that can be an expensive process.

Therefore, you can also do this server-side rendering where the React application gets rendered on the server, and then you ship just the raw JavaScript and HTML and CSS directly to the client, so the client doesn't have to take care of that transformation process. If you take those two approaches, where in those approaches does the Babel process take place? All right, that's a really good question. So I would say that, I mean, the recommended thing is that you always run Babel as a build-time step.

So before you do any of those things, you write all your code, you run it through Babel, and then you send that to the client. The only reason I can think of at the moment for wanting to transpile on the client-side is for a use case like our REPL. So on the Babel REPL, it lets you test out syntax. There's two panes, there's left and right, and you can type whatever you want on left, and it automatically compiles it on the right for you.

But if it's for your production app, there's no reason for you to have to do it on the client, unless you do the whole, we try to figure out what browser it is, and then we do it on the fly. But then you have to load all of Babel in the browser unless you do it in a web worker or something. So even if you're doing server-side rendering, you would run Babel, and then you would send it to the client. There's a few terms that I want to explore to help describe what Babel does.

Can you define the term polyfill? Yeah. Yeah, this is actually a pretty big source of confusion. So polyfill is, you could just say it's a piece of code that, yeah, I'd say fill or emulates or implements a certain kind of functionality that will be in the browser or already is in the language.

So what I would say is that it's different from syntax. And so a polyfill would be like, you can use a capital P, promise, or a symbol, or all these different, we call them built-ins. You can think of it as a standard library, basically, of JavaScript. And if you don't know if a browser supports it, then you could use a polyfill instead.

So a lot of people, they'll do this, they could check if it's supported in the browser, and if it's not, then they require their own thing. And this is different from what Babel does, because Babel converts syntax. It doesn't convert promise into a different piece of code. It could, but that would be really awkward, because that means every single time you use promise, it would implement the whole function every time.

When instead, you could just import the polyfill once, and then it would be there every time you use it. I don't know if that helps. Well, it's an example of that, if I have an arrow function in my code, and I want to make the arrow function compatible with older browsers, I might write a polyfill to satisfy the functionality of the arrow function in different ways on different browsers? That would be an example of the syntax.

I see. There's no way for you to polyfill, per se, for the browser, because it would just error at the parse level. Because the browser itself is trying to read through your code, and it's like, oh, I saw this parentheses and this other parentheses. I don't know what that is.

And so it would just completely error out. If you use it, it will convert it to a function and it knows what that is. So when I set the example of a promise, when you use promise, you have to do new promise or something like that. And so if I typed in promise, it's not going to error in the browser, because it's just a variable name.

It will just think it's undefined. Because if you type promise in the browser in the console, it will just be like, oh, I don't know what that is. And then what you can do is say, promise equals function, blah, blah, blah, implementation. Okay, right.

Because if it was a promise, it would error silently. And so you want to, I guess, is that the main difference? Yeah, so with the syntax error, it will tell you immediately, like this doesn't, I have no idea what this is. But if it's a, what I'm saying is a built-in or standard library function, you're free to implement it yourself, even though you probably don't want to do that, because you're probably gonna have bugs.

Another term, source map. What is a source map? Yeah, so I think it kind of explains it in some way. The thing is that if you use Babel, it doesn't have to be Babel, you can use a minifier, like Babel, or even simply bundling or concatenating your code together.

When you open it and try to view the source, or go to the element or the source inspector in your browser, DevTools, it won't be the same thing as what you're writing. The source files are different from what you're actually shipping to the browser. And so sometimes, and most of the time, it's really hard to understand what's going on. Even if you, you know, maybe you have like 10 files and then use like something like Webpack and then you bundle them to one file, when you're trying to look through like debugging or just looking through the code, it's all going to be one file and then you're going to have to look through and figure out like, oh, this file was like, a.js was this part of the giant file.

And the same thing with syntax. You know, you're writing your error functions but now they're regular functions and you don't know exactly where that is. Maybe the variables got renamed. Maybe if you minify it, you have no idea because you wrote this really awesome name that's kind of long, right?

And now they're all like A, B, C, D. And so source maps were created so that, yeah, it's literally a mapping between like every, and there's different forms of it but like this character or this line and column corresponds to this other line and column. And in the browser, it shows you, it recreates the original file for you so you can read it. Babel allows people to try out new browser features more aggressively because they can, as a developer, they can try out that feature and then in their production code and then write a Babel translation that makes it backwards compatible.

How does this affect web development? So I would say that it allows people, there's two things. One is if you're using things that are not in the language and things that are already in the language. I'm going to talk about things that are already in the language, like finalize in the spec.

So it lets people not have to wait until all the users that they support are able to, you can use that in syntax natively. In some sense, you don't ever really know if all your users support it unless you start dropping browsers or just airing like that. And so in some sense, you could say that maybe you always want to use a transpiler like Babel because you can't really know unless you're doing like an internal thing or you know you only support the latest version of a browser. But yeah, it just lets you not have to think about it.

There shouldn't be something you have to think about in the first place. So you alluded earlier to the fact that Babel is actually able to be a medium of conversation between the ECMAScript standards body. This is TC39. These are the people who make standards that JavaScript adheres to.

So ECMAScript is a standard that JavaScript adheres to. There are other implementations of ECMAScript. JavaScript is by far the most popular. So you could just think of ECMAScript as the JavaScript standards body.

I believe, correct me if I'm wrong. How do ECMAScript standards get defined and why is Babel an important place for discussions between developers and the standards body to take place? Yeah, so TC39 is the committee, technical committee 39. I don't know about the other committees.

I don't even know if there are 38 other ones. Yeah, so they meet every two months. And they is, so there are companies that can join the committee and they can send representatives for those companies. So examples of those companies could be all the browser vendors.

So whether it's Google, so Mozilla, Apple, Microsoft, and also other implementers. And then there's also the, so representatives from them, they could also be developers that work with those companies or the implementers of those JavaScript engines themselves. So like people working on like V8, SpiderMonkey, Chakra, so the people writing the C++ code. And then also there are, they're more like programming language experts where they're the ones that they have a lot of history in the background of programming in general.

They have a lot of experience in making languages. And then there's also just developers that are more involved in the tooling and the specs side of things. So I think you can also talk about the history of how this, the committee has evolved over time. Maybe initially it was just Brandon and then a few people and most of the people were like super involved in languages and then some implementers.

And then we had more and more implementers of browsers. And then eventually we had more and more developers that can advocate for the developers that are using language. Because the people inputting or the programming language experts, they might not be the ones using JavaScript in the day-to-day. And so I think it's, that's why it's been in the community's interest to get more and more people involved, so that we have a better sense of what the community needs, what they want, what are the problems in the language, not just from an academic one of you, but from what this is what we need because we're dealing with this issue.

Maybe people are implementing libraries or polyphills for themselves and we can implement that in the language or they're writing code in such a weird way that maybe we should have a syntax on top of that. Or we want to just change part of the language to do things that were never possible in the first place. There's so many different ways that people can shape the language. And I don't know if we can say that any one person or group is like, oh, I want the JavaScript to be an object-oriented language or I want it to be functional or I want it to do XYZ.

There's a lot of players and we want to take that into account. That's why maybe it seems a little crazy at times because it's the biggest language and all of the web and IoT and all these things, it's hard to really grasp what that looks like. Is there a dispute between the different browser manufacturers over the things in JavaScript that relate to the businesses of the different browser manufacturers? So for example, I can think of Safari and Chrome having different ideas for what level of advertisement should be in a browser.

And I can imagine that potentially percolating down into decisions in JavaScript. Does that happen? So I haven't been on the committee for that long. I'm actually still a guess and that's its own conversation.

But I guess that could be part of it. I don't really know if that comes up that often. But you could say that in the end, every representative does represent their company and they have certain interests. So maybe just the way they do their business, they might want a certain feature that other people don't want.

But no one's going to like, also the way the committee works is by consensus. So if someone says no, then it's not going to go forward. So you need to actually be a champion and convince everyone this is a good idea and that can be pretty difficult to do. So you can't just be like, oh, I need this and this is what we need and that's it.

So what has been your interaction with the browser manufacturers since getting involved in TC39? Well, I guess the thing is that I didn't really have that much interaction with people until I decided to go and even now we're trying to figure out what that looks like. It's kind of weird still that I work on this project that seems to be pretty important to the committee and even our ecosystem, but it's not even about funding per se. It doesn't mean that people have to pay me or the project.

It's just we don't even have enough resources for people to work on the project itself. It's like, I don't have to be the one working on it. It's just we all expect all this work to be done, but we stop thinking like, who's the one doing that? And it's like, well, if no one's going to do it, you can pay to do it.

But it's like, yeah, we should get more resources. And a very simple example of this, and I'm saying this more, which is good. It's company getting involved in the project by the fact that if they're the ones, you know, championing a new proposal, a new feature, whatever it is. they can be the ones that implement the Babel plugin and that will help move the proposal forward because it's like, oh, I already implemented it and then hopefully after we release that then you have feedback from users and developers and have a better sense of the confidence that this is a good idea.

And that's a really simple, straightforward way of how T3 and Babel can work together. And it's like actually moving that more formally into the process instead of just kind of like, oh, Babel implemented. It's kind of just like a, it's just there, kind of black box kind of thing. You do work solo now.

You're supported by Patreon and what's the other thing? Open Collective. Open Collective, which is kind of like Patreon but looks more like a, I guess you can support kind of a group of people rather than one person. So it's like if somebody wants to contribute to you specifically, they can contribute to Patreon.

They want to contribute to the Babel project in aggregate, then they can contribute to Open Collective. In any case, you're not part of any specific company. You're doing this solo. What are the pros and cons to that approach?

Yeah, so I would say I am solo in the sense that I'm not in a company but we do have a lot of other people on the team so I'm not working on Babel by myself so I just wanted to make that clear. Yeah, so the pros and cons. Yeah, I guess I'm kind of qualified to talk about this. So before, I was just doing this for fun in my free time and at the time I was working at Adobe on the Behance team in New York and I was doing all that and I realized we're using Babel at work and being a maintainer it didn't make sense to me that we would have issues or we want things to be in the project but then why would we wait for me to do it in my free time when I could just get paid to do it if we actually need it?

So I asked my boss if I could work on it at work and they actually graciously gave me half time so like 50% of my time doing it at work. And so the pros of that is that I don't have to stress out about working and then going home and then like most people why would you even want to do more code when you go home because you're tired and you have other things to do but I just happen to like it a lot and I had that privilege but being able to work at work it lets me kind of I don't know not have to go crazy with doing that outside of work but there are some issues so one is the fact that in the end you have to compromise maybe in a sense of the company wants certain things and then you might want certain things and you have to find things that align for both and maybe that's just a discussion you have to have and that's fine, that's good but there's also this personal sense of almost guilt and that's not the fault of anyone there it's just the culture where it's like well if I'm the only one doing it doesn't have to be that I'm the only one doing open source but if I'm the only one doing half my time on this project no one else is really involved everyone's working on things for work for deadlines and meetings and everything we're talking about is about Adobe or VHand stuff I'm always going to feel a sense of doing my own thing which may be kind of freeing but also I'm not part of the greater community and culture of the company and so it's not emphasized enough so even if it's your job you're always going to feel like am I doing the right thing or should I be spending more time on work stuff so that part is kind of difficult unless you've built a team you're talking about it and you're always going to feel like it's different and then also just that maybe over time you either find out you don't really want to do open source that much unless you're okay it's different where you're just like I want to take a break from my regular work and it's kind of just a side thing and that's totally fine but for me I guess I realized over time I want to be more invested in this and I believe in what the vision of this project is to the point where it's like yeah I actually do want to do this full time I don't want to work on other things and so it helped me to think about what that would look like and if I need to explore other options if they're not willing to do that because if I work on a product team I don't know if it makes sense for them to pay someone to work on open source full time when there's no tooling team even if you're at a big company I didn't find any company that would be willing to do that so that's why I ended up trying with this experiment with doing it on my own are you saying there wasn't any company you could have gone to to work on Babel full time? yeah I didn't find any company that would be doing that really? so Facebook would not be able to for example would not be able to hire you to work on Babel full time?

no that's so surprising to me I remember the I guess it's different so the OpenSSL thing I remember where there was some kind of vulnerability a while ago in OpenSSL and people were like how did this happen? it was like well there was like one or two people that were supporting it and they were open source developers and they weren't really supported in any particular way and it was like well oops as a community it was kind of a tragedy of the commons I guess there was never really like a post-mortem and figuring out what to do to support open source people do you remember the OpenSSL case? was there any kind of precedent set there? I think because it was so bad it's almost like why are we waiting for a catastrophe to happen for this thing to happen?

it's like the fact I'm still working on it now maybe it's bad because then no one knows what the current situation is it's like almost that the same issue with Node where they didn't have a release for a whole year and that's when people were like oh something's gone wrong and then suddenly all this thing happened and for us it's like well I'm still doing it and all these people are still involved and it's still working for people so there's no issue but it's like I don't want to have to like step away like almost on purpose just to make people feel the pain kind of thing I guess morally but maybe I should just so that people realize it for that issue it was I think a bunch of companies got together and they were able to fund but even then it's like are you only funding for that one year? What's going to happen next year when there is no apparent issue? It's like you have to maintain this thing forever for a long time like what about all these other projects that haven't had that catastrophe happen and the ironic thing is that that kind of already happened with Babel in a different way with Lefttad which I don't want to have to bring that up again but it's funny because that's my username now but with that that was a good example of not about like anything other than the fact that Babel is used by so many projects or all the whatever ecosystem Babel was the main project that used Lefttad as dependency and once that got unpublished everyone started like whoa what happened to my build and all that and I think that was a great example of that it's so ubiquitous that just because that one project wasn't able to get downloaded everyone started complaining about everything and that was like two years ago and it's like we're still you know trying to figure things out and you have to deal with you know people talk about like issues and core requests but you know that's just the project right there's also like the ecosystem there's all the projects that are using Babel too and how we get them to upgrade to be on the latest thing making sure they're using the best practices and then also the language and moving that forward so there's like all these different things that could be multiple full-time people maybe and yet you know we have a few people that are kind of doing it trying to figure things out and at the same time you have people that are new and it sucks because they don't they don't know how it works and they don't know who's working on it and I don't blame them for saying like oh it's complicated or why doesn't this work and then on the maintainer side you're like well you don't understand what I'm dealing with and then there's all this entitlement and complaining on both sides and it's no wonder that all these people get burnt out right it's just a weird situation is it working out for you or are you feeling like you're not making enough at this point and it's like kind of a frustrated experiment oh no for me right now no I feel really good I mean yes there's stress in many different ways whether it's money or not knowing enough about like business or sales or insurance or taxes and all those things but I you know I'm doing this because I believe in a certain vision of what the project is but also what open source is and not because like I think it's all going to be okay in the sense like I know what I'm going to do but I like working on this issue not just for battle but for open source in general and I would like to see it change I would like to see the culture of not how we use open source but how we care about open source how we maintain open source how we steward it I want that to change not just from a developer point of view but a company point of view and from people outside looking in like what's this programming thing about what's open source about I don't want it to be about like you know like making all this money and VCs and like that kind of thing it's like there's another side of open source where it's about community and helping people and serving and I think that's really important and also it's a little bit different it's just that you shouldn't have to sacrifice everything to do open source like you shouldn't have to like compromise where it's like oh if I want to do open source I have to decide to not make any money right or that in order to do open source I have to have all this free time or be like younger and like all that stuff it's like no anyone can get involved it doesn't mean anyone has to or should but changing the culture around that and maybe the best thing we could be doing is just the fact that companies should allow people to do open source during work there's also the futurist capitalist notion that the solution to this problem is to have open source protocols do an ICO and make their protocol into something that can be publicly traded but it sounds like that's not really the issue for you at this point it sounds like it's not like you need some new medium of people paying for it it's fairly straightforward if you want to invest in the protocol support Henry Zoo through Patreon or Open Collective it's really that simple and it's more a question of are there enough individuals are there enough corporations or is there a single corporation who can just say okay we're going to stand up here and contribute or virtue signal or whatever whatever is the value to them for supporting you somebody needs to do it otherwise it's a tragedy of the commons and you know the conversation needs to progress I mean well I think the conversation is progressing but you know if it doesn't progress from discussion into action then we'll see more OpenSSLs we'll see more left pads we will see more crises yeah it's really just it's not normal because we haven't done it before right like people kind of just expect open source to work they just use it it's there no one thinks about who's working on it especially if you're new right and if you're not new like it's just like if something works there's nothing to complain about but you forget that the maintenance cost is way higher than the initial cost and we need like companies or people to step up for the first time like once one company starts donating then other people are going to start doing they're going to start wondering like why are we doing it too it's kind of like almost just like competing but competing in terms of donating and trying to change that attitude instead of like why are we donating this is a waste of money it's like why are we donating because this is something we rely on and we need this as a community to take ownership of the things that you're using and to realize like yeah this is important to us and we're doing this together not like kind of like oh this is not my responsibility or this is not my issue it is your issue if you're using it does it need to be like a philanthropic line item for these corporations so that if they give to Patreon open source maybe they can you know do a tax write-off or something I mean that would be nice because that would be more like in line with oh it's like a non-profit and then they can get yeah they can write it off all that that's definitely a way to explore it but there's also just like it's literally in their interest if they want to sustain their business to do this and they built their businesses on top of open source and so there is this goodwill thing but that's more like a marketing thing it's like oh we're supporting open source so then now like people see them better or in a different light or that you have their recruiting because like we contribute open source and we employ people in open source and that's definitely a thing that's why people work at companies and that's definitely an incentive but it's just yeah changing the perspective around how people are using it it's interesting and I think another issue is like people and usually companies would rather donate to the open collection this is my experience rather than the Patreon they would rather donate to the project rather than the people you know that kind of intuitively makes sense like oh we need this project we don't care about the person even though maybe that person is the person that works on the project but what happens when that person leaves what happens when that person doesn't want to work anymore and we can think idealistically that you know there's this money in the pot and then random people will show up and they're going to take the money and make the project better but it's like do they really care about the project are they just trying to make money how does that actually work out how do we divvy up the money like there's a lot of issues with just paying people as well like I can't say that just because we have money suddenly everything's going to get better either there's a community issue there's an issue with like how to do that and maybe that's why a lot of people are like oh we need to just employ people and I think this doesn't mean there's one way of doing this there are a lot of different ways there are a lot of different projects not every project is as big a double it is simple but it's also pretty complicated too like just a lot of moving parts to all this right there's like a trust issue too right it's like a company decides like why are we going to give money to this random person but I would say that you're already trusting random people right now to use you know their code you're trusting me right now to maintain this thing but yet you're not willing to pay because for some reason people are like oh you're going to use the money in the wrong way but we're giving you know lots of money to people that are doing startups that are unproven too we are it's funny open source is like if you told an investor like you know we have this tool or project or company where you know 90% of the world is using it or whatever it is but we don't have we don't make any money they'd be really willing to give you money we just can't give the money back yeah it's a really interesting social problem where it's like yeah in the end it's not really about like programming per se it's like why it's really cool to be able to talk with friends that aren't in tech at all and they have they're really fascinated that this is even a thing all right well let's close on an aspirational note because you mentioned that you have a vision for what this looks like for anybody that's using Babel under the hood they probably feel like oh this is a solved problem I don't really need to contribute to this it takes care of my problems but it sounds like you have a real vision so to entice people to go to Patreon or to go to Open Collective and give to what Henry Zhu is going for here explain your vision what are you trying to do with Babel what's the big goal yeah so there's people could sponsor just for the fact that it takes a lot of time to maintain the project right just to keep the status quo but Babel is a little unique unlike other projects that just might go away because people don't want to use it anymore or it's not necessary but inherently Babel moves with the language so if you want JavaScript to improve then you'll want to support the efforts that we're doing with Babel as long as you're using JavaScript and you want JavaScript to be better and even if you don't it is the most popular language right now a lot of people are using it for the first time it's like how do we create better language for new people people that are more experienced in different use cases whether it's on the web or not and I would like to figure out how the project can be more of an educational resource too whether it's teaching people how it's compiling things I think this is probably one of the most accessible compilers there are just because it's for JavaScript it's written in JavaScript you can write your own plugin and it's like how do we get people that want to be involved with programming languages and compilers which seem to be very unappreciable things and guide them through that process it doesn't mean everyone has to become a compiler engineer or even contribute to the core code but you can contribute to our website the docs, the REPL there are a lot of really cool tools out there that are not consolidated that we could use help in and things that people haven't even created yet it's like people like to ask me oh I want to get involved in mobile stores tell me what to do I don't know what interests people I want to find out what interests you and to help you guide through that process unfortunately I'm just that one person so talking to 100 people or even just 10 people is difficult but yeah I want to encourage people to get involved and know that it is a process it will take time it's fine to just do open source for a day or two but there's also a cool thing in just working on something for a long time to kind of be committed to some kind of vision or purpose for what this thing represents in terms of like oh this is a feature of how languages can work and hopefully our project is a good representation of what open source can be in terms of a community and trying to like build on that and I think I'm trying to figure out open source in general but then through this specific project it's like how do we make a community that's not just about code you know bringing in people that are good at documentation or writing or videos or art there are a lot of things that we can be doing and a lot of the work I'm doing now is not coding at all it's like whether it's like fundraising or talking to people or doing meetups stuff like that there's a lot of there's a lot that can be done and a lot of things that we're not even thinking about so I'd like to encourage people to get involved and yeah find what interests you what inspires you and Rizu thanks for coming on software and great talking to you thank you wow We'll be right back.

Frequently asked questions

How long is this episode of Open Source Archives - Software Engineering Daily?

This episode is 1 hour and 0 minutes long.

When was this Open Source Archives - Software Engineering Daily episode published?

This episode was published on June 21, 2018.

Can I download this Open Source Archives - Software Engineering Daily episode?

Yes. Use the download control on the episode player to save the publisher-provided media file.