A compiler is a software program that translates code written in a high-level programming language into a lower-level language, typically machine code, that a computer's processor can execute. This process involves several stages including parsing, analysis, and optimization to produce executable code.