A compiler translates the entire program into machine code before execution, while an interpreter translates and executes the program line by line.