Runtime Vs. Compile Time
What Is the Difference Between Run-Time and Compile-Time? 1 26 Answers the Difference Between Compile Time and Run Time Is an Example of What Pointy-Headed...
What is the difference between run-time and compile-time?
26 Answers
The difference between compile time and run time is an example of what pointy-headed theorists call the phase distinction. It is one of the hardest concepts to learn, especially for people without much background in programming languages. To approach this problem, I find it helpful to ask
- What invariants does the program satisfy?
- What can go wrong in this phase?
- If the phase succeeds, what are the postconditions (what do we know)?
- What are the inputs and outputs, if any?
Must Read
Compile time
- The program need not satisfy any invariants. In fact, it needn't be a well-formed program at all. You could feed this HTML to the compiler and watch it barf...
- What can go wrong at compile time:
- Syntax errors
- Typechecking errors
- (Rarely) compiler crashes
- If the compiler succeeds, what do we know?
- The program was well formed---a meaningful program in whatever language.
- It's possible to start running the program. (The program might fail immediately, but at least we can try.)
- What are the inputs and outputs?
- Input was the program being compiled, plus any header files, interfaces, libraries, or other voodoo that it needed to import in order to get compiled.
- Output is hopefully assembly code or relocatable object code or even an executable program. Or if something goes wrong, output is a bunch of error messages.