Rust is a programming language that compiles into native machine code. Despite being a static-typed, compiled language, Rust contains many features typically found in interpreted, dynamic-typed languages such as:
- Type inference (E.g. no need to specify type for everything)
- Multi-variable assignment syntax
- For loops that run over collections (typically called ‘for-each’ in other lnaguages)
- ‘If’ treated as an expression rather then a statement
- A classless object system that allows one to use object-oriented syntax without having to maintain complex class hierarchies (Ruby`s ‘open classes’ without classes)
- A build tool that can resolve module hierarchies without resorting to things like C`s ‘#include’
- Generics and Traits that would let you do most things you would otherwise use ‘duck typing’ or class inheritance based polymorphism to do
- Macros that let you create mini-DSLs
The most interesting feature of Rust is its approach to resource management. Rust eschews the garbage collector in favor of inventing a concept called ‘ownership’. Ownership allows the compiler to track, at compile time, where and how resources are used, guard against typical resource usage and sharing errors, and inject allocation and de-allocation code where needed.
Rust’s basic syntax is reminiscent of the ‘C’-style family of languages, so it should be familiar to many programmers. Rust includes other interesting qualities apart from those mentioned above:
- Built-in syntax for unit testing.
- Built-in syntax for auto-generating documentation, that allows using markdown in the comments.
- Various pointer types to mitigate typical pointer programming problems (Some of them are only possible because of ‘ownership’).
- Concurrency and threading built into the language syntax.