Hello World
Recently, I've been hearing about the a new programming language called Rust. According to its homepage:
Rust is blazingly fast with a rich type system and ownership model that guarantees memory-safety and thread-safety.
It appears to be a replacement for C/C++ as a concurrent systems programming language, a certainly welcome niche. I know well the pain of developing multithreaded applications in C++ - data races too commonly lead to dreaded undefined behavior.
Rust is heavily inspired by Haskell, so it has all the strappings of functionalism (closures and higher-order functions, iterators, pattern matching, error handling), along with true Lisp-style macros. The classic "hello world" program makes use of the println! macro:
fn main() { println!("hello world"); }
And the classic "hello world" of functional programming, a factorial function which makes use of Rust's pattern matching and higher-order functions:
fn main() { fn fact(n: u64) -> u64 { match n { 0 | 1 => 1, _ => fact(n - 1) * n } } let x = fact(5); println!("{}", x); }
Rust has not yet been optimized for tail recursion, though.
A lot of this is pulled from the little I've seen of Rust so far. I hope you'll find some value from this journal of my exploration of Rust.