Top
Best
New

Posted by adius 18 hours ago

Ladybird adopts Rust, with help from AI(ladybird.org)
1106 points | 606 commentspage 5
drnick1 11 hours ago|
I wonder what is gained by this port though, if the C++ codebase already employed modern approaches to memory management. It's entirely possible that the Rust version will perform worse too as compilers are less mature.
maleldil 10 hours ago|
"modern approaches to memory management" aren't enough for complete memory safety.
drnick1 9 hours ago||
Maybe, but it's certainly possible to write memory safe code in C++. It may be more or less difficult, but it isn't typically the ONLY objective of a project. C++ has other advantages too, such as seamless integration with C APIs and codebases, idiomatic OOP, and very mature compilers and libraries.
rausr 16 hours ago||
I must admit to being somewhat confused by the article's claim that Rust and C++ emit bytecode. To my knowledge, neither do (unless they're both targeting WASM?) - is there something I'm missing or is the author just using the wrong words?

EDIT: bramhaag pointed out the error of my ways. Thanks bramhaag!

bramhaag 16 hours ago||
By 'Rust compiler' and 'C++ compiler', they refer to the LibJS bytecode generator implemented in those languages. This is about the generated JS bytecode.
rausr 16 hours ago|||
Yes, I re-read again, and I think you are correct. Thanks!
mdavid626 14 hours ago|||
Thanks! I was confused about this as well.
xwowsersx 16 hours ago|||
They're referring to LibJS's bytecode (the internal instruction stream of Ladybird’s JS engine), not to Rust/CPP output formats.
amedvednikov 3 hours ago||
Cool!

I've translated it from Rust to V in 45 minutes. Works great:

https://github.com/medvednikov/libjs_v

Compiles in 0.2 seconds on my M5 (compared to Rust's 3.3 seconds).

onetom 10 hours ago||
Were there any immediate benefits of this conversion, e.g. reduced memory use or lower CPU utilization?
GalaxyNova 7 hours ago|
Likely the opposite, as safe Rust has some extra safety checks for things like array bounds.
tolerance 15 hours ago||
Something of a culture clash here ain’t it, albeit an imbalanced one.
jurschreuder 15 hours ago||
Oooh noooo I will have to fork it before it is too late!
nothrows 11 hours ago||
This is sort of hilarious if you think about it. The Firefox browser is completely written in Rust. Now Ladybird is a "human-directed ai" Rust browser. Makes you wonder how much of the code the two browsers will share going forward given llm assisted autocompletes will pull from the same Rust Browser dataset.
d-us-vb 11 hours ago||
Probably not much: the requirement is exact equivalence of program inputs to outputs, and as such the agents are performing very mechanical translation from the existing C++ code to Rust. Their prompts aren't "implement X browser component in rust", they're "translate this C++ code to Rust, with these extra details that you can't glean from the code itself."
feverzsj 11 hours ago|||
It's like only 10% of Firefox is rust.
hu3 9 hours ago|||
I wonder where did you get the idea that Firefox was all Rust. Made me curious.
DetroitThrow 10 hours ago|||
Only a small portion of Firefox is written in Rust. Apparently some of the most performant and least buggy parts are those in Rust, but again, only parts like the CSS engine.
TiredOfLife 10 hours ago||
https://github.com/mozilla-firefox/firefox Rust isn't even mentioned in languages used.
usrbinenv 16 hours ago||
This will be another bad decision just like with Swift. From what I heard, Rust is notoriously bad at letting people define their own structure and instead beats you up until you satisfy the borrow checker. I think it'll make development slow and unpleasant. There are people out there who enjoy that, but it's not a fit for when you need to deliver a really huge codebase in reasonable time. I remember Andreas mentioning he just wanted something like C++, but with a GC and D would be absolutely perfect for this job.
Perz1val 7 hours ago||
Maybe, but will they have to fight with borrow checker for doing some other than (the very OOP) DOM components? They'll obviously use both for a long time in the future, so more functional places can get Rust, while more OOP places can benefit from C++
thiht 16 hours ago||
Nobody uses D
p0nce 14 hours ago|||
This is like the "real world" argument. Nobody uses that "in the real world", except well people that do.
Kapendev 13 hours ago||||
Well, I do!?!! It's even faster than zoomer langs like Odin. You should try it.
Kapendev 13 hours ago||
Zoomer is a good word btw. I love zoomers.
usrbinenv 16 hours ago|||
And? Does it work? Because it does. It's a lot closer to C++ and you literally need like a week to start being productive and it's insanely flexible as a language. Nobody uses Swift also, but the additional problem with Swift was that it's entirely Apple-centric.
thiht 15 hours ago|||
> Nobody uses Swift also

Yep, it was also a weird, not entirely pragmatic choice, even if it was well justified technically and all-in-all rational. D would be the same.

cromka 15 hours ago|||
Entirely Apple-centric?
throwaway2037 16 hours ago||
Fuck me. This is wild. Sorry for the potty mouth.

    > Porting LibJS
    > Our first target was LibJS , Ladybird’s JavaScript engine. The lexer, parser, AST, and bytecode generator are relatively self-contained and have extensive test coverage through test262, which made them a natural starting point.

    > Results
    > The requirement from the start was byte-for-byte identical output from both pipelines. The result was about 25,000 lines of Rust, and the entire port took about two weeks. The same work would have taken me multiple months to do by hand.
I'm not here to troll the LLM-as-programmer haters, but Ladybird (and Rust!) is loved by HN, and this is a big win.

How long until Ladybird begins to impact market dominance for Chrome and Firefox? My guess: Two years.

surajrmal 14 hours ago|
Note that Firefox doesn't have market dominance. It is under 5% market share. That said I imagine Firefox users to be the most likely to make the jump. However, the web is a minefield of corner cases. It's hard to believe it will be enough to make the browser largely useful enough to be a daily driver.
NoboruWataya 8 hours ago||
Why do you think Firefox users would be most likely to make the jump? The main reason I see people give for supporting Ladybird is challenging the dominance of the incumbents. That's not really a great reason to switch from Firefox because, as you note, it doesn't have any dominance. And there's also an argument that splitting the non-Chrome market into two only increases Chrome's dominance.

From what I can tell from HN, Brave seems to be popular with those users who hate Google but for whatever reason hate Mozilla even more, and I suspect those will be the most likely users to switch.

kayo_20211030 8 hours ago|
I don't get it, and I don't have a dog in the C/C++ vs. Rust race. Ladybird has ~1200 contributors with a predominance of C++ contributions, followed by HTML, and with "other" lying at 0.5%.

That's a lot of people contributing.

How many of them will be less willing to contribute in the future, and less productive when they do if a sizable portion is in Rust? Maybe there'll be more contributions and maybe there'll be less. I don't know. If you've managed to develop a community of 1200 developers who are willing to advance the project why upset the applecart?

Perz1val 7 hours ago|
There is a flock of people yelling around that they'd contribute if it was Rust, but won't touch C++
More comments...