Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

C vs Rust

Name: Anonymous 2015-02-13 1:07

C:
int main(int argc, char **argv) {
int r;
if(argc > 1) {
r = atoi(argv[1]);
} else {
usage();
exit(EXIT_FAILURE);
}
}


Rust:
fn main() {
let argv: Vec<Result<String,OsString>> = std::env::args()
.map(|x| x.into_string())
.collect();

let r = match argv.get(1) {
Some(x) => match x.parse::<i32>() {
Ok(v) => v,
Err(_) => {
show_usage();
panic!()
},
},
None => {
show_usage();
panic!()
}
}
}


Type explosion is to be expected. Do notation could have been used to keep the control logic as clean as C, but Rust is not HASKAL and never will be anything like HASKAL and you're an asshole for wanting to write readable code you filthy shit fuck.

Name: Anonymous 2017-04-29 18:56

Rust is very fast.

C:
#include <stdio.h>

int main()
{
int total = 0;
for (int i = 0; i < 100000; i++)
{
for (int j = 0; j < i; j++)
{
total += (j * j == i) ? j : 0;
}
}

printf("%lu\n", total);
return 0;
}
50085
real 8.25
user 8.25
sys 0.00

fn main() {
let mut total: i32 = 0i32;
for i in 1..100_001 {
for j in 1..i {
total += if (j*j) == i {j} else {0i32};
}
}
println!("{}", total);
}
50085
real 2.61
user 2.61
sys 0.00

And it's fair to claim that Rust enforces memory safety unlike C or C++. Reason why C/C++ programs are so vulnerable. The example in the OP just goes to show Rust handles errors better and it trains the programmer to do so.

Rust has a decent dev environment. The cargo is a very good project manager, Rust language server is the combination of Clang format, Clang complete and CPP check, with more features like snippets etc. And lastly, the Rust compiler is very impressive. For a language that's 2 years old it certainly helps produce fast, optimized and safe binaries that C never did. Rust compiler is like GCC+CPP check combined.

So FUCK YOU. Stay confined in your bubble world of baby duck syndrome while you can, I just got sick and tired of edgy C tards like you. No wonder C is dying.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List