Rust is an experimental, concurrent, multi-paradigm, compiled programming language developed by Mozilla Labs.[1] It is designed to be practical, supporting pure-functional, concurrent-actor, imperative-procedural, and object-oriented styles.
Rust | |
---|---|
Paradigm | compiled, concurrent, functional, object-oriented, imperative, structured, statically typed |
Designed by | Graydon Hoare |
Developer | Mozilla Labs |
First appeared | 2006 |
Typing discipline | static, strong, inferred, structural |
OS | Linux, Mac OS X, Windows |
License | BSD |
Filename extensions | .rs .rc |
Website | github.com/graydon/rust |
Major implementations | |
rustc | |
Influenced by | |
Alef, C++, Camlp4, Common Lisp, Erlang, Hermes, Limbo, Napier, Napier88, Newsqueak, NIL, Sather, Standard ML |
The main developer is Graydon Hoare, who began work on the system in 2006; Mozilla became involved in 2009.[2] In 2010 work shifted from the initial compiler, written in OCaml, to the self-hosted compiler written in Rust itself.[3] The self-hosted compiler uses LLVM as its backend.
To emphasise the experimental nature of the language, the Rust wiki clearly states: “This is a very preliminary work in progress. No supported releases yet nor defined release schedule/plans. Caveat emptor. It will crash. It will change syntax and semantics. It will eat your laundry. Use at your own risk. Etc.”[4]
Description
The goal of Rust is to be a good language for the creation of large client and server programs that run over the Internet. This has led to a feature set with an emphasis on safety, control over memory layout and concurrency. Performance should be comparable to idiomatic C++.[5]
Rust intentionally does not include any novel or untested ideas. The project aims to collect the best features of already-created, old languages, and package them into a useful, practical package.
The syntax of Rust is similar to C and C++, with blocks of code delimited by curly braces, and control-flow keywords such as if
, else
, do
, while
, and for
. Not all C or C++ keywords are present, however, whilst others (such as the alt
statement for multi-directional branching) will be less familiar to programmers coming from these languages. The syntax of Rust is effectively frozen whilst the semantics of the language takes priority.
The system is designed to be memory safe, and does not permit null pointers or dangling pointers. Data values can only be initialized through a fixed set of forms, all of which require their inputs to be already initialized.[6]
In addition to conventional static typing, Rust supports typestates. The typestate system models assertions before and after program statements, through use of a special check
statement. Any discrepancies can be discovered at compile time, rather than once a program is running, as might be the case with assertions in C or C++ code. The typestate concept is not new, first being introduced in the NIL programming language.[7]
Rust features type inference, through use of an auto
keyword. Variables declared with auto
do not require a value to be initially assigned in order to determine their type. A compile-time error results if any branch of code fails to assign a value to the variable.[8]
Criticism
Outside of comments, characters and strings, Rust source code only permits the use of ASCII text. The language FAQ argues that in practice most non-English using programmers stick to using ASCII identifiers, however this has drawn criticism.[9]
See also
References
- ^ "The Rust Language". Lambda the Ultimate. 2010-07-08. Retrieved 2010-10-30.
{{cite web}}
:|first=
missing|last=
(help) - ^ "Project FAQ". 2010-09-14. Retrieved 2010-10-30.
- ^ Hoare, Graydon (2010-10-02). "Rust Progress". Retrieved 2010-10-30.
- ^ "Rust Language". 2010-09-14. Retrieved 2010-11-13.
- ^ Walton, Patrick (2010-12-05). "C++ Design Goals in the Context of Rust". Retrieved 2011-01-21.
… It's impossible to be "as fast as C" in all cases while remaining safe… C++ allows all sorts of low-level tricks, mostly involving circumventing the type system, that offer practically unlimited avenues for optimization. In practice, though, C++ programmers restrict themselves to a few tools for the vast majority of the code they write, including stack-allocated variables owned by one function and passed by alias, uniquely owned objects (often used with
auto_ptr
or the C++0xunique_ptr
), and reference counting viashared_ptr
or COM. One of the goals of Rust's type system is to support these patterns exactly as C++ does, but to enforce their safe usage. In this way, the goal is to be competitive with the vast majority of idiomatic C++ in performance, while remaining memory-safe… - ^ "Language FAQ". 2010-09-14. Retrieved 2010-10-30.
- ^ Strom, Robert E.; Yemini, Shaula (1986). "Typestate: A Programming Language Concept for Enhancing Software Reliability" (PDF). IEEE Transactions on Software Engineering. ISSN 0098-5589. Retrieved 2010-11-14.
{{cite journal}}
: Cite journal requires|journal=
(help) - ^ Walton, Patrick (2010-10-01). "Rust Features I: Type Inference". Retrieved 2011-01-21.
- ^ Jelliffe, Rick (2010-11-08). "Vale Java? Scala Vala palava". Retrieved 2011-01-21.
… It is just plain ignorant to say that non-English programmers always write with ASCII. (Just as it would be ignorant to say that they never do.) It is that kind of rather blythe dismissal that foreign cultures and languages need to be supported that creates extra unnecessary barriers. That argument ran out of legs in the early 1990s: all platforms have well -established Unicode libraries with serviceable properties for this…