Mozilla's Rust: Safe, Concurrent and Practical Language

Rust language logoMozilla released the first numbered alpha released of Rust compiler in January 20th, 2012, after the work done by its lead developer Graydon Hoare since 2006. Mozilla stated that Rust is designed to be a "safe, concurrent, practical language", supporting pure-functional, concurrent-actor, imperative-procedural, and object-oriented styles.

Rust takes advantage of well-understood programming language technology, and combined it to create an aggressive compile-time error checking with the high degree of direct control over the machine necessary to write efficient programs.

According to Rust, "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."

Rust development version evolves quickly and is quite ahead of this release. After Mozilla got involved in the project in 2009, Rust was able to compile itself in 2011. Rust uses LLVM as its backend.

Rust is developed entirely in the open and solicits feedback and contributions from the community. The design of the language has been refined through the experiences of writing the Servo layout engine and the Rust compiler itself. Although its development is sponsored by Mozilla and Samsung, it is a community project. A large portion of current commits are from community members.

The goal of this general purpose, multi-paradigm, compiled programming language, is to be a language for the creation of large client and server programs that run over the internet. The syntax is very much similar to C and C++, and control-flow keywords such as if, else, do, while, and for. However, not all C or C++ syntax are present.

The system is designed to consume little memory and doesn't permit null pointers or dangling pointers. Rust's data values can only be initialized through a fixed set of forms that require inputs to be already initialized. A system of pointer lifetimes and freezing allows the compiler to prevent usual C++ errors. Rust also has stronger compile-time correctness checking than what C++ compilers provides.

Rust supports large-scale programming and its needs for reliability, efficient use of space and time, and concurrency.

Rust that features type inference, is similar to Erlang. In such systems, tasks communicate via message passing, rather than sharing data directly. For performance reasons, Rust also enables data to be sent without copying, using unique boxes. These unique boxes only have one owner, and can be released by the sending task for use by the receiver.

Rust is also influenced by Alef, C#, C++, Camlp4, Common Lisp, Cyclone, Haskell, Hermes, Limbo, Napier, Napier88, Newsqueak, NIL, Ocaml, Racket, Ruby, Sather and Standard ML

The object system within Rust is based around implementations, traits and structured types. Implementations fulfill a role similar to that of classes within other languages, and are defined with the impl keyword. Inheritance and polymorphism are provided by traits; they allow methods to be defined and mixed in to implementations. Structured types are used to define fields. Implementations and traits cannot define fields themselves, and only traits can provide inheritance, in order to prevent the diamond inheritance problem of C++.

In its initial release, Rust's features include:

  • Unique pointers, unique closures, move semantics.
  • Interface-constrained generics.
  • Static interface dispatch.
  • Stack growth.
  • Multithread task scheduling.
  • Typestate predicates.
  • Failure unwinding, destructors.
  • Pattern matching and destructuring assignment.
  • Lightweight block-lambda syntax.
  • Preliminary macro-by-example.