Dec-06-2016, 03:46 PM
(Nov-06-2016, 06:55 PM)micseydel Wrote: I've heard that Rust is largely replacing C. Assembly I think is useful for learning more about hardware, which is great, but shouldn't be misunderstood as (generally) useful. JS is a necessary evil right now :(
So I've been reading the Rust Book (https://doc.rust-lang.org/book/), and Rust is a crazy impressive language. Everything is immutable by default, and objects have a sense of 'ownership' and scope, which the compiler enforces, which makes cleanup easy. What I like is the way error handling is done... a given function can only raise a single type of error, if you want to return more than one, you need to create a new error type to represent it. If a function CAN return an exception, the compiler FORCES you to handle it (even if handling it is just re-raising it).
And almost everything is an expression. It almost feels like ruby, in that the last line of a function is that function's return value, even if you don't explicitly use the keyword "return". And almost everything returns a value... like match (their switch/case), or if. So you can do things like...
// this is a complete program // writes "The value: foobar" to console fn main() { let spam = "eggs"; let some_value = match spam { "12" => "twelve", "eggs" => "foobar", _ => "default value" }; println!("The value: {}", some_value); }