Cargo coding is when developers use a trial-and-error approach to coding – they don’t know what their code does, but they hope it will work. And, once it works, they stop working on the code, as they fear it might break. So, one manages to make the project work while having no idea how. It’s a *boom*-the-code-works tactic.

Does this sound like you? We hope not, as cargo coding can harm the development process. Everyone gets inspired from external sources – and that’s great! Researching and getting inspired by others’ work is what helps us stay creative and come up with unique solutions to our tasks. Problems arise when we do our work without understanding how or why we do certain things. 

In the tech world, it’s called Cargo Cult Programming. Surprisingly, it has its roots in the Second World War. Yep, you guessed it – it’s storytime!

The Beginning of Cargo Cult Programming

The Cargo Cult became popular in Melanesia, one of Oceania’s subregions in the southwestern Pacific Ocean. Besides small islands, the region also includes four independent countries – Fiji, Vanuatu, the Solomon Islands, and Papua New Guinea. During World War 2, the isolated and primitive cultures were shocked by the large number of soldiers arriving on their land by airdrop. Put yourself in the shoes of the natives – how would you feel if random humans started popping out from the sky without any previous heads up?

Besides this, soldiers carried with them canned food, carefully designed clothes, guns, and so on. Also, from time to time, packages with supplies landed separately on the island, mainly by airdrop too. And, when the war ended, the soldiers went back home, leaving the islanders behind. Can we take a moment to resonate with the confused natives? *moment of silence* Okay, now let’s continue with the story. 

This event left a permanent mark on the islanders. They wanted the soldiers and their cargo ships to return, as they associated them with Gods. Therefore, they started imitating their behavior using the soldier’s leftovers from the War. They believed that to get the soldiers back, they have to dress up and act like them. 

Let’s take a specific example. Some of the natives dressed up as ground traffic controllers, waving sticks around too. Why? Because they thought the soldiers and the cargo ships landed on their island thanks to them. It’s a cause-and-effect misunderstanding, as the natives believed the planes appeared thanks to the traffic controllers. We know it’s the other way around – the planes already exist and the ground traffic controllers have to help them land. 

The islanders understood the form but not the content. And that’s what cargo cult programmers do too – they understand what a code does without understanding how it does it. Which can be harmful to the development process. If you don’t understand the hows behind the code, you won’t be able to make changes to it when needed. Randomly making changes until the code works doesn’t really count as a good practice. 

The Cargo Culture

The cargo culture is sometimes supported even by programming courses. If you notice the courses you’re taking rely heavily on getting the syntax right but avoid focusing on the semantics, take it as a red flag. By syntax, we mean the structure of the language, and by semantics, we refer to the meaning behind the code. Now, obviously, without knowing the syntax you couldn’t make any program at all. But there’s a tendency to focus too much on this side, forgetting the importance of getting the semantics right as well. 

It’s programming by coincidence, which doesn’t serve you, your team, or your project. Don’t be a part of the Cargo Cult Programming group. The syntax, also known as the formal outward appearance, is the easy part of programming. It’s the understanding of the semantics that makes the difference. 

If this concept made you curious, you can also check out Microsoft’s take on it here. And, for more info on cargo cult, check out David Attenborough’s video where he explores the islanders of Tanna, who created a cargo cult around John Frum, an American soldier.