[Jprogramming] index origin 0
David Porter
dporter at cissoid.net
Mon Jul 26 23:04:55 HKT 2010
I studied electrical engineering, but graduated with a BS in
philosophy of science followed by an MS in photographic science. I used
APL for statistical computing of colorimetric data in two standards
laboratories. Later I used APL for digitizing an old Hardy
spectrophotometer and doing off-line digital signal processing on the
data for wavelength calibration. Still later, I supported a time-series
database for oil traders. I have done a little programming in J, and
with the help of this forum actually made a some money using J software
to warp infra-red images.
In my APL work, only occasionally did I use an index origin of zero. It
just seemed more intuitive to use the APL default index origin of one.
That may be counter-intuitive to someone else. The ability to make the
index origin a local variable allowed functions to be written either way
without regard to the larger program, except the added complexity of
changing index origins in the code. This made the re-use (stealing) of
code written with the "wrong" index origin relatively easy.
The choice of the index origin shares some problems with the choice of
standards. Ultimately, the choice is arbitrary, but should not be
capricious. Either index origin satisfies the arbitrary condition, and
neither seems to be capricious. Use of one may provide a sense of
elegance in a particular situation that the other does not, but this is
dependent on the situation.
In my opinion, the elegance of J, though frustrating to learn, far
surpasses any loss of elegance from not being able to choose an index
origin. The fixed index origin automatically facilitates the re-use of
code. That said, I do miss the ability to choose. Having the index
origin set to zero is not a great loss, but it did add one more
annoyance to learning the language. Maybe the only ones who might care
are the ones who once used APL and only those who used an index origin
of one.
Very happy with J, if I could ever get really good at it,
David Porter
More information about the Programming
mailing list