Live data from Hacker News

Mozilla Welcomes the Rust Foundation

blog.mozilla.org

141–150 of 184 posts

Re: Mozilla Welcomes the Rust Foundation

#141
post #127

Earlier quoted context omitted.

You mean Mozilla, the organization that has maintained a 6 million LOC[1] C++ codebase continuously for nearly 20 years? If they can't pull it off with C++, I don't care who can, C++ is not the right tool for the job and you can file writing such a thing in it as an esoteric programming challenge, together with template Tetris. 1. https://www.openhub.net/p/firefox/analyses/latest/languages_...

What language is the CSS engine used by Chrome or Safari written in?

Is it a parallel CSS engine like Stylo?

Re: Mozilla Welcomes the Rust Foundation

#143
post #89

> Mozilla used Rust to build Stylo, the CSS engine in Firefox (replacing approximately 160,000 lines of C++ with 85,000 lines of Rust). I would have loved to see two competing teams rewrite it, one in C++ and the other in Rust. Saying that the rewrite is better does nothing to say WHY it's better. Refactored code is almost always radically better, even when it's in the same language, for reasons that might be insulti…

> Refactored code is almost always radically better Sometimes it is, but it is hardly the rule. New issues will always be introduced. Also, some developers get into an endless cycle of unnecessary refactoring just to use the latest and greatest of some library or framework for no real technical reason.

I'm not saying refactoring is always worthwhile (it usually isn't, in my experience anyway).

But the refactor is generally done with the benefit of hindsight of all the things you would have done differently if only you'd known then what you know now.

It's like saying that the second draft or edited manuscript of a novel isn't going to be better than the initial draft. Of course it's better the second time. In theory, you fixed what was wrong with the first one and implemented new and/or improved ideas.

If your refactored code is worse than the original, I feel like you're doing something wrong.

Re: Mozilla Welcomes the Rust Foundation

#144
post #133

Earlier quoted context omitted.

Two points: - how does the performance of those fare against Stylo? - the developer of Chrome is so insanely rich that only a tiny tiny fraction of their budgets in practice finance all of Firefox. Summary: Mozilla manages to make an equally good or better CSS engine with a lower budget? (I admit Google might be running the Chrome team on a shoestring but my bet is they don't as coming in a position were they can kil…

Saying Rust allowed Mozilla to achieve a better result for less money is a much softer claim than saying C++ is an unsuitable language choice for this problem, which is what I was responding to. The second is the claim I would dispute. The former may be true.

You are absolutely welcome to dispute it, but the fact of the matter is that an engineering team with the expertise, history and resources to write at least two iterations of a CSS processor did their homework and chose to rewrite it in Rust, realizing significant performance gains across a smaller code-base. The advantage to that team being Mozilla is that alot of the discussions that lead to these implementations are captured in meeting documents, bugzilla tickets, other places, like this blog post explaining why and how they got the gains they did: https://hacks.mozilla.org/2017/08/inside-a-super-fast-css-en...

If you want to dispute the claims, do the research, otherwise it's just your opinion against the actual implementation that is shipping to millions of devices.

Re: Mozilla Welcomes the Rust Foundation

#145
post #98

Earlier quoted context omitted.

Thanks for sharing, even though it's from 2017 it was an interesting read.

2017 is when Stylo first shipped by default in Firefox. It's not like everything has rotted since then!

On the contrary, probably very few things changed since in Stylo.

Re: Mozilla Welcomes the Rust Foundation

#146
post #23

Earlier quoted context omitted.

Mozilla already tried re-writing the CSS engine in C++ before. They failed. C++ simply wasn't usable for writing a parallel CSS engine. "This top-down structure is ripe for parallelism; however, since styling is a complex process, it’s hard to get right. Mozilla made two previous attempts to parallelize its style system in C++, and both of them failed. But Rust’s fearless concurrency has made parallelism practical!"…

So you are telling me that a parallel CSS engine can't be usable if written in C++ but large scale particle/molecule simulators, AAA game engines and other high-fidelity simulator environments are 100% C++ codebases?

AAA games usually have the shoddiest code.

Re: Mozilla Welcomes the Rust Foundation

#147
post #42
post #23

Earlier quoted context omitted.

Mozilla already tried re-writing the CSS engine in C++ before. They failed. C++ simply wasn't usable for writing a parallel CSS engine. "This top-down structure is ripe for parallelism; however, since styling is a complex process, it’s hard to get right. Mozilla made two previous attempts to parallelize its style system in C++, and both of them failed. But Rust’s fearless concurrency has made parallelism practical!"…

> C++ simply wasn't usable for writing a parallel CSS engine. I think it can be said that Mozilla was able to use Rust to achieve what they failed to with achieve with C++. It's not justified to claim that C++ is/was not suitable for this purpose. C++ offers direct, low-level control over memory, and C++ can be used to implement anything which can be implemented in Rust. Maybe Rust has certain advantages which made t…

In this case possibly the best use of C++ was to write the LLVM compiler which could then be used to implement a DSL (Rust) that is better suited to the problem at hand.

Re: Mozilla Welcomes the Rust Foundation

#148
post #126
post #94

Earlier quoted context omitted.

> C++ offers direct, low-level control over memory, and C++ can be used to implement anything which can be implemented in Rust. Maybe Rust has certain advantages which made this problem a lot easier to solve for Mozilla, and I'm certainly happy to have Rust in the language landscape, but another team with other processes may have been able to use C++ to achieve similar goals. You could say the same thing about assemb…

> You could say the same thing about assembly programming or some language that uses GOTOs instead of structured control constructs ... or Brainfuck. I think this a reduction of the argument to the point of absurdity. C++ and Rust are certainly much more similar in terms of form and capability than C++ and brainfuck. > Claims about this or that language being unsuitable for a problem aren't really about stuff like Tu…

> I agree. C++ may very well have been unsuitable for Mozilla at the time they adopted Rust. What I take issue with is the general claim that C++ is not suitable for a parallel CSS engine at all. This is a very strong claim, and I do not believe one team coming to this conclusion for them is enough evidence to conclude this in general.

I know very little about rust, so take this with a grain of salt. It's possible that writing the CSS engine in C++ would require too many custom classes, containers, and build tools outside of the STL than equivalent code in Rust. For example, fast mutexes and mutex safety are not a standard part of C++ but vital to fast parallel C++ code, and the semantics of mutexes are thus very hard to get right. Static checkers for specific mutex implementations can decrease the risk of deadlocks and races but these are additions to C++. If rust provides primitive mutexes with static checking for correctness or other language features (maybe refcell or similar) then it might be worth using rust to stay within the standard language features instead of building add-ons for C++.

Re: Mozilla Welcomes the Rust Foundation

#149
post #73
post #42

Earlier quoted context omitted.

> C++ simply wasn't usable for writing a parallel CSS engine. I think it can be said that Mozilla was able to use Rust to achieve what they failed to with achieve with C++. It's not justified to claim that C++ is/was not suitable for this purpose. C++ offers direct, low-level control over memory, and C++ can be used to implement anything which can be implemented in Rust. Maybe Rust has certain advantages which made t…

The biggest advantage of Rust is that the liner types and the borrow checker forces one to structure the application in a way that is much more manageable long-term and less error-prone even with occasional sprinkle of unsafe code. Surely one can code in such style in C++, but it is very unnatural there with a lot of boilerplate, so one just would not consider it typically.

You mean "affine types". Linear types are required to be used while Rust allows one to manually drop a type. This allows you to get the next state and do nothing with it while a linear type would compel you to move to the next state.

Re: Mozilla Welcomes the Rust Foundation

#150
post #23

Earlier quoted context omitted.

Mozilla already tried re-writing the CSS engine in C++ before. They failed. C++ simply wasn't usable for writing a parallel CSS engine. "This top-down structure is ripe for parallelism; however, since styling is a complex process, it’s hard to get right. Mozilla made two previous attempts to parallelize its style system in C++, and both of them failed. But Rust’s fearless concurrency has made parallelism practical!"…

> Mozilla already tried re-writing the CSS engine in C++ before. They failed Blaming the tool for own failure to do the job isn't all that persuasive. > C++ simply wasn't usable for writing a parallel CSS engine. It might be not so much the proof of C++ deficiency as simply another manifestation of mismanagement of the browser development by Mozilla Foundation. > But Rust’s fearless concurrency has made parallelism p…

> Blaming the tool for own failure to do the job isn't all that persuasive.

I would argue it is persuasive if switching to a new tool lead to success. What would be the point of continuing to try the thing that's not working?

Post reply on HN