Rust is a compiled programming language which aims to replace C++. The designers wanted it to be similar fast, give the programmer similar fine-grained control over memory management, but more safety.
Rust does so by introducing the concept of ownership, borrowing and lifetimes of variables. Rust also makes sure that after the scope is finished, the memory of variables gets de-allocated.
I think FFI is interesting. It allows Rust to "talk" with C code.
Rust 1.0 was just released (source). This means the language should be stable.
If you want to know more, you should take a look at the beautiful A 30-minute Introduction to Rust.
Syntax Example
fn fib(n: u32) -> u32 {
if n <= 1 {
return n;
} else {
return fib(n-1) + fib(n-2);
}
}
fn main() {
let n = 36;
println!("The {0}th Fibonacci number is {1}.", n, fib(n))
}
Video introduction
Comparison
- benchmarksgame shows that rust is similar fast as C++. For some games it is faster, for some slower. Sometimes it needs less code, sometimes more.
- stackoverflow has only 1781 questions of which are 102 unanswered (5.7%). C++ has 356,824 questions and 55,172 questions are not answered (15.5%). But I guess that will change as soon as more people use Rust (and libraries written in Rust).
- GitHub: Wow, Rust seems to be growing fast!
Tools
As rust is still in very heavy development, you should build it yourself from the source at GitHub. Don't worry, there are very detailed instructions. (But it takes a lot of time to compile.)
cargo
package manager- Syntax Highlighting and auto completion for ST3 (via Package Control)
- Auto completion with Racer
Comparison to C++
1: No crashes because of code misuse (as long as you do not use unsafe {} )
2: No memory leaks
3: No data races (so you can thread this thing like mad, but better is has async task handling (crs pattern to). So lighting up your machines cores is no prob.
4: Cross platform (really much better than most)
5: Inbuilt version management, build system and test harness (with benchmarking to).
6: Package management system (no more I Cannot build XX, it becomes automatic)
7: Inbuilt generics and traits (c++ concepts and more)
8: Very strongly typed (near zero runtime)
9: Very fast
10 compiles into a c lib basically (easy integration)
Source: dirvine
See also
- www.rust-lang.org: Official Website
- doc.rust-lang.org: Shown with
fmt
- looks very nice! - doc.rust-lang.org/intro.html
- doc.rust-lang.org/book/
- doc.rust-lang.org/reference.html
- blog.rust-lang.org
- crates.io: Hosting site for community packages ☺
- rustbyexample.com
- joshondesign.com/2014/09/17/rustlang: A short introduction to Rust with a tiny ray tracer.
- learnxinyminutes.com/docs/rust
Conclusion
Rust looks very, very interesting. I am usually not a fan of new languages (e.g. I don't see a reason to use Go, Swift ... not to speak of Clojure, Julia, TypeScript, Dart). Most of the time, I don't see anything new which is better than in existing languages and almost always the material around (tools, libraries, community) is much worse than in existing solutions.
This seems to be different with Rust. Rust seems to provide everything I enjoy from Python, but in the fast, explicitly typed world.
@Johannes: Thanks for pointing me to Rust ☺