TypeScript is now one of the top 5 programming languages, but what is it exactly? And why has everyone adopted it in recent years? This week, Paul and Rich sit down with Orta Therox, a former engineer on TypeScript at Microsoft. He breaks down what makes up a type system, how to migrate to Typescript, and why it could be considered “CTO Optimized.”
Episode Links
Transcript
Paul Ford Humans have a strong tendency to build a full-application platform out of literally any technology. [Everyone laughs.] Like if you’re like, the RFID tags in your sneakers, they’ll be like: yeah but you can run Linux on that and now we’re off to the races.
Orta Therox There’s an app store for it, eventually.
[Intro music begins, ramps up, plays 14 seconds.]
PF Hey Rich.
Rich Ziade Hey Paul.
PF Postlight’s been around for a little while, wouldn’t you say?
RZ I mean in the world of technology we are dinosaurs almost.
PF No, no that’s not good marketing content. Regardless, I want to do an impression of the engineering function at Postlight for the first four years.
RZ Ok go.
PF JavaScript, JavaScript, JavaScript, JavaScript, JavaScript on the server, JavaScript on the client, JavaScript on mobile, JavaScript, JavaScript. Going to go to a JavaScript conference. Going to do some JavaScript stuff.
RZ So how was your weekend?
PF JavaScript. [Rich laughs.] Let me do an impression of the Postlight engineering culture in the last two years. You ready?
RZ Ok.
PF Typescript, Typescript, Typescript, Typescript, Typescript.
RZ So how was your weekend?
PF Typescript, and a little bit of JavaScript.
RZ Ok.
PF So do you know what Typescript is? Don’t pretend.
RZ I do yes, but I think we should give it two minutes of one-on-one. If only we had someone on the podcast who could help us define clearly for the masses what Typescript even is. You know anyone, Paul?
PF Through the miracle of technology, we have here on the podcast—he is muted right now, I’m going to tell him that—Orta Therox. Orta welcome to the Postlight Podcast.
[1:44]
OT Hey, thanks everybody. Honored to be here.
PF Orta you work on Typescript. Before you tell us about your job, what is Typescript? A lot of our audience won’t know.
OT Typescript is a language that compiles to JavaScript. It’s kind of a bit of a weird one in the sphere of languages. But basically the idea is if you had the delete button you could go from Typescript to JavaScript and that is a goal of Typescript.
PF What does that mean: if you had the delete button?
OT [Laughs.] Well think of it as like JavaScript is this language that people have been using for about 25 years that started out just as trying to make websites. A little script. Little bit of magic.
PF Make the monkey dance on the banner ad. Yeah, yeah, yeah.
OT Make something follow your cursor as you drag it around the page. The HTML stuff.
PF And now it’s 80% of the world economy, so—
OT [Laughs.] Exactly. And that’s the same tool that’s being used for very different scale problems, right? And Microsoft looked at that problem and said hey were building very big things in JavaScript nowadays and all of our engineers are just not that happy with the tooling. They love working in JavaScript but not being able to get autocomplete, or not being able to know whether the code is going to crash in your editor was just something you couldn’t do.
[2:55]
PF So wait, first of all, Typescript comes out of Microsoft. That’s important for people to know. But it’s all open source. It’s not one of those weird old-school Microsoft things. It’s the new Microsoft that’s like: hey everybody it’s on Github (which we happen to own). So there’s that. What is the big difference? Why did everyone all of a sudden start saying Typescript, Typescript, instead of JavaScript?
OT I think it’s all about the editor experience and being able to feel that you can reliably know the changes—changes only in the things that you would expect there to be.
PF What would break before that didn’t break when Typescript showed up?
OT So a lot of the simple ones are checking the function inputs and outputs and just making sure they’re consistent for your entire application. Like accidentally passing a string to something that expects a number is something you could very easily do in plain JavaScript. And JavaScript allows for a lot of that flexibility because it wants that flexibility. But that flexibility gets very hard when you’re building very complicated applications with a lot of people.
PF I mean the way I would put it is JavaScript doesn’t care. No matter what it is, JavaScript doesn’t care. You could be like, JavaScript I need you to add a string to a number. JavaScript is like, absolutely man. It’s not a problem for me.
OT Yeah and that flexibility is a power of JavaScript. It’s just: eventually you get to a point where maybe you don’t want that flexibility and you want to maybe be a lot stricter in order to then have a sort of better developer experience.
RZ Orta is Typescript its own programming language? Do you just write in Typescript instead of JavaScript? Is that how it works?
[4:25]
OT So you would write Typescript in a Typescript file, but then you would use a separate tool to change that into a JavaScript file. That JavaScript file would then run inside a web browser or inside a JavaScript run time of some sort.
[4:38]
RZ I see. So it’s sort of making life easier for the developer.
OT Yeah. That’s one of the goals—make life easier for the developer.
RZ In the end, it’s just JavaScript.
OT Yeah. And that’s honestly one of its powers. There are many competitors to Typescript like languages that give you flexibility and a really tight workflow but they turn into JavaScript. Not that it is JavaScript with a little bit more, and I think that’s what accounts for its popularity.
PF So let’s say I’m in a company that’s not as excited and motivated about Typescript as Postlight. Postlight got there a couple of years ago, but I assume it takes a while for the world to catch up. Here I am, a Postlight Podcast listener and my department of engineering is coming to me and saying we need to move our code over to Typescript. Help me understand that change. Is that expensive? Where does that start? What are they going to need to learn? They’re all saying it will take two minutes but I don’t believe them. Everybody gets optimistic. Let’s say I have 50,000 or 100,000 lines of JavaScript to make my big web app run that are critical to my business and now everybody’s excited about Typescript. What do I do now?
OT Honestly, it’s a great question and to some extent it depends in the same way that you would say for any technical migration, right? [Everyone laughs.]
PF It’s very comforting whenever—I don’t know if people know this, but whenever an engineer says it depends I’m like ok, we’re going to be alright, everything will be ok. It depends. [Everyone laughs.]
[6:00]
OT Typescript is built in a way to handle that sort of migration incrementally. So the idea here is—I have talked to you a lot about the sort of developer and editor experience about Typescript. And Typescript also provides that experience for JavaScript developers too. So for a lot of people they’re already using a very flexible version of Typescript when they’re just a JavaScript developer because they’re using a developer tool that gives them that tooling under the hood. So the way that we recommend to people to migrate is actually first to sort of make your JavaScript project a little bit more explicit to the Typescript tooling that you’re probably already using.
PF What would that tooling be like for example?
OT A good example would be using a very popular editor like Visual Studio Code, another Microsoft product that is built in Typescript. And there is a person on the Typescript team that interacts very regularly with that team to make sure it’s a very tight experience.
PF Interesting. I don’t think people processed that. So that’s one of the really big well-know IDEs out in the world, it’s open source, I didn’t know that. It’s fully written in Typescript?
OT Yeah it’s a canonical Typescript codebase. It was like the first one.
PF Your developers may already be using it just to get their work done in JavaScript.
OT Yes.
PF So start there.
OT So let’s say your developers are already using visual studio code and any JavaScript then is actually running their through a version of Typescript inside Visual Studio Code.The next step then is sort of define a project file. It’s like a little JSON file that you put in your project that sort of says, hey here are the files, here are the sort of rules. And you say: allow JavaScript, basically. And then it won’t tell you your errors, but it will start giving you a lot of autocomplete and sort of error-ish messaging. If it’s 100% certain that that error would happen in JavaScript regardless. Then suddenly you have migrated to Typescript by just putting a single file in your project. But you still have a long road ahead. That is part of the key. It’s like you first start turning on these options and then you go to the files that are the ones you think are the most risky. Every codebase has files and sections that people don’t want to touch—
PF True.
OT Either because somebody made it and then has left the company or it’s just really complicated stuff. Those are usually the best place to write Typescript in my opinion, and to sort of add additional tooling around it so that people feel comfortable making changes in these complicated areas of the code.
[8:18]
PF So like the code that pulls the user profile out of the database, but the user profile is always changing. I think this is the point where we explain what a type is. So we’ve gone from JavaScript which God knows, nobody wants to know why it was called JavaScript. It was just a ride on some marketing from the Java language back in the day. But a type is a thing and it’s a contested and complicated thing in the world of computer science. What is a type in this context?
OT In programming we have a few sets of literal things like these constant primitive things. Like a number, or what we call a string, which is a collection of characters that we sort of usually just enclose in quotes. That would be like the word fifty versus the actual number 50, which would be a number. The way that JavaScript sort of thinks about these primitives is that they can be sort of collected together into some called an object. So if you wanted to represent a user, the user might have an age and a first name and a last name. And that sort of would be a description of multiple keys and values inside an object. And Typescript gives you ways to describe: hey, this key can only accept a value of a string or a number or even another object itself. And that is what we call a type. The way in which we define the relationship between values inside a complex system.
[9:41]
PF I think what people who don’t program might not realize is that this sounds really simple but this is where all the problems creep in. This is like if you find out that somebody has replaced all your nails with screws and you’re like, oh but I have to build the house. It’s hard to nail screws into the wall. That’s what types are to programming.
RZ JavaScript was I think sort of this weekend experiment that got bolted onto Netscape and it was kind of half-assed.
PF It was famously a two-week, hey we’ve got to have something to make the monkey dance. Like literally it was we’ve got this thing, we’ve got the web page and the web page is made up of objects itself and how can we make the objects do things that they couldn’t do with just static HTML?
RZ Right and they thought the movie would end there. They thought ok fine you need the name to blink, we can give you something.
PF Yeah, the way it was for documents, so we’ll make the documents a little more lively.
RZ That’s right and JavaScript it just kept going. Humans kept going. As humans will do, they’ll take a thing and go, well you know what this could work and I’m comfortable with it and I feel confident in it and here we are. I want to shift the conversation to the developers here. I guess it’s a two-part question. The usability and the experience for developers is a fascinating thing to me because it’s one of those things that somehow translates into motivation and productivity in very intense ways. And I can’t think of anywhere else where they get that feeling. If you hear a developer talk about their environment and their IDE and whatnot, it’s intense and it’s passionate and it’s opinionated. It leads to better out product sometimes. Sometimes people obsess over the tool.
OT Does it? [Everyone laughs.]
RZ Well ok I’ll take that part back. But talk to me about what motivated you to wade into this part of the culture of software development? Because it’s really interesting.
PF Right and I think talk a little bit about the work you’ve done over the years. It would be great for people to hear.
[11:38]
OT I find quite a lot of parallels with woodworking. When I watch woodworking videos I see people make these really complicated jigs to eventually just do one tiny little piece of woodworking.
PF Yeah. [Laughs.]
OT I think that’s quite similar to how developers treat their tools and their tooling as well. So I got started making games and had to build tools to help build my games. And eventually I got to a point where I enjoyed working on the tools more than working on the games, which is a pretty normal experience for people who end up working in dev tools. And I spent a long time working as an IOS developer doing open-source scale on sort of a dependency manager tool that allows—again it’s a bit like an app store for developers. And eventually sort of realized that JavaScript was growing a lot in my own company that I was working at and we needed to focus on it too, even as IOS developers. And that eventually led me down the line to look at Typescript, see its growth and reach out to the team and say hey I think it’s growing much faster than maybe even you were expecting, and maybe I could come work on your community management and work on redoing all of your documentation. It’s kind of hard to understand if you’ve come from a non-compiler background.
PF Why do you think Typescript caught on because there have been many things that compile to JavaScript. There’s been Coffescript and really anything that is Coffee-related has a pun that points towards JavaScript. Lots of closure and all sorts of things. Why this one?
OT I think Typescript sort of caught on because it embraced what developers were already doing and then tried to give them a little bit more. So a lot of its competitors tried to outright replace JavaScript. And not take your existing knowledge of JavaScript with you. But instead, Typescript says you already know JavaScript, we’re just going to give you JavaScript with types and that types is just a way of saying, here’s your input outputs. You just need to learn JavaScript and the Typescript stuff that comes on top of that, that will give you a better developer experience and make you a bit more comfortable with your changes. But at the end of the day, you’re still writing JavaScript. And I think that’s a key abstraction that gives it the power to become as popular as it has become.
PF Give people a sense of how popular, right? We don’t need an exact percentage, but it’s more than 1 out of 100 engineers is writing this. It’s big now, right?
OT Yeah, Github releases these sort of rankings where they say how many new files are being made in a new programming language and Typescript is up there in the top 5 and that’s of every programming language.
PF That’s a beast for people who don’t that out of 150, that is a lot of growth really really quickly, especially on the base of JavaScript.
OT Yeah it’s estimated that 50% of all developers use JavaScript which must mean that a very substantial amount of that is using Typescript.
PF That means that the whole world is written in JavaScript, which is just terrifying when you think about it.
RZ I want to step out of the development world for a second and talk about the people who interact with the developers—the rest of society. I’ve led teams through a lot of different projects, some larger scale, some smaller. Agency, product, all sorts. And I’ve got to be frank. When they put the case together to change programming languages or to adopt one that just came out two weeks ago, I freak out.
[15:07]
PF You’re actually pretty flexible, though. I mean we’ve got Elixir in production, all sorts of stuff, at Postlight. But I agree with you, you do over time go ugh ok yeah this is the one? This will solve it? Because it’s been 25 years.
RZ Also I’m not CTO of American Express, where there’s going to be immense resistance to change because of the cost of change and the risks associated with it. How should that audience take in? I’ve got to say for me it’s been a learning experience because I want developers to be motivated and excited because better work comes out, better output, higher velocity. They just connect.
PF Typescript is different, though. Because something like Elixir is a new technology, it runs on a different virtual machine than people are used to. You’ve got to deploy it. Typescript just sort of showed up one day because it was JavaScript plus and it compiles to JavaScript. And it was built into the tech center they were already using.
RZ True. It wasn’t a full like rip the wiring out and do something new.
PF And even more, it came from Microsoft and it does enterprise things around types and objects that are even more rigid than JavaScript so it’s actually CTO optimized as a new technology in a way that very few other technologies would ever land.
[16:31]
RZ Right.
PF Cause I’m just thinking of making the case it’s like: yeah ok I guess so. And then everybody’s like more productivity and 40% of people already use it! And you’re just like ugh fine.
RZ Talk about that dynamic a little bit, Orta—the dialogue that often occurs.
OT So I’ve already framed it as incremental revolution.
PF That’s your memoir!
RZ That is wild.
PF Dude, there you go. Dot org is the name of the website. Incremental Revolution. That is such a VC book title.
RZ Oh man that’s a strong move! You’ve got us! [Laughs.]
OT [Laughs.] It’s true though, right? You don’t want to throw away everything and Typescript’s approach of this really long possible migration is absolutely not seen in many of the programming languages at all and I think it accounts for a large amount of its popularity and also what makes it very approachable—to describe to non-technical folks the advantages of using this separate language.
PF You want to know what makes this work? The fantasy of engineering, especially object-oriented development, was that you’d map out the whole world, you’d get it all structured just right and then you’d sit down with that map and say: let’s make the code. Let’s get it all buttoned up, push to production. And obviously it’s an evolving system, good for us. But the reality is you end up with this hairball of inherited open-source code, legacy stuff, things in different languages, APIs with a lot of mismatch. And you’re just kind of in the fog all the time, which we don’t like to talk about that much. Most of your engineering time is kind of in the fog. I just had somebody—I was dealing with a bug on code I wrote like a year ago this morning, because I’m still on the hook for certain things. And it was just like oh yeah I have no idea what’s happening here. No clue, I don’t remember it, I don’t remember writing it, I don’t remember this function. And then you multiply that by hundreds of thousands of functions. So I think that that’s the real world of building stuff, which again makes for terrible conference talk. Nobody wants to go to the incremental fog disaster, no one knows what the hell is happening talk. But if you do something like this where it’s just like ah we didn’t really know where we were headed but it turned out that it’s a lot more organized than it used to be—if you make it easier to organize things, boy does that make people happier.
[18:54]
OT It’s like putting labels next to wires and things like that. It just gives you the ability to not have to follow the wire all the way to the source to try to figure out whether it’s connected or where it’s connected to.
PF Types sort of give you little boxes for things. That’s true, you can point to them. So ok here’s Typescript, it’s a big open-source project inside of Microsoft. Obviously not their priority, it’s not the number 1 thing that Microsoft does. How does that fit into the overall Microsoft Gestalt? You still have Windows. Are they going to take care of this thing going forward?
OT I think at some point in the last 10 years, Microsoft really did a 180 on trying to figure out how to pitch its developer tools and persuade the entire developer audience that Microsoft is something you should be using again. To me as a startup-y person, the entire world moved to using Macs and then using Linux on their servers, and that just left Microsoft as this existing group of C-Sharp developers and Windows developers but completely ignored what people were doing in—well I said 50% of people used JavaScript, so Microsoft was completely ignoring that audience. I think Typescript was one of the first breakthroughs for Microsoft, both internally and then externally. To this entire new developer audience and then they just gave Typescript the freedom to figure out: what does the Typescript language need to be outside of the forces of influence of Microsoft bureaucracy? So it was like what is best for Typescript and web developers was actually the key thing, not necessarily what is good for Microsoft to sort of pull in these developers.
[20:29]
PF It’s just fascinating to think about Microsoft or really any organization—going that’s an interesting idea, don’t kill it. Most organizations can not afford interesting.
RZ I think there was more foresight than that. I think this speaks to Microsoft’s second wind. Microsoft’s second wind is very much powered by a long game of not being too orthodox about their own ecosystems. This to me is the same rationale as, you know God bless Internet Explorer but it’s time to just move on to Chromium because there’s no value differential there so let’s get on with it, embrace the communities that can power us and off we go and boy it has worked beautifully for them.
PF It feels like the pivot was rather than we need to be everywhere, acknowledging well we’re everywhere and now we just need to grow layers of Microsoft everywhere we are. Put down more and more Microsoft soil that we can then grow more Microsoft inside of it. Does that mean that the entire world is covered with Microsoft like a fungus? Maybe. But it’s effective.
RZ I mean I think they looked at the whole world and said you know what, we could sit here and just stay enamored with our own ecosystem which is Windows essentially and C Sharp and the like.
PF They got spanked on the phone right? There were those moments, too.
RZ That was an experiment, wasn’t it? Weren’t they going to buy Nokia at one point?
OT They did buy Nokia.
RZ They did? They bought it?
PF Yeah.
RZ Is that why Nokia’s not around anymore? [Laughs.]
PF Yeah that’s why you can’t get any custom ringtones anymore. [Rich laughs.]
OT I think that’s completely right, personally. I think Microsoft got spanked on the phones and phones are the most profitable consumer device. And then had to figure out ok how do we get people into Microsoft ecosystems? Everybody’s building Apple products in Apple languages, Google products are all done in Java. I’m not going to say Windows is a shrinking market but it is definitely a mature existing market where there are a lot of existing systems and a lot of new systems are—usually Webby—replacing them.
RZ Their cloud moves have been—they caught Google flat-footed. Google Cloud is a tiny percentage of what Azure is now. Again, driven by I think a different worldview which is less about self-love and more about ok here’s the new world, let’s go.
PF Well you get more of the world if you don’t try to control it. If you’re just kind of everywhere. Some of us, that’s what open source did—open source is just sort of like well, you know, it just kind of exists everywhere it goes and it shows up in every country and every project and everybody got used to it. Is there anything else you want to hit on? Any sort of advice people should have in the world?
RZ What advice would you give to the young engineer who has the comp-sci degree and the tools seem to change every 65 days? What’s a good place to start? What’s the advice you’d give that graduate?
OT So first of all, I don’t think you need to graduate to be good at programming. A good chunk of my colleagues don’t have higher computer science examples. I think, realistically, you need both a desire to have an outcome. I don’t think you can easily just wander into programming and get anything done. If you know what you want to build, you’re going to be in a much better space for doing that. And JavaScript as a language is a very good space for doing that in part because it’s everywhere and it does everything, somehow. I think if you wanted to get started: pick a project, maybe just fix your own website, maybe try to make an app for a friend.
PF Build something.
OT Build something.
PF Should I try to learn Typescript first or JavaScript first?
OT JavaScript.
PF Ok don’t start cause—why? You just told me about this cool exciting new thing. Why should I learn the old busted thing first Orta? [Rich laughs.]
OT It’s kind of funny because when I first looked at the documentation for Typescript which when we redid it, we actually made it so if you’re new to programming, we just say straight away, hey Typescript shouldn’t be your first language, you should go learn JavaScript and then you can come back at this level of the guide. Realistically, Typescript provides all of these extra tools on top of JavaScript and you need to know JavaScript in order to really write code that does anything. Typescript should just completely be deleted away from the code that you write to because JavaScript, so you need that foundation to do anything useful.
PF Do you think of Typescript as a language or as a sugar on top of JavaScript? How does your brain organize around that concept? How do you define it?
OT We try to describe it as JavaScript with types and it gets a lot easier in your head to think about Typescript as a separate language because you have a different file name for your files, you have different configurations, and generally you want to be searching for the word Typescript when you’re trying to find answers for things around that problem.
PF When’s it all going to compile to Web Assembly? Just run?
OT That comes up a lot. A lot of people ask this question. And the thing about Web Assembly is in order to have Web Assembly you nearly always have a JavaScript run time. And JavaScript tends to run faster in JavaScript than inside Web Assembly. And so it doesn’t actually make sense to put Typescript into Web Assembly because it’s already there, but if there’s somebody rewriting Typescript maybe to try and see if there’s a faster way to do some of the hard calculations that run inside it, then they would probably be using Web Assembly to get it to run.
PF There we go. I always like to ask about Web Assembly. I’ve been asking about it for six years.
RZ 2015 Paul messages me: this is the future.
PF Yeah—
OT I don’t think you’re wrong. A lot of JavaScript tooling nowadays is being built in languages that turn into Web Assembly like Rust and Go. Most of my JavaScript tooling is now being built in those languages using Web Assembly.
PF So for people who don’t know Web Assembly is like a virtual machine, like a fast computer inside of your browser. When I started saying this to Rich in 2015, there was still kind of—and just a little bit—there was one web. And now I feel like there’s a million webs. [Rich laughs.] It just blew up in the last six, seven years where instead of there being one still sort of dominant thread, there’s now Typescript and JavaScript and Rust that compiles to Web Assembly and it’s a very broad platform where it used to be a lot more specific. So Orta what are you up to now? What can you tell us about? You’ve moved on from Microsoft, you’ve moved on from Typescript. Give us the scoop. Tell us everything you’re doing.
[27:02]
OT Well I actually can’t. The thing I’m working on—
PF Ahhh top secret developer!
OT [Laughs.] I know! It’s a stealth startup!
PF That’s good, those are the best.
OT Yeah, genuinely I can’t really talk about much of it. It’s trying to apply web tech in an interesting space for games.
PF That’s cool, so that’s something to watch. When it’s time for you to tell the world what you’re working on, how would people know? How can people get in touch with you?
OT Follow me on Twitter. I am just my first name @Orta on Twitter and I don’t tweet very often, I try to treat it almost as a change log. But I think it’s a great space for developers to be if you’re not there and also a great way to get information.
PF There you go everybody: Twitter. It’s healthy for you. [Laughs.]
RZ The change log for your life. [Laughs.]
PF Well this is terrific, thank you. Ok this is really good because I think right now several hundred business leaders have said ok you can have Typescript in an email while they were listening to this podcast to their head of engineering.
[28:01]
RZ The world’s a better place.
PF The world is a better place. Ok you can have it, have your types as long as it enterprise. Microsoft approved—I’m ok with it.
OT It’s been worked on for 10 years, they know what they’re doing.
PF Yeah it’s going to be ok. Just relax. The future of JavaScript is here and it’s JavaScript with types. So let us know when your game is out I’m sure it’s any day now. Nothing easier to do than build a game on the web. [Laughs.]
OT That’s it. That’s my deadline, tomorrow. [Everybody laughs.]
[Outro music fades in.]
PF And if people want to learn about Typescript, they want to get their head around it, where do they go?
OT Honestly the best source is typescriptlang.org the official website. We redid all of the documentation in the last two years so it is very up to date and it is very approachable nowadays.
PF Great. Well Rich, once again there are new things happening.
RZ I’m just glad we didn’t talk about Clojure.
PF Oof. I still love Clojure, I think it’s a great language, Clojure script is great but Typescript is a little less away from the mainstream of web technology. A little more organic to how stuff gets built. So Rich who are we? What are we talking about?
RZ We are Postlight. Postlight is a very talented group of designers, engineers, product strategists, product managers. There’s a lot of passion for craft inside of Postlight. That’s why this conversation was sparked by a lot of the dialogue that happens inside the firm. Check us out at postlight.com. Reach out at hello@postlight.com. Orta, thank you so much.
PF Yeah, thank you Orta for coming on and many thanks to Preston Richie, one of our lead engineers, for recommending Orta.
RZ Thank you, Preston!
PF Yeah come back anytime.
OT Yeah it was an honor.
[Outro music ramps up and ends.]