Well, I'm not 80% of all researchers.
In my coding, there isn't a variable that I don't mutate at one point in time. Or at least, the ratio is severely different. I do have consts but very few of them.
Okay, I'm not saying Rust is bad. The threading model in Rust is absolutely sublime but that's only because I already think C++11's threading model is sublime and Rust's is incredibly similar.
But I'm a scientific programmer. How can Rust help me? Is Rust the language I should use? These aren't meant to be hostile questions. I am literally asking, is Rust good for scientific applications? This thread has shown me that it seems best for security-intensive applications but everything I write, I want people to see everything. I also need performance above all else.
"...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson
It's also not the goal according to the developers of the language. The goal is to have a language with the same performance of C++ and better safety than Java while still not having GC. For example, it statically guarantees you have no data races, while Go only detects them heuristically. If anything, web stuff is still half-baked in Rust.
"...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson
Of course not, but it doesn't have a standard HTTP library yet, just some attempts by community members.
On another note, Rust compiler is pretty smart:
it actually realizes that this is a valid programCode:fn main() { let compiler_knows_this_is_initialized; let mut x = 1u8; loop { if x > std::rand::random() { compiler_knows_this_is_initialized = x; break; } x += 1; } println!("{:u}", compiler_knows_this_is_initialized); }
Whoa, I'm tripping out. Either I don't know enough about const-ness or you're mutating an immutable variable...
Or can read-only variables be initialized with a value once and only once? Or does the initialization have to happen at declaration? I always thought it was at declaration.
Apparently not. You can write:
the compiler knows that it wasn't used before it was initialized and it will compile and print 1Code:let x; x = 1; print!("{}", x);
if you write
the compiler will barf at youCode:let x; print!("{}", x); x = 1;
Code:const.rs:3:18: 3:19 error: use of possibly uninitialized variable: `x` const.rs:3 print!("{}", x); ^ note: in expansion of format_args! <std macros>:2:23: 2:75 note: expansion site <std macros>:1:1: 3:2 note: in expansion of print! const.rs:3:5: 3:21 note: expansion site error: aborting due to previous error
this can be done because Rust has a loop() so it knows you can only escape via break
Java does the same thing in case of for(;;) and while(true) but not in other cases like while(1 == 1) so it's a little bit embarassing that while(true) and while(1 == 1) don't work the same way