News for hackers. Stuff that matters.
Re:Apt Rust requirement raises questions by steveklabnik on Tuesday November 25, 2025 @12:08PM (#46047981)
The issue though is that this isn't a solvable "problem". This is how programming languages' syntax work. It's like saying that C's if syntax is bad because these are equivalent:

  if (x > y) {

  if ((x > y)) {

  if (((x) > (y))) {
Yes, one of your co-workers may write the third form. But it's just not possible for a programming language to stop this from existing, or at least, maybe you could do it, but it would add a ton of complexity for something that in practice isn't a problem.
Re:Apt Rust requirement raises questions by dragonwriter on Tuesday November 25, 2025 @12:15PM (#46048054)
Well, the solution usually isn't in syntax, but it often is solved by way of code formatters, which can normalize the syntax to a preferred form among several equivalent options.
Re:Apt Rust requirement raises questions by steveklabnik on Tuesday November 25, 2025 @12:20PM (#46048107)
I certainly would support rustfmt turning those redundant forms into the simpler one.
Re:Apt Rust requirement raises questions by estebank on Tuesday November 25, 2025 @01:59PM (#46049352)
I suspect rustfmt would consider this out of scope, but there should be a more... "adventurous" code formatter that does more opinionated changes. On the other hand, you could write a clippy lint today and rely on rustfix instead
Re:Apt Rust requirement raises questions by xscott on Tuesday November 25, 2025 @12:25PM (#46048162)
Only `b` has the equivalent of "superfluous parens".

It's practically your job to defend Rust, so I don't expect you to budge even one inch. However, I hate the idea of letting you mislead the casual reader that this is somehow equivalent and "just how languages work".

The grammar could've used `Generic[Specific]` with square brackets and avoided the need for the turbo fish.

Re:Apt Rust requirement raises questions by steveklabnik on Tuesday November 25, 2025 @12:43PM (#46048375)
It hasn't been my job to work on Rust in for years now. And even then, it was not to "defend" Rust, but to write docs. I talk about it on my own time, and I have often advocated for change in Rust based on my conversations with users.

If you're being overly literal, yes, the <>s are needed here for this exact syntax. My point was not about this specific example, it's that these forms are equivalent, but some of them are syntactically simpler than others. The existence of redundant forms does not make the syntax illegitimate, or overly complex.

For this specific issue, if square brackets were used for generics, then something else would have to change for array indexing, and folks would be complaining that Rust doesn't do what every other language does here, which is its own problem.

Re:Apt Rust requirement raises questions by xscott on Tuesday November 25, 2025 @01:31PM (#46049001)
> For this specific issue, if square brackets were used for generics, then something else would have to change for array indexing

The compiler knows when the `A` in `A[B]` is a type vs a variable.

Re:Apt Rust requirement raises questions by steveklabnik on Tuesday November 25, 2025 @01:59PM (#46049359)
A compiler could disambiguate, but the goal is to have parsing happen without knowing if A is a type or a variable. That is the inappropriate intertwining of parsing and semantics that languages are interested in getting away from, not continuing with.

Anyway, just to be clear: not liking the turbofish is fine, it's a subjective preference. But it's not an objective win, that's all I'm saying. And it's only one small corner of Rust's syntax, so I don't think that removing it would really alleviate the sorts of broad objections that the original parent was talking about.

Re:Apt Rust requirement raises questions by kstrauser on Tuesday November 25, 2025 @01:01PM (#46048631)
> The grammar could've used `Generic[Specific]` with square brackets and avoided the need for the turbo fish.

But then people would grouse about it using left-bracket and right-bracket as brackets in a type "context".

Re:Apt Rust requirement raises questions by GoblinSlayer on Tuesday November 25, 2025 @02:54PM (#46049944)
The problem here is that angle brackets are semantics dependent syntax. Whether they are brackets or not depends on semantic context. Conversely square brackets are always brackets.
Re:Apt Rust requirement raises questions by steveklabnik on Tuesday November 25, 2025 @03:10PM (#46050134)
Square brackets would be semantically dependent if they appeared in the same position of angle brackets. There's nothing magical about [] that makes the problems with <> disappear.
Re:Apt Rust requirement raises questions by GoblinSlayer on Tuesday November 25, 2025 @04:25PM (#46050983)
It disappears the problem that angle brackets are sometimes not brackets. I.e. a<b>c is parsed as (a<b)>c or as (a(<b>))c.
Re:Apt Rust requirement raises questions by xscott on Tuesday November 25, 2025 @04:57PM (#46051285)
It also comes up when you want compile time expressions as parameters to your generics:

    // nice and clean
    let a = Generic[T, A > B]::new(); 

    // gross curlies needed because of poor choices
    let a = Generic::<T, {A > B}>::new();
Re:Apt Rust requirement raises questions by kstrauser on Tuesday November 25, 2025 @03:53PM (#46050645)
So that’s the Specificth element of Generic?
Re:Apt Rust requirement raises questions by GoblinSlayer on Tuesday November 25, 2025 @04:28PM (#46051018)
It's Brackets(Generic,Specific).
Re:Apt Rust requirement raises questions by xscott on Tuesday November 25, 2025 @01:06PM (#46048688)
Lol, yes they would. However, I wouldn't. :-)