Better Programming

Advice for programmers.

Follow publication

Inclusive Code-struction: A How-To Guide

Gargee Suresh
Better Programming
Published in
4 min readFeb 9, 2023
Image by DALL-E

“Code is the universal language that speaks to all, but not all code speaks to everyone.”

This is a powerful truth we must keep in mind as developers. It’s easy to fall into the trap of using language or syntax that may not be inclusive or considerate of all users. This can take many forms, from insensitive terms to assumptions about the experiences of different users. But with awareness and effort, we can write code that is inclusive and respectful to all. This guide is here to help you identify and replace non-inclusive code and technological terminology so your codebase can be a welcoming and inclusive space for everyone.

Identifying Problematic Phrasing

Awareness is the first step toward change. Let’s start by highlighting some of the non-inclusive terms commonly used in coding syntax and exploring the alternative terms that promote inclusivity and diversity.

The table below contains a list of terms and their replacements, along with explanations as to why they must be replaced, and have been compiled from various sources. Now we know what to look out for!

Taking Action — Replacing with inclusive Alternatives!

Now that we are aware of non-inclusive terms to look out for, we can start replacing them with inclusive alternatives. Here are some practical steps we can take toward making this happen:

  • Use inclusive language while naming variables
  • Replace non-inclusive system commands with inclusive ones by creating aliases
  • Avoid insensitive terms in error messages
  • Review code libraries and dependencies
  • Being mindful and inclusive in conversation

Use inclusive language while naming variables

In code, variable names play an important role in helping other engineers understand what a piece of code is doing. When naming variables, it’s important to choose inclusive and respectful language. For example, instead of using “master” or “slave,” consider using “primary” and “secondary.” Instead of using “blacklist” or “whitelist,” consider using “denylist” and “allowlist.”

// Non-inclusive variable names
var masterData = [];
var slaveServer = "";

// Inclusive variable names
var primaryData = [];
var secondaryServer = "";

Replace non-inclusive system commands with inclusive ones by creating aliases

Many system commands, like “kill” or “war room,” can carry implications of violence. To promote a more inclusive environment, consider creating aliases for these commands that are more respectful and neutral. For example, instead of using “kill,” consider using “stop” or “halt.” Instead of using “war room,” consider using “operations room” or “ops room.”

# Non-inclusive system command
$ kill <pid>

#
Inclusive system command with alias
$ alias kill='stop'
$ stop <pid>

Avoid insensitive terms in error messages

Error messages should be clear and descriptive but also mindful of the language used. Avoid using insensitive or offensive terms, and replace them with more neutral language.

Here’s an example of how you could replace non-inclusive terms in error messages:

//Before
if (user.age < 18) {
throw new Error("User is not old enough");
}


//After
if (user.age < 18) {
throw new Error("User does not meet the age requirement");
}

Review code libraries and dependencies

Check the code libraries and dependencies you are using and make sure they do not contain any non-inclusive language or biases. Consider using alternative libraries or submitting a patch to remove the problematic language if they do.

Use inclusive language with comments and documentation

Comments and documentation are an important part of code, helping to explain what the code is doing and how it works. Just like variable names, it’s important to choose inclusive and respectful language. For example, instead of using “crazy” or “cripples,” consider using “baffling” or “slows.” Instead of using “dummy” or “handicap,” consider using “placeholder” or “obstacle.”

// Non-inclusive comments
// This function returns a crazy result
function crazyResult() {
// ...
}

// Inclusive comments
// This function returns a baffling result
function bafflingResult() {
// ...
}

Being mindful and inclusive in conversation

Finally, it’s important to be mindful and inclusive in our conversations, both in person and online. This means avoiding insensitive, harmful language, or perpetuating harmful stereotypes. When in doubt, it’s always a good idea to do a quick internet search to see if a term is considered non-inclusive and choose an alternative if necessary.

By taking these steps, we can create technology that is more inclusive and respectful to all people. Let’s all do our part in promoting diversity, equity, and inclusivity in the tech industry!

Gargee Suresh
Gargee Suresh

Written by Gargee Suresh

I'm a feminist software engineer here to debug the patriarchy, one line of code at a time. Fuelled by the smell of Paint and Paati's Puliyodhara.

No responses yet

Write a response