Debugger vs Compiler
In general, compiler is a computer program that reads a program written in one language, which is called the source language, and translates it in to another language, which is called the target language. Traditionally, source language was a high level language such as C++ and target language was a low level language such as assembly language. Debugger is a computer program that is used to find bugs/errors in other programs. Debugger allows a programmer to stop execution of a program at a point and examine the characteristics such as variable values at that point.
What is a Debugger?
Debugger is a computer program that is used to find bugs/errors in other programs. Debugger allows executing a program and inspecting each step in the program execution. It also allows stopping the execution of the program at some point and changing some variable values and then continuing the execution. All of these capabilities are provided to help the programmer to make sure that her program is behaving correctly and to help in identifying bugs in the code. Most of the debuggers provide the ability to execute a program step by step (also called single stepping), pausing to examine the current state of the program by providing a breakpoint and tracking variable values. Some advanced debuggers allow the programmer to skip a location that causes a crash or a logical error in the code and continue execution from a different location. Some of the popular debuggers are GNU Debugger (GDB), Microsoft Visual Studio Debugger, etc.
What is a Compiler?
Compiler is a computer program that reads a program written in one language, which is called the source language, and translates it in to another language, which is called the target language. Most often, the source language is a high level language and the target language is a low level language. So, in general compilers can be seen as translators that translate from one language to another. In addition, compilers perform some optimizations to the code. A typical compiler is made up of several main components. The first component is the scanner (also known as the lexical analyzer). Scanner reads the program and converts it to a string of tokens. The second component is the parser. It converts the string of tokens in to a parse tree (or an abstract syntax tree), which captures the syntactic structure of the program. Next component is the semantic routines that interpret the semantics of the syntactic structure. This is followed by code optimizations and final code generation.
What is the difference between a Debugger and a Compiler?
Debugger is a computer program that is used to find bugs/errors in other programs, while compiler is a computer program that reads a program written in one language and translates it in to another language. Compilers also have the capability to detect syntax errors and other compile time errors, but debuggers provide more capabilities (such as monitoring the memory) to detect bugs in programs. These two are two different programs, but most of the times, a debugger and a compiler are integrated into a single package.