3 ms·
This is almost overly permissive... Yeah sure it looks the same but the semantics are so different that the statement seems... wrong
by arthurcolle 4y ago
This is almost overly permissive... Yeah sure it looks the same but the semantics are so different that the statement seems... wrong
- vlovich123 4y agoAs someone with a long history of c++ experience I found rust syntax fairly familiar even if some details are meaningfully different. For example, most code you read is very very similar. I found an easier time coming to Rust from c++ in terms of syntax familiarity than swift. I found swift much faster to write code once I actually got my head around it (I also had substantial experience with Objective-C/C++ prior to picking up swift). I think the strong counter is that you only really learn a language once, but Swift is a bridge from those coming from Objective-C not C++ and tries to hit other language goals so it’s hard to compare. Certainly this is the first real language giving c++ a run for its money in a way that nothing else has before, that’s not nothing, and it’s hard to argue whether the syntax chosen is part of that success or in spite of.
- ssokolow 4y agoBecause Rust is, in effect, a GC-less Ocaml derivative with a coat of cherry-picked C++ syntax as paint. That's why the semantics are so different. It's more of the lineage that began with ML in 1973 than of the ALGOL 68 lineage like C is. The Rust compiler was even originally written in Ocaml before it became self-hosting. That's also where syntax elements like these come from: - let for variable declaration and postfix type annotations separated with colons - 'a (Ocaml's equivalent to <T> for generics, because, on an abstract/theoretical level, Rust's lifetimes are a special type of generic parameter, right down to "a" apparently being the habitual default type variable name, just like "T" is in C++) - Option (option in Ocaml), Some, and None - match - fn (fun or function in Ocaml) - -> and => (just -> in Ocaml) for function returns and match arms - ()