In short
Podcast Summary: RxJS with Ben Lesh
Episode Overview
- Podcast Title: Software Engineering Daily
- Episode Title: RxJS with Ben Lesh
- Description: Ben Lesh, the creator of RxJS, discusses his journey into engineering and the significance of the RxJS library, which is used for composing asynchronous and event-based programs.
Key Participants
- Josh Goldberg: Host, independent full-time open-source developer, known for his work in the TypeScript ecosystem.
- Ben Lesh: Creator of RxJS, with a background in programming starting from a non-traditional path.
---
Key Topics Discussed
- Ben Lesh's Journey into Software Engineering
- Early Interest: Began programming at a young age but initially pursued a career in graphic design after attending art school.
- Discovery of Programming: Transitioned to programming through curiosity about web development while working at Ohio State University.
- First Job: Secured his first programming gig by demonstrating willingness to learn and underselling his qualifications.
- Introduction to RxJS
- What is RxJS?
- An open-source library designed for composing asynchronous and event-based programming.
- Provides operators for transforming, filtering, and managing streams of data.
- Observable Concept:
- RxJS uses observables, which are push-based types, unlike iterables which are pull-based.
- Observable streams allow for dealing with events over time, providing a powerful way to manage data flows.
- Comparative Concepts: Observables vs. Iterables
- Iterables: Consumer requests data (pull-based).
- Observables: Producer sends data to consumers (push-based).
- Importance of Cancellation: Observables offer cancellation, which is not available with promises.
- Challenges and Misunderstandings
- Complexity of Async Programming: Async code can lead to issues such as reentrancy and unpredictability.
- RxJS's Bad Reputation: Often criticized due to the complexity it introduces, especially for developers unfamiliar with its operators.
- Future of RxJS and Standardization
- Browser Integration: Observables are being standardized via W3C for browser implementation.
- Benefits of Standardized Observables:
- Multicast by default, reducing the need for manual subscription management.
- Impending Changes in RxJS: Future versions will align with the standardized observable structure, with considerations for backward compatibility.
- Open Source Contributions and Community
- Being Conspicuously Helpful: Emphasizing the importance of contributing to communities through helpfulness, answering questions, and sharing knowledge.
- Impact of Open Source on Career: Engaging with open source can enhance career opportunities and visibility within the tech community.
- Artistic Background and its Influence
- Connection Between Art and Code: Both disciplines require creativity, problem-solving, and a desire to produce enjoyable work for others.
- Recent Artistic Endeavors: Completed a portrait of his parents after a long hiatus, demonstrating the fusion of his artistic and programming skills.
---
Conclusion The episode provides a deep dive into the world of RxJS, discussing its relevance in modern software engineering, particularly for dealing with asynchronous programming challenges. Ben Lesh's journey highlights the importance of adaptability and the impact of community engagement in the tech industry.
Additional Resources
- Listen to the Episode: [RxJS with Ben Lesh](https://softwareengineeringdaily.com/2025/07/29/rxjs-with-ben-lesh/)
- RxJS Documentation: [rxjs.dev](https://rxjs.dev)
- Josh Goldberg's Work: Twitter, Twitch, YouTube, and other platforms as @Joshua K. Goldberg.
---
This markdown file captures the essence of the podcast and focuses on the key discussions, insights, and personal anecdotes shared during the episode, providing a comprehensive overview for readers.
Written by AI. May contain mistakes. Listen to the episode to check what was said.
Transcript
Automatic transcript. May contain errors.0:01RxJS is an open source library for composing asynchronous and event based programs. It provides powerful operators for transforming, filtering, combining, and managing streams of data, from user input and web requests to real-time updates. Ben Lesch is the creator of RxJS. He joins Josh Goldberg to talk about his path into engineering and the RxJS library. This episode is hosted by Josh Goldberg, an independent full-time open-source developer. Josh works on projects in the TypeScript ecosystem, most notably TypeScript ES Slint, the tooling that enables ES Slint and Prettier to run on TypeScript code.
0:41Josh is also the author of the O 'Reilly Learning TypeScript book, a Microsoft MVP for developer technologies, and a live code streamer on Twitch. Find Josh on Blue Sky, Mastodon, Twitter, Twitch, YouTube, and.com as Joshua K. Goldberg.
1:10ben lesh welcome to software engineering daily hey thanks for having me i haven't seen you in a while yeah it's been a bit i'm excited to talk to you you've been doing a lot of really interesting stuff around observables and rxjs but before we get into all that can you tell us how did you get decoding? Well, let's see. I had been doing like little basic programming stuff when I was a kid, but then I went to art school, dropped out of art school after about three years and was working doing graphic design work at Ohio State University working there. I was not going to school there. There was a situation where someone was working on a website or whatever, and I was curious about it and I thought I could fix something or work on it.
1:51And basically I learned how to to do like some basic html and javascript stuff and i had a friend that was like dude you know how much more money you can make doing this and i was like really so at the time there was no google there was no stack overflow none of that i basically loitered in barnes and noble and read books because that was the only way to get recent information like they weren't at the library or anything you know practice doing stuff on my little compact presario eventually I got my first programming gig it was there was an ad they were trying to hire somebody for it was like 80 bucks an hour or something like that for four hours a day I had to call them over and over and over again because they're not calling me back because I you know wasn't qualified for what they were looking for and they finally brought me in they were like they asked me some questions I got probably half of them right and they were like so you know what we're gonna ask is we like I was like do you think you're qualified for this and I was like well no but but I really think I can do what you need done and I'm willing to learn and I'll work for$10 an hour.
2:52So if I work for two days and you don't like me, then you've only paid me for what you're going to pay somebody else for one hour. And you could probably even still hire that person if you wanted. They liked that answer and I got the job and it was a one month contract, which is I think why it was open for so long. And they kept me for like three months or something like that. And they gave me a letter of recommendation because I asked for one. And after that, it was you know, I got other programming jobs and the pay was higher and everything. So. That's a fascinating interview technique to offer to undersell.
3:24Yeah. Yeah. I mean, you can get away with it when you're, how old was I? I was 20, I think, 19, 20. So. So what tech stack was that? And I, I'm just curious. The first gig actually was a lot of just HTML and JavaScript. So the JavaScript was funny. The very first thing I had to write was they wanted, people don't remember this probably, but there's a thing. It still exists. If you get into any browser and you say window.status, there's just an empty string there. And there used to be this property in window you could set called window.status and you set it to any string. And you know, when you hover over a link, modern times, it shows like a little, like the URL underneath, like on the bottom of the whole page, that was the status bar.
4:05And you used to be able to set that manually with window.status. And they stopped allowing people to do that because it was a way that you could be like, aha, you're going to click on this link and it's not actually the link because someone was setting it. It was like a security hole. But what I was tasked with doing was making like a little ticker that played in that window.status of all the deals that were going on in this e-commerce site that day. So I learned about set interval there. That was the first time I ever used set interval and I had to slice a string and make it tick along and continuously wrap.
4:41And that was the first, that was the first professional problem I ever solved. Just getting a ticker at the bottom of the page with a now deprecated API. Right. Yeah. But you can get the string off of it if you want. That's the empty string is still there. That's, that's kind of representative of what you're known for in the web community. Now you're doing some sort of timing, some sort of streaming data shenanigan in JavaScript with bizarre APIs. How did you go from that to working on libraries like RxJS? Oh, boy. It's a long path. After that job, I was doing visual basic programming and ASP, classic they would call it now, but at the time it was just ASP.
5:20Got into doing.NET development, did that for 10 years. The reason I got into JavaScript development was around the time Angular was new, we were trying to build... I was working at a company, They were doing pharmaceutical robotics and they were trying to build like this client that was very rich in features. There was this belief amongst software engineers at the time that JavaScript was a joke. It was a joke language. You could never make good money doing that. It was not the work that you wanted to land on. And I was like, all right, I'm the senior. At the time, I was the senior engineer on that team.
5:58And I'm like, that's fine. I'll do this work. I don't care. and so and you know this was back when you had to like you had to like concatenate your javascript files yourself and all these other things there was like you had to basically build your own build tools so that's kind of how i got into it and i had to answer a bunch of questions on stack overflow about angular to learn things about angular so i'd find ones i didn't know the answer to figure out the answer and answer it it just so happens that that meant that i was one of the top answers on Stack Overflow. And someone at Netflix was building something with Angular, trying to build something with Angular.
6:31And they saw my name over and over and over again. And they said, hey, why don't we see if we can get this guy to come work for us? And I thought it was a joke. I got this email from Netflix. And I thought it was one of my friends screwing with me, like, that Netflix was like, hey, we're just randomly reaching out to you to see if you're interested in working for us kind of thing, right? Like, I didn't apply. And so I went and I was like, all right, I'm going to go to this interview. I'm going to have a phone conversation. That's what I thought. And I had a phone conversation with the person. I was very honest with them about my level of ability or whatever.
7:00And they were like, well, great. We'll have you come out. And I'm like, okay, cool. So I've never been to California. I'm living in Pennsylvania at the time. I mostly spent time in Ohio, Michigan, Pennsylvania. I was like, okay, so I get a free trip to California. And that's probably all this is going to amount to. I'll get a little tour of Netflix. That'll be awesome. Then the next thing you know, one of the, I think the VP of engineering or somebody was walking me out to the front door, like talking positive. I'm like, okay, so I'm going to get an offer, but there's no way it's going to be enough to get my family to move to the most expensive place in America to live.
7:31And then it was, so I ended up at Netflix and at Netflix, this is a really long story. I told you, like we're going to get to the RXJS thing at Netflix was my first introduction to RXJS. I'd never seen it before. And I started using it for some things as I started to understand it better and was working on real-time streaming dashboards. So Netflix, the RxJS really helped with memory management and this really busy streaming dashboards of charts and things. And of course, the updating streams and all of that. There was a feature that we needed. It was a re, I think retry when. So I added that feature through open source.
8:09And I'd also done a lot of work in open source on the Angular code base at the time too. even though I was working in Ember at Netflix, which is funny. Yeah. So since I had a lot of open source experience, I was approached by Jafar Hussein, who worked at Netflix at the time, and Eric Meyer, the guy who invented observables, and this guy named Ben Christensen, who worked on RxJava, who worked down the aisle for me. And they came over and they said, hey, we want to talk to you. And they said they wanted me to work on RxJS, to rewrite it. And I told them I was not qualified. And I I told them they should give them a list of other people they should pick.
8:44And they were insistent because of my open source experience. And so the rest is stuff that people know, I think. But yeah, that was 11 years ago almost now. So yeah, wow. On the reactive-extensions-rxjs-github, we see issue number 482 and pull request number 486. And yeah, over a decade ago. That's incredible. I also love that you've now used another interesting technique, stack overflow as a form of development, that a lot of this was started in part by you finding questions you did not know the answer to and answering them. That's a powerful technique. Yeah. Well, I mean, what I tell people, you know, I don't know that you could still use stack overflow for that now.
9:26But like what people should do if they want to make it somewhere is be conspicuously helpful. and right now the climate's pretty weird right now i feel like all of the really popular developers are these like kind of loud bombastic people on youtube or whatever like they're not i wouldn't classify them as being helpful all the time like sometimes they're the opposite of that i think but there are some of the information they give out is helpful and giving information to people in general is helpful i guess so but i think that being conspicuously helpful either in your own community, giving talks, writing blog articles, like whatever you can do, or just answering people's questions and being kind and nice and that sort of thing, like is really a pathway to success.
10:10Like you're going to be a lot luckier in your career if everyone knows that you know things and everyone thinks that you're useful and helpful than if you just sit and be quiet and keep your head down and that sort of thing. So, and Stack Overflow, that was, it wasn't intentional on my part. It was more just like, I want to be helpful and I want to learn the answer to this question. So therefore I'm picking out interesting questions and seeing if I can figure out the answer. We're going to talk about RxJS, but I have to agree with you for a brief moment that there's this kind of growing area of developers who are technical, who create content, you know, content creators.
10:46And it's a very different thing to be a great content creator versus a great, let's say, contributor. A lot of overlap, a lot of people who do both, but it is two similar areas, similar to how front end and full stack are similar areas. And it can be hard, I think, for people to understand when someone is speaking as a content creator, just to spread information versus educating, helping best practices get spread or even evolve. There's a monetary, a heavy monetary component to the content creation thing too, right? Like there's, it's not just people out there, like I'm curious and I want to be helpful.
11:19Therefore, I'm out there doing things. And, you know, ideally I get rewarded in some way by my getting a better job or something at some point. But like, these are folks literally like making money off of the number of views they get for things, which is, it's a different kind of incentive. Like it's, it's not, there's probably less incentive to be helpful anyways. Like unless the helpfulness is the reason people are showing up to your channel, I suppose. But I'm a little bit cynical about it. I have children. I've watched my children's brains rot watching weird short things on YouTube. I hear the word YouTube and I'm just like, I shudder a little bit.
11:56But it's just because I'm, I think I'm just getting old and cranky when it comes to that sort of thing. So yeah. Old and cranky, he says with a happy smile and laughter. Let's simulate stack overflow for a bit. The heyday of stack overflow. I'd like to ask you a few questions. To start, let's say that you find someone has asked, what is RxJS and why would I want to use it? How would you answer a question like that? Oh boy. Well, I mean, first of all, I know the answer to that question, but like I would probably just start off with you look at that thing and you're like, all right, so most people don't want a whole like book or they do want the book, but they need the summary.
12:37So you start off with some bullet points like RxJS is about streaming data. RxJS is the opposite of iterables. RxJS is the cancelable asynchronous type for zero to n values. And you can just start off with those simple bullet points and then dive deeper into what each one of those things actually means. What is asynchronous data? How is it the opposite of iterables? Why is cancellation important? Those sorts of things. you can come up with something that might take somebody a couple hours to read if you really wanted to get into the whole details of it. But the important thing is that people get the very, very high level bits of it and why they would reach for that particular type or push versus pull and some of these other things.
13:23Yeah, that's a great segue. The next question is, I've heard of these things that RxJS sounds like, but I don't understand the difference. What is the difference between an iterable and something that's provided by RxJS? Oh, okay. Well, so an iterable, we use those all the time. So if you use a for of loop, that's using an iterable. So you've got this, and I know you know this, but this is obviously simulated. But yeah, an iterable, if you use a for of loop, what it's doing is it's taking the object on the right side of that of and it's saying, hey, give me your iterator. And it calls the symbol.iterator thing.
13:58This iterator comes out and all the iterator is is just an object basically with a next method on it. And for every loop through, it calls next and it gets back a result that says it has a value and says whether or not it's done. If it's done, the loop stops. If it's not done, it takes the value and goes into the loop. And so what you're doing then is you're pulling values out when you iterate. So you as the consumer, the person that wants the data is saying, oh, I'm going to do something. Okay, give me the next one. You pull it out. And then you say, I want some data. And you say, okay, give me the next one.
14:29You pull it out. Now, an observable is exactly the opposite of that, where you subscribe and you give it a function that is your next. And it calls your function when it has the next value. So instead of you, the producer saying, or the consumer saying, I'm going to do something. I'm ready. give me the next value, you're saying, I'm waiting for you to give me a value and I will do something with it when you give it to me. So that's more like an event. So any sort of event that you might have, like a click events or mouse movements, or even getting a HTTP back or something like that, those are all models.
15:03You can be modeled as an observable. So that's, that's the, that's the main difference is one is you're pulling values out and the other one's pushing values at you. That push versus pull description makes a lot of sense, I think. And for anyone who has extra time, I think you gave a fantastic talk on this at RevoJS 2023 on pushing and pulling in JavaScript. Another topic that comes up a lot in the context of pushing and pulling is observables. Now you've been working on observables. Can you just define for us what does it mean to work on an observable or even what an observable is? Okay. Well, observables were the original like kind of team that created this was at Microsoft under Eric Meyer.
15:42And literally they went at it from an academic standpoint and were like, what if we took an iterable and pulled it inside out, like made the dual of it, if you will, and made this pull-based type, the iterable into this push-based type observable. That's kind of how it started. Or another way to go about it is if you've ever seen the observer pattern, people don't realize, but they use it all the time. So the observer pattern, there's two things. There's a subject and there's an observer. And the subject is shaped like add observer, remove observer and notify. Those are like the three things on a subject.
16:13And it does what you would think where the observer then has like a notify on it. That's all it has. And you take this, you take this observer, you give it to the subject. And then the subject when by adding it or whatever, the subject, whenever is notified, will notify all the observers of that subject. Right. And so it starts with that. But there's kind of a missing piece in here where you can kind of functionally chain any subject to any observer by like kind of chaining them together. And the way you do that actually is with observables. Like people don't often think about it. But an observable really what it is is you have this type that when you subscribe to it, it executes a function internally and says, hey, create a producer.
16:57here is this observer for you to next values into or call next on whenever you get a value or call error complete or whatever but we'll just focus on the next part of it and what happens is when you subscribe it calls that function creates the producer starts that producer starts nexting values and then when you unsubscribe there's some teardown logic that you've registered in there that will say oh i know how to tear this down with it's a web socket you might close it. If it's a mutation observer or whatever, you might disconnect it, like that sort of thing. So it's a really, really, really simplified type, the observable itself in its raw form.
17:35It exists in every single language that exists as far as I'm aware of. Well, every Turing complete programming language anyway, there's not one in like CSS or something, but it's a really, really, really simplified type and it's used for a great number of things, which is why it's being moved or been put through standards bodies, and it's being now added to the browser. That's a fascinating process that I think would be interesting to walk through, because for a very long time, as you said, this was just a common practice in a lot of libraries. And RxJS is, to many understanding, the most common, the very popular way to do observables.
18:15APIs are the foundation of reliable AI, and reliable APIs start with Postman, Trusted by 98 % of the Fortune 500, Postman is the platform that helps over 40 million developers build and scale the APIs behind their most critical business workflows. With Postman, teams get centralized access to the latest LLMs and APIs, MCP support, and no-code workflows all in one platform. Quickly integrate critical tools and build multi-step agents without writing a single line of code. Start building smarter, more reliable agents today. Visit postman.com.sed to learn more. so what is it about observables that you think has made it so that people not just want to do it but want to standardize it in the web altogether i think the most powerful thing about it there's several powerful things about it but the one of the things that's interesting for for folks is if you've got an iterable uh an iterable is a set of things as we know it's like an array can be an iterable a number of different things can be an iterable so an iterable is a set of things and if you have an observable it's also a set of things but it's a set of things over time.
19:18But what's true about sets of things is let's just say you have a basket. A basket can contain a set of things. If you have a container for a set of things like an observable or an iterable or a basket, you can take a basket of apples and create a basket of sliced apples by putting it through some mapping process of slicing it, right? You can take a basket of apples and make a basket of not rotten apples by filtering out all of the rotten apples. you can do the same thing there's obviously arrays and intervals have map and filter right flat map and these other operations all of those same operations exist on observables but the difference is the observables are events so now all of a sudden you can take events and coordinate them together with these same sort of operations you would use on you know these these static synchronous sets so that's the biggest thing i think that attracts people to it originally like initially.
20:09Now, what I also know is, and this is one of the reasons we liked it at Netflix was it also has this very deterministic teardown feature where when you're not subscribing, it tears everything down. Like if you chain a whole bunch of other stuff together, it will automatically tear everything down. If you have a retry, it will tear everything down and stand it all back up again. Like, and you still have this deterministic kind of memory management that gets really, really hard when you're manually coding events together where you might have to be like, oh, if I get this, then I have to subscribe to this.
20:41I have to start this web socket. And when I get this message, I have to send this HTTP request or whatever. All of those things, if they're mid-flight, become very difficult to make sure that you get all of those things torn down appropriately if you're manually writing it, where if they're all wrapped in observables, it's almost like having a finely block in every bit of your code to make sure that things are being torn down. Yeah, I can see why that would make for a much cleaner code, both to write and read. Using the example you brought up of your very first experience, little ticker at the bottom, that kind of brings up a lot of the concepts of observables and piping through, right?
21:16Where you need to start something, you need to update on an interval, you have constant actions, and then at some point you might want to dispose of it. Or start it back over again, like repeated or whatever. Yeah. Now, easier to read, that's in the eye of the beholder as with all code. But so RCS does have a bad name to some folks. And the reason is, honestly, async programming is really hard. Like there's no way around it. Like you're taking like synchronous programming with iterables or anything else you're doing, if this, then this, if this, then this, and you can read it top to bottom, left to right.
21:47No problem. Asynchronous programming, even with for a wait, you go down, you get to an await statement and it goes off into the universe. Like it's not on your page of code anymore. It's, it could be doing literally anything at that point. You could be awaiting a message coming from Saturn. Like there's who knows what that's doing and it could fail or not fail. So every single bit of asynchronous code, it goes off to some Schrodinger's cat problem and then comes back and then you continue on your way. And you can even do something where you do asynchronous code, but it makes a call out. And since you've left that synchronous code block, you can become reentrant where that call out actually comes back into the top of the same function.
22:27So if you've got any shared state, you've got an issue. And that's not a problem that's unique to RxJS. However, RxJS makes asynchronous work so easy that people create those problems, I think, easier because they're doing more asynchronous stuff, a smaller amount of space. And then they build more complex asynchronous things. and yeah, it becomes difficult. And then the other thing is, if you don't understand what a flat map is, you're gonna have a hard time. It's something, I hear fewer complaints about people who don't do or don't understand the operators anymore because it's been around so long.
23:06And I think a lot of people have exposure to it now. But that's not to say that I haven't seen some absolutely abhorrent code where people were using RxJS for things that they should not be using it for. You know, the completely synchronous things. They'll be like, yeah, let's just wrap this in observables. And you're like, no, dude, this is just, you're going over arrays. Just do arrays stuff. You'll be fine. You've made one request to one HTTP endpoint. It's okay if you don't cancel it when you're no longer using it. It'll just come back. And yeah, it'll eat some resources for a second, but it's probably not the end of the world.
23:39There's a give and take there. How do I know whether the app I'm working on is a suitable candidate for updating to RxJS or upgrading? So observables, and let's just talk about observable itself and not all the operators, just observables. Observables are good candidates for anything where you get more than one value or maybe no values, synchronous or asynchronous, it doesn't matter. So they're a good candidate for things where you could get no values, you could get multiple values, asynchronous usually, ideally. And then the other thing they're good for is cancellation. So promises have no cancellation.
24:11If you have a promise in flight, it must resolve or reject. You can't just be like, oh, this is done now. And if you have it resolved with null, so it's not annoying, then you've got to handle that null every single place that you could be using that promise. Therefore, you have to reject it. But now you have this error that you have to handle and you have to look and be like, is this an abort error or is it like an actual error? And then you have to handle it appropriately. So promises, they're not truly cancelable without a lot of annoying steps. and observables don't have that problem. Observables are more like, this is a push space type.
24:50You cancel it. It's done. Like it just silence. It tears everything down, finalizes itself or whatever it needs to do and carries on with life. So anything where you need some sort of cancellation, observables are really, really good for that. And of course, you know, things with zero to end values. Now, then you get into the operators and stuff. And if you're doing a lot of coordination of events, like say you've got two streams of data coming in and you have to make sure that they line up. Observables are really, really good at that because we have these operators where they can like RxJS has zip.
Read the full transcript
25:22They can zip things together or you can take a stream of data and you can like switch another stream of data to a different stream of data every single time. Like it's really, really good at event coordination. But if you don't have a lot of events to coordinate like and you don't have any cancellation, it's probably OK. You don't really need to use observables for. My little app that renders a chart when I click a button might not need it, but like your rich data visualization platform or your Netflix dashboard perhaps would be a better candidate. Yeah, for sure. For sure. Even if it's not a real-time updating dashboard, if you're in a situation where you're like, look, I just kicked off 12 network requests.
26:00And when they come back, they're all going to do something heavy, like try to update a chart. I know that the user might click away and unmount all those things. you probably want to make sure that those 12 network requests are cancelable. And that doesn't mean you're going to tell the server to not respond. It just means you want to tell the browser, hey, this fetch here is done or this XHR is aborted. Do not do anything with this. Don't even attempt to parse it or read the headers or anything. Just forget it. Because you've got one thread in web development, so it can get a little heavy if the app is busy enough.
26:39Sure. Which is, by the way, I think a lot of web developers don't pick up on because most of the time we have no need for this. You can abort fetch requests, XMLHttp requests in the standard DOM. That's actually a feature. Yeah. So for a while, the fetch for a while did not have abort. They added abort signals for that purpose. But XHR always had an abort. It always had one. So the XHR was the only cancelable way to make one of these requests. And it does have impact. Again, if you're making a bunch of requests, there's a difference between saying, oh, it came back, forget it, like you would do with the old fetch before abort existed, and abort, like just stop.
27:19Because one is still going to do a bunch of work before it gets to your code, and you can tell it to drop it. And it'll have put things in memory that need to be garbage collected on the same thread. It'll have done a bunch of processing on the same thread. I'd probably done some JSON parsing, which is slow as dirt on the same thread. So it's not ideal. But in most cases, like you said, it doesn't matter. It's fine. In most cases, it's not like a big deal. But then anywhere that I'm going to be working, where I'm working on something that's got more intense problems than make one call, load a list of stuff on a page, yeah, they probably need cancellation or some other nicer mechanisms for handling that sort of stuff.
28:01I'm going to want to talk about the future of RxJS. But before you, I can't resist gloating or expressing glee over the operators page in the RxJS docs. You have a very lovely website, rxjs.dev, with a guide that goes over all sorts of articles and information and full docs on all the things you can get from RxJS. And honestly, very well written. A lot of the pages, especially the subscription page, I found to be very useful. But the operators page is one of the biggest lists of just all these different functions. And there's Ajax and bind callback and bind no callback. And it kind of makes sense what's stated in the front page, the introduction to RxJS of think of RxJS as Lodash for events.
28:43You have every possible conceivable kind of event handler in there. Do you have thoughts on the plethora of stuff provided by RxJS for events? I don't like most of them. no because all right so i inherited this this is rcs is not my creation rcs started at microsoft and was actually this is the truth was actually it was written as a build target for microsoft project volta which predates typescript by a bit and the idea there was you write stuff in c c sharp and then compile it you write like dot net code and you compile it to javascript and And so they needed build targets for Rx.net, which was very popular at the time.
29:28So RxJS was up there. And so they had things like, oh, what is it? Like the same thread scheduler and stuff. And it's like, well, there's only one thread. What are you talking about? Like they had all this other, like these weird names for things. And it was very much because it was a build target for that. So there's like, it came from this compiled language where it didn't matter how many methods there were on something because the compiler would remove everything you didn't use, right? to JavaScript land where the versions of RxJS before what I worked on it would just be like, all of these operators are on prototype for observable.
30:02And therefore you get all of them, boom, like the bundle is now this big. So that was one of the things that we had changed. But like every operator you see there, window, window, window, when, window time, like all of these different window things, which I've never seen anyone use, I don't think. Those all came from this original implementation. I'll be dead honest. I don't even think I could name all the operators if I had to. I'd be closer than a lot of people, but I think I'd miss a few. I think that I could get by with probably 10 to 12 of them, realistically, out of a list of 80 or however many there are.
30:39So that's what I think about it. I am happy that what's being offered in the browser is a more minimal but important list of things. RxJS will still be necessary for people to really get the full power of observables, I think, until I can convince them to add just a couple more features. But yeah, when I see that huge list, I just think, if I could get away with it and I can't because it's so widely used, I would slowly trim away at a lot of these things. And I have to some degree, but there's just, I mean, there's only so many ways that you can write window when. So it's there. It doesn't need a lot of maintenance.
31:16Will it be in future versions if I have to rewrite RxJS for this new observable for the platform? Will window when be there? Probably not. But that doesn't mean the previous version of RxJS won't still be actively maintained because there's so many people using it. TBD on whether every single one of them will exist. Right. Yeah. I'm sure I'll get people that are real excited to contribute that want to add it, but like whether or not they can prove to me that we actually need it out in the world, like, yeah. The most telling thing is when I worked at Google, I could look through hundreds of thousands of build targets that use RxJS and see what they actually used.
31:56And so I know which ones are used and which ones aren't used that often. And some of these people are like, were RxJS nuts. They were so crazy to use RxJS for things. So they tried to use all the operators. The window one I'm picking out in particular, because I recall no one using window out of all of that. So they use buffer. They use all the different buffers and all these different things. They use every other operator. But I remember a window in particular, I didn't find too many instances of at the time. Is there an operator called instance of? I'm wondering if that's an accidental pun you made.
32:31There's observable instance in the docs. Okay. But no, let's talk about this actually. For some time, I remember on social media, there was a small push to try to get observables built into JavaScript through TC39. That's not what's currently happening, but it's still happening in some form. What's going on with observables? Right. So observables are being standardized through the W3C, the WhatWig added to the browser. And they're being added to the browser in that anything that's in event target, so like buttons or anything where there's add event listener, remove event listener, will now have a when method on it.
33:10And you can say when click, and it will give you an observable of clicks. And the advantage to using said observable of clicks is when you subscribe to it, n times, it only really actually adds one listener. So it's multicasting that. So the observables for the web platform are a little bit different than the ones from RxJS in that they are multicast by default, which means they're reference counted. Like if you have a bunch of subscribers to it and it'll wait for all of them to unsubscribe before it removes that event listener. So it's very useful for that. It's going to be useful for a variety of other things.
33:46Like you can then do like the whole, the classic idiomatic RxJS example of like, When you mouse down on this thing, you take all of the mouse movements until there's a mouse up, right? And you can now create some draggable elements or some movable thing. Or you can draw on a canvas or whatever you want to do with that information. But that's the sort of use case that it has built in. And then, of course, it has the type where you can create your own observable. It's got all of the important operators on it. It's got, you know, map and filter and these things. so that's kind of how it's landed and that is the result of about 10 years ago it was in tc39 proposal that stalled and the idea was put forth that well there's no we need a use case to add this thing to to javascript we can't add this thing to javascript without a known use case and and they're like well the best use case is probably event target why don't you try it over at the W3C.
34:46And so that's what happened. Like five or six years ago, I was tasked to write up a proposal while I was working at Google. And I think their proposal number was like 544 or something like that. And it was this hugely liked, it's got tons and tons of thumbs ups and rocket ship, whatever emojis that people add to GitHub issues, probably more than any other issue that they've had. Then we had to make the case for it. And the case was made that these things exist everywhere because over that period of time, like the usership for RxJS had not only like gone upwards, but there was tons and tons of libraries that are widely used like React Router and Vue to some degree and trying to think Svelte that had their own observables inside of them.
35:32Relay had its own observable inside of it. Like they were indistinguishable from the RxJS observable, except for their own little proprietary things because they needed them for various purposes. If you go to the readme on the proposal, you can see all the uses of it. The other thing is I could say, what is it, like two or three years ago, I looked in the overall downloads of RxJS since I had started working on it was up over 2 billion total for the time that it existed. So the number of total downloads every year is still more than all of the frameworks added together. like there's there's a lot of evidence that people want to use observables for things even though there's plenty of people loud people out there like oh observables are the worst developers are really bad i can tell you that but observables themselves they never hurt anybody on their own it was always in the developer that hurt somebody with them there's a lot of so the tc the tc39 process and the w3c process are very very different and the w3c what wig stuff i think you need to have, and someone can correct me if I'm wrong about that, but I think you need to have two implementers, people that actually create browsers interested in this in order to proceed to the very first stage.
36:42Then after they're interested, it goes, you go to something like TPAC, it's discussed, there's a proposal, all this other stuff. And then an implementer implements it and they put it behind a flag and there's some discussion and more discussion and so on. So that's where we're at. And like right now, it's very, very close to being released. It's already been announced that we're going to try to land it here. And I think Chromium 133 or something like that. That's very exciting. So yeah, so it'll be available. That makes it available in Chromium and Edge and whatever the newer Electron is that comes out after that.
37:15Firefox and Safari and Opera, all those folks are interested in it as well, but I don't know when they'll get to it. They've been a little slower to release features. It's not their fault. It's just how things shake out, I suppose, but they definitely all have interest that all those people were involved in the discussions that I was in. So, and then the only other thing that needs to be done is it needs to be added to node who has vested interest in wanting it in there because they have event target as well. So after that, it'll be everywhere if, if not in some browsers that are slow to catch up, but the polyfill is pretty small.
37:50So this is what you mentioned earlier that the core API, the stuff that you don't wrinkle your nose at is not that much stuff. But from those very bare primitives, you're able to create a lot of really beautiful logic with the observables. Right, right, right. Yeah, almost everything I would want to use is there. You've got your finely and your catch. And instead of tap, we have inspect, I think. There's some really good stuff in there. The only stuff that we don't really have yet that does belong, but it's not there right now, is there's no concat, for example. there's no merge is one that's kind of powerful where you can like merge two observables together and like mix their events sort of thing but like which is fine because like i said we've got low dash for events so this now like literally rxjs and low dash are kind of on the same path where low dash like existed before arrays had so many nice features i think arrays used to just kind of have like filter and map and i think maybe reduce and now there's flat map and all these there's a variety of ways you can use an array now that didn't exist whenever Lodash first came out.
38:59And so now I think that RxJS is probably going to be kind of in the same path, which is fine. That's great. I'm happy to relinquish control of that too. There's no reason that Ben Lesh of all people should be the arbiter of everyone's favorite async push base type. Like that's not, it's probably not a good state for the world to be in if that's the single point of failure for that because I'm not that great of an open source maintainer. I don't know, Ben. You've distributed or demonstrated a lot of the really common positive attributes of an open source maintainer, which is you wish people would use fewer of the features of your library.
39:35You've expressed excitement about pushing it to a better place, in this case, the web platform. To me, those are pretty good indicators that you're doing a good job. No. Well, great. I'm glad. I'm glad to hear it. Yeah. What does that mean for the next major version of RxJS? Are you just going to be a thin wrapper around observables? I'm working on it now. I had to put it out. So originally, the next major version was going to be, I remove all the deprecated stuff, make the total size of RxJS another 20 % smaller because I cut it in half the previous version. I was going to make another 20 % smaller in this version.
40:07And then this proposal caught on and I was like, okay, but then it really caught on. I'm like, okay, this is actually going to happen. And it's going to be maybe a little different shape than our observables. So I stopped all new production on RxJS code because I wanted to make sure I did. I thought it'd be silly to release RxJS 8. And then immediately afterwards, here's RxJS 9, the thing that is, you know, wildly different because it's trying to make peace with the platform. So right now, and especially also because it's just me working on this right now, what's going to happen is RxJS 8 is going to end up being targeted at the web platform shape of Observer.
40:46and wrapping that and relying on a polyfill that will provide if you don't have it, because there's going to be people that don't have it. And then RxJS 7 will exist for a very long time. I don't know how long I'll extend my support of that, but we're going to have to keep it going for quite some time because there'll be a lot of people that are stuck on RxJS 7 or using RxJS 7 until I figure out how to wait to provide some sort of backwards compatibility or migration path for for folks, if that's even necessary. If you're using ArcGIS 7, hell, if you're using ArcGIS 6, it's fine. You probably want to move to 7 because it's faster and smaller.
41:24But if your app works, I would not spend tons of money and time updating something like that unless you really, really were excited about it or there was some great pressing reason to do it. And younger me would be like, no, you update to the newest thing all the time. Don't be crazy. You're going to get so behind, but older and more experienced me has learned like, oh, you know, it's okay if you're using this old version of whatever, there's features to ship and make sure everyone's getting paid and making money at your company. And don't worry about what version of RxJS you're on, but you know, I'll do my best to try to provide a path for people.
42:04And, you know, also make sure this version of RxJS 8 is a lot more simple. And hopefully, hopefully at the end of that, like I can just kind of watch it and make sure it stays on a good course. And as I stated before, there's only so many times you can, so many ways you can write a window when or whatever, like it's not, it doesn't require a ton of maintenance once it's, once it's up and running. It's not like a, it's not like a framework or something where there's, there's the platform shifting underneath it. This is pretty, pretty close to the metal JavaScript stuff. You are working at privatives.
42:39You know, we recently had recently interviewed Jessica Janik from Angular, for example, who went on in detail about all the interplays between streaming and suspense and server rendering and delays and deferrals. And yes, it's great to not have to deal with that ever shifting target of what users need and what the browser does. But at the same time, you are dealing with complex data. I mean, at the end of the day, moving from RxJS, let's say six to seven, or even six to eight is a very amorphous kind of hard to measure task compared to say just upgrading your typescript version right like there's a lot of stuff that's really hard to detect when it asynchronously breaks unexpectedly i think the the thing about it is that the contracts are like when when each thing should happen is very like kind of academically constrained so there's a set of guarantees like you can't you can't next after you air you can't air twice like you know there's there's all these these things as like if there's an error like before, and this is actually fairly recent because not every version does this, but like if there is an error, you tear down everything.
43:44As soon as you know that something bad has happened, you tear down everything and then you push the error. So like there's all these rules that exist about how it's supposed to behave such that the only real rule that's changed with the new observable in the platform is that it is ref counted and multicast. In some ways may surprise some folks and in other ways, and most of the time, I think it's going to be helpful to people because the reason that decision was made is because the very, very primitive version of observable, which is cold by default, and we'll start a new subscription for every time you subscribe all the way up to the chain, that behavior, I think, despite being the more correct behavior, the academically correct behavior and the more composable behavior, I think that behavior confused some folks.
44:32Like a lot of people were thinking, oh, well, if I start this stream over a WebSocket and I subscribe to it seven times, there should only be one WebSocket. And what would happen if you wrapped it with an old observable would open N WebSockets for however many subscriptions unless you shared it or whatever. So, and if you go through and you look at people's code bases that use a lot of RxJS, everything's like share, share, share, share, share to prevent that from happening. So this is kind of does that behavior by default. So that's the only place that it'll really get hairy when people go to convert things over.
45:04There's other things that would require some manual work. Like, for example, RxJS 7 uses these pipeable operators. With pipeable operators, you're basically doing functional piping. And the reason that exists is so we don't bloat bundle sizes by adding a bunch of methods. Well, the platform just has methods on the observable. So we need to come up with a better way to do that. I think I've developed a pretty good way. We'll see how that goes through alpha. And then we need to make sure that we still support the old pipeable operators and all these. So there's a variety of things that have to happen.
45:40It's definitely not going to be easy. I would never sit here and be like, oh, it'll be easy. And then someone else will listen to this at some point. They'll be like, God, that Ben Lesh, that bastard, I can't believe he said it would be easy. No, but you'll get paid for every hour that you do it. I guarantee it. Well, I don't guarantee that. You could be open source, you poor bastard, but if you're not working in open source,
46:04then you're, you're ideally collecting a paycheck while you're doing this and, you know, enjoy, enjoy the money. You're welcome. Thank you. Cool. Well, that's all the time we have for RxJS as much as I would love to dive into so many of the cool things in it. I just have one last question for you, Ben. I'd like to end with something not technical. You dropped out of art school, but you're still an artist. Can you tell us any particular artsy things you've done recently that you found? Oh, well, the most recent thing I did was, and it was the first oil portrait I have done in, God, 20 years probably, is I painted a portrait of my parents, my mom, my poor mom, she's terminally ill.
46:46And like after art school, I'd never gotten them any paintings ever. Like I went and started working and I was busy and then I had kids and blah, blah, blah. And like, I never painted everything, anything and gave it to my parents. So this last, I mean, a couple of months ago, I had finished a pretty good size painting. It was three feet by two feet or maybe a little bit larger portrait of both my parents side by side, like the classic portrait thing. And I was able to present that to my mom. That was a big deal. That was a big deal. Do you still draw often? I think I remember you drawing at a conference.
47:17Yeah. I think I drew a picture of you actually. I drew a picture of you when you're on stage. So So yeah, I do draw. I have a sketchbook that I bring around. Usually I do it on trips. When I'm here at home with kids and work and housework and everything, I don't get the time I'd like to do it. And if I do it, it bothers me when I get distracted in the middle of it. But if I go to a conference, sometimes I'll sit there and I'll sketch the speakers on stage. Or if I'm traveling abroad or I'm at an amusement park with my kids and they're off doing their thing, I'll sit somewhere and I'll just sketch people I see sitting around.
47:50So I like that. That's the best way I kind of do art these days is just quick pencil sketches of random people as I'm roaming about. Well, I'm just curious now to end the interview on the curiosity note. You get so much out of open source, clearly. You've had a wide impact. You've improved the platform. You've tackled very many interesting problems, design, code, et cetera, with RxJS. What are the parts of your brain that you find are being scratched by the drawings, the art side that arts by RxJS in your day-to-day job? I mean, they both kind of do the same thing. You're building something from scratch, right?
48:23So there's a process, you're building something from the ground up, like you have to kind of anticipate the next thing you're going to do while you're doing it. So if it's a painting, you start with an underpainting and then you build layers up and you think about, you know, where's the dark and where's the light and like, what, what do I need to accentuate over what the actual photo shows and those sorts of things like you, you're problem solving effectively in order to produce something that other people can enjoy. And like, that's the same, it's the same thing for me with, with open source work or work stuff I do at work.
48:55I am generally problem solving to give something to other people that they'll enjoy. So that sounds sappy, right? But it's true. It's true. That's what I do. It's a lovely sentiment and it's a great way to end the interview. Ben, if there is anything people wanted to find out more about you, about RXJS, is there some place or set of places on the internet you would direct them? Oh, let's see. I'm on Twitter at Ben Lesh. I'm on bluesky at benlesh.bsky.app. For now, I didn't put my custom domain in. I'm not that cool. But yeah, those would be the two places you could find me other than going and trolling on issues on GitHub.
49:35Feel free to ask me questions. I try to be helpful with people if they message me. I do try to respond. Although Twitter's DMs used to be my go-to spot. And recently, they've gotten so gnarly with so much spam that I have a hard time even opening it and paying attention to it. So I'm sorry if you messaged me in there and you fall in with all the other people trying to get me in some sort of cryptocurrency scheme. I do have this one blockchain. Just kidding. But no, Ben, thank you so much for coming on to the show. This was fantastic. We talked about RxJS and observables and the platform, and I'm really excited for where you're taking the project.
50:09This is good stuff. Thanks, Josh. I'm happy to see your face again. Yeah, it's been a bit. Cheers. Thanks for listening, y 'all.
From the publisher
RxJS is an open-source library for composing asynchronous and event-based programs. It provides powerful operators for transforming, filtering, combining, and managing streams of data, from user input and web requests to real-time updates. Ben Lesh is the creator of RxJS. He joins Josh Goldberg to talk about his path into engineering and the RxJS library.
The post RxJS with Ben Lesh appeared first on Software Engineering Daily.
