Comment by jm4
5 days ago
I'll see if I can find it. I don't remember the specifics on rust, but it sounded like they gave it a fair shot. It was basically the one to beat until they figured out it wasn't going to work. The decision to adopt Swift wasn't made on a whim and, frankly, I'm skeptical it will happen any time soon, if ever. I think it's one of those situations where they want to make it more accessible to a next generation of developers the same way Linux is adopting rust. Swift is actually a really nice language, despite being associated primarily with Apple. It would be cool to see higher adoption.
Ladybird has an interesting way of documenting web standards in code. They put a link to the reference doc at the top of a function and then each rule in a comment where it is implemented. It's very easy to follow and good quality code. Another project I recall having high quality code was KHTML. Not coincidentally, Andreas Kling worked on that one too.
There are examples here: https://github.com/LadybirdBrowser/ladybird/tree/master/Libr...
Anyway, the point is what they are doing is working well and Swift won't be ready for a while. If it ever happens, it won't be a rewrite. It'll more likely be a situation where it's written in both the same way Linux is both C and rust.
> [Rust] was basically the one to beat until they figured out it wasn't going to work.
I'd love to know more about this.
Found it! It was on a podcast: https://changelog.com/podcast/604
Here are some key quotes: "something that matters to us a lot is OO. Web specs & browser internals tend to be highly object-oriented, and life is easier when you can model specs closely in your code."
"So what I’ve done is I’ve asked a bunch of people to “Please implement these things in a couple of different languages. And then we can talk about how that went, what you liked about each language, and which one you would like to work in every day.” And what we ended up with was that people were initially excited to work in Rust, because there’s a lot of hype, and it’s like a popular language… And you would think that it’s the greatest thing since sliced bread… And in many ways it is, if what you want is sliced bread. Or I don’t know where I’m going with that. But it works well for a lot of things."
"But it turns out it’s not ideal for building a browser… Because the browser stack sits on top of this API that was designed in the ’90s, inspired by Java and XML and stuff like that at the time. This ‘90s API, and it set the core of the web stack. And it’s super object-oriented, and it’s just hard to express all that stuff in Rust, because Rust doesn’t lend itself to object-oriented programming. It doesn’t have inheritance, for example, which is a very fundamental building block."
"And so what happened was I asked people to write in Rust, and they were initially excited, and then they came back frustrated. And nobody had a good time working in Rust, as far as I understood, when doing anything but trivial programs that like take an input and transform it into something else. The moment you try to model something, sort of in a browser space, it just became tedious."
"So we looked at some other languages, and the one that everybody has liked so far has been Swift. So it’s a bit of an unlikely candidate, but we decided to look at it, because it is a safe, modern language, that has great object-oriented programming capabilities. I would say it’s even better than C++ in many ways. And it’s a little weird, because it feels like an Apple product almost, but they’ve been making great strides on Linux and Windows. Especially now, the upcoming Swift 6 is looking like it’s going to be a really good release on other platforms as well… So that’s sort of where the ship is pointing right now. We haven’t committed to it, because we’re still figuring out how to do some things, but it’s been really positive, and everybody’s enjoyed working in it, myself included. It’s been fantastic. So that’s sort of what we’re looking at."
> This ‘90s API, and it set the core of the web stack. And it’s super object-oriented, and it’s just hard to express all that stuff in Rust, because Rust doesn’t lend itself to object-oriented programming. It doesn’t have inheritance, for example, which is a very fundamental building block.
That's a rather strange criticism, seeing as the only thing about objects that's slightly involved to express in Rust is implementation inheritance; and even then, it can be phrased in a very reasonable way by using the generic typestate pattern. I.e. expressing a class that can be inherited from as a generic object MyBaseClass<T>, where T holds the "derived" object state (and can itself be generic in turn, thereby extending the type hierarchy) and methods can either be implemented for any MyBaseClass<T> or for some specific MyBaseClass<MyDerivedObject>.
(This aims to do the right thing whenever a method on the base class relies on some method implementation that's defined deeper in the hierarchy, i.e. there is an indirection step, aka open recursion. That's the part that is missing when using simple composition.)
I appreciate the details.
Ultimately I'm not dissuaded from my original impression.
I worked at a company doing web scraping, and our code sucked and we knew it, and the lead programmer kind of liked Elixir, and we were always going to rewrite in Elixir one day, and he would mention it in interviews and stuff, and put it on job requirements, but really there was almost no Elixir in the company. We came up with all sorts of reasons Elixir would make sense technically, I even offered some myself because I got positive social feedback when I spoke well of Elixir. But now that I'm out of the company, I can see that Elixir is not uniquely suited to solve the problems we had. It was just one guy liked Elixir and so ultimately we all did.
I still predict the same for LadyBird. You can even see in the Tweet I linked that they choose C++ because of one person, so I'm guessing that one person also likes Swift. Time will tell.
1 reply →