News for hackers. Stuff that matters.
Re:C uses "&" for the address-operator because 'ampersand so... by AnimalMuppet on Tuesday October 10, 2023 @08:28AM (#37831201)
> Compare "for (I=0;I<N;I+=5) {" of C with "for I from 0 to N by 5 do" or "for I in 0:N:5 do" of previous languages. C requires typing a lot of redundant characters in the most frequent cases.

Um, "for (I=0;I<N;I+=5) {" is fewer characters than "for I from 0 to N by 5 do".

Re:C uses "&" for the address-operator because 'ampersand so... by adrian_b on Tuesday October 10, 2023 @08:48AM (#37831380)
"for I from 0 to N by 5 do" is the verbose variant, which is typical for a language like PL/I or Algol 68.

The syntactically equivalent, but non-verbose, is "for I ∈ 0:N:5 ⟨", which beats easily C.

Re:C uses "&" for the address-operator because 'ampersand so... by jandrese on Tuesday October 10, 2023 @08:55AM (#37831442)
Do people have normally keyboards with a ∈ key?
Re:C uses "&" for the address-operator because 'ampersand so... by loup-vaillant on Tuesday October 10, 2023 @09:55AM (#37832149)
Just remove the ∈ and ⟨ characters, and make braces mandatory:

  for i 0:N:5 {
    // loop body
  }
By the way, the same should have been done with if and while: optional parentheses, mandatory braces:

  if a == b {
    // code
  }

  while idx < end {
    // code
  }
Re:C uses "&" for the address-operator because 'ampersand so... by d-lisp on Tuesday October 10, 2023 @02:42PM (#37835829)
It's possible that parsing a complex condition wrapped by parentheses was found more convenient.
Re:C uses "&" for the address-operator because 'ampersand so... by loup-vaillant on Friday October 13, 2023 @02:21PM (#37873763)
It’s not. Not for humans (the extra parenthesis is just useless clutter), and not for machines (I’ve written parsers, both alternatives are as easy to implement).
Re:C uses "&" for the address-operator because 'ampersand so... by AnimalMuppet on Tuesday October 10, 2023 @09:25AM (#37831773)
Sure. And the observant will note that I didn't say that C was shorter than that version. Even if you replace "∈" with "in", it's still shorter.

Still... when did that syntax come out? Was it in Algol 68, or PL/I? It seems a bit unfair to complain about C being verbose if it was shorter than anything else available at the time.

Re:C uses "&" for the address-operator because 'ampersand so... by adrian_b on Tuesday October 10, 2023 @09:42AM (#37831986)
"∈" was actually proposed for Alphard, at the same time with C.

When later implemented, including in an Algol 68 variant that inspired the UNIX Bourne shell, "∈" was replaced with "in", which could be written with ASCII.

Algol 68 could use either keyword pairs, like "do" and "od" (which became "do" and "done" in the UNIX Bourne shell) or, optionally, various kinds of parentheses in their place, for conciseness.

The notation "0:N:5" or "0:N", when the step is 1, for arithmetic progressions is ancient. Even Fortran used it, but with the mistake of using comma instead of colon, which introduced a syntactic ambiguity, because comma was also used for other purposes. Using colon started with Algol 60, but that one preferred keywords instead of symbols in the arithmetic progressions used inside "for", so it did not use the notation consistently.

Fortran in 1954 or the language of Heinz Rutishauser, in 1951 (the first one with a "for" statement), were already much more concise than C.

Re:C uses "&" for the address-operator because 'ampersand so... by Vvector on Tuesday October 10, 2023 @10:06AM (#37832283)
The most frequent case would be increment by 1, so:

for (I=0;I<N;I+=1)

versus

for I from 0 to N do

Re:C uses "&" for the address-operator because 'ampersand so... by f1shy on Tuesday October 10, 2023 @02:23PM (#37835591)
I do not remember the author of the quote: A program is written once and read multiple times. Optimize for reading, not writing.

The argument “is more keystrokes” in this context is beyound what i can comprehend.