Imagine finding a moth inside your computer. This strange event in 1947 marked the beginning of a practice that has since become an essential part of programming: debugging. Debugging has a very strange history. Why do you think we call software errors 'bugs'? The answer lies in the early days of computing. The term "bug" was created in 1878, when Thomas Edison himself was the first to use the term "bug" to describe a technical error.
In 1945, two professors at the University of Pennsylvania, John Mauchly and J. Presper Eckert, built the Electronic Numerical Integrator and Calculator (ENIAC). ENIAC was the first programmable, electronic, general-purpose digital computer. While some other computers had similar features, ENIAC was the first to combine them all. It was powerful enough to solve many types of math problems by being reprogrammed. The project was funded by the United States Army and finished in 1945, with its formal dedication in 1946. The press often called it a "Giant Brain" because it was about a thousand times faster than the electro-mechanical machines of its time. This all leads to the establishment of the first computer, one of these computers, the Mark III, was being built at Harvard. Grace Hopper was working on the Mark III when she ran into a unique problem with its functionality, something she never saw before.
After running some tests, Grace Hopper realized there was a problem she couldn't solve easily. She decided to open up the Mark III to see what was wrong inside. To her surprise, she found an actual moth stuck in the machinery, causing it to malfunction. She removed the moth and taped it into the logbook, noting it as the "first actual case of bug being found." This incident led to the term "debugging" being used in programming, meaning to find and fix errors in computer systems. The simplest way to debug code is to add print statements that help you pinpoint where the problem is occurring. This method is often called "printf debugging," named after the printf() function in the C programming language.