Back to overview

Demystifying Type Inference with Jared Forsyth

In this episode, Jared Forsyth, a long-time Khan Academy engineer and functional programming enthusiast, joins Kent to explore the fascinating world of type inference. Jared previews his Epic WebConf talk, "Hindley and Milner Walk Into a Bar," where he dives into the mechanics of type inference algorithms and their impact on modern programming languages. They discuss the importance of understanding the fundamentals of language design, why type inference matters, and how getting comfortable with these concepts can make developers more effective.

Jared Forsyth, a front-end infrastructure engineer at Khan Academy, shares insights into type inference and programming language design. With nearly a decade of experience working with React and React Native, Jared has a deep appreciation for tooling and developer experience. His Epic WebConf talk, "Hindley and Milner Walk Into a Bar," will break down type inference algorithms and how they improve developer ergonomics by reducing the need for excessive type annotations.

Jared and Kent discuss the practical benefits of understanding language internals, including how it can improve debugging, enhance problem-solving skills, and make learning new languages easier. They also talk about Jared’s passion for local-first web development, functional programming, and how in-person conferences help build lasting relationships.

Watch this episode.

Meet Jared at Epic Web Conf.

Guests

Jared Forsyth
Jared Forsyth

Transcript

00:00 Hey, hey, everybody, I'm Kent C. Dodds, as usual, and this is Jared Forsyth, a good friend of mine. How are you, Jared? Hi, I'm doing great. Awesome, yeah, we go back quite a while, because you lived here in Utah, and I think we probably just met at meetups and Utah JSConf and stuff like that.

00:18 And one of the cool things, I'll let you introduce yourself here in a second, but one of the cool things I can think about is you work at Khan Academy. I think you were there when React came out, you were among the first people to use React, is that right? Yeah, so Khan Academy was maybe the first production user of React.

00:40 That was before I joined, but I joined maybe a year after that. I've been there for nine years, and we were an early adopter of React Native, and it's, yeah. Yeah, that's worked out.

01:01 And do you work very closely with Mr. Rizig, Mr. JQuery over there? Yeah, yeah, that was a big draw. He's been there for 11 years. Wow. And yeah, he's actually on my team, so we talk a lot. He's a fantastic guy. Oh, that is so awesome, yeah.

01:21 A lot of people, even folks who are just getting started in web development, even if they're not using JQuery, we're all impacted by what he did, so that's kind of cool that you get a chance to work with him. He seems like a super chill dude, too. I've never met him, but he seems really cool.

01:40 Yeah, it's great when you meet your heroes and they turn out to be really nice, really empathetic, really helpful. That was great. Yeah, very cool. Well, Jared, why don't we get to know our hero, Jared, a little bit. Can you tell us a little bit about yourself? Sure.

01:57 So like I said, I've been at Khan Academy for nine years doing lots of mobile native development, React Native. I helped with the transition to that, and more recently doing what we call front-end infrastructure, so working on tools and tooling for people working on the front-end,

02:16 both our mobile front-end and our web desktop front-end. And that's a lot of linting and test, we use React testing library, all that good stuff. And helping with migrations, help setting design practice, that kind of stuff.

02:37 Yeah, that makes tons of sense. And thanks to React Native, it's like very much that learn once, write anywhere sort of thing. Do you share very much code between the code bases? We, not very much, it ends up being the case. With, there are enough differences

02:58 between React Native and Web Native that it makes sense to maintain them separately. However, being able to easily switch between code bases, because it's the same kind of code, same language, same tooling and everything is really essential. Yeah, 100%.

03:16 And honestly, that's a big reason why I like full-stack JavaScript as well, because I'm jumping back to the back-end. What is your back-end over there at Khan Academy? At this point, it's mostly Go. We've got a microservices architecture. There are a couple of services that are in JavaScript for the code sharing.

03:39 Our, the toolkit that we've written for math problems, we call it Perseus, it's an open source project, you can look at it, is very complex for handling different kinds of questions, kinds of number inputs, graph inputs, that kind of stuff. We run that front-end and back-end,

04:01 and we didn't wanna rewrite it in Go, so that's a Node.js service. Gotcha, yep, that makes sense. Well, that is awesome to hear about your time there at Khan Academy. You are one of probably the most technical talks that we're gonna be having at Epic Web Conf. The title is, I'm reading it because I didn't wanna get it wrong.

04:21 Hindley and Milner walk into a bar. I've heard these names, but I don't know what they mean, or who they are, or anything. Can you give us a little idea of what is your talk going to be about? Yeah, so I'm gonna talk about type inference algorithms. That is the algorithm that knows what type your variable is

04:43 when TypeScript is checking your types, for example. That is a type inference algorithm. One downside of using static types is you have to write them everywhere, right? You've gotta annotate all your function definitions. Now, if you were using old-school Java, or C, or C++, you'd have to annotate all of your variable declarations,

05:03 too, which just balloons in size. It's a maintenance nightmare. So it's nice that TypeScript will infer the types on your variable declarations. I'm gonna be talking about a more powerful algorithm that is limited in other ways, but that makes it so you don't even have to annotate

05:22 your function annotations, your function declarations. And my goal with this talk is to get people more comfortable with the nuts and bolts that go into making a language. I think that programming is a lot more difficult

05:43 than it should be, and part of that is our choices for programming languages are pretty limited. And frankly, because it's daunting to try and write a programming language. I've talked to a lot of smart people, and when the concept of writing a language comes up,

06:03 they're like, oh, that's a big deal, right? That's how I feel. Yeah, so I wanna get people more comfortable with it so we can have a lot more exploration of the design space so that we can have better programming languages that are easier to use, more fun to use, and help you out more often. Yeah, love it, love it.

06:24 I think one of the things that I really appreciated when I started getting to working with ASTs with Babel and ESLint was that the language itself opened up to me so much more. When you're starting out, the syntax is a challenge,

06:42 but the syntax challenges just completely disappeared when I could look at the syntax itself and kind of see an AST in my mind. Like, okay, that's an identifier. This is a function declaration. Here, like, here what the different pieces are, and here's why I can omit this particular character

07:01 in this area because of, you know, this is an expression or whatever. And so having that deeper understanding, even if people don't end up going to write their own language, I think will make them use the language that they use more effectively. That's right. We're gonna be popping up with a hood so that you're a little bit familiar with how the engine works,

07:20 what happens if it starts billowing smoke, even if you're not gonna build your own car. Yes, yeah, absolutely. So Jared, when we're at the conference, I just wanna know, for you, you're traveling to this conference. You've traveled to conferences before. What is the reason that motivates you to, like, leave your family at home,

07:39 take a break from work for a little bit to go to an in-person event like this? I love conferences for the people that I meet. Without exception, when I go to a conference, there's somebody that I run into that I would not have run into otherwise, somebody that I either know from the internet or we've worked on a similar project,

08:03 and we just have really great conversations. So that's what I'm excited about. Oh, I love that, yeah. It's those relationships that you can build in person that you, like, you could still build relationships over the internet, like, that's totally a thing, but, like, it changes when it's in person. And so, yeah, I'm absolutely looking forward to that.

08:22 We should see if we could get your team over to the conference as well, and then I would love to be able to meet John. That would be pretty sweet as well. Yeah, yeah, I'll try and sell him on it. Okay, that sounds great. So, awesome, when we're there, you're going to have people that you know, people that you don't, and some people are going to want to come up and meet Jared Forsythe.

08:42 What is the sort of thing that they could talk about that would get you really interested and excited? A couple of topics that I'm interested in. Obviously, programming languages, new functional languages like Gleam or Rock, Elm to some extent, although that's kind of less of the new hotness these days. OCaml, I'm also really interested

09:11 in local-first web development. So, technologies that allow you to do real-time synchronization without heavy dependence on a server, collaboration, that kind of stuff. Yep, love all of those topics. That sounds very interesting, and I'm sure there will be plenty of people who come to the conference who also want to talk about those things.

09:31 So, go to Jared if those things sound really interesting to you. Jared is very approachable, friendly, so I think that you'll really enjoy chatting with Jared. So, yeah, with that, Jared, thank you so much for giving us some of your time to get to know you a little bit, and we're really looking forward to seeing you

09:50 in March in Salt Lake City for Epic Web Conf. Thank you. Thank you, I'm excited. Okay, bye, everybody.

Sweet episode right?

You will love this one too.

See all episodes

Featured episode

Beyond Code Assist: Driving Impact as a Next-Gen Developer with Mark Techson

Season 6 Episode 14 — 10:01
Mark Techson