[Python-ideas] [Python-Dev] Inclusive Range (original) (raw)
Carl M. Johnson cmjohnson.mailinglist at gmail.com
Tue Oct 5 12:52:39 CEST 2010
- Previous message: [Python-ideas] [Python-Dev] Inclusive Range
- Next message: [Python-ideas] [Python-Dev] Inclusive Range
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
I did some research before posting and saw that they talked about that Dykstra paper on C2's page about zero indexing, and honestly, I count it as a point in favor of starting with 1. Dykstra was a great computer scientist but a terrible computer programmer (with the exception of "Goto Considered Harmful" [a headline he didn't actually give to his article]) in the sense that he understand how to do things mathematically but not how to take into account the human factors in such a way that one can get normal people to program well. His theory that we should all be proving the correctness of our program is, to my way of thinking, a crank's theory. If regular people can't be trusted to program, they certainly can't be trusted to write correctness proofs, which is a harder task, not a simpler one. Moreover this ignores all of the stuff that Paul Graham would eventually say about the joys of exploratory programming, or to give an earlier reference, the need to build one to throw away as Brooks said. Proving correctness presumes that you know what you want to program before you start programming it, which is only rarely the case, mostly in the computer science classroom. So, I don't consider Dykstra's expertise to be worth relying in matters of programming, as distinct from matters of computer science.
In the particular case, the correct way to represent an integer between 2 and 12 wouldn't be a, b, c, or d. It would be i in range(2, 12) (if we were creating a new language that was 1 indexed and range was likewise adjusted), the list [1] would be range(1), and the empty list would be range(0), so the whole issue could be neatly sidestepped. :-)
As for l == l[:x] + l[x:y] + l[y:] where y > x, I think a case can be made that it would be less confusing as l == l[:x] + l[x+1:y] + l[y+1:], since you don't want to start again with x or y. You just ended at x. When you pick up again, you want to start at x+1 and y+1 so that you don't get the x-th and y-th elements again. ;-)
Of course this is speculation on my part. Maybe students of programming find 1-indexing just as confusing as 0-indexing. Any pedagogues want to chime in?
-- Carl Johnson
- Previous message: [Python-ideas] [Python-Dev] Inclusive Range
- Next message: [Python-ideas] [Python-Dev] Inclusive Range
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]