You did have to be careful. The browsers back then, if you pushed them a little bit too hard, they would crash. So one of the biggest problems we had early on with Gmail was that it would just crash your browser. And this is before we launched it. It was one of my fears, like maybe we will just never get to the point where it doesn't crash your browser. Fortunately, we got past that.
This is Dalton and PB from Y Combinator. Today we're going to talk about a little bit of memory lane here, which is how PB created Gmail. We've talked about this before, but what I would like to talk about today is from a technical perspective how you created Gmail. And so let's set this up, audience. Most of you that are building web applications are vibe coding it and thus you're not looking at the code. Great. [laughter] In the prior generation, maybe you looked at the code, but you were probably using web frameworks. There's been many, many web frameworks to make it easy to interact with JavaScript if you want to do something in the browser. Well, back when PB created Gmail, this predated web frameworks, and so you were writing raw, hand-rolled JavaScript and making JavaScript do something that most people said was impossible. So that's enough of my lead-in. Like, bring us back. What was the state of the art then? What was...
Yeah, so I mean this was back, you know, we started towards the end of 2001. So this is like 25 years ago now. And at the time, JavaScript was mostly known as like a thing to make websites super annoying by doing like pop-up ads or, you know, it was not something that was very well respected. Essentially no one at Google even knew JavaScript, myself included.
Well, wasn't it created by what's his name, Netscape, in like two weeks as a hack? Like wasn't the whole history of JavaScript really weird?
It started off as LiveScript, and yeah, it was Brendan Eich built that over a very short period of time. And it's actually kind of a weird language. It does prototype-based instead of class-based. It has some kind of strange decisions, but also some kind of cool stuff in it. And then it got rebranded JavaScript because Java was like really hot.
And so they just started calling it JavaScript.
That was some marketing guy that got a promotion for that, right?
Instead of LiveScript, it became JavaScript. And that was back, of course, when Java was supposed to run inside of your browser in applets. And actually that was really how I got started was reading the HotJava white paper in 1995 where they talked about mobile code execution. And I just got very excited about this idea that code could travel over the internet and so that you could actually build an application that was dynamically partitioned between the server and the client so that you could put some things in the client to make them super fast and other things on the server. And so I got excited about this idea that in the future we would actually just access applications through the web browser. And so actually the first time I tried to build a web-based email I tried doing it as a Java applet back in 1997, but it didn't really work. I didn't make it that far. And Java applets just never turned out to be that good. So then, you know, when I started working on Gmail again in 2001 I actually wasn't using much JavaScript to start with. I, you know, again have a very iterative approach to development. So I started by just making a simple email search. But then, you know, one of the key values inside of Google technically was just that everything should be super fast. And so, you know, Larry would complain that it's too slow. And, you know, I'm looking at how can I make this faster. And one of the really straightforward ways is just to avoid server round trips, right? So like back before JavaScript, every time let's say you were using Yahoo Mail, every time you click on a link it would reload the entire page. So every single action required reloading the whole page including, you know, everything that's on the page. And so it was by its very nature slow. So I just started basically trying to make it as fast as I possibly could. And that led me to increasingly realize I should just write the entire thing in JavaScript.
And a couple of things. Number one, this only works because the XML HTTP request thing in IE. But you want to... again, because I have a feeling people don't know about that.
So one of the tricks is behind the scenes, you know, instead of reloading the whole page, you want to be able to do an HTTP request to the server. There's actually a few different ways to do this. I investigated a bunch of them. XML HTTP request turned out to be the best one. But you can also use like hidden iframes. You can actually do image tags for some things. There's a lot of... I don't know if this is still the case, but when I wrote the like one tiny snippet of JavaScript on the Hacker News site, I think I was using an image tag to smuggle back the upvotes and downvotes. So there's a few different ways, but yes, the best one is XML HTTP request. But basically what happened around, you know, 2001, 2002 was that the web browsers were actually finally getting good enough that it was possible to do this sort of thing. So people who said it can't be done were technically right, just out of date.
Yeah, yeah, yeah. So [laughter] because there actually had been a number of attempts, like I think one was called desktop.com. People had tried to build fully browser-based things and they just weren't very good.
And so from my perspective, the XML HTTP request thing was a hack. And I'm defining hack as it was being used by programmers in a way that the designers didn't really intend. And the fact that you could take this little feature that they built to like animate... Who knows why they built it?
I think they actually built it for Outlook.
Yeah, yeah. So I think they actually built it for the exact purpose I used it. But it was originally... yeah, it was based on XML because XML was super hot. You know, like why is XML in the name?
It was just a weird part of the browser. That's where I'm going. It wasn't like the main thing. It was a feature that no one was really using. So that was weird. And then number two, I remember you telling me that you faced a lot of skepticism from folks inside of Google that this could ever work.