Live data from Hacker News

Mozilla Welcomes the Rust Foundation

blog.mozilla.org

111–120 of 184 posts

Re: Mozilla Welcomes the Rust Foundation

#111

> 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…

Is there a comparison of Stylo to the Chromium/Blink equivalent somewhere? Performance, complexity, etc?

Re: Mozilla Welcomes the Rust Foundation

#112
post #69
post #6

Earlier quoted context omitted.

Mozilla also played a big part in this foundation being necessary after it laid off most of its employees involved in Rust last year. The foundation is a good idea of course, but they could have handled it better, e.g. setting up the foundation first, so that the Rust developers could transition to it without the disturbance and bad PR generated by the layoffs? It's not that Mozilla is so cash-strapped that it had to…

> setting up the foundation first, so that the Rust developers could transition to it I don't think the Foundation ever plans to employ so many people to work on the language. Most of the people who left Mozilla now continue to work on Rust at Amazon, Microsoft and Facebook. By no means am I defending Mozilla here, just saying that the Foundation wasn't the solution to employ 10+ engineers working full time on the la…

Yeah, of course a Big Tech company would rather employ a developer and allow them to contribute to Rust (and influence its development in the direction of the company they work for) than donate money to the foundation so that it can pay developers. Silly me...

Re: Mozilla Welcomes the Rust Foundation

#113
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…

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

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

Re: Mozilla Welcomes the Rust Foundation

#114
post #23

> 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…

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!"…

> They failed. C++ simply wasn't usable for writing a parallel CSS engine.

WebKit has CSS engine is written in C++. Chromium has one too.

Re: Mozilla Welcomes the Rust Foundation

#115
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!"…

> They failed. C++ simply wasn't usable for writing a parallel CSS engine. WebKit has CSS engine is written in C++. Chromium has one too.

It’s not currently parallel though, right? That part is critical to the point being made.

After all, Gecko had a C++ implementation too. Nobody is suggesting that any implementation is literally impossible.

Re: Mozilla Welcomes the Rust Foundation

#116
post #78
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…

One thing that software developers frequently forget to do is to be humble. It is entirely possible that the best developers on this planet using the best tools and methodologies, processes, whatever, are just not smart enough to do some things. Considering how many things we have achieved, we should just acknowledged this human attribute: imperfection. If our tools require us to be perfect, maybe they're just not go…

> If our tools require us to be perfect, maybe they're just not good tools for some goals.

> if they failed a few times, that's a pretty strong argument against C++.

Well, they're migrating (at least part of) the codebase to Rust, in a lot of places because of security. Make your own conclusion, I guess?

Re: Mozilla Welcomes the Rust Foundation

#117
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!"…

> They failed. C++ simply wasn't usable for writing a parallel CSS engine. WebKit has CSS engine is written in C++. Chromium has one too.

And Firefox had one too. But it wasn't parallel. That's what is being discussed here.

Re: Mozilla Welcomes the Rust Foundation

#118
post #34

Earlier quoted context omitted.

The quote says that a parallel CSS engine in C++ was hard to get right in their case.

Parallelism is hard in both Rust and C++. When I think about low level parallelism, like in the case of rendering, I believe that Safe Rust will only get you so far perfomance-wise. To get the best speed you will still need unsafe. I'm wondering how their engine fares compared to Chrome.

It's not really scientific but if you look at the language benchmark game Rust is generally toe-to-toe with C++ without requiring any unsafe code.

Here's a random example: https://benchmarksgame-team.pages.debian.net/benchmarksgame/...

Rust is pretty damn close to the fastest C++ version without any unsafe (but using a bunch of generic libraries which may have unsafe code, to be perfectly fair).

Note that the winning C++ entry is also vastly more complex code and I wouldn't want to have to maintain that.

The n-body benchmark is even more in Rust's favour: https://benchmarksgame-team.pages.debian.net/benchmarksgame/...

Here Rust wins the benchmark without unsafe or non-std dependencies. I also find the code very readable and natural looking.

Disclaimer: I love Rust so much that I wish that I could marry it, I'm obviously thoroughly biased.

Re: Mozilla Welcomes the Rust Foundation

#119
post #44

Earlier quoted context omitted.

The post's claim is: > C++ simply wasn't usable for writing a parallel CSS engine. That's a stronger claim than that C++ was hard to get right. It's a claim that the language is not up to the task.

When the time cost of getting it right and _keeping_ it right exceeds the amount of time actually available in a day, the result is equivalent to "the language is not up to the task". I mean, you can implement anything you want in assembly, in theory. In practice, the cost of iteration tends to be high enough that implementing things with somewhat rapidly changing requirements (which includes CSS, to be clear!) prett…

The fact that we disagree does not imply "confusion on my part".

> When the time cost of getting it right and _keeping_ it right exceeds the amount of time actually available in a day, the result is equivalent to "the language is not up to the task".

Again, this is referring to the particular approach that the Mozilla team took to the problem. If anything, one of the most valid criticisms of C++ is that the API is too large, and it has too many tools to work with at the expense of clarity. C++ allows you to express just about anything, and I do not think the standard of evidence has been met that the problem of writing a CSS engine could not be expressed in C++ in a way which would be both performant and maintainable.

C++ has been used for many complex, high-profile projects which are widely used. There is nothing magical about CSS which creates problems C++ is incapable of solving.

Re: Mozilla Welcomes the Rust Foundation

#120
post #57

Earlier quoted context omitted.

Unsafe rust exists for a reason. There are cases where perfectly safe code cannot be expressed according to Rust's ownership rules, and an escape hash is needed. Of course the "average" developer probably should not resort to unsafe as a rule of thumb. Also regarding the standard library, as far as I understand it's not entirely true that it never resorts to unsafe rust. For example, I understand that the standard li…

> Also regarding the standard library, as far as I understand it's not entirely true that it never resorts to unsafe rust. I think you're misunderstanding the parent comment. The stdlib constantly resorts to unsafe code. Tons of methods like `split_at_mut` and `make_ascii_uppercase` are just safe wrappers around an unsafe one-liner. Rather, the observation is that _with the benefit of the stdlib and common crates_, m…

I agree that most developers don't need to bother with unsafe code, and will not pay a performance penalty for staying within safe rust. My only point is that it's not necessary to be so dogmatic as to say that no-one should ever write a line of unsafe rust.

For instance, if you read the rust book, they make references to times you might want to use unsafe:

> Borrowing different parts of a slice is fundamentally okay because the two slices aren’t overlapping, but Rust isn’t smart enough to know this. When we know code is okay, but Rust doesn’t, it’s time to reach for unsafe code.

Post reply on HN