Pular para o conteúdo

Conheça Walt Disney World

Rust (programming language)

Rust
Paradigm(s) compiled, concurrent, functional, object-oriented, imperative, structured, statically typed
Appeared in 2006
Designed by Graydon Hoare
Developer Mozilla Labs
Typing discipline static, strong, inferred, structural
Major implementations rustc
Influenced by Alef, C++, Camlp4, Common Lisp, Erlang, Hermes, Limbo, Napier, Napier88, Newsqueak, NIL, Sather, Standard ML
OS Linux, Mac OS X, Windows
License MIT
Usual filename extensions .rs .rc
Website rust-lang.org

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.

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] It successfully compiled itself the following year.[4] The self-hosted compiler uses LLVM as its backend.

Version 0.1 of the Rust compiler was completed in January 2012.[5] Mozilla described it as an alpha release, suitable for early adopters and language enthusiasts.

To emphasize 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.”[6]

Contents

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++.[7]

Rust intentionally does not include any novel or untested ideas. The project aims to collect the best features of already-created, old languages, and collect 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, while 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 while the semantics of the language takes priority.

The system is designed to be memory safe, and it 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.[8]

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.[9]

Rust features type inference, for variables declared with the let keyword. Such variables 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.[10] Type inference does not apply to variables declared within the signature of a function; for example fn fib(n: int) -> int { } cannot be shortened to fn fib(n) -> { }.

Criticism

Early in its development, Rust prohibited the use of non-ASCII characters in identifiers. A language FAQ argued that in practice most non-English-using programmers used ASCII identifiers for naming variables and functions; however, the limitation drew criticism.[11] A language change in February 2011 removed this restriction.[12]

See also

References

  1. ^ "The Rust Language". Lambda the Ultimate. 2010-07-08. http://lambda-the-ultimate.org/node/4009. Retrieved 2010-10-30. 
  2. ^ "Project FAQ". 2010-09-14. https://github.com/mozilla/rust/wiki/Doc-project-FAQ. Retrieved 2012-01-11. 
  3. ^ Hoare, Graydon (2010-10-02). "Rust Progress". http://blog.mozilla.com/graydon/2010/10/02/rust-progress/. Retrieved 2010-10-30. 
  4. ^ Hoare, Graydon (2011-04-20). "[rust-dev] stage1/rustc builds". https://mail.mozilla.org/pipermail/rust-dev/2011-April/000330.html. Retrieved 2011-04-20. "After that last change fixing the logging scope context bug, looks like stage1/rustc builds. Just shy of midnight :)" 
  5. ^ Anderson, Brian (2012-01-20). "[rust-dev] The Rust compiler 0.1 is unleashed". https://mail.mozilla.org/pipermail/rust-dev/2012-January/001256.html. Retrieved 2012-01-20. "Today Mozilla and the Rust community are releasing version 0.1 of the Rust compiler and associated tools…" 
  6. ^ "Home". 2010-09-14. https://github.com/mozilla/rust/wiki. Retrieved 2012-01-11. 
  7. ^ Walton, Patrick (2010-12-05). "C++ Design Goals in the Context of Rust". http://pcwalton.blogspot.com/2010/12/c-design-goals-in-context-of-rust.html. 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++0x unique_ptr), and reference counting via shared_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…" 
  8. ^ "Doc language FAQ". 2010-09-14. https://github.com/mozilla/rust/wiki/Doc-language-FAQ. Retrieved 2012-01-11. 
  9. ^ Strom, Robert E.; Yemini, Shaula (1986). Typestate: A Programming Language Concept for Enhancing Software Reliability. IEEE Transactions on Software Engineering. ISSN 0098-5589. http://www.cs.cmu.edu/~aldrich/papers/classic/tse12-typestate.pdf. Retrieved 2010-11-14. 
  10. ^ Walton, Patrick (2010-10-01). "Rust Features I: Type Inference". http://pcwalton.blogspot.com/2010/10/rust-features-i-type-inference.html. Retrieved 2011-01-21. 
  11. ^ Jelliffe, Rick (2010-11-08). "Vale Java? Scala Vala palava". http://broadcast.oreilly.com/2010/08/vale-java-scala-vala-palava.html. 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 blithe 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…" 
  12. ^ "Commit dabccadd3202513ab0bcb424e2c62c90ab23062d". 2011-02-26. https://github.com/mozilla/rust/commit/dabccadd3202513ab0bcb424e2c62c90ab23062d. Retrieved 2012-01-11. 

External links

Personal tools
  • Log in / create account
Namespaces
Variants
Actions
Navigation
Toolbox
Print/export