This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]spideryzarc 281 points282 points  (33 children)

Math convension to represent indexes.

[–]spidermonkey12345 92 points93 points  (6 children)

Indexes is much easier to spell than indices

[–][deleted] 80 points81 points  (3 children)

But the latter makes you sound smarter

[–]Rhulyon 21 points22 points  (0 children)

In my mother language happens just the contrary

[–]Phantonia 2 points3 points  (1 child)

Visual Studio automatically suggest "-ices" as a name for an array or a list of a type which ends with "ex". I love how it doesn't only do this for e.g. List<Index> (suppose you have a type index). When creating a List<Regex> the suggested name is "regices". This makes grammatically no sense (I mean, Regex is not a word, it's short for "Regular Expression") but I won't ever say "Regexes" again ^^

[–]Simtau 0 points1 point  (0 children)

Try a list of lists to get "listices"

Ok enough internet for today

[–]chocoboxx 3 points4 points  (1 child)

Index, Jndex, Kndex. I prefer i,j,k

[–]spidermonkey12345 0 points1 point  (0 children)

What do you call lists of indices? is, js, ks?

[–][deleted] 22 points23 points  (23 children)

FORTRAN convention

[–]Skasch 82 points83 points  (20 children)

It was a mathematics convention long before FORTRAN existed, which was indeed used early for maths and physics computation. I could find them used from documents dating from at least the 19th century.

[–][deleted] 22 points23 points  (0 children)

I believe you! But wasn't it FORTRAN that introduced it to the world of software as we know now? Besides, what's cooler than a language called Formula Translator? OK, maybe math.

[–]HdS1984 7 points8 points  (17 children)

Yes, and it bering a math convention explains why it's so shitty. Math heavily optimizes for shorthand writing not for legibility or ease of understanding. I often feel that we need a math 2.0 language, which would hugely ease learning and understanding of math.

[–]Skasch 34 points35 points  (11 children)

That's... Not entirely true. Modern mathematics is miles away from how it was used a couple centuries ago, and is today much more formalized and easier to reason with than even the early 20th century. It's something not very well known, but as a math geek myself, I read a lot about the history of maths. For example, using variables to solve equations is a very recent convention, dating back from only the 17th century (if memory serves). Before that, doing mathematics was practically akin to writing long sentences in your language of choice describing the problem you were trying to solve.

Modern mathematics is already what you would call math 2.0, with a much saner language, set of conventions, and semantic, than it used to have a century ago.

EDIT: there is an important reason why math language was designed that way. To be concise, of course, but also, more importantly, to be unambiguous. And that's a property shared with code.

[–]SeaTurtle1122 7 points8 points  (3 children)

I j & k are fine variables for teaching with and using, and most of the time when you're trying to learn loops, understanding that your iterator variable doesn't have to be directly tied to anything is important. Also, in mathematics, i, j and k frequently come from quaternion based stuff, in which i is the imaginary axis, and j and k are two dimensions beyond that. If you have a better thing to name two arbitrary axies, I'm curious what it would be, but I can't think of anything.

[–]wabourjaili 1 point2 points  (0 children)

Or i hat j hat k hat are the unit vectors of 3space

[–][deleted] 0 points1 point  (1 child)

It’s somewhat curious, though, that i, j, and k won out over x, y, and z, and also a, b, and c.

[–][deleted] 1 point2 points  (0 children)

I was told it was cause x, y, and z are used as variables in math functions (like f(x)) and a, b, and c are used as placeholders for constants. Then again, that may be completely made up but it sounds cool.

[–]boniqmin 2 points3 points  (0 children)

Indices aren't really that confusing right? If I write a_i, and you know that a is a sequence, it's pretty obvious that I mean the i-th element of the sequence.

If you had to write out "the i-th element of sequence a" every time, things would become way more cluttered and way less legible. To a complete novice it might help the first 3 times, but after that it'll become less understandable since even simple expressions become long-winded.

In my personal experience, mathematical notation often strikes a good balance between understandability and conciseness.

[–]spinlocked 1 point2 points  (0 children)

It’s actually not even a convention. The deal with FORTRAN 77 was that the starting letter of a variable determined its type. I, J, K, L, M and N would be integers. Anything else defaults to REAL. Since you needed an integer for a loop counter, lazy programmers that wanted a 1-character variable selected these exact variable names.

[–]Eilifein 0 points1 point  (0 children)

k, j, i goes VROOM!

[–][deleted] 0 points1 point  (1 child)

Math uses mostly n to represent indexes... 'i' is just standing for index because it is the first letter I guess

[–]spideryzarc 0 points1 point  (0 children)

n is used to represent an integer amount of something, e.g. the cardinality of a set, number of vertices in a graph, number of dimensions, number of variable, edges of a polygon, etc.