Safe to say all programmers are familiar with bugs. By definition, a bug in programming is described as:
An error, flaw or fault in a computer program or system that causes it to produce an incorrect or unexpected result, or to behave in unintended ways — Wikipedia.
Chances are you’ve played a part in unintentionally sneaking one into your code, or have debugged someone else’s to fix it. After all, a bug can be anything from an infinite loop to a division by zero to using an uninitialised variable! These examples go to show how just a simple overlook could mean unwanted behaviours in your code.
On some occasions, it’s hard to pinpoint the exact root cause of a bug, especially as some will break unrelated things in your code. These false flags often lead us to think something else is causing it. Most editors, however, make it extremely easy for developers to debug their code — allowing them to run their solution in debug mode. Visual Studio Code embraces the term with a little bug icon on the button responsible for loading up debug mode. GitHub includes the term as one of its predefined labels when raising an issue. And the word is tossed around now and again between development teams on stand-ups. But ever wondered where the term came from? It goes back a lot further than you think!
The earliest recorded mention of a bug in this context predates programming and even computers. It is thought to have first been used in the 1870s to describe mechanical malfunctions in hardware engineering. Thomas Edison described them as “little faults and difficulties” in a letter to his associate in 1878 when describing his inventions.
Since then pinball games were advertised as “bug-free”, problems with military gear were described as bugs, and film producers started adding the term to their scripts. The term became increasingly popular to describe any unwanted behaviour in mechanical inventions and day to day machinery.
When it came to software programming, it was Ada Lovelace who first wrote about the possibility of errors residing in solutions. She expressed her concerns about the possibility of Charles Babbage’s Analytical Engine — a general-purpose computer — receiving the wrong instructions from the inserted program cards. In other words — carrying out orders different to the ones expected — otherwise known as a bug.
About 100 years later, the most peculiar encounter ensured that it would be the first people remembered when accounting for the term’s origin.
An Actual Bug
I have to admit, I was amused to read that an encounter with an actual bug in the context of computing was recorded in history. Operators of the electronic computer Mark II — worked on by renowned computer scientist Grace Hopper in the Harvard Faculty at the Computation Laboratory — found a moth trapped in one of the machine’s relays, causing it to malfunction.
After carefully removing the insect, they taped it onto a page in the machine’s log along with a comment that read “first actual case of bug being found”.
From Insects to Disasters
On a serious note, software bugs can have serious consequences if not found and flushed out. Here are a few of the most noted disasters due to software bugs in history.
Mars Climate Orbiter
NASA lost its Mars Climate Orbiter spacecraft — launched in 1998 to study the Martian climate — due to inconsistencies between the systems of measurement used. The navigation team who controlled the probe from Earth used parameters in English units, whilst the spacecraft software used the metric system. This failure to convert the units into metric ultimately resulted in a miscalculation in the Orbiter’s trajectory that cost NASA millions of dollars.
In some cases, these bugs can be fatal to its machine’s users. This was the case with the Therac-25 — a computer-controlled radiation therapy developed in 1982. Due to programming errors, the machine at times gave its cancer patients radiation doses that were 100 times greater than normal resulting in serious injury. Patients showed radiation burns several days later, along with symptoms of radiation poisoning. Three of those injured patients later died as a result of the overdose.
A study from the universities of Washington and California concluded that overconfidence in the software was a contributing factor, along with what they presumed to be less-than-acceptable-software-engineering practices.
Knight Capital Group Stock Trading
In 2012, Knight Capital Group — an American global financial services company that ceased operations in 2013 — incurred a loss of $440 million in half an hour after a software bug on their system started trading about 150 stocks erratically. Knight was later on acquired by rival Getco LLC the summer after the event occurred.
Apple Maps was initially released in September 2012 with the idea of replacing Google Maps as the default mapping app for Apple’s OS. The app, however, was immediately deemed as unreliable by users all over the world reporting incorrect fundamental location data. Reports included the Statue of Liberty missing, a Florida supermarket mislabeled as a hospital, and Hong Kong showing as several miles from Hong Kong Island.
Code vs Developer vs Processes
Who is held accountable for bugs? Much of the debate around this topic falls with the notion that no software can ever be completely bug-free. Some argue that the term ‘bug’ divorces the idea that it’s man-made. It is also worth mentioning that bugs can arise from not only code specific errors, but from design flaws and incorrect processes. The London Ambulance Service (LAS) Computerised Dispatch System (CAD) is a clear example of this — where its project management was also frowned upon — therefore implicating multiple parties involved.
The term bug, in this context, is found to have first been mentioned concerning electronic engineering in the 1800s, with Ada Lovelace expressing concerns that software would not be exempt. It seems that bugs were causing havoc even then, including a physical bug found inside the relay of an electronic computer. In some cases, they can be costly and the consequences irreversible, for both companies and their consumers.
Although undoubtedly a part of a software developer’s life, much can be done nowadays to catch them early on in the process.
More often than not, each debugging tool will be aimed at primarily one or two specific languages. Below are a few I found along with their respective languages:
- Rookout — used to debug JVM, Node.JS, and Python code. Remote debugging is available with Rookout, as well as the ability to debug both staging and production applications.
- Zend Studio — for code editing, testing, and debugging of PHP solutions.
- Visual Studio & Visual Studio Code — useful for debugging .NET solutions, with the latter offering access to a remote development extension pack (useful for helping a colleague debug their code from afar!).
- GDB — an extremely versatile debugger supporting C, C++, Go, Pascal, Rust & more.
- Eclipse — a renowned IDE for Java development also supporting C#, Python, Ruby, and PHP.
- React Native Debugger — for, as the name may suggest, all of your React Native debugging!
And these are just a handful of all of the ones out there, have a browse, pick your favourite and go bug-free!