Live data from Hacker News

The Manuscripts of Edsger W. Dijkstra

cs.utexas.edu

71–80 of 129 posts

Re: The Manuscripts of Edsger W. Dijkstra

#71
post #68

Earlier quoted context omitted.

One-based is not better for iterating backwards. Zero-based indexing is naturally coupled with using only half-open ranges. When using zero-based indexing and half-open ranges, accessing an array forwards, backwards or circularly is equally easy. In this case you can also do like in the language Icon, where non-negative indices access the array forwards, while negative indices access the array backwards (i.e. -1 is t…

The problem is that half-open ranges work best when you the start is closed and the ending is open. In forward iteration we use [0,n) but for backwards iteration we have to use (-1, n-1] or [0,n-1], both of which are kinda clunky.

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 difference of the range limits, i.e. n, which is how you check that you have written the correct limits. When the end of the range is less than the start, that means that the index must be decremented. In some programming languages specifying a range selects automatically incrementing or decrementing based on the relationship between the limits. In less clever languages, like C/C++, you have to select yourself between incrementing and decrementing (i.e. between "i=0;i-1-n;i--").

It is easy to remember the backwards range, as it is obtained by the conversion rules: 0 => -1 (i.e. first element => last element) and n => -n (i.e. forwards => backwards).

To a negative index, the length of the array must be added, unless you use a programming language where that is done implicitly.

In the C language, instead of adding the length of the array, one can use a negative index into an array together with a pointer pointing to one element past the array, e.g. obtained as the address of the element indexed by the length of the array. Such a pointer is valid in C, even if accessing memory directly through it would generate an out-of-range error, like also taking the address of any element having an index greater than the length of the array. The validity of such a pointer is specified in the standard exactly for allowing the access of an array backwards, using negative indices.

Re: The Manuscripts of Edsger W. Dijkstra

#72
post #59

Earlier quoted context omitted.

If I use ordinal numbers to count, then counting tells me the number of objects. Sometimes I want to know the number of objects. EDIT: Yeah, I don't know why book chapter labels shouldn't start with "0". It seems fine to me. They could use letters instead of numbers for all I care.

If they use letters instead of numbers, note that letter "A" is the first alphabet, not zeroth alphabet.

When I'm counting letters it's more convenient to go "one, two, three." When I'm finding the offset between letters it's more convenient to go "zero, one, two." Neither of these methods is going to displace the other.

Definitions are fine, and I agree that "A" is the first letter. But that's no use to people who need to think clearly about the offset between "A" and "C" right now. Should I tell them they're wrong, they have to count to three and then subtract one? Because the dictionary says so?

Re: The Manuscripts of Edsger W. Dijkstra

#73

Earlier quoted context omitted.

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

The proofs/programs (Howard/Curry) correspondance has been fairly well established I think.

It's the requirements discovery phase that always breaks every pure mathematical treatment of software development.

(And also, like DW points, that software is way more complex. But on this case, it's the requirements discovery.)

Re: The Manuscripts of Edsger W. Dijkstra

#74

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...

> when judging the relative merits of programming languages, some still seem to equate "the ease of programming" with the ease of making undetected mistakes. This hits so hard. cough dynamic typing enthusiasts and vibe coders cough

> Another thing we can learn from the past is the failure of characterizations like "Computing Science is really nothing but X", where for X you may substitute your favourite discipline, such as numerical analysis, electrical engineering, automata theory, queuing theory, lambda calculus, discrete mathematics or proof theory. I mention this because of the current trend to equate computing science with constructive type theory or with category theory.

https://www.cs.utexas.edu/~EWD/transcriptions/EWD12xx/EWD124...

Re: The Manuscripts of Edsger W. Dijkstra

#75
post #56

> As a result of the educational trend away from intellectual discipline, the last decades have shown in the Western world a sharp decline of people's mastery of their own language Dijkstra already wrote this in the 80s and today many teachers still complain about this fact. I also know that, at least in the Netherlands, the curriculum is judged based on the percentage of students that pass. If too few students pass,…

South Africa is a sad example of this. And so systems are deteriorating country-wide.

Re: The Manuscripts of Edsger W. Dijkstra

#76

Completely silly fact: knowing 0 about the guy except that he gave his name to the famous algorithm, I had somehow assumed he was Indian. Weird to see a white Dutchman in the picture.

All comes down to some degree of "linguistic intuition", that one acquires from not necessarily speaking foreign languages, but some exposure and proximity to them. My bet is that most Europeans, faced with "Edsger Dijkstra" would have instinctively pointed towards the general direction of Holland and upwards.

Funnily enough, I’m western European, have visited the Netherlands several times and I’m friends with some Dutch people.

No idea how this slipped by for so long.

Re: The Manuscripts of Edsger W. Dijkstra

#77
post #52
post #47

Earlier quoted context omitted.

I've read them all. While they are fun to read as their commentary come from a place of logic, there is a lot of emotion baked in and little room for being open minded about potential alternatives that could find their ways to reality. Dijkstra was very smart but you can tell thinking is a little closed, which is not objectively bad, but it happens a little too much for my taste.

I love Dijkstra’s writings, but, yes, he had very strong opinions that at times were abrasive. Alan Kay said it best when he said, “arrogance in computer science is measured in nano-Dijkstras.” Some famous Dijkstra quotes: “It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration.” “Obje…

> I love Dijkstra’s writings, but, yes, he had very strong opinions that at times were abrasive. Alan Kay said it best when he said, “arrogance in computer science is measured in nano-Dijkstras.”

https://news.ycombinator.com/item?id=11796926

    alankay on May 30, 2016 | next [–]

    This quote keeps on showing up out of context. Edsger and I got along quite well. He loved to be the way he was and pushed it. ...
(and yes, I left that out of context so that people would go read the whole thing)

Re: The Manuscripts of Edsger W. Dijkstra

#78
post #68

Earlier quoted context omitted.

The problem is that half-open ranges work best when you the start is closed and the ending is open. In forward iteration we use [0,n) but for backwards iteration we have to use (-1, n-1] or [0,n-1], both of which are kinda clunky.

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?

Re: The Manuscripts of Edsger W. Dijkstra

#79
post #54
post #5

Something which I occasionally link to, is this: https://www.cs.utexas.edu/users/EWD/ewd08xx/EWD831.PDF >. It not only shows why computer languages should start their indexes at 0 (instead of 1), but also shows why intervals should be specified as lower-inclusive and upper-exclusive.

That particular EWD is one of my pet peeves, because of how it always pops up in discussion about array indexing. There are several situations where 1-based indexing is better, but which Dijkstra doesn't mention. For instance, one-based is much better for iterating backwards. I think a compelling argument can be made that 0-based is better for offsets and 1-based is better for indexes, and that we should not think of…

In my view, zero based is good for making hardware. Resetting a pointer to zero allows using the same circuit for each bit.

Granted, that's an argument for hardware, not for languages, and even the hardware angle is probably long obsolete.

Re: The Manuscripts of Edsger W. Dijkstra

#80
post #20

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...

Thanks for the link. Great read. Apparently Dijesktra loved using em-dash!

If you look at the scanned pdf from what looks like a typewriter written document, he was using two hyphens everywhere. Links on the top of the page.
Post reply on HN