Home / Definitions / Rust

Rust

Webopedia Staff
Last Updated May 24, 2021 8:03 am

Rust is an open source programming language focused on performance and safety, particularly safe concurrency, meaning that many computations can be performed at the same time or out of order. Rust is syntactically similar to C++, but it provides increased speed and better memory safety. It was developed by Mozilla to be a better tool for developing the Mozilla Firefox browser, but the language has since become useful to many programmers for software development because of its effectiveness. Rust offers the syntax advantages of high-level languages with the control and performance of low-level languages.

Rust is used to develop device drivers and operating systems such as BlogOS, Redox, Rux, and Tock. While Rust and C++ are similar, they have their differences. Rust is safe by default—all memory accesses are checked. It is impossible to corrupt memory by accident. It does, however, allow users to write unsafe code if desired. In comparison, unsafe code is the default in C++. Unsafe code is more vulnerable to security threats and harder to keep bug-free, but it can, on occasion, be useful in achieving performance gains.

Rust is a statically-typed language rather than a dynamic one, meaning that all types are known at compile-time instead of at run-time. This allows for a large class of errors to be caught in the early stages of the development process and for compiled code to be executed more quickly because the compiler knows the exact data types that are in use. The unifying principles behind Rust are:

  • Strictly enforcing safe borrowing of data
  • Functions, methods, and closures to operate on data
  • Tuples, structs, and enums to aggregate data
  • Pattern matching to select and destructure data
  • Traits to define behavior on data