4 ms·
I hope Rust doesn't face the same fate as other ambitious projects by Mozilla. Rust has a quite unusual syntax compare to any other systems programming language
by mundanevoice 10y ago
I hope Rust doesn't face the same fate as other ambitious projects by Mozilla. Rust has a quite unusual syntax compare to any other systems programming language. Also, there is a big learning curve. Keeping all the benefits aside, I really hoped Rust had a simpler syntax. I really think, one day a language will borrow the good parts of Rust with a simpler syntax and get ahead of it. Rust in its current form will never be as successful as C/C++.
- naasking 10y ago> Rust has a quite unusual syntax compare to any other systems programming language. In what way? It's very C-like in its basic syntactic structure, just more regular.
- mundanevoice 10y agoWell, I was not talking about basic syntactic structure. For eg: take a look at this https://github.com/servo/servo/blob/master/components/constellation/event_loop.rs#L18 https://github.com/servo/servo/blob/master/components/conste... I am not against Rust. Rust has some great ideas and intent. I just feel they should have created simpler syntax. A more complex and unusual syntax doesn't have any real benefits IMO.
- naasking 10y agoYou still haven't pointed out what syntax is problematic exactly. I've never programmed in Rust, but I don't have any trouble reading it coming from a C and C# background. What exactly is the problem with the example you linked to?
- pcwalton 10y agoWhat's the issue with that example?
- naasking 10y agoNot having programmed in Rust, the fact that Rust requires all type parameters to be used, thus ruling out proper phantom types, was semantically surprising to me. But I don't understand what syntactic issue the other poster had with that example.
- steveklabnik 10y agoThat's what https://doc.rust-lang.org/stable/std/marker/struct.PhantomData.html https://doc.rust-lang.org/stable/std/marker/struct.PhantomDa... is for!
- naasking 10y agoYes I get it, it just seems unnecessary to require every type parameter to be used. Do you have a link to the discussion motivating this choice?
- steveklabnik 10y agoIn my understanding, it has to do with variance. This happened a very long time ago, before 1.0, and so I don't know where the discussion happened, off the top of my head.
- naasking 10y agoFound it: https://github.com/rust-lang/rfcs/blob/master/text/0738-variance.md https://github.com/rust-lang/rfcs/blob/master/text/0738-vari... It still seems bizarre to me that a purely type-level expression is forced by an effectively non-existent term. That RFC specifically states that the main problem is that the results of variance inference are largely erased by assuming invariance. That seems like a sensible default for unused type parameters too. It seems from the conclusion of that post that PhantomData only survived because this was the smallest change they had to make to get this all to work better, and because some of this PhantomData could be used for other analyses in the compiler (although it's not clear if better type information could have replaced these uses anyway).
- pcwalton 10y agoCan you elaborate as to the specific syntax problems you see with Rust?
- sullyj3 10y agoThe type and lifetime annotations can get pretty confusing.
- pcwalton 10y agoDo you have a specific proposal as to what lifetime syntax should be changed to?
- mundanevoice 10y agoThis is from servo codebase - https://github.com/servo/servo/blob/master/components/domobject_derive/lib.rs#L37-L46 https://github.com/servo/servo/blob/master/components/domobj... Take a look at this. It isn't as simple and clear as C/C++ for example and requires significant investment in parsing and understanding the code.
- pcwalton 10y agoYou quoted a macro definition. The equivalent in C++ would be heavy preprocessor use, which is usually much worse.
- mkawia 10y agoThat's quote ,a library that generates code for you at compile time ,it takes code as input,has it's own syntax. It's like compile-time reflection. It's not code rust programmers would normally write, I'm one of those programmers. I'm glad some libraries like serde,rocket and diesel are using it to generate code instead of doing run-time analysis.