4 ms·
For me the Rust code is easy to read. Personally I don't think it's reasonable to ask programming languages 'easy to read for people not familiar with them' / '
by cranej 7y ago
For me the Rust code is easy to read. Personally I don't think it's reasonable to ask programming languages 'easy to read for people not familiar with them' / 'read like English' / or something similar.
- StreamBright 7y agoWhy is that? The number one reason I do not like Rust is the use of ', & and so on to represent something that would be trivial to implement with plain English. Example: struct HReq<'a> { } struct HReq<a: LifeTime> { } Isn't that better?
- steveklabnik 7y agoThat doesn’t show the difference when you have more than one, and you also didn’t show how much more verbose the usage gets inside the struct. It’s not a language level constraint to name lifetimes with a single letter. But folks tend to not use longer names for good reason.
- StreamBright 7y agoI just have a hard time deciphering what the intention was with these single character things. Are you suggesting to use 'a_lifetime? What is that good reason? I usually use longer names to help the next person reading my code.
- steveklabnik 7y agoRust was originally implemented in OCaml, and takes a lot of inspiration from it. The ‘a syntax is used by OCaml for generic type parameters. Rust is in a weird spot because we have two different kinds of generic parameters: types and lifetimes. They need to be distinguished from one another somehow. Nobody loves the lifetime syntax, but nobody has ever proposed something that would end up significantly better. I’m not proposing you should use ‘a_lifetime, I’m saying you could. In the end, it ends up obscuring more than helping.
- kccqzy 7y agoThat would mislead people into thinking it's a type variable satisfying a trait called LifeTime instead of a lifetime variable. It would be confusing.