HTML5 Zone is brought to you in partnership with:

Dr. Axel Rauschmayer is a freelance software engineer, blogger and educator, located in Munich, Germany. Axel is a DZone MVB and is not an employee of DZone and has posted 246 posts at DZone. You can read more from them at their website. View Full User Profile

Servo: A Vision for the Future of Firefox

02.03.2012
| 3872 views |
  • submit to reddit
Recently, Mozilla stopped the Electrolysis project [1] that was to give Firefox per-tab processes. Hence, I was relieved when David Bruant pointed out to me that Mozilla haven’t given up on a parallel browser. They are working on a project called Servo which is being implemented in the Rust programming language.

Servo – the next Firefox

Firefox has grown to a very large code base, written in C++. C++’s main forte is speed. Writing a web browser in it poses two problems:

  • Safety: one of the key issues for a web browser is to keep users safe from attacks. C++ is an inherently unsafe language (especially when it comes to memory management).
  • Parallelism: Single-core speeds are improving at a decreasing rate, hence multi-core parallelism is the best strategy for making the web faster. C++ is not ideally suited for parallel programming.

With C++, safety and parallelism are antagonistic goals. Quoting Brendan Eich [2]:

Adding more threads to utilize multiple cores while fighting security bugs is like team-juggling chainsaws to music where the record player has been sped up!

The Servo project [2] is about building a parallel browser:

  • Use Rust instead of C++ which is safer and better equipped for parallelism.
  • Try to parallelize as many stages of the rendering process as possible (ongoing research).
  • Implement the DOM mostly in JavaScript (which makes it faster, because there are less context switches).

Note that Servo is a research project, it may or may not become an actual product. Furthermore, Firefox will be evolved in parallel; first voices on Firefox 10 sound positive. For example, the following tweet by Mikeal Rogers:

Firefox 10 looks like it's going to pull me away from Chrome. Crazy fast & the new inspector is amazing.


The Rust programming language

On January 20, 2012, the release of Rust 0.1 was announced on the rust-dev mailing list. The announcement describes Rust as a “strongly-typed systems programming language with a focus on memory safety and concurrency”. Version 0.1 is usable, but many features are still in flux:

This is the initial release of the compiler after a multi-year development cycle focusing on self-hosting, implementation of major features, and solidifying the syntax.

Version 0.1 should be considered an alpha release, suitable for early adopters and language enthusiasts. It's nifty, but it will still eat your laundry.


Rust
is an interesting language. To me, it looks like a mixture of C (syntax), Common Lisp (polymorphism via generic functions), Erlang (Actor-style concurrency), ML (immutable data, modules), and several other ideas. The following code from the language tutorial gives you a first impression:

    fn fac(n: int) -> int {
        let result = 1, i = 1;
        while i <= n {
            result *= i;
            i += 1;
        }
        ret result;
    }


As a systems language, Rust shares several goals with Google’s Go, but its inception predates that language. Mozilla plans to use it for desktop applications and server-side endeavors.

References

  1. Firefox Electrolysis project put on hold
  2. Future Tense (slides from Brendan Eich’s talk during a Mozilla all-hands in April 2011)

 

Source: http://www.2ality.com/2012/02/servo.html

 

Published at DZone with permission of Axel Rauschmayer, author and DZone MVB.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

Tags: