Comment Rust made a mistake in going C++-syntax (Score 3, Interesting) 149
They could have made the same simple concepts without going C++ style. This is obviously just aesthetics, but I don't think the language looks nice compared to lots of newer languages (Swift, Ruby, Kotlin, and even D).
The
This match syntax is just ugly and hard to type:
match header[0] {
1 => Ok(Version::Version1),
2 => Ok(Version::Version2),
_ => Err(ParseError::InvalidVersion)
}
The following is ugly and is not obvious:
use std::sync::{Arc, Mutex};
use std::thread;
use std::sync::mpsc;
fn main() {
let data = Arc::new(Mutex::new(0u32));
let (tx, rx) = mpsc::channel();
for _ in 0..10 {
let (data, tx) = (data.clone(), tx.clone());
thread::spawn(move || {
let mut data = data.lock().unwrap();
*data += 1;
tx.send(());
});
}
for _ in 0..10 {
rx.recv();
}
}
A simple printf function has to be a macro, because the techniques it uses are unsafe which is a main feature of the language.
OK a lot of these gripes are trivial; I guess I'm getting at the fact that they went an academic route about how to deal with pointers and memory allocation safely, and then built everything around that. It was so academic and engineering-like and they didn't think or try very hard about the design and aesthetics.