A compiler is a program that translates a program written in a source language into an equivalent program in a target language. It has two major parts - analysis and synthesis. In analysis, an intermediate representation is created by analyzing the lexical, syntactic and semantic properties of the source program. In synthesis, the target program is created from the intermediate representation through code generation and optimization. The major techniques used in compiler design like parsing and code generation can also be applied to other domains like natural language processing.