Ever-focused on advancing the Web, Mozilla’s research arm has joined forces with Samsung to create a new browser engine based on a new programming language called Rust.
Mozilla Research is collaborating with Samsung to deliver an advanced technology Web browser engine called Servo that will take advantage of the faster, multi-core, heterogeneous computing architectures on the horizon. And Rust is the language Mozilla felt compelled to create purpose-built for the task.
“Servo is an attempt to rebuild the Web browser from the ground up on modern hardware, rethinking old assumptions along the way,” Brendan Eich, CTO at Mozilla, wrote in an April 3 blog post. “This means addressing the causes of security vulnerabilities while designing a platform that can fully utilize the performance of tomorrow’s massively parallel hardware to enable new and richer experiences on the Web. To those ends, Servo is written in Rust, a new, safe systems language developed by Mozilla along with a growing community of enthusiasts.”
Mozilla and Samsung are bringing both the Rust programming language and Servo, the experimental Web browser engine, to Android and ARM, Eich said. This will enable them to further experiment with Servo on mobile. And Samsung has contributed an ARM back-end to Rust and the build infrastructure necessary to cross-compile to Android.
But why the need for yet another programming language? “Rust, is a systems language that is focused on speed, safety and concurrency,” a Mozilla spokesperson told eWEEK. “Rust is an attempt to create a modern language that can replace C++ for many uses while being less prone to the types of errors that lead to crashes and security vulnerabilities. Because Servo is designed from the ground up using Rust as its main implementation language, Servo will also tend to avoid sources of bugs and security vulnerabilities associated with incorrect memory management common to browsers implemented in unsafe languages such as C++, resulting in a faster, more secure experience for people browsing the Web.”
Eich goes a bit further in his post:
“Rust, which today reached v0.6, has been in development for several years and is rapidly approaching stability. It is intended to fill many of the same niches that C++ has over the past decades, with efficient high-level, multi-paradigm abstractions, and offers precise control over hardware resources. But beyond that, it is *safe by default*, preventing entire classes of memory management errors that lead to crashes and security vulnerabilities. Rust also features lightweight concurrency primitives that make it easy for programmers to leverage the power of the many CPU cores available on current and future computing platforms.”
According to the Rust language Website, “Rust is a curly-brace, block-structured expression language. It visually resembles the C language family, but differs significantly in syntactic and semantic details. Its design is oriented toward concerns of “programming in the large,” that is, of creating and maintaining boundaries—both abstract and operational—that preserve large-system integrity, availability and concurrency. It supports a mixture of imperative procedural, concurrent actor, object-oriented and pure functional styles. Rust also supports generic programming and metaprogramming, in both static and dynamic styles.”
Mozilla, Samsung Building Rust Programming Language, Servo Browser
“It is great to see experimentation with browser engines,” said Al Hilwa, an analyst with IDC. “This is also a good development for Mozilla, namely to take a varied approach to Google and work with Samsung on this. It is also Samsung flexing more platform muscles and wanting to see itself [as] something more than just a device maker.”
Mozilla and Samsung are working to complete the first major version of Rust and to provide developer tools and improve the performance of the language, Eich said.
Adding “safety” to a programming language typically means some sort of performance penalty. “Safety has a cost, but Rust tries to do as much at compile time as it can,” Eich told eWEEK in an email. “And runtime optimizations help: we have an nbody.c vs. nbody.rs benchmark (n-body problem solver) that shows Rust faster than gcc currently. The important point is that C++ when written with manual safety on top is both harder to write and less efficient than when the language support enables greater productivity *and* better optimizations by the compiler and runtime. Safety is not free and can’t be treated as free, but lack of safety is not an option for browsers and OSes.”
“At the same time, we will be putting more resources into Servo, trying to prove that we can build a fast Web browser with pervasive parallelism, and in a safe, fun language,” Eich said in his post. He also invited developers to help with the project and contribute to the effort by checking out the source for Rust and Servo on GitHub. “Then come participate in the development process on the Rust (https://mail.mozilla.org/listinfo/rust-dev) and Servo (https://lists.mozilla.org/listinfo/dev-servo) mailing lists,” he said.