10 ms·
Dijkstra is of course brilliant and I recognize much of his tone is tongue in cheek and irreverant but sometimes I find his writing so nasty, pompous and arroga
by wfo 10y ago
Dijkstra is of course brilliant and I recognize much of his tone is tongue in cheek and irreverant but sometimes I find his writing so nasty, pompous and arrogant that it becomes irritating; claiming, after a series of opinions about what he personally finds "nice" or "natural" that there is a "most sensible" way of doing things and that everyone else is being ridiculous. A tamer one of his offenses but still unpleasant.
I agree on the numbering but many people don't. He doesn't mention how nicely it works with the modulo operator, which is I think the most compelling reason. But having L[2] be the third index in an array is horribly counterintuitive and leads to countless mistakes. CS students when they begin do not like it, it is not natural. It is beaten into them by scary red error messages and instructors over months and years until they finally accept it.
- surement 10y agoAs a student, I had way more difficulty adjusting to Matlab/Octave being 1-indexed than my first programming language being 0-indexed. It's very rare (and not a good sign if you're doing it: use a struct or tuple) to look for the "third" element in a list, and much more common to run through every element, and, for example, < is cleaner than <=.
- int_19h 10y agoIt depends on the context. It's actually pretty common to make queries like "give me the third element" in data analysis, especially when your data sources come as a vaguely organized mess. At the same time, it's not actually all that common to index elements in loops these days - most languages have some kind of a for-each construct that hides indices (and some, like Python, only have such a construct).
- NoodleIncident 10y agoBoth slices and the 'for i in range(N)' are 0-indexed.
- int_19h 10y agoYes, they are. My point was that when you enumerate collections in Python, it doesn't matter, because it's just `for x in xs: ...` - you don't actually see the indices. This is in response to "much more common to run through every element" in the parent comment - it's just not a relevant scenario for indexing in most languages today. But slices definitely are, yes.
- qwertyuiop924 10y agoIndeed. Frankly, I find Dijkstra's writing horribly grating and irritating. The majority of his articles seem to be just him insulting things he doesn't like, another thing I find grating (for one thing, I can't think of anything he does like off the top of my head). He also seems to have a habit of passing his opinions off as fact. But he is really smart, and often right, so while I can be annoyed by him, I can't actually ignore what he says, because it does matter.
- Avshalom 10y ago>>for one thing, I can't think of anything he does like off the top of my head it's been occasionally opined that the biggest issue Dijkstra had with computer science is that it often needed to be applied to computers.
- qwertyuiop924 10y agoThat sounds about right...
- hughes 10y agoFor those of us less familiar with his work, do you have an example of some of his less tame, more arrogant writing?
- qwertyuiop924 10y agoHis paper "How Do We Tell Truths That Might Hurt?" Is a good example, IMHO: 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. The use of COBOL cripples the mind; its teaching should, therefore, be regarded as a criminal offence. APL is a mistake, carried through to perfection. It is the language of the future for the programming techniques of the past: it creates a new generation of coding bums. The use of anthropomorphic terminology when dealing with computing systems is a symptom of professional immaturity. More: I think of the company advertising "Thought Processors" or the college pretending that learning BASIC suffices or at least helps, whereas the teaching of BASIC should be rated as a criminal offence: it mutilates the mind beyond recovery. Given, I'm cherry-picking here. Not everything Edsger says is like this. Not by a long shot. He is brilliant, make no mistake. But I must leave you with a quote from Sir Alan Kay that I found on the Wikiquote page while I was researching this: You probably know that arrogance, in computer science, is measured in nanodijkstras. Given, it's Alan, so I don't know how serious he was being.
- fungiblecog 10y agoAnd you don't find that extremely funny? I think finding fault with this kind of opinion is a symptom of the modern concept of "taking offence". Ie nobody can express an opinion without also showing that they respect others' opinions. But that's not right. We don't have to respect each others' opinions if we think they are wrong. What we must do in a free society is respect their right to have, and express, a different opinion. Dijkstra clearly thinks that teaching BASIC is damaging people's brains so he says that loudly and clearly with a touch of humour. Should he water it down to avoid offending people that like BASIC?
- 10y ago
- zAy0LfpBZLC8mAC 10y ago> But having L[2] be the third index in an array is horribly counterintuitive and leads to countless mistakes. Really, that's just a confusion caused by language and historical accidents. There is nothing that inherently links "one" to "first", or "two" to "second"--it just so happens that for some weird reason, it's common in English to abbreviate "first" as "1st", "second" as "2nd", and so on. But just as "A" is the first letter of the alphabet (and not, say, the Ast), "0" is the first cardinal number, and "first" is the first ordinal number. And there is a very simple reason why zero is the correct default first array index: Zero is the neutral element of addition, and (sub)array indexing is an additive operation.
- anigbrowl 10y agoThere is nothing that inherently links "one" to "first", or "two" to "second" $10 says you don't have any children.
- jstimpfle 10y agoOf course there is something that links "third" to "three", "fourth" to "four", etc. It's called language. So it's not surprising that we abbreviate "third" with "3rd". The historical "accident" is that we don't start with "zeroth". That's probably what you wanted to say but the reasoning tripped me up.
- zAy0LfpBZLC8mAC 10y agoWell, yeah, I didn't want to go that deep into it, of course there is a reason why they are linked. But none that links them inherently, which is what I wrote. And the accident really simply is that "zero" wasn't an accepted concept yet when ordinal numbers were invented, which led to the first ordinal number being called "first" and not "zeroth". Meanwhile, humanity largely has accepted zero as a useful and coherent concept, but just didn't bother to update the names of ordinals to fit better with that, which is where the confusion comes from.
- cousin_it 10y ago
- once-in-a-while 10y agoL[2] has nothing to do with "second". It just means "plus 2". If you consider Monday the first day of the week, then Monday[1] is (naturally) Monday + 1. Zero indexing just feels right, I can't help it (it's written in our DNA).
- Avshalom 10y agoI consider monday the second day of the week
- once-in-a-while 10y agoMe too (for both historical and religious reasons). I just meant to be "modern friendly" ;)
- Avshalom 10y agowhat do you mean by modern friendly? Egypt and it's 100 million (possibly other muslim majority countries?) consider thursday-friday the weekend.
- d0mine 10y agoIn C: L[2] == *(L + 2) == *(2 + L) == 2[L]
- graycat 10y agoI underline what you said and add to it: I started with arrays with Fortran. There can pass an array as an argument to a parameter of a subroutine, and the subroutine can address the darned array any way it wants. Why? Sure, maybe want to sort the array based on a slice here omitting details. Sure, such programming would need a lot of well done documentation and still is dangerous. And such array fooling around stands to get into trouble with compiler options to check array bounds. Then I did a lot with PL/I: There get arrays, structures, structures of arrays of structures of arrays, etc. Also get to set the lower and upper bounds of each array index to anything -- positive, negative, or zero, including during execution -- that can be represented in the usually 16 bit array indexing arithmetic. And, it turns out, all that array indexing, even for arrays of structures of arrays, etc., is just ordinary multi-dimensional array arithmetic -- nearly as useful as objects but with much simpler storage allocation and array indexing. And if look carefully at that arithmetic, then do see how to have any subscript (index) lower bounds and upper bounds with just trivial modification of the usual array indexing. And, yes, when I wrote C code, no way did I like the high emphasis on starting an array at index 0. Besides C doesn't even really support arrays, e.g., with several subscripts, and forces a programmer to write a macro or some such that does the arithmetic. And there are problems in a subroutine that receives such an array. And compiler support for checking array bounds is in trouble because the language syntax and semantics don't even support arrays with several dimensions. So, have to write, say, a matrix package that has a C structure for the details of number of dimensions and the upper/lower bounds for each dimension -- it works but get no compiler based debugging support or I/O support, and no doubt the compiler can't do some indexing optimizations that Fortran and PL/I can do because the data being used for the indexing is, in the semantics, not subject to being changed by the user's code during the indexing arithmetic. E.g., with PL/I, in the execution logic, each structure or array, each aggregate has a little table, a dope vector that describes the aggregate, yes, within a subroutine and within runtime subroutines, e.g., for doing I/O on the whole aggregate. PL/I was in good shape before C was developed. PL/I was used for the operating systems Multics and much of Primos. So, PL/I offers programmers much more than C and, still, is good for both applications and operating system code, especially in array indexing. Sorry, Dijkstra.
- drivers99 10y ago
- benaadams 10y agoBiggest mistake with 0-based arrays is calling it an "index" rather than an "offset"; in terms of offsets 0 makes perfect sense.
- ieatkittens 10y agoWow. Everything just changed.
- Walkman 10y agoWhy didn't you born sooner? :D
- mettamage 10y agoI had to laugh really hard at this one. Thanks for making my evening :)
- mettamage 10y agoThanks for saying this :) It's things like these that I'd wish people would tell sooner rather than later.
- zAy0LfpBZLC8mAC 10y agoThat indeed is a very good way to phrase the core of the problem for non-mathematicians, thanks :-)
- jlubawy 10y agoIn C it also helps to think of it in the equivalent pointer form: p == &(p[0]) p[0] == *(p+0) p[1] == *(p+1) where p is a pointer to some arbitrary data type. Then it becomes an offset in memory.
- deleted 10y ago[deleted]
- nimos 10y agoI think this would help a lot for people learning computer systems as well. Matches the underlying pointer arithmetic logic. Let's all agree to switch to using offset instead of index?
- pwdisswordfish 10y ago> But having L[2] be the third index in an array is horribly counterintuitive and leads to countless mistakes. Keep calling it the second, then. And use 'zeroth' for L[0]. Problem solved. Also, what is 'counterintuitive' is very often just a question of habit. I've many times seen Americans (at least those not scientifically inclined) express confusion over metric units. I have been using the metric system all my life in every its domain: I buy apples in kilograms, measure rooms in metres, water in litres, and I regard it as the most natural thing in the world. I find the American unit system batshit insane (why is 'ounce' a unit of mass, but 'fluid ounce' a unit of volume? WTF is up with all those different conversion factors?) and if I had the power to wipe the it from the face of the Earth, I'd do it in a heartbleed. I'm sure that if I asked some people from my country about this, I'd find many agreeing with me. But I realise there are people who feel just the opposite. (I still think they're wrong, but I get where they're coming from.) Zero-based indexing is similarly just a question of what people are used to. When those students start appreciating the nicer mathematical properties of zero-based indexing (and half-open ranges that go along with it), it'll become second nature to them. (I suspect the reason why many people don't is because laymen don't often work with abstract algorithms and indexed data structures where those properties display their usefulness.)
- Normal_gaussian 10y ago> CS students when they begin do not like it, it is not natural. Nice of you to speak for them. Unfortunately you are in error.
- neal_jones 10y agoI don't understand, is it nicer for you to speak for them?
- Normal_gaussian 10y agoI know he is wrong as I have a proof by contradiction, 0-index felt natural to me. So I do not have to speak for anyone but myself to highlight the overreaching nature of the claim.
- jccalhoun 10y agoI'm glad you wrote this. As a non-programmer but someone who was a math education minor 20 years ago, I was really having a hard time with some of the statements like "That is ugly" or "starting with 0, however, gives the nicer range." I was trying to think of a reason why it would be computationally inelegant or something.