What is the deal with $i, $k, and $j?

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

I use them because that's the only place I get to use variables who's purpose isn't immediately obvious by reading the variable name.

Guilty pleasure :twisted:
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

see, this is why I love this forum so much... we have some smart mofos here. Thanks guys. :D
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

Maugrim_The_Reaper wrote:So which mathematician do we blame, arborint?
It goes back at least to the 17th Century because I believe Newton and Leibnitz used in their work on calculus (Newtons integral symbol is an S for "sum"). That's also the century of Decartes, Euler, Pascal, et al. so a lot of the mathematical notion we use comes from that era. Any mathematicians in the group who know history trivia?
(#10850)
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Post by alex.barylski »

I asked this question I swear I did, although I cannot find it here, I posted the results of that disscussion on another web site and the general census appears to be in agreement with Arborint...although I thought it was timvw that answered me originally, perhaps it was arborint.

One thing worth noting...

I know many of those who replied on the "other" website and I am aware some of them are mathematicians by trade or at least in background.

Those who had a background in math, typically agreed that "i" transcended into programming from FORTRAN as computers were originally only a tool for mathematicians, etc...

Whereas developers who had extensive backgrounds in programming in assembler...argued it was used to simply represent the Index register...which is what I've always assumed, having zero background in math, but moderate, working knowledge of assembler...

So really, I think this is debatable to the nines...as either party could be right, although the math argument does have history behind it, assembler developers have much more influence on us as developers in general than any math focused FORTRAN developer may have had...

Either way, I don't really care...after reading this book on XP I'm gonna break with tradition in the name of common sense and start using $a through $z so I can quickly determine the nesting level of the given index...also leaving nothing to guess and making a more strict convention.

Did I mention that book on XP was quite an inspirational read, 200 pages went by like there was no tomorrow...I read it all in one sitting I found it so captivating :P

Last time I read a book front to cover in one sitting, was

1) April Raintree
2) Catcher in the Rye

Sorry, I'm done plugging the whole XP thing :P
User avatar
julian_lp
Forum Contributor
Posts: 121
Joined: Sun Jul 09, 2006 1:00 am
Location: la plata - argentina

Post by julian_lp »

nice question, specially beacause it is a thing which I've asked myself so many times. :)

BTW: I find using both $i and $j an open door to make mistakes, I use $i and $k every time I've to write a nested loop...
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Post by alex.barylski »

I have never really had a problem with using any convention, but when I've got into 3-4 levels of nested for loops I have occasionally used a $j twice (using it inside a for and then again 2 levels deeper simply because I lost count of what letter came next).

I figure it's easier for most people (like it is myself) to know exactly what comes after b than it does to know what comes after s...

personally I find myself having to quickly repeat the preceeding 3-4 letters before I can continue with the trailing letters....whereas ABCDEFG I have no problems at any point...

meh...whatever floats your boat I guess :P
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

arborint wrote:
Maugrim_The_Reaper wrote:So which mathematician do we blame, arborint?
It goes back at least to the 17th Century because I believe Newton and Leibnitz used in their work on calculus (Newtons integral symbol is an S for "sum"). That's also the century of Decartes, Euler, Pascal, et al. so a lot of the mathematical notion we use comes from that era. Any mathematicians in the group who know history trivia?
According to http://members.aol.com/jeff570/operation.html our friend Euler was the first to use the sigma symbol for summation in 1755.
User avatar
Oren
DevNet Resident
Posts: 1640
Joined: Fri Apr 07, 2006 5:13 am
Location: Israel

Post by Oren »

arborint wrote:Newtons integral symbol is an S for "sum"
Not exactly. It is an S, but it's for "Surface" not "Sum".
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

timvw wrote:According to http://members.aol.com/jeff570/operation.html our friend Euler was the first to use the sigma symbol for summation in 1755.
As ever Tim, thanks ... great page.

I think it is pretty safe to say that most of early computerdom had a solid foundation in classical mathematics -- both hardware and software people. That and the fact that early computers were much more "computators" than machines today, hence the math focus.
(#10850)
Post Reply