Live data from Hacker News

The Manuscripts of Edsger W. Dijkstra

cs.utexas.edu

91–100 of 129 posts

Re: The Manuscripts of Edsger W. Dijkstra

#92

Earlier quoted context omitted.

One should always use a single kind of half-open range, i.e. with the start closed and the ending open. The whole point here is to use a single kind of range, without exceptions, in order to avoid the errors caused by using the wrong type of range for the context. For backwards iteration the right range is [-1,-1-n), i.e. none of those listed by you. Like for any such range, the number of accessed elements is the dif…

What would you do if your array is so large that it requires an unsigned int64 index?

In C/C++ there are no true unsigned integers (true unsigned integers do overflow, generating errors in such cases or they generate carry/borrow on certain operations).

The so-called unsigned integers of C/C++ are in fact modular integers, i.e. where the arithmetic operations wrap around and where you can interpret any 64-bit number greater than 2^63-1 as you please, as either a positive integer or as a negative integer. For instance you can interpret 2^63 as either -2^63 or as +2^63.

So using 64-bit "unsigned" integers for indices does not create any problems if you are careful how you interpret them.

However, as another poster has already said, in all popular ISAs the addressable space is actually smaller than 2^64 and in x86-64 the addresses are interpreted as signed integers, not as unsigned integers, so your problem can never appear.

Some operating systems use this interpretation of the addresses as signed integers in order to reserve the negative addresses for themselves and use only positive addresses for the non-privileged programs.

The reason why the addressable space is smaller than afforded by 64 bits is that covering the complete space with page translation tables would require too many table levels. x86-64 has increased the number of page table levels to 4, in order to enable a 48-bit address space, while some recent Intel/AMD CPUs have increased the number of page table levels to 5, in order to increase the virtual address size to 57 bits.

Re: The Manuscripts of Edsger W. Dijkstra

#93
post #58

Earlier quoted context omitted.

Before starting to walk, you were at the start of the first block, not at zeroth block. There is no block prior to first block. Otherwise that block would be called as first block. Think of jogging on a road. When you are at the beginning of the road, you are at the start of the first mile, not in the zeroth mile. It doesn't have one more mile prior to first mile.

O you’re right. How could I forget the first minute of each day is 12:01, or that a previously unknown computer exploit is called a 1-day exploit. And everybody knows a pandemic starts with patient 1!

The patient-0 terminology arose from a misreading of the label patient-O, where O is the letter O.

When numbering discrete elements you usually start with 1, so first is 1, second is 2 etc.

Indexes in C are not ordinal numbers though, they should be thought of as offsets or distances from the first element. So [0] is 0 steps away from the first element, hence the first element. The confusion arise when you think these indices are actually ordinal numbers.

Re: The Manuscripts of Edsger W. Dijkstra

#94
post #29

Earlier quoted context omitted.

Usually the chapter 0 is preliminary or prerequisite material. It makes sense in an obvious and intuitive way if you want an ordinal "before the first", even if that sense isn't a rigorous mathematical one (although I think there's no problem with it). I guess the practice was influenced by computer science - I don't know of an example that precedes it, but one fairly early one I've found is Bishop and Goldberg's Ten…

Hopefully they don't discover another more fundamental law, to be called as "minus oneth" law

Indeed

Re: The Manuscripts of Edsger W. Dijkstra

#95

The most important one in the context of 2025 is this one: On the foolishness of "natural language programming". https://www.cs.utexas.edu/~EWD/transcriptions/EWD06xx/EWD667...

Setting aside the the elephant in the room (modern coding LLMs are in some sense indeed compilers for natural language -- except they still "compile to" ordinary programming languages) it nonetheless seems to me that even conventional programming languages use too little, not too much, natural language.

Example:

- "&&" rather than "and",

- "||" rather than "or",

- "if (A) B" rather than "if A then B"

This only makes the code harder to read for beginners without apparent benefit. I'm not sure whether Dijkstra would have agreed.

Thankfully though, programming languages already use mostly explicit (English) language in function names. Which is a much better situation than in mathematics, where almost every function or operator is described by a single nondescript letter or symbol, often even in Greek or in a weird font style.

There is a tradeoff between conciseness and readability. Mathematics has decided long ago to exclusivly focus on the former, and I'm glad this didn't happen with programming. If we read Dijkstra as arguing that only focusing on readability (i.e., natural language) is a bad tradeoff, then he is right.

Re: The Manuscripts of Edsger W. Dijkstra

#96

Earlier quoted context omitted.

O you’re right. How could I forget the first minute of each day is 12:01, or that a previously unknown computer exploit is called a 1-day exploit. And everybody knows a pandemic starts with patient 1!

The patient-0 terminology arose from a misreading of the label patient-O, where O is the letter O. When numbering discrete elements you usually start with 1, so first is 1, second is 2 etc. Indexes in C are not ordinal numbers though, they should be thought of as offsets or distances from the first element. So [0] is 0 steps away from the first element, hence the first element. The confusion arise when you think thes…

I agree with all of this.

The original discussion was regarding there's no such thing as a zeroth X, and what I've been trying to say this whole time is sure there is, it's the beginning. Which is why you start counting time from 0.

Interesting about patient-O though. I didn't know that.

My previous comment may have seemed snarky, but that wasn't my intention. I tried to originally write something that didn't seem sarcastic but it was just long.

The best way to explain my point was to just to agree and then list the contradictions that arise, e.g. The day starts at 12:01 since there's no zeroth minute, etc... and that unfortunately has the effect of looking like snark.

Re: The Manuscripts of Edsger W. Dijkstra

#97
post #95

The most important one in the context of 2025 is this one: On the foolishness of "natural language programming". https://www.cs.utexas.edu/~EWD/transcriptions/EWD06xx/EWD667...

Setting aside the the elephant in the room (modern coding LLMs are in some sense indeed compilers for natural language -- except they still "compile to" ordinary programming languages) it nonetheless seems to me that even conventional programming languages use too little, not too much, natural language. Example: - "&&" rather than "and", - "||" rather than "or", - "if (A) B" rather than "if A then B" This only makes…

Working a bit with some old programming languages that are very natural language like (FORTRAN’s .and. and .or. or COBOL’s IS GREATER THAN) I don’t think the readability increases that much, maybe the benefit is more approachability. In a more symbolic language skimming code is much easier because the symbols provide visible distinction between more syntactic control flow and the declared functions, variables etc.

Re: The Manuscripts of Edsger W. Dijkstra

#98
post #95

The most important one in the context of 2025 is this one: On the foolishness of "natural language programming". https://www.cs.utexas.edu/~EWD/transcriptions/EWD06xx/EWD667...

Setting aside the the elephant in the room (modern coding LLMs are in some sense indeed compilers for natural language -- except they still "compile to" ordinary programming languages) it nonetheless seems to me that even conventional programming languages use too little, not too much, natural language. Example: - "&&" rather than "and", - "||" rather than "or", - "if (A) B" rather than "if A then B" This only makes…

I suspect Dijkstra would have disagreed with you about "and" and "or", judging from his criticism of the technical report which had the line "even the standard symbols used for logical connectives have been avoided for the sake of clarity".

Personally I think one advantage of '&&' and '||' is that it's clear they're a notation that you need to know the syntax and semantics of. For instance typically '&&' is "short-circuiting" and will not evaluate its RHS if the LHS is true; a natural-language "if a and b then ..." doesn't suggest that critical detail or necessarily nudge you to go and check. (Not that Dijkstra was in favour of short-circuiting logical operators, to judge by https://www.cs.utexas.edu/~EWD/transcriptions/EWD10xx/EWD100... point 4...)

More generally, I'm not sure of the benefit of tailoring the language syntax for beginners rather than experienced practitioners; the advantage of '&&', '||' and the rest of the "C-like" syntax stuff in a new language is that it's familiar to a wide base of existing experienced programmers.

Re: The Manuscripts of Edsger W. Dijkstra

#99
post #7

Earlier quoted context omitted.

I love that essay. It's such a joy to read, and even though it is very short and to the point it says so much both about the topic itself and society at large. And its just so obviously correct.

It is not obviously correct. The unstated premise is that programming is - or should be - similar to writing mathematical proofs.

No, the premise is that programming is the act of writing precise specifications, which is easier in a precise language. Similarly to mathematical proofs.

Re: The Manuscripts of Edsger W. Dijkstra

#100

Earlier quoted context omitted.

The patient-0 terminology arose from a misreading of the label patient-O, where O is the letter O. When numbering discrete elements you usually start with 1, so first is 1, second is 2 etc. Indexes in C are not ordinal numbers though, they should be thought of as offsets or distances from the first element. So [0] is 0 steps away from the first element, hence the first element. The confusion arise when you think thes…

I agree with all of this. The original discussion was regarding there's no such thing as a zeroth X, and what I've been trying to say this whole time is sure there is, it's the beginning. Which is why you start counting time from 0. Interesting about patient-O though. I didn't know that. My previous comment may have seemed snarky, but that wasn't my intention. I tried to originally write something that didn't seem sa…

OK but I’m not sure I get your point then. Are you saying Edwin Aldrin was the first man on the moon because Neil Armstrong was the zeroth?
Post reply on HN