DSPRelated.com
Forums

horrible C indexing

Started by Grant Griffin April 1, 2006
Am I the only person who's noticed that C's zero-based indexing is 
nothing short of...well...horrible?  And it doesn't end there: C has 
been so influential that its insanity has spread to tons of other 
languages: C++, Java, C#, Python, Perl--heck, even LISP.

Am I the only one here who's suffered a needless off-by-one bug as a 
result of C's horrible zero-based indexing?  Let's see a show of hands...

But more important, to those of us in DSP, is the fact that C's indexing 
doesn't conform to Matlab--which wisely employs one-based indexing in 
accordance with the centurys-old convention of linear algebra.  Now, one 
might ask, "who died and left Matlab in charge?"  Well, nobody, I guess. 
  But if the Matlab folks hadn't gotten this right, why would so many 
DSP folks shell out *thousands* for Matlab, when zero-based alternatives 
like SciPy (http://scipy.org/) are absolutely, 100%, free?  There can be 
only one answer: one-based indexing.

OK, I can already hear some of you about to cite the old "legacy code" 
chestnut as a reason C can't be changed.  True, there's a lot of C code 
out there.  But there's absolutely no reason that C can't switch to 
one-based with a zero-based compatibility mode.  OK, I know, I know: C++ 
programmers can easily create their own one-based array object.  But 
what sense does it make for countless programmers to home-brew a 
solution when Dennis Ritchie could just get off his duff and fix the 
problem once-and-for-all?  After all, Grace Hopper did it for FORTRAN.

Sound radical?  I don't think so: let's face it, we live in a one-based 
world.  For example, ask a child to count their fingers, and they'll 
invariably assign "one" to the first (er, "zeroth") finger.

Still not convinced?  OK, what about the calendar?--what if today was 
"April 0th"?

=g2
_____________________________________________________________________

Grant R. Griffin
Publisher of dspGuru                           http://www.dspguru.com
Iowegian International Corporation            http://www.iowegian.com
See http://www.iowegian.com/img/contact.gif for e-mail address
Hello Grant,

It is great to see your wit has not waned. Thanks for writing on this April 
Fool's Day. Maybe one day we will get indexing based on the irrational 
numbers - but that uncountable thing will likely get in the way ;-)

Clay



"Grant Griffin" <nospam@yahoo.com> wrote in message 
news:4a503$442e975f$4088dbc7$1304@EVERESTKC.NET...
> Am I the only person who's noticed that C's zero-based indexing is nothing > short of...well...horrible? And it doesn't end there: C has been so > influential that its insanity has spread to tons of other languages: C++, > Java, C#, Python, Perl--heck, even LISP. > > Am I the only one here who's suffered a needless off-by-one bug as a > result of C's horrible zero-based indexing? Let's see a show of hands... > > But more important, to those of us in DSP, is the fact that C's indexing > doesn't conform to Matlab--which wisely employs one-based indexing in > accordance with the centurys-old convention of linear algebra. Now, one > might ask, "who died and left Matlab in charge?" Well, nobody, I guess. > But if the Matlab folks hadn't gotten this right, why would so many DSP > folks shell out *thousands* for Matlab, when zero-based alternatives like > SciPy (http://scipy.org/) are absolutely, 100%, free? There can be only > one answer: one-based indexing. > > OK, I can already hear some of you about to cite the old "legacy code" > chestnut as a reason C can't be changed. True, there's a lot of C code > out there. But there's absolutely no reason that C can't switch to > one-based with a zero-based compatibility mode. OK, I know, I know: C++ > programmers can easily create their own one-based array object. But what > sense does it make for countless programmers to home-brew a solution when > Dennis Ritchie could just get off his duff and fix the problem > once-and-for-all? After all, Grace Hopper did it for FORTRAN. > > Sound radical? I don't think so: let's face it, we live in a one-based > world. For example, ask a child to count their fingers, and they'll > invariably assign "one" to the first (er, "zeroth") finger. > > Still not convinced? OK, what about the calendar?--what if today was > "April 0th"? > > =g2 > _____________________________________________________________________ > > Grant R. Griffin > Publisher of dspGuru http://www.dspguru.com > Iowegian International Corporation http://www.iowegian.com > See http://www.iowegian.com/img/contact.gif for e-mail address
Grant Griffin wrote:
> Am I the only person who's noticed that C's zero-based indexing is > nothing short of...well...horrible? And it doesn't end there: C has > been so influential that its insanity has spread to tons of other > languages: C++, Java, C#, Python, Perl--heck, even LISP. > > Am I the only one here who's suffered a needless off-by-one bug as a > result of C's horrible zero-based indexing? Let's see a show of hands... > > But more important, to those of us in DSP, is the fact that C's indexing > doesn't conform to Matlab--which wisely employs one-based indexing in > accordance with the centurys-old convention of linear algebra. Now, one > might ask, "who died and left Matlab in charge?" Well, nobody, I guess. > But if the Matlab folks hadn't gotten this right, why would so many DSP > folks shell out *thousands* for Matlab, when zero-based alternatives > like SciPy (http://scipy.org/) are absolutely, 100%, free? There can be > only one answer: one-based indexing. > > OK, I can already hear some of you about to cite the old "legacy code" > chestnut as a reason C can't be changed. True, there's a lot of C code > out there. But there's absolutely no reason that C can't switch to > one-based with a zero-based compatibility mode. OK, I know, I know: C++ > programmers can easily create their own one-based array object. But > what sense does it make for countless programmers to home-brew a > solution when Dennis Ritchie could just get off his duff and fix the > problem once-and-for-all? After all, Grace Hopper did it for FORTRAN. > > Sound radical? I don't think so: let's face it, we live in a one-based > world. For example, ask a child to count their fingers, and they'll > invariably assign "one" to the first (er, "zeroth") finger. > > Still not convinced? OK, what about the calendar?--what if today was > "April 0th"? > > =g2 > _____________________________________________________________________ > > Grant R. Griffin > Publisher of dspGuru http://www.dspguru.com > Iowegian International Corporation http://www.iowegian.com > See http://www.iowegian.com/img/contact.gif for e-mail address
It's a pleasure to read another of Grant's Rants. Thanks. Jerry -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
duh, i don't get it.

r b-j

Clay S. Turner wrote:
> Hello Grant, > > It is great to see your wit has not waned. Thanks for writing on this April > Fool's Day. Maybe one day we will get indexing based on the irrational > numbers - but that uncountable thing will likely get in the way ;-) > > Clay > > > > "Grant Griffin" <nospam@yahoo.com> wrote in message > news:4a503$442e975f$4088dbc7$1304@EVERESTKC.NET... > > Am I the only person who's noticed that C's zero-based indexing is nothing > > short of...well...horrible? And it doesn't end there: C has been so > > influential that its insanity has spread to tons of other languages: C++, > > Java, C#, Python, Perl--heck, even LISP. > > > > Am I the only one here who's suffered a needless off-by-one bug as a > > result of C's horrible zero-based indexing? Let's see a show of hands... > > > > But more important, to those of us in DSP, is the fact that C's indexing > > doesn't conform to Matlab--which wisely employs one-based indexing in > > accordance with the centurys-old convention of linear algebra. Now, one > > might ask, "who died and left Matlab in charge?" Well, nobody, I guess. > > But if the Matlab folks hadn't gotten this right, why would so many DSP > > folks shell out *thousands* for Matlab, when zero-based alternatives like > > SciPy (http://scipy.org/) are absolutely, 100%, free? There can be only > > one answer: one-based indexing. > > > > OK, I can already hear some of you about to cite the old "legacy code" > > chestnut as a reason C can't be changed. True, there's a lot of C code > > out there. But there's absolutely no reason that C can't switch to > > one-based with a zero-based compatibility mode. OK, I know, I know: C++ > > programmers can easily create their own one-based array object. But what > > sense does it make for countless programmers to home-brew a solution when > > Dennis Ritchie could just get off his duff and fix the problem > > once-and-for-all? After all, Grace Hopper did it for FORTRAN. > > > > Sound radical? I don't think so: let's face it, we live in a one-based > > world. For example, ask a child to count their fingers, and they'll > > invariably assign "one" to the first (er, "zeroth") finger. > > > > Still not convinced? OK, what about the calendar?--what if today was > > "April 0th"? > > > > =g2 > > _____________________________________________________________________ > > > > Grant R. Griffin > > Publisher of dspGuru http://www.dspguru.com > > Iowegian International Corporation http://www.iowegian.com > > See http://www.iowegian.com/img/contact.gif for e-mail address
Wow! I never thought of it that way...

--RY

Grant Griffin <nospam@yahoo.com> writes:

> Am I the only person who's noticed that C's zero-based indexing is > nothing short of...well...horrible? And it doesn't end there: C has > been so influential that its insanity has spread to tons of other > languages: C++, Java, C#, Python, Perl--heck, even LISP. > > Am I the only one here who's suffered a needless off-by-one bug as a > result of C's horrible zero-based indexing? Let's see a show of > hands... > > But more important, to those of us in DSP, is the fact that C's > indexing doesn't conform to Matlab--which wisely employs one-based > indexing in accordance with the centurys-old convention of linear > algebra. Now, one might ask, "who died and left Matlab in charge?" > Well, nobody, I guess. But if the Matlab folks hadn't gotten this > right, why would so many DSP folks shell out *thousands* for Matlab, > when zero-based alternatives like SciPy (http://scipy.org/) are > absolutely, 100%, free? There can be only one answer: one-based > indexing. > > OK, I can already hear some of you about to cite the old "legacy code" > chestnut as a reason C can't be changed. True, there's a lot of C > code out there. But there's absolutely no reason that C can't switch > to one-based with a zero-based compatibility mode. OK, I know, I > know: C++ programmers can easily create their own one-based array > object. But what sense does it make for countless programmers to > home-brew a solution when Dennis Ritchie could just get off his duff > and fix the problem once-and-for-all? After all, Grace Hopper did it > for FORTRAN. > > Sound radical? I don't think so: let's face it, we live in a > one-based world. For example, ask a child to count their fingers, and > they'll invariably assign "one" to the first (er, "zeroth") finger. > > Still not convinced? OK, what about the calendar?--what if today was > "April 0th"? > > =g2 > _____________________________________________________________________ > > Grant R. Griffin > Publisher of dspGuru http://www.dspguru.com > Iowegian International Corporation http://www.iowegian.com > See http://www.iowegian.com/img/contact.gif for e-mail address
-- % Randy Yates % "I met someone who looks alot like you, %% Fuquay-Varina, NC % she does the things you do, %%% 919-577-9882 % but she is an IBM." %%%% <yates@ieee.org> % 'Yours Truly, 2095', *Time*, ELO http://home.earthlink.net/~yatescr
Grant Griffin wrote:
> Am I the only person who's noticed that C's zero-based indexing is > nothing short of...well...horrible? And it doesn't end there: C has > been so influential that its insanity has spread to tons of other > languages: C++, Java, C#, Python, Perl--heck, even LISP. > > Am I the only one here who's suffered a needless off-by-one bug as a > result of C's horrible zero-based indexing? Let's see a show of hands... > > But more important, to those of us in DSP, is the fact that C's indexing > doesn't conform to Matlab--which wisely employs one-based indexing in > accordance with the centurys-old convention of linear algebra. Now, one > might ask, "who died and left Matlab in charge?" Well, nobody, I guess. > But if the Matlab folks hadn't gotten this right, why would so many > DSP folks shell out *thousands* for Matlab, when zero-based alternatives > like SciPy (http://scipy.org/) are absolutely, 100%, free? There can be > only one answer: one-based indexing. > > OK, I can already hear some of you about to cite the old "legacy code" > chestnut as a reason C can't be changed. True, there's a lot of C code > out there. But there's absolutely no reason that C can't switch to > one-based with a zero-based compatibility mode. OK, I know, I know: C++ > programmers can easily create their own one-based array object. But > what sense does it make for countless programmers to home-brew a > solution when Dennis Ritchie could just get off his duff and fix the > problem once-and-for-all? After all, Grace Hopper did it for FORTRAN. > > Sound radical? I don't think so: let's face it, we live in a one-based > world. For example, ask a child to count their fingers, and they'll > invariably assign "one" to the first (er, "zeroth") finger. > > Still not convinced? OK, what about the calendar?--what if today was > "April 0th"? > > =g2 > _____________________________________________________________________ > > Grant R. Griffin > Publisher of dspGuru http://www.dspguru.com > Iowegian International Corporation http://www.iowegian.com > See http://www.iowegian.com/img/contact.gif for e-mail address
Hahahaha, Thanks Grant, that just made my day, I actually thought you were being serious until got to the April 0th part. Brilliant!!!
Hey Grant,

Thanks for the reference to Grace Hopper, whom I had never heard of
(to my discredit).

In finding out about her, I came across this fascinating website on
Women in Science that I thought others might enjoy.

  http://www.sdsc.edu/ScienceWomen/index.html

--Randy


Grant Griffin <nospam@yahoo.com> writes:

> Am I the only person who's noticed that C's zero-based indexing is > nothing short of...well...horrible? And it doesn't end there: C has > been so influential that its insanity has spread to tons of other > languages: C++, Java, C#, Python, Perl--heck, even LISP. > > Am I the only one here who's suffered a needless off-by-one bug as a > result of C's horrible zero-based indexing? Let's see a show of > hands... > > But more important, to those of us in DSP, is the fact that C's > indexing doesn't conform to Matlab--which wisely employs one-based > indexing in accordance with the centurys-old convention of linear > algebra. Now, one might ask, "who died and left Matlab in charge?" > Well, nobody, I guess. But if the Matlab folks hadn't gotten this > right, why would so many DSP folks shell out *thousands* for Matlab, > when zero-based alternatives like SciPy (http://scipy.org/) are > absolutely, 100%, free? There can be only one answer: one-based > indexing. > > OK, I can already hear some of you about to cite the old "legacy code" > chestnut as a reason C can't be changed. True, there's a lot of C > code out there. But there's absolutely no reason that C can't switch > to one-based with a zero-based compatibility mode. OK, I know, I > know: C++ programmers can easily create their own one-based array > object. But what sense does it make for countless programmers to > home-brew a solution when Dennis Ritchie could just get off his duff > and fix the problem once-and-for-all? After all, Grace Hopper did it > for FORTRAN. > > Sound radical? I don't think so: let's face it, we live in a > one-based world. For example, ask a child to count their fingers, and > they'll invariably assign "one" to the first (er, "zeroth") finger. > > Still not convinced? OK, what about the calendar?--what if today was > "April 0th"? > > =g2 > _____________________________________________________________________ > > Grant R. Griffin > Publisher of dspGuru http://www.dspguru.com > Iowegian International Corporation http://www.iowegian.com > See http://www.iowegian.com/img/contact.gif for e-mail address
-- % Randy Yates % "So now it's getting late, %% Fuquay-Varina, NC % and those who hesitate %%% 919-577-9882 % got no one..." %%%% <yates@ieee.org> % 'Waterfall', *Face The Music*, ELO http://home.earthlink.net/~yatescr
Grant Griffin wrote:
[...]
> Still not convinced? OK, what about the calendar?--what if today was > "April 0th"?
This is a good one :-) And here is the answer: http://www.cs.utexas.edu/users/EWD/ewd08xx/EWD831.PDF bye, -- piergiorgio
Randy Yates wrote:
> Hey Grant, > > Thanks for the reference to Grace Hopper, whom I had never heard of > (to my discredit). > > In finding out about her, I came across this fascinating website on > Women in Science that I thought others might enjoy.
I'll check it out shortly. Do you know that she or her group gave the word "bug" its programming connotation? One of the programs her group had written gave errors. Tracing was very difficult in relay computers programmed in binary, as you can imagine. After concluding that the computer was broken, not the program -- was that the first case of "It must be the hardware? -- diligent examination found a moth's wing preventing one of the contacts from closing. After that, every error was jokingly attributed to a bug. Jerry -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
Praetorian wrote:
> > Hahahaha, > Thanks Grant, that just made my day, I actually thought you were being > serious until got to the April 0th part. Brilliant!!!
some of us who were around 6 years ago might remember this thread which is where i suspect that Grant derived the title from: http://groups.google.com/group/comp.dsp/browse_frm/thread/d38b592e9015bf71/a5b6a43fa71ed966#a5b6a43fa71ed966 here are other threads of old: http://groups.google.com/group/comp.soft-sys.matlab/browse_frm/thread/d89d79a12bcf4c64/c95a6a4eb72bde21?hl=en#c95a6a4eb72bde21 http://groups.google.com/group/comp.soft-sys.matlab/browse_frm/thread/d14bc1d9028612a0/73ebca3edf7bb129?hl=en#73ebca3edf7bb129 http://groups.google.com/group/comp.soft-sys.matlab/browse_frm/thread/83304388e38985e1/aee053ee44c27801?hl=en#aee053ee44c27801 http://groups.google.com/group/comp.soft-sys.matlab/browse_frm/thread/ca82c61b27cf6fc1/700c5b40de772635?hl=en#700c5b40de772635 (you might have to unwrap the line. too much of pain-in-arse to use tinyurl.com.) anyway, i am adding comp.soft-sys.matlab to this because TMW must never be allowed to smugly and conveniently forget their cheesy and substandard "feature" in their *very* expensive product, nor be allowed to pretend that they had ever successfully refuted the need to fix it, nor be allowed to say they had no idea there was this problem. TMW has no excuse, they're big enough to put in the small resources to fix it (in a backward compatible way), they've been told time and again what the problem is and what a well-defined solution would look like, there is just no excuse so mocking MATLAB is the remaining alternative to doing nothing (which seems to be TMW's preference). r b-j