A bug in software or hardware is a coding error causing unexpected or erroneous operation. The first documented use of the term in respect of computers relates to a dead moth which was causing faulty operation of a relay in an early electro-mechanical computer. However, the term had been used by engineers for many years previously in a wider context.