Compare the Difference Between Similar Terms

Difference Between Compile Time and Runtime

Key Difference – Compile Time vs Runtime
 

Most programs are written using high-level programming languages. These programming languages have a syntax similar to the English language. High-level languages are easily understandable by humans but they are not understandable by the computer. Therefore, the written program or the source code should be converted into machine understandable format. It is called the machine code. The time period to convert the source code to machine code is known as compile time. Tasks such as syntax analysis, semantic analysis, and code generation occur at compile time. Time period to run the executable file generated at compile time is referred as runtime. Both are terms related to different program lifecycle phases. This article discusses the difference between compile time and runtime. The key difference between compile time and run time is that compile time is the programming life cycle phase that converts the source code into an executable file while runtime refers to the programming life cycle phase that runs the executables generated at compile time. The errors occurring at compile time are known as compile-time errors and errors occurring at runtime are known as exceptions.

CONTENTS

1. Overview and Key Difference
2. What is Compile Time
3. What is Runtime
4. Similarities Between Compile Time and Runtime
5. Side by Side Comparison – Compile Time vs Runtime in Tabular Form
6. Summary

What is Compile Time?

The programmer can give instructions to the computer using a programming language. Most programming languages used by a programmer are high-level programming languages. They have a syntax similar to the English language. These languages are easily readable and understandable by the humans. The program written using a high-level language is known as a source code. The source code can contain a set of lines or many lines depending on the task. The instructions provided using high-level language is not understandable by the computer. The computer understands the machine code. Therefore, the source code must be compiled into machine code to be an executable program. The programming life cycle phase is called compile time. It is the time period to complete the compilation process. The operations at compile time include syntax analysis, semantic analysis, and code generation.

Figure 01: Compile time and Runtime

During compilation, errors can occur. They occur due to syntax and semantic errors. These errors avoid successful compilation. The compiler indicates about the compile time errors. It will display a message on which line the error occurred. Some common compile-time errors are missing curly braces, misspelling identifiers, and misspelling keywords. When a compile error occurs, the programmer should fix that error.

What is Runtime?

The runtime is also known as execution time. It is the time when a program is running in contrast to other program lifecycle phases such as compile time, load time, etc. When the compilation process is completed, it is run by the user. The time period to run the executable generated at compile time is referred as runtime. The term runtime can be used to refer errors. Even the program is compiler properly, there can be errors.

These errors will not give the expected output. It can also terminate the execution of the program. These errors occur at runtime so they are known as runtime errors or Exceptions. Some runtime errors are dividing a number by zero when the array is out of bound and running out of memory.

What is the Similarity Between Compile Time and Runtime?

What is the Difference Between Compile Time and Runtime?

Compile Time vs Runtime

Compile time is the programming lifecycle phase that converts the source code into an executable file. Runtime is the time when a program is running, in contrast to other program lifecycle phases such as compile time, link time, and load time.
 Errors
Compile time errors are syntax and semantic errors. Runtime errors are known as exceptions.

Summary – Compile Time vs Runtime 

Compile time and runtime are two phases of programming lifecycle. This article discussed the difference between compile time and runtime. Converting the programmer’s source code into machine code occurs at compile time. Running the executable file generated at compile time is referred as runtime. When there is an error at compile time, the compiler displays a message according to the error. Even the program compiled, it might not give the expected output. In that case, it is a runtime error or an exception. The difference between compile time and run time is that compile time is the programming life cycle phase that converts the source code into an executable file while runtime refers to the programming life cycle phase that runs the executables generated at compile time.

Reference:

1.“Compile time.” Wikipedia, Wikimedia Foundation, 16 Dec. 2017. Available here
2.“Run time (Program lifecycle phase).” Wikipedia, Wikimedia Foundation, 18 Feb. 2018. Available here