What is the differences between COMPILE TIME AND RUNTIME ?

Compile time and runtime are two distinctly different times during the active life of a computer program.

Compile time

  1. Compile time is when the program is compiled .
  2. Programmers use the term static to refer to anything that is created during compile time and stays fixed during the program run.
  3. 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…
  4. What can go wrong at compile time:
    • Syntax errors
    • Type checking errors
    • (Rarely) compiler crashes
  5. 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.)
  6. 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.


  1. Runtime is when it executes (on either a physical or virtual computer).
  2. They use the term dynamic to refer to things that are created and can change during execution.
  3. We know nothing about the program’s invariants—they are whatever the programmer put in. Run-time invariants are rarely enforced by the compiler alone; it needs help from the programmer.
  4. What can go wrong are run-time errors :
    • Division by zero
    • Dereferencing a null pointer
    • Running out of memory
    • Also there can be errors that are detected by the program itself:
      • Trying to open a file that isn’t there
      • Trying find a web page and discovering that an alleged URL is not well formed
  5. If run-time succeeds, the program finishes (or keeps going) without crashing.
  6. Inputs and outputs are entirely up to the programmer. Files, windows on the screen, network packets, jobs sent to the printer, you name it. If the program launches missiles, that’s an output, and it happens only at run time 🙂

Resources :
  1. Stack overflow
  2. Kansas State University

Comment here