chantastic.fm

75: Sunil Pai on The Future of UI Frameworks

Episode 75 · December 5, 2019 · 00:48:24

Hosted by chantastic · With Sunil Pai

Sponsored by Linode and Infinite Red

Download MP3 · Jump to transcript

React Core Team member Sunil Pai in the chair today.

React is a complicated project. It's open source but lead by facebook. That's a hard pill for many to swollow. But, for it, we get a framework that's battle-tested at facebook scale — every experimental API tested by billions of users.

Today, Sunil and I dive into the future of React as a UI framework, how Concurrent mode marks a shift in focus from developer experience to user experience, and what it'll take to finally get better designer tooling for React.

Featuring

Links

Sponsors

Linode

Instantly deploy and manage an SSD server in the Linode Cloud, with your choice of Linux distro, resources and location. linode.com/react

Infinite Red

In over your head with a React or React Native app? Infinite Red can help. They're React Native core contributors who've been designing, building and shipping apps for over 10 years. reactpodcast.infinite.red

Transcript

[00:00:00] Michael Chan: This is React Podcast. I'm Chantastic. Today we've got React core team member Sunil Pai in the chair. React is a complicated project. It's open source but led by Facebook. That's a hard pill for many to swallow, but for it, We get a framework that's battle-tested at Facebook scale. Every experimental API tested by billions of users. Uh today, Sunil and I dive into the future of React as a UI framework. How concurrent mode marks a shift in focus from developer experience to user experience, and what it'll take to finally get better designer tooling for React. Thanks to our sponsors this week, Linode and Infinite Red. Deploy a server in Linode Cloud in minutes. Offering cloud computing plans for every workload, from simple web hosting to CPU-intensive needs like video encoding and machine learning, Linode offers a balance of power and price for every customer. When you're in the business of delivering content to customers, you know how important it is to have that content on a server as close to that person as possible. Linode helps you do that. Linode has 10 data centers worldwide. 2 were just added in Toronto and Mumbai. Combine that with native SSD storage, a 40 gigabit network, and the industry's fastest processors, they can help you serve your customers as fast as possible. Visit linode.com/react to get a $20 credit. Give them a try. That's linode.com/react, and the promo code REACT2019 will automatically be applied. Infinite Red builds beautiful, functional apps in React Native, and they want to help you bring your ideas to life. Got an idea you want to share with the world? They can help you build it. Got an app that's old and all kinds of busted and need help making it agile again? They'll help you fix it. Use their expertise in design, mobile, React Native, Ruby on Rails, Node, Phoenix, and Elixir to get your app back on track. Right now, when you start a new project, you'll get 2 tickets to Infinite Red's Chain React Conf. Chain React is North America's only React Native conference, and attendees say it's the friendliest, most educational conference they've ever been to. At the conference, you'll get to meet the team and see why they're the React Native industry experts to take your app the distance. To start a project, go to our very special URL, react podcast.infinite.red. That's reactpodcast.infinite.red. And get 2 tickets to Chain React Conf 2020. Build a beautiful, functional React Native app with Infinite Red. Sunil, welcome back to React Podcast. Thanks, Michael. Glad to be back. I uh I I knew we were coming back to React Conf. We were both gonna be here. And I thought I need to get you back on the show because I had so much fun last time you were on the show.

[00:03:16] Sunil Pai: I had a I had a great time too. I remember it was good. It was right after my talk and I was quite pooped, but I had a great time talking to you. It was fun.

[00:03:25] Michael Chan: I remember also you— uh it was particularly good because you messaged me a couple of days later and you're like, "Hey, is there any way we could uh cut some stuff out of this?"

[00:03:34] Sunil Pai: I'm surprised I did not get fired for at least 2 or 3 things in that. And for the sake of, like, for my own sake, I don't want to point out what those bits are, but it still worries me.

[00:03:43] Michael Chan: We'll leave that as an assignment for the uh the listener. So are you excited for this conference? You're just kind of on like on easy mode, right?

[00:03:51] Sunil Pai: Super excited. This is my first React Conf, like a legit React Conf. Uh, and I'm surp- like the other two great things about it is I'm on the team, which by the way, still don't believe, like it feels really weird. And I don't have to give a talk, no slides, no nothing. I'm just going to be cruising through the day.

[00:04:08] Michael Chan: This is like the ideal scenario. To make things better, we just got room service. Cheers, man.

[00:04:14] Sunil Pai: Cheers.

[00:04:18] Michael Chan: So that's one of the things I wanted to talk with you about. I wanted to- last time we spoke, you had, I think, just recently gotten hired on at Facebook and you were working on the Oculus team. So we talked about some of the stuff you were doing there. But like pretty shortly after, you moved to the React team. What did that- like what did that transition look like? How did you- how'd you go from like one to the other and like why did they bring you in?

[00:04:42] Sunil Pai: Oh, completely strange. Like I did not expect it at all. Um, I was in Menlo Park for an Oculus offsite, uh, and Sebastian and Sophie pulled me to the side and they were like, okay, listen, like, do you just want to come write React with us? And I was like, I guess, are you sure? Are you mistaken? Uh, it was a little strange, uh, because, and this was weird because I had no React contributions at the time. I've I've never contributed to the codebase before I joined the team. Interesting. Which is why I was like, are you all sure? I mean, like, sure, I'll do the job, but really? And they're like, no, yeah, sure. Like, we all like you. It's cool. Just join the team. So that happened. And then it took another 3 months for me to like wrap up my stuff in Oculus. Uh, that was pretty good. Like, don't get me wrong, like, uh, Oculus for me was a dream job. And the only job I would have left uh it for was a position on the React team. And that's exactly what happened. Uh, so that was nice. Uh, and now I get to hang out with Dan, Dominic, and Rachel has joined the team on the in London. And, um, yeah, it's super fun.

[00:05:46] Michael Chan: Awesome. What's the what's the London office like? So there's about, like you said, it's you, Dominic, Rachel, and-

[00:05:52] Sunil Pai: That's that's the React team in London.

[00:05:54] Michael Chan: Okay, cool. Um, what's that like? Do you do you all work together all the time over there?

[00:05:58] Sunil Pai: Uh, kinda. So, okay, so to get into that, I have to tell you what the React team is like. I don't think anyone actually discussed this, so you get to hear like the inside scoop, behind the scenes. Beautiful.

[00:06:09] Michael Chan: That's what I'm after all the time.

[00:06:10] Sunil Pai: So it's a team with very strong personalities, and uh because very few people join them at all, like very rarely, they suck at onboarding, like getting new people onto the team. They're like, okay, you're on the team now, figure it out. And I'm like, are you serious? Like, I have no idea what to do next. Uh, but the best thing about it is, of course, that these are people that I've known for years. They're kind of friends, um, and they're very, very good at their jobs.

[00:06:37] Michael Chan: Yeah.

[00:06:37] Sunil Pai: So it's been an a very intense learning process for me. This last year has been super strange for me. And that's just it. Like, even when I was in Oculus, even though I was a part of Facebook, it was easier because like the things I was building were for thousands of people. Yeah. Now suddenly this stuff goes out to 2.5 billion people the moment you make a commit, which is super weird. Like, It's- and that's just it. Like, if you break it, you have to fix it. There's nobody else who's gonna find out that you even broke it. Like, you need to find it, fix it. Uh, and like, at the React team, which means it affects literally every other team in Facebook. So you you you can't- you have to be, I think, very intentional about the work you want to do. And but if you get that right, the impact is amazing. Not- and that's just it. You affect every team in Facebook. 2.5 billion users, but also then suddenly it goes into open source and 3.5 million React developers are using it. 3.5 million React developers, by the way, that's my estimate. That's a rough estimate. That number makes no sense to me.

[00:07:38] Michael Chan: Yeah, it's wild.

[00:07:39] Sunil Pai: Which is why, for example, I think when people point out, oh, the React community has a problem, I I think to myself, oh, it's both a React community and a tech community problem because the React community is so huge right now. It's about 60% of all JavaScript developers now use React.

[00:07:54] Michael Chan: Wild.

[00:07:55] Sunil Pai: Why, by the way? Why? Use something else, it would be way less stressful.

[00:07:59] Michael Chan: That seems like a lot of pressure because you have both the internal pressure of like making it work for Facebook, but then also the external pressure of the the community. Because I feel like a lot of us are familiar with the the pressure of making something uh work for different teams in our organization. Not at the scale of Facebook, but like, you know, but then very few of us are also trying to make something that works for the community as well.

[00:08:26] Sunil Pai: Oh, even stranger, like, uh, while, while I've been doing open source for a while, I've never actually been part of an infrastructure team. I've always been a product engineer. I think like that's kind of like where my strength is and all that jazz. So this for me, it was also like, um, a different way of prioritizing things or even like building on things. You can't just half-ass something and say, okay, I'll iterate on it. Like over the next 2 months. No, if you get it, you you gotta get it right. Like you'll have to get- but it also means that you have to speak to like 10 teams and get it right.

[00:08:55] Michael Chan: Yeah.

[00:08:55] Sunil Pai: Um, very strange experience, but incredibly learning. And like everyone's on- everyone on the team is kind of supportive. They've done it. There's like a playbook to do things.

[00:09:04] Michael Chan: Yeah.

[00:09:04] Sunil Pai: Um, I uh I don't know how many people on the podcast know, but uh React- Facebook runs on React Master.

[00:09:11] Michael Chan: Okay.

[00:09:12] Sunil Pai: So we literally sync from the GitHub repo like thrice a week now.

[00:09:16] Michael Chan: Really?

[00:09:17] Sunil Pai: Yeah, sometimes more. If we like, sometimes we'll do it twice or thrice a day if we are working on something interesting.

[00:09:21] Michael Chan: Interesting. So that was one thing that I wanted to ask is like, is it like, how split is it? Like, do you have like a, like a kind of like a copy of of React for Facebook and then you like, you know, sync them up manually? Or is it you're pulling from the the master repo on GitHub?

[00:09:38] Sunil Pai: We are pulling from master, uh the master repo. It's not like a duplicate repo inside Facebook. No, there's a script that literally Copies down everything from master, builds the React bundles for Facebook and deploys it. There's no separate repo inside Facebook.

[00:09:53] Michael Chan: Wild.

[00:09:53] Sunil Pai: It is like, it's strange.

[00:09:55] Michael Chan: Yeah, that is strange. How, how does, so how does that work then when you're developing? Cause I know there's a, um, like this week we saw certain features, like was it useTransition and, uh, useDeferredValue? That's it.

[00:10:07] Sunil Pai: Is that right?

[00:10:08] Michael Chan: And those, uh, those got pulled from work in Facebook. Um, how does that typically, like, how does that like happen when you have something that you need to make to support teams at Facebook, but it's not necessarily like kind of like open source-y yet? If you can talk about that.

[00:10:26] Sunil Pai: I can totally talk about it. And that's just it. I think, okay. So the reason the React team doesn't talk about new features openly is because we want to temper expectations. We have made this mistake in the past where we are like, oh, we are working on something exciting. And then some- everybody's like, where is it? Where is it? The best example of which is probably concurrent mode.

[00:10:45] Michael Chan: Yeah.

[00:10:45] Sunil Pai: What's interesting about, by the way, this podcast, dear listener, is that we are doing it the day before React Conf, and there will be announcements tomorrow that change whatever we're talking about right now. Anyway, but concurrent mode, we have- we started talking about it about a year and a half ago, I think.

[00:11:00] Michael Chan: And we can talk about it. It's gonna be- it's gonna be a couple of weeks, so we can talk about it as if it already happened.

[00:11:05] Sunil Pai: Sure. The point being that Like, I think we learned our lesson that people think that it's, uh, um, what's the word for- it's imminent. Like, it's- Oh, sure. So we don't talk about it. But anybody who's having a look at the PRs knows exactly what's going on. It's very strange to me that people didn't notice SuspenseList, which is an amazing feature.

[00:11:25] Michael Chan: Yeah, yeah, yeah.

[00:11:26] Sunil Pai: It's been in master for months and months now. Like, we've been using it inside Facebook.

[00:11:30] Michael Chan: It is. So I've been trying to create some course material, like, in anticipation of um of of this conference and like Suspense. And I hadn't really followed along, but it was amazing to see that everything was there. And also just using master React, um, there were warnings to say like, max duration isn't here anymore. And then you like go look at the repo and like, oh wait, there's all this other shit that like I just didn't even know was here. Right. And it's in, it's in the production build of of React.

[00:12:00] Sunil Pai: Oh, and it's being used in Facebook. That's just it. Like we don't build a feature and then not use it. It's being built. Oh, so React is driven by Facebook's needs. Like it or like it, it's a blessing and a curse. It means that it is incredibly well tested by the time it comes out and all that jazz.

[00:12:15] Michael Chan: But you get the benefit of Facebook scale.

[00:12:18] Sunil Pai: Exactly. Yes. And that's kind of bad also because it means we are not building a static page generator for now. We might have a different story later. Sorry. Pardon me. Do you edit out burps, by the way? I was curious about this.

[00:12:31] Michael Chan: I don't know. That's a good question.

[00:12:33] Sunil Pai: Okay. Anyway, so there was a burp there, listener, if it wasn't caught by the mic. Anyway, my point though is that if you see a PR that's probably landed, there's a good chance that it's being used in product code in Facebook within days, if not hours. Okay. Like there's the reason that it was built was because there's a need inside Facebook and then it's built and iterated on. Uh as another example, uh Dominic and Nicholas worked on a whole bunch of uh uh on the event system stuff. I think it was codenamed uh React Flare. Uh I don't think that'll ever reach um open source soon because it was experimental. Yeah. But experimental doesn't mean that it wasn't used inside Facebook. Facebook is the testing ground for our experiments. It's not just built and then we make like a couple of demos for ourselves. No, like we literally pick a product, push it to production, have a few million people hit on it and see like what errors pop up and then either pull it back or- So it's kind of exciting to work with this kind of constraint/strength where Your test- you know what, uh, I've been working on something pretty exciting with images and how we load images in concurrent mode. Uh, and uh, Yuzi will talk about it, I think, tomorrow in the keynote. And this is the first feature that I built in a JavaScript library in tandem with a user research team. Like literally reading user research and with the team who were like, okay, this is the way that it should probably behave. And this is now going to be a React feature that people will get for free. The moment they like install it or use it. That's kind of amazing. Like as opposed to the open source uh lone ranger on a weekend, built a great feature and wait waiting for people to like try it out and stuff, right? Like so very strange way for me to build features for JavaScript libraries. It's been fascinating.

[00:14:18] Michael Chan: Interesting. Um, now I'm gonna dive into that, but like, do you feel like this touches on something that I'm kind of curious about is Do you feel like the way that Facebook uses React and the way that React is developed to support both the community and Facebook, do you feel like more things are gonna be developed as, um, maybe like like add-ons, I guess, to React, as opposed to being like built into like core? Like, uh, I I think specifically, um, I know that some of the work on like in uh React Flare is focused on like a different type of like event system, right? But that seems like it could kind of be used maybe as like an add-on. This is bad language, but like as an add-on or like some type of like augmentation of of React.

[00:15:07] Sunil Pai: Uh, so you're actually right. And it is something that we have been exploring. Uh, instead of just using two packages, React and ReactDOM, uh, the Flare work actually resulted in a third package, which was React-Events. And had a bunch of like subfiles, uh submodules underneath it. Uh some of the thinking behind that was that uh if we are going to do a new event system, which we might not, by the way, like I said, this is- Sure.

[00:15:31] Michael Chan: Yeah.

[00:15:31] Sunil Pai: It's actually like more likely than not that it's not going to happen at this point.

[00:15:36] Michael Chan: But at the same time, it's in the repo. Like people know that it's out there. Can play with it.

[00:15:40] Sunil Pai: It's going to morph into something else. Maybe that's a better way to put it. We have learned our lessons from it and Dominic and Nicholas are going to work on it and make it something. But the idea was that you shouldn't have to install uh or download code for every platform for a particular browser.

[00:15:55] Michael Chan: Okay.

[00:15:56] Sunil Pai: Uh I think a good example of that is uh Safari 13 supports pointer events.

[00:16:01] Michael Chan: Okay.

[00:16:01] Sunil Pai: Uh or whatever the new Safari is called. I guess I think it's version 13. I don't I don't know. Right? Uh but we don't want to send, so which means we don't want to send polyfills for Safari.

[00:16:11] Michael Chan: Yeah.

[00:16:12] Sunil Pai: Something as simple as that. Traditionally, React has not shipped- has not ever shipped dead code. But if we started supporting every platform in React DOM, we would now be shipping dead code. Yeah. Code that would not run on some platform or the other. So we have considered it. Um, I think that said, I think like we have some other ideas, not just around React and its internal dependencies, but also how we load product code. Without going into too many specifics, I think we are like the next year or so, we are starting to think about uh how the server-side rendering story ties in with sending code and dependencies to a browser. Uh so I think we don't really want people to start uh directly using multiple packages. Like we'll try to automate that as much as we can, like or just make it part of the build system. But yeah, I think we are getting to a place where we don't want to ship everything at once.

[00:17:08] Michael Chan: Yeah.

[00:17:09] Sunil Pai: If if that answers your question.

[00:17:10] Michael Chan: Yeah, no, no, no, absolutely. And I guess that's that's something that I'm I'm fascinated by because, you know, when I when I started, it was like you import React, right? There wasn't even like React DOM, right? Exactly. And now the the platforms, like those kind of split out into um different renderers, I think I think they are. And um and it seems like as the capability of React grows, like the goal is to keep React really small and then just have you kind of almost like build more of the framework that you need for your platform.

[00:17:43] Sunil Pai: So without directly answering your question, uh I know that I know that where we are right now is definitely not uh where we see ourselves in like 2 or 3 years or like 5 years. Um like I think that's actually kind of the driving factor of like React, right? Like Uh, React competitors come at us, and I don't- I, I, I use that- that's a terrible phrase because it's not really competition. Like, it's fine, no one's winning.

[00:18:09] Michael Chan: Other libraries in the same space.

[00:18:11] Sunil Pai: Other libraries in the same space, I think, try to compete on the feature set that we have right now.

[00:18:15] Michael Chan: Yeah.

[00:18:16] Sunil Pai: Uh, which is good. It's great because it- people are building stuff today. And now, uh, I always say this every time anybody asks me, like, I consider Preact to be a React success story. Hmm. Uh, I- Rich Harris is gonna hate me for saying this, and I'm pretty sure I dissed him on the last podcast as well. Uh, but I consider Svelte to be a React success story.

[00:18:38] Michael Chan: Interesting.

[00:18:39] Sunil Pai: If React hadn't changed what it did in 2013 when it came out, and for the next 6 years after that, where it keeps challenging people with new ideas, uh, a lot of other UI frameworks would have frozen their thinking where they were. Like 3 or 4 years ago, where they would have been happy with that. Maybe that's good, like it works for a lot of people, don't get me wrong. Uh, but React itself, React and the React team is not satisfied with where they are right now.

[00:19:06] Michael Chan: Sure.

[00:19:07] Sunil Pai: Uh, there's an endgame in sight that's gonna take a few years to get to, that's going to take not just techno- technology change, but like social change, tooling change, the way our ecosystem operates with not just with like code, but like how do we get designers into the game?

[00:19:25] Michael Chan: Yep.

[00:19:25] Sunil Pai: Such a simple fundamental question that no real framework has an answer for today. Uh, so that for us is like, I think, the eventual goal. Uh, we have the patronage of Facebook and the fact that we do great work for them uh to support us right now. But I think eventually the game is to like figure out how do we solve UI programming for way more people. I am impressed with 3.5 million React developers right now, but that number I hope gets a lot bigger in the future.

[00:19:52] Michael Chan: Well, that's one thing I love about the way I hear you and the React team talking about React. Um, and I think it's exemplified in concurrent mode as like a mental model, right? Like, let's take like actual concurrent mode in practice out of it. But like the idea that it represents is a focus not so much on code or the APIs, but on the user. And that's something that I, as someone who does a lot of like interaction design and like user interface design, like those are the problems that as a designer, like I'm tasked to solve for people, right? Like it's a very like human part of programming. And I feel like a lot of uh- Alternate libraries in this space Um, really focus on like the the developer experience, like the the the code experience. And you know, maybe following the lead of, you know, you know, face uh of of React or not. Um, but not having that that ultimate vision for like how do we make things better for for the user. And um, that's something that I've really, really enjoyed about watching React. And then also just like kind of like talking with people on your team. Um, do you converse about React in those terms, like as a team?

[00:21:13] Sunil Pai: I think the team gets annoyed when somebody else comes up with a new benchmark or a new, like, micro complaint about like React and stuff. And we we are like, yeah, we know, like, we know this part of it sucks. Like, what what what point are you getting at? I want to say that, okay. So recently I had like a tweet thread where I was like, oh, do you understand why JS bundles are big? It's not because of the frameworks. Uh, it's because of like business requirements. It's because the platform doesn't really have a way to do a nicely styled file upload dialog. Yeah. Something as simple as that. And that has its own conversation. And maybe, like, I'm not 100% right when I say it's only business requirements. It can be a number of things. Your framework encourages you to write code a particular way or whatever. I think developer experience is important because that's the flip side of the question. Why then do people choose frameworks? Why do you choose a framework? You can make- the abstract way of saying it is, oh, because I want to build beautiful user interfaces and stuff like that. But for me, a very concrete reason to use frameworks is to prevent bugs. Like React, for me, like the big deal about React when I started using it was, oh, I don't now need a template and a separate update function, which I need to keep in sync and all that jazz. Like it brought down the number of bugs I had. Yeah, yeah. Which meant that I could write code faster, which meant I could deliver features better. And at which point you read the- reach the abstract thing is, oh, if I use React, I can build nice user uh experiences.

[00:22:40] Michael Chan: Yes.

[00:22:40] Sunil Pai: Uh so after a point though, it starts feeling navel-gazing, this developer experience question, right? Like how much pointier can your JSX become? It's pointy enough right now. Uh so then we start talking about it in terms of, okay, why then do people— uh if we have solved these questions, why then are they choosing React? If we can just stop building it, like we're kind of done right now. Why? So What directly user-facing consequences can we make by people using React? One of the examples, and I think that's been the concurrent mode thing, people are now blind to the number of spinners and initial loading states that a website goes through. I'll give you an example. The new Twitter, really nice new website built on React, all that jazz. Um, what what I'd ask you to do is to literally record your screen using QuickTime or whatever it is you have. Record the first 5 to 10 seconds until the page loads and try to count the individual number of loading states in between. This number for me, and I've done this across many sites, by the way, uh it's on average, it's between 10 to 20, like individual loading states. You can't tell because it happens between 3 to 4 seconds. Sure. But when people say they prefer apps to sites, there's a reason. They're not being silly about it. Maybe they can't express it in words yet because they don't have the vocabulary, but something like multiple things just flitting in front of you. And once you see that, by the way, you can't unsee it. Like all web pages are now ruined for me. So-

[00:24:08] Michael Chan: Because there's a stability, a stability of a native app, right? Exactly. And that you don't have on the web. And it's like almost like a meme at this point, right? Where like you go to click something and then there's like something else like slides into place. Exactly.

[00:24:22] Sunil Pai: Like a freaking ad, a notification thing, or like an image that Didn't have- so the platform, I think, is trying to solve this in a number of ways. Um, couple of interesting ones are the way if you give images a width and height now, or an aspect ratio, they now don't bounce around the page.

[00:24:39] Michael Chan: Okay.

[00:24:39] Sunil Pai: Uh, Jen Simmons had a great video on this yesterday. I would recommend watching it. Uh, then there's- I think there's a new API they're launching which gives you a score for how stable your web page is while it starts up. Oh, interesting. Like how much it actually jumps around. Like you can actually- assign it a score and say, okay, product team, fix this number, bring it down to 0 or whatever it is.

[00:25:01] Michael Chan: Interesting.

[00:25:01] Sunil Pai: But now the interesting thing comes. Okay, can we make it so that if you use React, that number is 0 by default? Right? Like that is a directly user-facing consequence. The developer experience should be- for this should be the default. Like you should not have to write a single line of code for this to happen. It has to be the- you have to work really hard to make it not happen. Can we can we ship a React that does that?

[00:25:28] Michael Chan: Yeah.

[00:25:29] Sunil Pai: Uh, what what does the programming model look like? We think it looks like Suspense, by the way, right now. And we think we are right based on the new facebook.com. It might not be. Somebody else might come up with a better idea. Uh, but I really like that you asked the question, like what the like what are the user-facing consequences of using your framework? How do you How do you actually build user- how does your framework enable you to build better user interfaces? And mind you, I'm not even talking about like design. I'm not talking about layout and typography, or I am talking about accessibility. That is something we have been working our asses off on, and I'm super excited about that work, by the way. Again, you should talk to Dominic about it. He's just- he spends all his time on this now, and he has some crazy work in in in in motion right now. But my point is that like, I think On the React team, we are now at this place where we're like, okay, fine, the bundle sizes are controversial and we'll work on making that better. We have a much better server-side rendering story in place. Again, super excited about uh that work as well. Uh but how do we make make it that your Hello World app that you build with React comes with all these things out of the box? Does not bounce around. You add how many ever images you want. We should start erroring or warning you if you don't give a proper aspect ratio to images. Uh, by the way, don't you think this is strange? Like, I think the React website says that it's a library for building user interfaces, and we don't have an opinion on styles or images, which are kind of most of what a UI like builds on. So we should-

[00:27:06] Michael Chan: I thought maybe it was only a matter of time before you, the Kind of like CSS in JS guy brought up this uh this styling argument.

[00:27:16] Sunil Pai: Right. So, and you know what? I'm annoyed. Like, because I've done some good work this year, but none of it has had to do with CSS. It's pissing me off, to be honest. It was because of priorities and Facebook needed a testing API or whatever the fuck. But I think now is about the time we fix this stupid styling thing. Or you know what? That's just it. Even if we don't fix it. We should at least have an opinion so that we can cut down the- like Twitter. Twitter will shut up for a while. I think that would be nice. I think uh that would be good.

[00:27:43] Michael Chan: How do you- I mean, I know that some of these things you probably can't talk about, but uh how do you see that? And um does that play at all into the work that you were talking about with uh like images and and and whatnot?

[00:27:55] Sunil Pai: So this is what I think about like methodologies, okay? Whether it's object-oriented programming, Or functional programming or um whatever architecture you choose for your CSS or how you choose to do tests or whatever it is, right? Uh and like which language, whether you're using Elm or ClojureScript or whatever. I think uh whatever methodology you choose, uh if the constraints that that that system has picked are good, Mm-hmm. Then you will end up with a good product. Okay. Uh in some on some vector, in some for some kind of measurement. So for example, um if you use Clojure and ClojureScript and immutable data structures, uh it's a little easier to make sure data is in sync across the page or like to do time travel stuff and all that jazz. If you use uh OOCSS, which uh so uh, so that's Nicole's CSS architecture. Uh, you end up with a file structure which is easy to parse, like, for a brain. Like, you- it just matches, like, oh, this is a hierarchy, and like, learn it and all that jazz. So really, the question is like not about like what you do, but about what you don't do. Like, it's about the consistency. Could you just repeat your question to me? Because I knew I was going somewhere with this.

[00:29:16] Michael Chan: Well, the question was just like, like, how do you see How do you see being more opinionated about uh UI in React?

[00:29:24] Sunil Pai: Okay, yeah, so, so I think React has gotten like, React has gotten some abstractions wrong previously, like way earlier, of course. Uh and we have, we don't know whether the decisions we have taken in the last year or so are wrong yet, but we'll see.

[00:29:38] Michael Chan: Time will tell.

[00:29:39] Sunil Pai: Time will tell. Uh so I I look at stuff like styling in the same way. Uh different people on the team have different opinions about this, by the way. I don't think we have a unanimous take yet on what it should be like. Uh, and like I said, we haven't really worked on it because we've been doing concurrent mode and all that jazz. But I think it'll boil down to the same thing. We will end up picking a set of constraints. We will say, okay, fine. Maybe you don't do nested selectors. Oh, this is purely hypothetical, by the way. The things I'm saying right now are-

[00:30:08] Michael Chan: We won't hold you to it. As a community, we promise not to hold you to it.

[00:30:12] Sunil Pai: You say this now, but like-

[00:30:15] Michael Chan: I'll come after these people with a stick soon. My point is that- I got your back.

[00:30:18] Sunil Pai: My point is that we will- we or somebody in the community, and we'll think it's a good idea and just adopt it, will pick a set of constraints that works for most people.

[00:30:28] Michael Chan: Yeah.

[00:30:28] Sunil Pai: That it'll be like, for example, I don't think uh CSS-in-JS object notation is it because it excludes way too many people. It excludes people who uh write good CSS. CSS is a nice language actually. I wrote some of it a while ago.

[00:30:43] Michael Chan: I love CSS.

[00:30:44] Sunil Pai: Right? It's actually nice.

[00:30:45] Michael Chan: Yeah. I just tweeted the other day, CSS is amazing.

[00:30:47] Sunil Pai: CSS is CSS. Yeah, CSS is CSS. That's a good tweet.

[00:30:52] Michael Chan: Thank you. Thank you.

[00:30:53] Sunil Pai: So, so I don't think object notation is going to be it.

[00:30:57] Michael Chan: Yeah.

[00:30:58] Sunil Pai: I like object notation. Sure. I kind of got some, like I wrote Glamour, which was all about that. But I don't think that's the solution because I don't think- the reason I'm saying that is because I don't think those are the right constraints, like I said. Uh, so I think the solution will not come by creating new ideas and abstractions, because now we have like a spectrum of solutions across like whatever. I think the correct solution will come by saying, okay, let's just pick these set of constraints and we have an escape hatch if you want to do something else, whatever. Yeah, yeah, yeah. But these are the things we are picking for now because it solves so-and-so problems for Facebook properly. Probably, but like everybody else in the community as well. Uh, and I, and it will enable 2 or 3 new things that we are thinking about that's not possible yet with the current system. So that's where we're- so if you're asking me to like do a far in the future, what will it look like? I think it'll fall like in 2 years when we do another podcast episode, I'll be like, see, I told you, it was just the constraints. It might not look like anything we have right now, but it'll be about picking those constraints.

[00:32:03] Michael Chan: Well, I wonder too, there's this kind of thought that um, Webflow and uh Framer are like pioneering, which is the idea that, you know, you shouldn't necessarily have to think about CSS at all, right? Like if you're already in a design tool, that you should just be able to basically design your thing and then hook it up to whatever data structures you need.

[00:32:23] Sunil Pai: Awesome. I'm glad you brought this up because I've wanted a mic to bring out my Webflow hate for a while.

[00:32:29] Michael Chan: Okay.

[00:32:29] Sunil Pai: Uh, so first of all, uh, Vlad and everyone on that team is amazing and I love them. Uh, and I'm gonna tell you why- what my problem with Webflow is, is that it doesn't live inside the IDE. Like, the entire- the inst- that entire UI should be inside, uh, Sublime Text or VS Code or whatever it is that you're saying. Uh, I think a lot of design tools get this wrong, where, uh, they're completely separate from the development process and they export like artifacts that you can then work on.

[00:33:00] Michael Chan: Interesting. But, but that kind of- I'm gonna push back just a little bit. That kind of like assumes that like the developer experience is maybe the more important one when like working with those design components.

[00:33:14] Sunil Pai: Oh, my problem is the handoff. Like, like, no, you know what, if you're making a website that you're not going to change ever again, maybe you do some bug fixes or maintenance on it, fine, that's great. But codebases are like living things that teams work on and keep changing. So what happens when like the requirement changes on the development side or the design side? Do you then have to regenerate all that art- all those artifacts again? People are trying to do a good job of this, by the way. I know, uh, I know Webflow is also looking into this. I think Modulz is another thing, uh, another company that's doing some very exciting work around this. Um, there are, there are like other- this thing, but my entire- when I say it should belong in the ID. Uh-huh. Uh, I don't mean that, again, it's in a separate folder there. I mean, I don't ever want to write CSS by hand again.

[00:34:03] Michael Chan: Right, right.

[00:34:04] Sunil Pai: That when I click on the CSS file in the left, in my sidebar, what should open up is the Webflow UI in in my IDE.

[00:34:12] Michael Chan: Well, this is something that I have always loved about SVG and like, yeah, the hand- I'm oversimplifying this in saying it, but like, There's something so cool about like SVG where you can open it up in an editor, you know, a code editor, make the change and it, it's fine. Right. But then you can also open up that same file in a visual editor. Right. And I would love to see something like that for React components. And it feels like, why isn't there, right? Like, why can't I open my React component inside of a visual editor that just makes the changes that I would have made?

[00:34:47] Sunil Pai: Why, Michael, tell me why, why are we not working on this? I can give you- I have an answer for that question as well, by the way. It's because developers fucking love building shit for other developers. We don't build it for the people who really need the tools. It's super annoying.

[00:35:02] Michael Chan: That's interesting.

[00:35:03] Sunil Pai: CSS-in-JS is amazing for other developers. Do you get it? Not for designers. It, it enabled a whole bunch of developers to become better at styling. Don't get me wrong.

[00:35:11] Michael Chan: Absolutely. Yeah.

[00:35:12] Sunil Pai: But it's- we love building shit for like ourselves, you know.

[00:35:16] Michael Chan: It is a little bit of like a fuck you to designers, right? Even the object notation, like you were saying, it's like, oh yeah, yeah. Like, you know, if you want to do it, yeah, that's fine. We use CSS, but it's like a different CSS.

[00:35:24] Sunil Pai: And some designers got over the hump and learned how to write JavaScript objects and they went on to build great things with it. But that's not the point. Like the point is that it's kind of exclusionary by definition, like by the nature of it. You know what? Did you see- have you checked out SwiftUI yet?

[00:35:40] Michael Chan: Uh, I, I mean, I've, I watched the the video, but I haven't played with it.

[00:35:44] Sunil Pai: So pissed off when I saw that because I really thought React and the web would get there first. What's even more annoying is that ever since they launched how many months ago, no one has made any progress in that direction. Yeah. From the website. Neither have I, but I have an excuse. I work for Facebook. I don't have time for shit. Like, I pay too much rent in London or whatever. I don't care. Uh, this is a collective failure. Like, I think on all our parts. SwiftUI is amazing. So SwiftUI, uh, you can see a preview and the code next to each other. If you click on a box in the preview, the cursor goes to in the left side in the code, it highlights that. If you click on, not JSX, whatever that component thing is called, if you click on it on the in the code, then the component in the preview is highlighted.

[00:36:28] Michael Chan: Yeah.

[00:36:29] Sunil Pai: That's just such a simple feature that we should have like right now. Uh, I I I keep thinking about this like with DevTools, right? Like when you're working on a React website, for example, why can I not right-click on a component in my webpage and open it up in my code editor. Why not?

[00:36:49] Michael Chan: Yeah.

[00:36:50] Sunil Pai: Like now that I've said it to you, it's kind of obvious. Yes. This should be part of my development workflow. Who has built this? Nobody.

[00:36:56] Michael Chan: Do you feel like that, like having it be like an actual, like website is too, like a whole page is too much, but like if we did just limit it to like UI components, that maybe that's like an achievable first step.

[00:37:08] Sunil Pai: Sure. Sure. I mean, anything is better than like, uh, arguing about- I don't know, what have we argued about in the last few weeks? Uh, shipping Lodash 3 times in a bundle. I don't give a shit, man. That's something webpack will fix at some point, right? You know, that's just it. Like, problems- I look at problems like that and I'm like, oh, that's unfortunate and it sucks, but it's something tooling can fix. Yeah. Also, it's the kind of tooling that developers would love to fix because it's for other developers.

[00:37:37] Michael Chan: Well, what- okay, so, so in fleshing out this idea you would have to, like you said, find certain constraints that you were willing to like have these components fall under, right? Right. Because it couldn't necessarily, or at least not right away, know how to parse all of these certain aspects that are part of, you know, certain CSS-in-JS solutions, right? Sure. Or even to be able to commit back to those where, you know, because that could get very confusing, right? If like the CSS is in a different file and like all that kind of stuff. Um, do you feel like you'd have to limit this to components where all of that was isolated inside of a single like module? Like if it was all like tied together?

[00:38:18] Sunil Pai: Uh, not necessarily. I think you can work around- like there are workarounds. Like this is devil in the details. Like yes, no, sure.

[00:38:24] Michael Chan: Um, well, cause I think it'd be easy enough to read, but being able to, from that UI layer, then commit back to- that could be challenging.

[00:38:32] Sunil Pai: So the people then who are at the best position to solve this are not the React team. But it's teams like Gatsby and Next. Because they have like, this is in, they they are very opinionated about how these things are built.

[00:38:45] Michael Chan: Interesting.

[00:38:45] Sunil Pai: Right? Like you don't really touch their build system. I mean, sure you do. And I mean, you're allowed to, like they have plugins for how you do your build and all. But otherwise they own most of that tool chain, that that that part of the pipeline.

[00:38:58] Michael Chan: Yeah.

[00:38:58] Sunil Pai: So they are in the best position to say, make sure that if this folder has only MDX files in it, And there you go. That is the constraint.

[00:39:07] Michael Chan: Interesting. So you feel like people who are already closest to the um the product maybe um have the best like vantage point for maybe making this because they've already made some decisions on some of those constraints.

[00:39:20] Sunil Pai: Exactly, it's already opinionated for these things. If I and that, mind you, this isn't even an original idea, but but I think uh Jackson and John O'Tander, I think they're both on the Gatsby team right now. They're working on some very exciting stuff Yeah. In this space. Uh, John, of course, is uh maintainer and creator of MDX itself, I think, right? Is he working for Gatsby? I'm not sure. Maybe he's not.

[00:39:42] Michael Chan: I don't know. In that world.

[00:39:44] Sunil Pai: Exactly. But my point is that these meta frameworks are already opinionated enough about all these things and people love them for it. Like the sites are fast. Sure. Like they've solved a whole bunch of problems, but All they need to do is like, just go, I think what I think, in my opinion, I think they just need to go one step further and say, okay, you know what, this is what we think the future of actually building these websites are going to look like.

[00:40:08] Michael Chan: Interesting. And that, that feels like it would kind of align with the goal of Gatsby because like, like Gatsby has, is ambitious beyond just being like what developers use to generate their static sites. And so to be able to commit uh components, um, using their- using a visual editor feels very much in line with-

[00:40:29] Sunil Pai: I mean, that's just it. Like, uh, their early mover advantage is having developers like their product, but that's not gonna make them the money that they want. I mean, in open source, who makes money? What they want is for people who don't know how to write JSX and this thing to start using Gatsby. And they're in a very great place to execute on this. Gatsby and Next, I think, come to mind, but Uh, whoever out there wants to create a new meta framework around React or any other framework library, like please pick Svelte, pick whatever, but don't do this whole thing of trying to compete based on the features right now. Like you can put out a tweet and a benchmark and argue with big shots on the Facebook team or Richard. That's all small potatoes. Look like broader, look like 5 years in the distance and see if you can, if you can get designers to start using your JavaScript framework, that's huge. Like that's suddenly a game changer across the industry. And I kind of hope React does it, uh, but we'll see.

[00:41:27] Michael Chan: Do you feel like this is something now that I feel like React developers have kind of rallied around, um, styled-components and Emotion. Do you feel like this is something that they could even tackle as a different differentiator?

[00:41:41] Sunil Pai: Uh, sure. But styled-components and Emotion are not opinionated enough.

[00:41:45] Michael Chan: I see.

[00:41:45] Sunil Pai: I think- I mean, maybe.

[00:41:47] Michael Chan: They would have to be more opinionated though in order to make that happen. Yeah, yeah, yeah.

[00:41:52] Sunil Pai: Like, because my my point about this is you want to get to a place where you're not writing code, right?

[00:41:56] Michael Chan: Yeah.

[00:41:56] Sunil Pai: Uh, and the Emotion Style Components thing very much is about the, oh, you can write the best code. And I'm like- and I I love both of those projects, but I'm like, yeah, I don't want to fucking do this for the next 20 years. Are you serious? I don't want to remember Like in 10 years, there's gonna be CSS5 and there are gonna be like 400 new key-value attributes. I don't want to remember that shit.

[00:42:18] Michael Chan: Yeah, yeah, yeah. That that is true. I feel like the more that I work in code and the more that I work in like design systems and doing all this kind of stuff, like the more I feel like, like, why am I like, why am I doing this? Right? Like the the important work that that we're doing is like, you know, design system, like authors or kind of in designing a product in general is not mapping it to code, but it's, it's in deciding what the constraints are visually for our, our product, like our customers, right? And like, why, why do we need to do that in code?

[00:42:50] Sunil Pai: Why? So, uh, I'll give you a very concrete example. All right, um, CSS grids. Awesome technology.

[00:42:58] Michael Chan: Amazing.

[00:42:58] Sunil Pai: I think the best thing CSS folks have come out with in the last 10 years.

[00:43:02] Michael Chan: I mean, CSS grid and CSS, uh, custom properties variables, like It's a different game now.

[00:43:07] Sunil Pai: Yeah, a game changer.

[00:43:08] Michael Chan: Yeah, yeah, yeah.

[00:43:09] Sunil Pai: But writing CSS grids will take you like a couple of weeks of working through those things. It's tough. Now, this is why I want Webflow to be successful, by the way, because if they make enough money, I think I can convince Vlad to open source their grid editor, which is awesome. Their grid editor is the best in the business right now, I think. Which is why I want like his business to make money. I'm like, okay, make the money so you can open source this and then like we'll just steal it, we'll do the rest of it. Uh, but, but you see, like the tech is beautiful. Yes. Like it is, oh my God, like the industry has been aching for doing- and I'll say it, you know what people say, oh, the web is different from print. No, like print layouts were like way ahead of the game like 50 years ago. Uh, CSS grids finally gives us parity with stuff like that. Uh, but you have to- you have to learn way too much to become even like moderately successful in using the feature.

[00:44:03] Michael Chan: Yeah.

[00:44:03] Sunil Pai: So, uh, so yeah, you shouldn't have to. My entire point is you should not have to know the syntax and the quirks to make use of such a beautiful feature.

[00:44:14] Michael Chan: Yeah, I love it. Well, I think we should probably end there. We got a- we got a conference to register for and some people to say hi to.

[00:44:21] Sunil Pai: Okay. Uh, I don't think I said anything worth firing, so I might as well- let's Let's see. Uh, uh, so, oh, uh, audience, uh, Michael Jackson, the Michael Jackson, was in the room with us today. Uh, so if you heard him smirking in the corner or singing in the bathroom, that was him. It was not us. Uh, what else could I get myself fired for? Oh, I'm drinking a beer and I'm at a professional conference. That's not cool either, I guess. I don't know.

[00:44:48] Michael Chan: Oh no, they're gonna be serving us beer at registration.

[00:44:50] Sunil Pai: I guess.

[00:44:51] Michael Chan: Yeah, we're just pre-gaming a little bit.

[00:44:52] Sunil Pai: Uh, also, uh, oh, uh, I told myself I wouldn't say it for this entire trip, but I'll say it once and I won't say it again. Vegas, baby. Is that an American thing to say? It is, right? Vegas, baby.

[00:45:03] Michael Chan: I think so. I think so. A little bit different, but yeah, yeah, you got it. You got it. Um, thanks for having

[00:45:09] Sunil Pai: me on, Michael.

[00:45:09] Michael Chan: Oh, it's my pleasure. Also, we got a pitcher idea.

[00:45:12] Sunil Pai: Oh, oh, excellent. Uh, so you would have probably heard this by the time the podcast comes out, but uh, we are renaming Hookz. Uh, hooks are a terrible name. Uh, there were, and there were terrible names before hooks itself. They were called augmentors or fixins or whatever. No, all of that is dead.

[00:45:28] Michael Chan: Fixins is still good. No, no, no. Okay, okay, okay. Not as good as this.

[00:45:32] Sunil Pai: So we're calling them usies.

[00:45:34] Michael Chan: Usies.

[00:45:35] Sunil Pai: It's perfect, right? Chuck a couple of usies in your component, uh, a useState, a useEffect, just whatever usies you need.

[00:45:43] Michael Chan: I just need a few usies.

[00:45:44] Sunil Pai: Yeah, all you need is usies.

[00:45:46] Michael Chan: Are function components my usies?

[00:45:47] Sunil Pai: Exactly, man. Like, and it's perfect. It works so well. Like, oh, your usie here is wrong. Uh, don't nest your usies so much. Uh, I'm also trying to pitch that uh custom uh usies are called reusies. But you can think about it. But usies, okay, you heard it here first. Or or or or not. Maybe weeks later. But yes, this is the big announcement of the conference. Fuck up fuck up concurrent mode. Fuck all the new features. Use these is where it's at.

[00:46:14] Michael Chan: Developers love building shit for other developers. It hurts because it's true. Thanks, Sunil, for being you and for being on the show. For episode links, visit reactpodcast.com/75. And hey, if you're new to React, I'm doing my annual introduction series. Visit react.holiday, another fun You can find it via Twitter, YouTube, Dev.to, email, or just on react.holiday. Uh, whether you're a React pro or brand new to React, there's plenty for you in this modern introduction to React, hooks, suspense, and concurrent mode. Thanks to our wonderful sponsors for making this episode possible. Linode. Instantly deploy and manage an SSD server in the Linode cloud. Get a server up and running in minutes. Get a $20 credit when you visit linode.com/react and use the promo code REACT2019 at checkout. Bring your ideas to life with React Native. Hire the industry experts at Infinite Red. Visit reactpodcast.infinite.red and get 2 tickets to next year's Chain React Conf. See why they're the industry experts to take your React Native app the distance. This episode of React Podcast was edited by Mikael Delport. It was produced by Mikael Delport and Sarah Jackson. You can find React Podcast on Speck, a network to help designers and developers level up. Visit speck.fm to find other shows that will take you further in your career. Help us out by reviewing this show on iTunes. Your reviews help the show grow and help us ensure great guests and awesome content week to week. To join the discussion, visit reactpodcast.com/chat or follow us on Twitter @reactpodcast. I'm @chantastic. To stay out of the discussion but get updates, visit reactpodcast.com/news and sign up for emails. Thanks so much for giving us your attention. We'll be in your ears again next week. Thanks for listening.