Live data from Hacker News

Mozilla Welcomes the Rust Foundation

blog.mozilla.org

61–70 of 184 posts

Re: Mozilla Welcomes the Rust Foundation

#61

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

They don't explicitly state that the rewrite is better? They just mention that they reduced the amount of code from 160,000 to 85,000 lines. Using competing teams for this purpose seems like a waste of money to me.

> Using competing teams for this purpose seems like a waste of money to me.

You're not wrong! My point was more that we can't take this single data point as proof of Rust's superiority.

Re: Mozilla Welcomes the Rust Foundation

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

A steak knife makes a poor scalpel but with enough effort you could probably perform a kidney transplant with one. It would just take 5 times at long and the patient would be at serious risk of bleeding out the entire time.

You could in theory write the CSS engine in assembly too. A theoretical team, somewhere, could probably manage it. But given better options, it is not a reasonable thing to do.

Re: Mozilla Welcomes the Rust Foundation

#63
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?

Having worked in a AAA engine, with some of the things I saw done to make the performance tradeoffs I wouldn't want that code style anywhere near a security sensitive domain like the browser.

Re: Mozilla Welcomes the Rust Foundation

#64

Earlier quoted context omitted.

I started following it when he first started working on it back then, but I actually lost (some) interest once it became more about the memory safety features. It's not that I don't think the borrow checker etc. stuff is really awesome. I just find the original concept very appealing and incremental. Essentially an OCaml for systems level programming. A sane C++. I feel like Rust is making its moves slowly into that…

I'm just curious, feature-wise, what keeps OCaml from being an OCaml for systems level programming?

1. Control of memory layout is a big one. Ocaml has a very lisp-like object representation except without a cons-cell special case. If you try to directly translate some ocaml to rust (and the types are ok), you will gain from having fewer pointer dereferences and likely more cache-friendly shallow data structures in the standard library. There are some plans to make the compiler better for layout control (look for “unboxed types”)

2. Parallelism. There is currently a python-like lock so that only one thread may run ocaml at a time. There is a long-running project (multicore) to fix this

3. (Opinionated) lack of control of mutability: it is easy to have everything immutable or an object with fields that are always mutable, but you can’t easily have something like rust’s mut, which only sometimes allows mutation. Some changes to this may come with/after algebraic effects which come after multicore, but these are mostly about avoiding atomically where possible rather than making things const.

4. The compiler just isn’t as good as a c++ compiler and it needs to be better to undo a deeper stack of abstractions. I think it’s particularly bad for not really doing monomorphisation. On the other hand, it’s fast.

5. (Opinionated) it isn’t great for writing generic code, but maybe modular implicits will fix that.

That said, it is possible to write fast systems level programs in ocaml (you can be careful and avoid allocation in critical sections, or just have gc because for most systems it doesn’t matter that much. You can split things into multiple processes if necessary.) You could look at mirage for an example of something big and low level written in ocaml.

Re: Mozilla Welcomes the Rust Foundation

#65
post #59

Earlier quoted context omitted.

I'm just curious, feature-wise, what keeps OCaml from being an OCaml for systems level programming?

The GC and the GIL.

The GIL is not problematic if one uses processes, not threads, for parallelism. And for system-level programming it may be even better long-term solution as one can sandbox child-processes.

But GC is really problematic.

Re: Mozilla Welcomes the Rust Foundation

#66

I've never seen the original introduction of Rust from Graydon Hoare before seeing the link in this post: http://venge.net/graydon/talks/intro-talk-2.pdf The original vision for Rust sounds a lot like a typed Erlang without the BEAM.

I started following it when he first started working on it back then, but I actually lost (some) interest once it became more about the memory safety features. It's not that I don't think the borrow checker etc. stuff is really awesome. I just find the original concept very appealing and incremental. Essentially an OCaml for systems level programming. A sane C++. I feel like Rust is making its moves slowly into that…

If you can stomach a GC enabled by default, a D is a good attempt at sane C++. The syntax is instantly familiar for a C++ programmer, and the templates are very similar to C++ (although saner).

Re: Mozilla Welcomes the Rust Foundation

#67

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

They don't explicitly state that the rewrite is better? They just mention that they reduced the amount of code from 160,000 to 85,000 lines. Using competing teams for this purpose seems like a waste of money to me.

You're making some big assumptions here and I don't think you even realise it.

Re: Mozilla Welcomes the Rust Foundation

#68

Earlier quoted context omitted.

I guess that depends on where the engineers are, and how much they are paid - I've never known anyone (in coding) to be paid > £100k (~$140k) - but then maybe I move in the wrong circles! So you could certainly get more than 4 engineers on board, plus some project managers etc

> I've never known anyone (in coding) to be paid > £100k (~$140k) - but then maybe I move in the wrong circles! In London, >£100k is easy for contractors but I think you'd have to have some managerial responsibilities to get that as a perm (team lead or upwards.) But I may also be moving in the wrong circles...

Ah yes, I didn't consider contractor rates

Re: Mozilla Welcomes the Rust Foundation

#69
post #6
post #3

I know Mozilla played a big part w.r.t Rust, but it's strange to see this on the front page... we had this 2 days ago https://foundation.rust-lang.org/posts/2021-02-08-hello-worl... , and now we have a low-effort blog post front-paging that is welcoming the foundation.

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 language.

Re: Mozilla Welcomes the Rust Foundation

#70

I've never seen the original introduction of Rust from Graydon Hoare before seeing the link in this post: http://venge.net/graydon/talks/intro-talk-2.pdf The original vision for Rust sounds a lot like a typed Erlang without the BEAM.

I started following it when he first started working on it back then, but I actually lost (some) interest once it became more about the memory safety features. It's not that I don't think the borrow checker etc. stuff is really awesome. I just find the original concept very appealing and incremental. Essentially an OCaml for systems level programming. A sane C++. I feel like Rust is making its moves slowly into that…

Yeah agreed. While they're improving some of the usability around it, it is still a bit hard to understand.

But I think it is beating C++ at its own race. The C++ weirdness is just... Bureaucratic and verbose.

Rust is clunky at times but even then it is smoother than C++

Post reply on HN