Comment

Comment by brundolf

I think most of what people call Rust's "ugliness" is actually just Rust's explicitness. You have to chain a lot of method calls for things that might happen implicitly in other languages; you have to annotate lifetimes and constrain generic type params; sometimes you have to manually parameterize the generics you're using; etc. But I think most of that is unavoidable without shifting some of Rust's core values.

The only piece of surface-level syntax that I'm really truly bothered by is the closure syntax:

  fn_with_a_callback_1(|param| param + 2);

  fn_with_a_callback_2(|param| {
    println!("{}", param);
  });
- The fact that the | | is the same character on each side

- The lack of directionality from the args -> to the body

- The lack of any kind of overlap with the normal function syntax fn foo()

Especially compared with something like JavaScript which has a really lovely lambda syntax, this one's hard to look at. I'm sure there were good reasons around ambiguity with other syntaxes or something, but... eesh.

parent brundolf 3 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton