3 ms·
This language is awesome, but I'm quite conservative when it comes to syntax. I don't like how Rust is trying to move away from C when considering syntax. I ten
by jokoon 7y ago
This language is awesome, but I'm quite conservative when it comes to syntax. I don't like how Rust is trying to move away from C when considering syntax. I tend to prefer languages that can adopt the "C flavor". Python, in my view, does this very well: its syntax is simple, because it borrows a lot from C in its "flavor".
Rust is not doing that, and that's a hurdle.
In my view, the "C flavor" is very important because it's a standard of how people are able to read code. This has nothing to do with the C programming language, I'm just saying that simplicity is what made C popular and easy to use. I can understand that Rust brings very nice innovations, but in my view it should have done so while keeping the "C flavor" as most as it could have.
I admit it's a conservative view, but I tend to believe that a language can be more easily adopted if at its most basic level, it's simple to read for beginners. Rust is not great: I'm not talking about its learning curve, I'm just talking about the "flavor". A language is a tool of expression and communication, features matter less than readability.
- adamnemecek 7y agoRust is C + ocaml. C doesn't have some of the features of Rust and in those cases it makes sense to adopt the ocaml syntax.
- pornel 7y agoRust has quite C-like syntax IMHO, with a few important fixes. Types are easier to write and don't have typedef parsing gotcha. Array of 10 functions returning functions in Rust is `[fn() -> fn(); 10]`. I'd faint trying to write such type in C. if (foo) bar(); is if foo {bar();} Same length, but without possibility of "goto fail" error. Rust may look ugly, especially with generics, but on the technical level there isn't much wrong with the syntax. It's quite readable once you know it. And you can grep function definitions!
- wtetzner 7y agoI'm not sure I follow. Rust syntax seems far more similar to C than Python syntax does. What parts of the Rust syntax do you feel depart from C-style syntax?
- jokoon 7y agofn add2(x: i32, y: i32) -> i32 { x + y } variable declaration is varname: type, it makes it very hard to read when declaring arrays or other things return type is after the paren the let keyword seems redundant/unnecessary, a little like var in js Those are good example of "c flavor". I guess they're easier to parse, but still I would rather have C flavor instead.
- wtetzner 7y agoGotcha. I think with even a small amount of experience with the language, you'll find those things won't bother you anymore. I personally find the "varname: type" syntax easier to read. Also, keep in mind that Rust has type inference, so you can say things like "let foo = 37;", and the compiler will infer the type of "foo". The "varname: type" syntax is more compatible with optionally specified types, because it nicely fits in if you want to add the type info explicitly: "let foo: u64 = 37;".
- zozbot234 7y ago"Very hard to read"? As in, harder to read than the C declaration syntax for the same types? That's a logical impossibility!
- jokoon 7y agoSTL containers are pretty easy to read