Understanding the Difference Between 'Indexes' and 'Indices'

Hero image for Understanding the Difference Between 'Indexes' and 'Indices'. Image by Maksym Kaharlytskyi.
Hero image for 'Understanding the Difference Between 'Indexes' and 'Indices'.' Image by Maksym Kaharlytskyi.

Whilst the development community, especially in frontend web development, is generally forgiving with terminological slipups like the pronunciation of 'GIF' or the occasional synonym mixup, or whether what we do is 'frontend', or 'frontend', or 'front end' development, there's one topic that's been on my mind: the difference between 'indexes' and 'indices'. It's not just a question of linguistic accuracy, but one of clarity and precision in coding and communication. So, what exactly is the difference between 'indexes' and 'indices', and more importantly, which one should we be using?


The Distinction Between 'Indexes' and 'Indices'

One of the subtle yet significant distinctions in technical terminology is understanding when to use 'indexes' versus 'indices'. Both are plural forms of 'index', a word that signifies an indicator, a guide, or a pointer, often used to reference or locate information. In our case, in programming, an 'index' most often refers to the position of an item within an array, like the numerical identifier of a specific data point in a list.

In most general contexts, 'indexes' is the preferred plural form. This term is widely used in everyday language and businessrelated scenarios. For instance, when referring to a list of contents in a book, or in the context of financial markets (like the Dow Jones Industrial Average), 'indexes' is the standard terminology.

On the other hand, 'indices' is often reserved for more technical or scientific discourses. This form of the term is particularly prevalent in mathematics, where it refers to the exponents in mathematical expressions, and in various branches of science and engineering. In these fields, 'indices' carries a more specialised and precise meaning, often relating to numerical or positional references within a set or system.

This sounds a lot like my point a few moments ago: we use indices to describe the position of an element within an array. However, in the realm of computer science and programming, the distinction becomes more nuanced. Whilst both 'indexes' and 'indices' are technically correct and understood, there's a subtle preference that varies based on the context and the community's conventions.

This brings us to an intriguing point: in programming, especially in languages like JavaScript and Python, the distinction between 'indexes' and 'indices' takes on a nuanced flavour. Whilst both terms are technically correct and understood within the programming community, there's a subtle preference that leans towards 'indexes' in specific contexts.

Take, for example, JavaScript arrays. An array is a fundamental data structure used to store multiple values in a single variable. Each element in an array is accessed by its numerical position, known as its 'index'. In everyday JavaScript coding, when we talk about looping through an array or accessing its elements, we refer to these positions as 'indexes'. The term 'indexes' naturally fits into this discourse.

The reason we tend to see 'indexes' over 'indices' in such scenarios boils down to the conventions of the language and its community. JavaScript, being a language with roots in web development and general programming, tends to align with the language's accessibility and easeofuse principles. It's about choosing the term that resonates more with the wider audience of developers, many of whom might come from diverse backgrounds, not strictly limited to scientific or mathematical fields. Choosing terms that are widely recognised and understood in the community facilitates clearer communication and understanding.


Origins and Contextual Use

Forgive me a bit of a history lesson here, I really have done much more reading about this particular topic than I should have done!

The terms 'indexes' and 'indices' share a common origin but have branched out in their usage over time, reflecting the evolving nature of language and the diversification of fields of knowledge.

Etymology and Historical Usage

The word 'index' originates from Latin, where it primarily meant an 'indicator' or a 'pointer'. Historically, 'index' was used in the context of books and manuscripts to refer to tables of contents or lists of information. As the usage of the term expanded, so did its plural forms. 'Indexes' became the standard form in general English usage, especially in literary and business contexts.

Indexes in General Context

In everyday language and nontechnical fields, 'indexes' is the preferred term. It's commonly used to refer to alphabetical listings in books, directories, and, notably, in financial markets. The use of 'indexes' in these contexts is guided by the general principles of English language usage, where simplicity and familiarity often dictate word choice. Although I know a few people who have learnt English as a second language and would not agree with that point at all!

Indices in Technical and Scientific Contexts

In contrast, 'indices' found its stronghold in more technical, scientific, and mathematical realms. This usage can be traced back to the influence of Latin in scientific discourse and the tendency in these fields to adhere to traditional forms. In mathematics, 'indices' are used to denote exponents or other mathematical notations. Similarly, in various scientific disciplines, 'indices' often refer to numerical or positional references in data sets or complex systems.

The Divergence in Usage

The divergence in the usage of 'indexes' and 'indices' reflects the adaptation of language to specific domains. Whilst 'indexes' aligns with the general trend of English towards simplicity and accessibility, 'indices' represents the precision and specificity often required in scientific and technical fields. This divergence is not just about convention but also about the audience and context. A financial analyst might discuss 'stock indexes', whilst a mathematician might work with 'matrices and their indices'.


Use of These Words in Web Development

We've already established now: in the world of web development, particularly when working with JavaScript, the term 'indexes' is more commonly used and accepted. This preference is not just a random choice; it's grounded in the history, community practices, and the nature of web development itself.

Simplicity and Accessibility in JavaScript

JavaScript, as a language, was designed with the goal of making web development accessible and straightforward. It is a language known for its flexibility and low barrier to entry, making it a popular choice among developers of varying skill levels. In keeping with this ethos, 'indexes' is preferred because it aligns with the language's principle of simplicity.

Practical Examples in Web Development

In practical terms, when dealing with arrays in JavaScript or managing states and props in React, developers often refer to the position of elements as 'indexes'. For example, consider a common task like iterating over an array of items to render a list in a React application. Developers typically use a loop to go through each element, accessing them by their 'index'. In these scenarios, talking about 'indexes' of array elements makes the concept more approachable and understandable, especially for those new to programming.

Community Conventions and Communication

The choice of 'indexes' over 'indices' in web development also reflects community conventions. In online forums, documentation, and tutorials related to frontend development, 'indexes' is predominantly used. This consistent usage helps in maintaining a standard terminology across various learning and development resources, which in turn fosters clearer communication within the community.

Why Not 'Indices' in Web Development?

It stands to reason that what we do as developers is grounded in maths and science, but whilst 'indices' is not incorrect, its use is less common in the context of everyday web development. The term 'indices' might be more prevalent in discussions involving complex algorithms or when dealing with data structures in more computer scienceoriented contexts. However, for most web development tasks and in frontend frameworks like React, 'indexes' remains the term of choice.

Practical Implications in Development

In the realm of React, a popular JavaScript library for building user interfaces, the understanding of 'indexes' takes on practical significance, especially when dealing with lists and managing state. To help settle the debate, the official React documentation for Lists and Keys uses 'indexes' and not 'indices'.

Rendering Lists in React

A really common task that we will all have come across in React is rendering lists of items. Whilst it is quite frowned upon, we developers often use the array's 'index' as a key when rendering lists of elements.

State and Props Management

React's reactivity system, which involves the management of state and props, often requires careful tracking of 'indexes'. When state or props of a component are an array, modifications like adding, removing, or rearranging items in these arrays necessitate a clear understanding of how 'indexes' work.

Best Practices with 'Indexes'

Whilst using 'indexes' as keys in lists is common, React best practices suggest using unique and stable identifiers when available. This is because using 'indexes' as keys can cause issues if the order of items in the array changes, leading to inefficient rerenders. Understanding when and how to use 'indexes' correctly is crucial for optimal React development.

Enhancing Code Readability and Maintenance

Using 'indexes' consistently in React development (as they do in the documentation) also enhances code readability and maintainability. When developers adhere to this convention, it makes the codebase more uniform and understandable, especially for new developers or when working in a team.

So, the use of 'indexes' in development is not just a matter of terminology but also a matter of practical application.


Wrapping up

As I mentioned at the very start, it would be incredibly unlucky if you came across anybody who really cared which word you used to describe the plural of 'index'. If you go by the idea that what we do as developers is rooted in mathematics and science, then 'indices' is the logical winner. However, that simply isn't the case in daytoday use and development.

The preference for 'indexes' in development aligns with the ethos of simplicity, accessibility, and community conventions. It's a choice that facilitates clearer communication, ensuring that code (and documentation) is approachable and understandable to a wide audience, including those who may not have a deep background in computer science or mathematics.

As frontend developers, our tasks transcend writing code; we need to be effective communicators both with our computers and with our fellow developers. Understanding the nuances of terms like 'indexes' and 'indices' is part of this communication process, enabling us to write code that is not only functional but also clear and maintainable.

Whilst I think it's healthy to be mindful of these linguistic and terminological distinctions, embracing the conventions of the community contributes to the collective knowledge and practices of the field.

At the end of the day, the choice of words we use in our code can be as impactful as the code itself, shaping how we think, communicate, and solve problems in the world of frontend development.


Categories:

  1. Development
  2. JavaScript