A D vs. Rust example

Ola Fosheim Grøstad ola.fosheim.grostad at gmail.com
Wed Oct 26 15:48:02 UTC 2022


On Wednesday, 26 October 2022 at 14:59:02 UTC, Don Allen wrote:
> If you think that the user experience would be any different if 
> Mozilla used Go or D for the work they are doing with Firefox, 
> then you and I just need to agree to disagree.

Browsers are generally written in C++? They use a dedicate GC for 
dealing with javascript objects. The renderer for Chrome called 
Skia is written in C++ and is gradually moving rendering to the 
graphics co-processor.

You cannot easily do these things with a run-of-the-mill GC as in 
Go, and not at all with a freeze-the-world GC.

Browsers do a lot of work in the background. A browser is 
basically one gigantic runtime for javascript. You don't want to 
deal with another heavy runtime at the same time. That would make 
performance tuning very difficult.

That said, I don't know how much Firefox relies on Rust. 
Wikipedia says that Mozilla dropped Servo (the engine that was 
being implemented in Rust).

> dealing with Rust's challenges, I turned to D. The performance 
> of the C, Rust and D versions of the most processor-intensive 
> application are within a few percent of each other, 
> indistinguishable in actual use.

You probably didn't generate much garbage. And frankly, you can 
easily write a well-performing basic financial application in 
Python without paying any attention to algorithms or memory. So I 
don't think this is a good use case for comparison.

> Electron is at least partly implemented in C++. I've tried the 
> Atom editor, which is based on Electron, and it *is* annoyingly 
> slow.

Electron is just a stripped down browser with some additonal 
APIs. Electron applications are written in Javascript.

It is possible to make javascript applications perform well, but 
you need to design the software carefully and do some performance 
tuning.



More information about the Digitalmars-d mailing list