Earlier quoted context omitted.
> And the clumsy Arc >> makes users feel bad about using runtime cost paid types Yeah, this would look worse than any of the "complicated syntax" examples in the blog post. A language should be designed so that the typical case is the easiest to read and write. Syntax for the most common abstractions. Rust forces you to be explicit if you want to do an Arc >>, but lets you inherit lifetimes almost seamlessly. That me…
Simple != idiomatic. It's perfectly idiomatic to `Arc >` in Rust, and it is more complex because it deals with more concerns than a simple reference, namely being thread-safe. Sometimes you need that, sometimes not, but you have to be explicit about it.
Rust's Ugly Syntax (2023)
111–120 of 171 posts
Re: Rust's Ugly Syntax (2023)
#112Earlier quoted context omitted.
> The use of ' as a symbol that has any meaning on it's own has got to be one of the most stupid choices I've seen in a language Can you clarify why you have that opinion? What would your syntax suggestion have been?
Because pretty much any other language has '...' for strings, or at least something to do with text. It's also a character that in all other languages (that I know of) must be closed with another '. Now you could say, we don't close it in contractions in English, so there's a case where one ' can just exist on it's own. That's sort of fine, a bit outside of the realm of programming, but fine, but then I think you sho…
Not once has this come up for me. They are in completely different places syntactically and can never overlap.
Sure, `'` might be text related in a lot of languages but definitely not universally. In LISP 'foo is shorthand for (quote foo) and also does not have a second character. Ocaml uses 'foo for types and foo' is just a valid identifier. Standard ML also has 'foo for type variables and I believe also allows identifiers named foo'. Haskell allows identifiers named foo' as well.
Maybe it's odd coming from languages you are familiar with, but it's not at all something that is unique to Rust.
> Rust does this with ! as well if I understand correctly
I am not sure how the case with ! is similar. Macros just end with ! to make them clearer visually, it's not part of an operator. There can never be any syntax ambiguity with them, neither visually or lexically. Also what would be the point. Take this example:
try!(do_something(...)).further();
Do you really think this would be more readable? (macro try(do_something(...))).further();Re: Rust's Ugly Syntax (2023)
#113Re: Rust's Ugly Syntax (2023)
#114Re: Rust's Ugly Syntax (2023)
#115Earlier quoted context omitted.
That's orthogonal. If the type was `&[u8]` instead of `Path` the type signature would be: pub fn read >(path: P) -> Result > The reasons for it to be generic and us `AsRef` remain. The reason for Path over &[u8] is, AFAIK, because not all byte slices are valid paths on all OSs, but also because a dedicated type lets the standard library add methods such as `Path::join`
So abstraction is still a point, but Rust cares about memory layout as well.
pub fn read>(path: &dyn P) -> Result>
In which case the size of `path` is always the same(two words[0]) and the same machine code could be used regardless of how the function is called. Rust still cares about the memory layout but because `&dyn AsRef` has the same layout for all implementations of `AsRef` there's no need for monomorphization[1].0: https://doc.rust-lang.org/1.80.1/reference/types/trait-objec...
1: https://rustc-dev-guide.rust-lang.org/backend/monomorph.html...
Re: Rust's Ugly Syntax (2023)
#116Re: Rust's Ugly Syntax (2023)
#117Earlier quoted context omitted.
why? It makes type information unnecessarily longer without adding information, and feels like writing "end_stm" instead of ";" after every line
It's more like if a ; was allowed somewhere else and had a different meaning there. enum foo; blah ...;
Re: Rust's Ugly Syntax (2023)
#118Earlier quoted context omitted.
It's worth pointing out here for people not familiar with Rust, that this is the result of code generation by a third party crate to enable async methods on traits.
Which isn't even needed anymore; now the compiler accepts it without any macros.
Re: Rust's Ugly Syntax (2023)
#119Earlier quoted context omitted.
It's worth pointing out here for people not familiar with Rust, that this is the result of code generation by a third party crate to enable async methods on traits.
Which isn't even needed anymore; now the compiler accepts it without any macros.
Imo, Rust should introduce some syntax like `async(dyn+Send)` that desugars to `Box + Send>`. This solves most of the async wards if you don't care about heap allocation and perfect performance.
Re: Rust's Ugly Syntax (2023)
#120Earlier quoted context omitted.
The use of ' as a symbol that has any meaning on it's own has got to be one of the most stupid choices I've seen in a language. It's made worse by the fact that you can still use '...' as s character literal. Not only is is incredibly ugly it's also rather confusing, but it fits well into how I view Rust, complicated for the sake of making the developers look smart. It wouldn't fit the syntax of the language obviousl…
A lifetime keyword would actually go a long way in improving ergonomics. You could even make it synonymous with '. Then people can choose. Maybe one will get much more traction and the other can be deprecated.