Live data from Hacker News

Rust's Ugly Syntax (2023)

matklad.github.io

121–130 of 171 posts

Re: Rust's Ugly Syntax (2023)

#121

Earlier quoted context omitted.

absolutely yes. I even gave three different places where parenthesis can be used and have different meanings

You can also use the letter a in 3 dufferent places and have different meanings, and is also not an example.

Why aren't those 3 examples of the same characters having different syntactic meaning valid?

Re: Rust's Ugly Syntax (2023)

#123
post #92
post #55

Earlier quoted context omitted.

That's because the code triggering compilation error is using reference. If you use Rc or Arc (which pays runtime cost) there should be no lifetime at all. Albeit I admit there somewhat exists a community sentiment like "if you use Rust, you should maximize its zero cost abstraction feature so lifetime is good and generics good", and my (minor) opinion is that, it's not always true to all users of Rust. And the clums…

> 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…

Not sure why you'd compare modern C++ to K&R which is a C book. Modern C is in fact less ugly than ancient C due to sugar like compound literals.

Re: Rust's Ugly Syntax (2023)

#125

Earlier quoted context omitted.

in OCaml, the single quote is a valid char for an identifier: let f = ... and let f' = ...

I did not know that, and I question that choice as well. Why would you use that? It's a little less bad, because you can just have your own style guide that says "Don't do that".

As an OCaml beginner I've mostly seen it used for inner functions in lieu of calling the inner function `f_impl`.

Re: Rust's Ugly Syntax (2023)

#126

"I think that most of the time when people think they have an issue with Rust’s syntax, they actually object to Rust’s semantics." You think wrong. Rust syntax is horrible because it is verbose and full of sigils

Still trying to understand when i have to put ||

Re: Rust's Ugly Syntax (2023)

#128

Earlier 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…

Wait. Are you a Cobol programamer? Your argument has nothing to do with ' per se; it's completely generic for every "symbol" in a language. https://www.mainframestechhelp.com/tutorials/cobol/arithmetic-statements.htm "Confusing" is mostly a question of familiarity; "ugly" one of taste. When you're designing a language's syntax, there is a tension between making the language feel recognizable to beginners/non-users an…

> IMHO, baseline languages like Python are great for writing down what you already think but terrible for iterating on your understanding, and 95% of our work as engineers is (should be?) changing our understanding of the problem to fit reality as it bumps us in the face.

I have to disagree. I've been working on HashBackup for 15 years now, and believe me, my understanding of backups has grown immensely over those years - with Python. Python may have some things I have to work around, as all computer languages do, but after all this time I still love working on and just reading through the code that has resulted from over 3200 commits.

Python's simple, easy-to-read syntax, encourages me to change things, even in a complex section of code that I haven't looked at in years. For me, Rust's emphasis on multi-character syntax vs keywords makes it visually unappealing and ugly, and I don't think I'd enjoy working on ugly code for 15 years, even if it does run fast. Not intending to start a huge language discussion, but I do think the specific point of Python not being suitable for experts in a problem domain is not true, at least not for me.

Re: Rust's Ugly Syntax (2023)

#129

"I think that most of the time when people think they have an issue with Rust’s syntax, they actually object to Rust’s semantics." You think wrong. Rust syntax is horrible because it is verbose and full of sigils

Still trying to understand when i have to put ||

Is it harder to understand than when to put lambda: in Python code?

Re: Rust's Ugly Syntax (2023)

#130
Here's the cleaned up version of Rust from the OP:

  pub fn read(path: Path) -> Bytes {
    let file = File::open(path);
    let bytes = Bytes::new();
    file.read_to_end(bytes);
    bytes
  }
Here is is in raku (https://raku.org):

  sub read(Str:D $path --> Buf:D) {
    $path.IO.slurp: :bin
  }
[the `--> Buf:D` is the raku alternative to monads]
Post reply on HN