Sujet : Re: Which code style do you prefer the most?
De : 643-408-1753 (at) *nospam* kylheku.com (Kaz Kylheku)
Groupes : comp.lang.cDate : 06. Mar 2025, 21:49:11
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <20250306123054.409@kylheku.com>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
User-Agent : slrn/pre1.0.4-9 (Linux)
On 2025-03-06, Scott Lurndal <
scott@slp53.sl.home> wrote:
David Brown <david.brown@hesbynett.no> writes:
On 05/03/2025 18:51, Scott Lurndal wrote:
Richard Harnden <richard.nospam@gmail.invalid> writes:
On 05/03/2025 17:09, Janis Papanagnou wrote:
On 05.03.2025 17:40, bart wrote:
[...]
>
Seriously, short variable names for common things - i, j, k for loop
counters;
So, one might ask _why_ i, j, k instead of a, b, c?
Answer: Fortran IMPLICIT INTEGER
>
Nonsense.
>
Ask rather why Fortran picked i, j, k for integer-type index variables.
Their use for that function in maths /long/ predates Fortran.
>
That doesn't mean that C programmers didn't adopt the
use of i,j,k from FORTRAN.
This is impossible to to know, because it would require us to have
access to every historic program, which would have to be accompanied by
a rationale as to why it chose i.
When we speculate about this, we cannot ignore the reality that a lot
of programmers would have had enough of a math background to have seen
i as an index variable upteen times and used it themselves in numerous
homework assignments and exam answers.
It comes to reason that any given programmer uses i as a loop dummy
for one of two reasons:
1. They pick up the practice from reference manuals, tutorials,
other people's code or from programming teachers: their whiteboard
scribbling or course materials.
2. They spontaneously choose i due to their math background.
The second case terminates the recursion. The former case continues
through other programmers: those who wrote the reference manuals or
tutorials, or taught the classes. Did they get the "i" from other
reference manuals, tutorials, source code or programming teachers? Or
did they spontaneously get it from their math background?
The idea that i came into all other programming use exclusively through
Fortran means that no programmer ever came up with i due to their math
background, except for those early programmers working with Fortran.
Fortran programmers "seeded" the letter i into programming, and all
subsequent use of i in programming traces back to their documentation
and sources.
A weaker form of the idea is that "i" did come into programming via
paths not involving Fortran (e.g. spontaneous use due to someone's math
background), but those lineages died out; that all current, surviving
use of i is (in principle, if not in realistic fact) traceable to
Fortran sources or docs.
I would say that, independently of being an utterly unverifiable
conjecture, either hypothesis is highly improbable.
The math influence on naming is simply too pervasive for it to have been
possible for early Fortran people to have perpetrated an air-tight
gatekeeping on math-based naming.
-- TXR Programming Language: http://nongnu.org/txrCygnal: Cygwin Native Application Library: http://kylheku.com/cygnalMastodon: @Kazinator@mstdn.ca