Ladybird chooses Swift as its successor language to C++
I've copied the full tweet below (it's from August, I missed this news somehow):
We've been evaluating a number of C++ successor languages for @ladybirdbrowser , and the one best suited to our needs appears to be @SwiftLang đȘ¶
Over the last few months, I've asked a bunch of folks to pick some little part of our project and try rewriting it in the different languages we were evaluating. The feedback was very clear: everyone preferred Swift!
Why do we like Swift?
First off, Swift has both memory & data race safety (as of v6). It's also a modern language with solid ergonomics.
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. Swift has first-class OO support, in many ways even nicer than C++.
The Swift team is also investing heavily in C++ interop, which means there's a real path to incremental adoption, not just gigantic rewrites.
Strong ties to Apple?
Swift has historically been strongly tied to Apple and their platforms, but in the last year, there's been a push for "swiftlang" to become more independent. (It's now in a separate GitHub org, no longer in "apple", for example).
Support for non-Apple platforms is also improving, as is the support for other, LSP-based development environments.
What happens next?
We aren't able to start using it just yet, as the current release of Swift ships with a version of Clang that's too old to grok our existing C++ codebase. But when Swift 6 comes out of beta this fall, we will begin using it!
No language is perfect, and there are a lot of things here that we don't know yet. I'm not aware of anyone doing browser engine stuff in Swift before, so we'll probably end up with feedback for the Swift team as well.
I'm super excited about this! We must steer Ladybird towards memory safety, and the first step is selecting a successor language that we can begin adopting very soon. đ€đ
Nitter link:
https://nitter.poast.org/awesomekling/status/1822236888188498031
Original post:
https://x.com/awesomekling/status/1822236888188498031
Some of Kling's replies in that thread are also pretty interesting:
My general thoughts on Rust:
- Excellent for short-lived programs that transform input A to output B
- Clunky for long-lived programs that maintain large complex object graphs
- Really impressive ecosystem
- Toxic community
In the end it came down to Swift vs Rust, and Swift is strictly better in OO support and C++ interop.
The September monthly report for Ladybird released the day after I posted this. It provides basically the same information:
This Month in Ladybird September 2024
The section about Swift:
Successor language search progress
Over the past year, our core contributors have been exploring potential safe languages to complement or succeed C++. We evaluated several options, including Rust, Swift, Fil-C, and others. While some languages offered compelling features, many fell short in either C++ interoperability or providing the level of memory safety we needed.
After extensive testing and discussion, Swift emerged as the top choice among our core developers, thanks to the new Swift 6 interoperability features and its growing cross-platform support. As a result, weâve decided to adopt Swift as our C++ successor language.
That said, this will be an incremental shift. The existing C++ codebase is deeply embedded in the project, and a complete rewrite would be impractical. Instead, weâll be gradually introducing new components in Swift, carefully integrating them with our existing C++ code over time. Look forward to a dedicated blog post on the topic soon.
Interesting choice overall, I do wonder what it means for the short term future of the browser on various non Apple platforms. Even though the language might support more platforms now, I am willing to bet that the majority of developers still are Apple oriented ones.
Overall, I don't think it matters that much. The browser is still far removed from prime time, so over time I am sure the language will attract a wider array of developers some of who will also contribute to the project.
Huh, that is something that could use some more context. I am not active in either community, but so far from what I have seen everyone talking about RUST seems nice and helpful to each other.
I think the large community and surge in popularity has led to some Blub elitism. Of course thatâs going to be any PL community but that elitism has peaked in the last couple of years for Rust.
Though I still wouldnât generalize the entire community as toxic.
Edit: I believe I unintentionally gave credence to some of the uglier generalizations about the Rust community with my speculation about the origin of Klingâs criticism. In this speculation I gave Kling the benefit of the doubt and while I still think thatâs fine I wasnât aware it would stir more unsavory opinions out of the woodwork.
I don't use Rust or consider myself part of the community.
Rustoceans are some of the friendliest people I know. They can be passionate about their language, but having been around when C++, Java, and Python were the hot new languages with fanbases, their fans don't hold a candle to any of them.
The large majority of the "toxicity" I've seen is actually out of the people complaining about Rustoceans, which range from "gotcha" level debunking of arguments to actual conspiracy theories. There are also some cases where someone posts an obnoxious comment about Rust, only to look into their post history and see that they actually don't like the language at all and are just stirring the pot.
I have no way of knowing this for a certainty, but I have a pet theory that part of the issues stem from the fact that Rust was one of the earliest projects to embrace a Code of Conduct.
Sorry for the necrobump â I have had this exact suspicion for a while now.
It makes sense that the "toxic community" meme could germinate and spread from interactions where someone violates the code of conduct and is told off. The residual negativity, justified or not, is bound to be pointed somewhere.
Ironic, of course, because in my experience the code of conduct has been incredibly effective. Like you say, the toxicity I can remember has disproportionately come from snide, clearly nontechnical or otherwise bad-faith criticism of the language or its community. And it feels so unfair to me that the "toxic" idea seems to arise from the outside and is still attributed to the inside.
Honestly I'm kinda ambivalent about even writing this because it sounds like such an uncritical defence. "See? Rust lemmings can't even take criticism."
I know that's ridiculous, but I actually have participated in Rust discussions on Reddit and IRC and stuff before, and every time I read "toxic" or "evangelism" or whatever I have to remind myself to roll my eyes rather than second-guess my own experiences and actions.
I dunno. I'm a people watcher. I like trying to see the social tides. (A sociologist??) And in person I like to consider myself a people greaser. I lube them right up so they can fit together better. (A mechanic???)
On a more positive note, to the extent that Rust community discussions are nontoxic, I wonder if that's due partly to the type checker being so strict. It's like a shared villain. Everybody loves a good villain.
Iâm not part of any community, but believe me the ârusteaceansâ are the most obnoxious people I have ever seen(on twitter) and thatâs saying much. At least with the racist you know that most of them are trolling. But ârustaceansâ are just incredibly awful people. I mean Iâm trying not to generalize, and I know thatâs not everyone from that community, but they tend to be really insufferable and no, Iâm not guiding myself from a âmemeâ
Man, I was about to go to bed
No. Your comment is putting Rustaceans beneath racists on twitter and that is plain wrong. You are generalizing and to a harmful extent.
I normally wouldnât dignify this with a response but I feel partially responsible for my comment earlier in the tree proceeding this. I disagree with everything you are saying and I think you should consider just how drastic of a false equivalence there is between racism and programming language elitism.
I will admit that it was drastic and maybe not the best way to express what I wanted to say, in my defense I was irritated and sleepy. The mentions about ârustaceansâ toxicity didnât come out of nowhere and not just for technical reasons, anyway I tried to express too that I was not trying to generalize but I saw this behavior in many ârustaceansâ, even the core team is justâŠ
Iâm not sure if I could call what they do âelitismâ. Saying to people to the programming language theyâre building should not exist, because we already have rust and theyâre just wasting their time and blah blah, and in my comment you can see just how much I hate it, and is not only one person doing it, that why there are so much friction between âcommunitiesâ, I think recently is not that bad
Maybe this is a difference between online and IRL communities? Every rustacean I've coincidentally met offline has been extremely nice and helpful (in general, unrelated to Rust).
Kinda sounds like Twitter being Xitter. I'd expect most rustaceans to use BlueSky or Mastodon for technical reasons.
I started to think that every community has two sides, one when you try to enter and learn the language and other when you say that you donât like something( and I mean valid criticisms) they do things way way different than âusualâ, specially the rust community that behaves like a cult basically, and again Iâm not saying this because of a meme Iâve seen it from afar and itâs really disgusting. That why I mentioned that even for twitter standards, it is not nice, and still most of the community still is in twitter at least most known members.
And I understand what you say, and I know is true, but men at some point itâs just tiresome to watch. And I kinda like the language, but at the same time I wouldnât have to like to deal with that.
Ironically this is the nicest rust user I know or at least the less toxic: https://x.com/DrawsMiguel
In the interest of hopefully judoing this into a better discussion:
Not only are these really good points, I think the second one is one of the greatest weaknesses of the language.
Rooting ownership in a stack frame, like Rust does (both stack- and heap-allocated values), ties object ownership to the call stack hard; also the way references project into other references implies a tree structure for data which simply doesn't work for more general graphs.
I guess I should have known better than to necromance this one though, sorry about that. :-/
I'm genuinely surprised Swift is so good outside the macOS ecosystem. I've been hearing about their desire to distance from Apple and become truly cross-platform which is delightful.
I'm disappointed Rust didn't make the cut, but to be fair I do think Rust's C/C++ interop leaves a lot to be desired. You can fairly easily call C functions from Rust, but doing the opposite (which I assume the Ladybird team needs a lot more) can be literal hell to figure out.
Also yes, toxic community đ
I hope this inspires more people to use Swift for systems programming - the current situation is a nightmare. I spent a solid hour googling how to make a threadpool with a number of max concurrent workers yesterday and StackOverflow helpfully told me that I shouldn't worry about it and just let Grand Central Dispatch handle it.
The computer ran out of memory.
I think Swift is a pretty underrated programming language. I know a few people who argue "we need a higher-level Rust" (by which they usually mean "we need better tooling and not worse-is-better language design"); I think this already exists and Swift kind of provides this.
There's also some notes from the original Rust implementer here: https://graydon2.dreamwidth.org/5785.html
I wasnât aware of Swift 6âs effort to offer better support for Linux and Windows, thatâs really cool. I still need to read through the 5->6 changes to see what theyâve done to improve memory safety and concurrency.
Having recently learned more about Zig, I wonder if that was one of the languages they evaluated as a C++ replacement. Itâs still underbaked right now but there are a few projects making good use of Zig in production. Is there a longer write up anywhere discussing all the languages they evaluated?
The Zed editor is great counter-example but I still agree itâs much harder to bootstrap complex applications in Rust. (Coming from a novice Rust programmer).
It's been my experience, at least, that the lack of Core Foundation and Foundation frameworks on anything other than macOS has led to a gap in what would otherwise be considered Swift's standard library.
These gaps are being filled with the open source rewrite of Foundation, though, which should put Swift in a reasonably usable state for cross-platform work pretty soon.
Even now it's dramatically more usable for that purpose than Objective-C ever was, with there being several Linux server packages (e.g. Vapor) as well as a Chromium UI for Windows (Arc) built with it.