from Hacker News

How Stylo Brought Rust and Servo to Firefox

by mnemonik on 11/28/17, 5:28 PM with 191 comments

  • by kbd on 11/28/17, 8:41 PM

    It's gratifying to see how successfully the same organization has learned from the debacle that was the rewrite from Netscape 4 to Mozilla in the first place. That time, they didn't release for years, losing market share and ceding the web to Internet Explorer for the next decade. Joel Spolsky wrote multiple articles[1][2] pointing out their folly.

    This time, their "multiple-moonshot effort" is paying off big-time because they're doing it incrementally. Kudos!

    [1] https://www.joelonsoftware.com/2000/04/06/things-you-should-...

    [2] https://www.joelonsoftware.com/2000/11/20/netscape-goes-bonk...

  • by thomastjeffery on 11/28/17, 8:01 PM

    > Stylo was the culmination of a near-decade of R&D, a multiple-moonshot effort to build a better browser by building a better language.

    This is the most impressive, and useful aspect of all the recent work in Firefox. Rust is an amazing language. It really brings something new to the table with its borrow checker.

    The fact that rust was created as part of a greater effort to work on a web browser is amazing.

  • by haberman on 11/28/17, 7:39 PM

    I'm a huge, huge fan of Rust, Stylo, Servo, WebRender, etc. Hats off to everyone involved.
  • by FlyingSnake on 11/28/17, 8:36 PM

    > They borrowed Apple’s C++ compiler backend, which lets Rust match C++ in speed without reimplementing decades of platform-specific code generation optimizations.

    This was a pretty smart move by the Rust team, and this gave them a rock solid platform to go cross-platform. In words of Newton, "If I have seen further it is by standing on the shoulders of giants". Kudos team Rust, and let's hope they eat C++'s lunch soon.

  • by VeejayRampay on 11/28/17, 9:46 PM

    It might sound very naive to say this, but I found it very cool that it was someone from the States, an Aussie and a Spaniard working on this, open source is something magical when you think about it. Props to everyone involved, all those projects sound like a lot of fun for a good cause.
  • by linkregister on 11/28/17, 9:51 PM

    I love Firefox Quantum and it has replaced Chrome as my browser at home. It's memory consumption is far lower with the same amount of tabs open.

    That said, why does it perform slower than Chrome on most benchmarks? Is it due to the Chrome team doing much more grunt work regarding parallelism and asynchronous I/O? Or are there still features in the current Firefox build that still call the original engine?

    Does Rust have a runtime penalty as Golang does?

  • by DonbunEf7 on 11/28/17, 7:17 PM

    "So it’s pretty clear by now that “don’t make mistakes” is not a viable strategy."

    This is more generally known as Constant Flawless Vigilance: https://capability.party/memes/2017/09/11/constant-flawless-...

  • by Brakenshire on 11/28/17, 8:49 PM

    One thing I've been wondering is that Stylo and Webrender can parallelize CSS and Paint, respectively, but I haven't seen any mention in Project Quantum (the project to integrate Servo components into Firefox/Gecko) of any component to parallelize layout, which is probably the biggest bottleneck on the web at the moment.

    Is parallel layout something which can only be done through a full rewrite, hence with Servo, and bringing Servo up to full web compatibility, or can this be handled through the Project Quantum process, of hiving off components from Servo into Firefox?

  • by fulafel on 11/28/17, 7:28 PM

    Congratulations, it's really an unparalleled performance of parallel performance.
  • by agentultra on 11/28/17, 8:12 PM

    This is a great story. For large, existing code-bases incremental change is the only strategy I've seen work. Kudos to the team behind it.
  • by pitaj on 11/28/17, 6:50 PM

    One thing I've noticed about Firefox, especially on mobile, is that transform animations are pretty janky.

    Does anyone know if this is being worked on? Should I submit a bug report?

  • by m0th87 on 11/28/17, 8:42 PM

    > For example, register allocation is a tedious process that bedeviled assembly programmers, whereas higher-level languages like C++ handle it automatically and get it right every single time.

    Ideal register allocation is NP-complete, so a compiler can't get it right every single time.

    I'm not sure how good in practice modern compilers are at this, but would be curious to know if there's some asm writers who can actually consistently outperform them.

  • by bdmarian on 11/28/17, 8:49 PM

    I really like the new Fox. I’ve tried switching over completely but I think it’s causing some random BSODs on my Latitude E5570. The laptop does have a second Nvidia graphics card, for which there is no driver installed. ( don’t ask :) I’m perfectly fine with the onboard Intel and I much prefer the extra hours of battery life)
  • by vatotemking on 11/29/17, 5:29 AM

    > The teams behind revolutionary products succeed because they make strategic bets about which things to reinvent, and don’t waste energy rehashing stuff that doesn’t matter.

    This needs to be emphasized more

  • by Vinnl on 11/29/17, 10:01 AM

    This is a great write-up that gives me warm fuzzy feelings.

    What also is interesting for me to realise, though, is that a lot of this was happening at the same time as Mozilla was largely focused on Firefox OS, and receiving a lot of flak for that.

    It's a shame that Firefox OS failed, but it was clear that they had to try many different things to remain relevant, and it's excellent to see that one of those is very likely to pay off. Even though Rust might've been dismissed for the same reasons Firefox OS was.

  • by JupiterMoon on 11/28/17, 7:27 PM

    FF has for me crashed more times in the last week than in the previous year. - Multiple installs on different Linux systems. The last crash was with a clean profile.

    And then there's the disappearing dev tools - that's fun.

    EDIT: I hope that there is something weird with my systems. But I fear that the rush to push this out might have been a little hasty.

    EDIT EDIT Apart from the crashes the new FF has been nice. I've been able to largely stop using chromium for dev work - so not all is bad.

  • by Annatar on 11/29/17, 7:57 AM

    For example, register allocation is a tedious process that bedeviled assembly programmers,

    Yet more propaganda. I’ve been part of the cracking and demo scene since my early childhood. If you didn’t code in assembler you might as well not have taken part in it at all, because small fast code was everything. None of us ever had an issue with register allocation, nor do we face such issues today. Not 30+ years ago, not now.

  • by thomastjeffery on 11/28/17, 8:13 PM

    > the breadth of the web platform is staggering. It grew organically over almost three decades, has no clear limits in scope, and has lots of tricky observables that thwart attempts to simplify.

    It would be great to create the html/css/javascript stack from scratch, or at least make a non-backwards-compatible version that is simpler and can perform better. HTML5 showed us that can work.

  • by gjem97 on 11/28/17, 8:36 PM

    What parts of FF 57 are written in Rust? Just Stylo?

    Edit: I don't intend for this to sound like I'm complaining, just interested.

  • by mi_lk on 11/29/17, 12:07 AM

    Off-topic, but does anyone know why in FF on Mac the pinch to zoom functionality is disabled by default? Is there any performance concern?
  • by xtf on 11/29/17, 8:49 AM

    Thanks Mozilla Going to donate
  • by wyldfire on 11/28/17, 7:22 PM

    Anecdote regarding this new FF:

    I would find frequent cases where my system would stall for 10-20s (could not caps lock toggle, pointer stopped moving). I almost always have just Chrome and gnome-terminal open (Ubuntu 16.04). I had attributed it to either a hardware or BIOS/firmware defect.

    Now, after switching to Firefox I have gone a week without seeing those stalls.

    YMMV -- I never bothered to investigate, it could be something as simple as slightly-less-memory-consumption from FF, or still a hardware defect that FF doesn't happen to trigger.

  • by xstartup on 11/28/17, 9:31 PM

    I use firefox/rust every day. Thanks for the one of the most interesting language!
  • by nopit on 11/28/17, 8:00 PM

    Installed the new firefox, had 1 tab running for a few days which had allocated more than 10gb of virtual memory. I had high hopes but im sticking with chrome.