What is the design philosophy behind Rust declaration and assignment syntax and what were the problems with the traditional C/C++/C#/Java syntax that inspired them to change ?
I actually see a lot of newer languages choosing this same syntax, and I was very curious WHY ?
// Rust, Golang, Kotlin, Jai, Zig:
let number := 5;
let x: i32 = 10;
// C/C++/C#/Java
int number = 5;
int x = 10;
Notice that in the C-variants, the type is explicit (except when using auto or var keywords).
In Rust, the type declaration is optional.
So… I am guessing that on the scale of verbosity-VS-conciseness, Rust choose to be more concise and easier to WRITE rather than choosing verbosity and easier to READ ?
My curiosity also extends to function parameter declarations: Whereas, with C/C++/C#/Java i am used to
// Type goes before parameterName
void example(int param) { }
with Rust:
// parametersName goes before Type
fn example(param: i32) { }
Here I see that Rust is being consistent (which is refreshing). But god, I’ve read through so much Java code that I am used to the Type being “front and center” which means that the Rust equivalent is very difficult to read (as quick as I’m used to)… indeed, I don’t really care about what the parameter’s name is… To me, that’s an implementation detail that I don’t even need to know about… For functions, methods, & constructors… I am more concerned with what the types are… so that I can fill out the signature correctly… Then coding merely becomes an easy exercise akin to Legos where you merely fit all the building blocks together… and the compiler enforces that you’ve done it correctly.
Anyways, Rust seems like an awesome language… and I am curious what people coming from other statically-typed languages think about some of Rusts design philosophy and any problems with the traditional C/C++/C#/Java that you believe inspired Rust to go against the curve.