Sobes.tech
Junior — Middle

What is the difference between programming languages that require compilation and those that are interpreted at runtime?

sobes.tech AI

Answer from AI

Compiled programming languages convert source code into machine code before running the program. This means that the program is translated into an executable file, which is then run directly by the processor. Examples: C, C++, Go.

Interpreted languages execute source code line-by-line during program execution with the help of an interpreter. This provides flexibility and ease of debugging but usually reduces performance. Examples: Python, JavaScript.

Main differences:

  • Runtime: compilation occurs beforehand, interpretation — during execution.
  • Performance: compiled programs generally run faster.
  • Portability: interpreted programs are easier to run on different platforms without recompilation.

Example of compilation and execution in C:

// hello.c
#include <stdio.h>
int main() {
    printf("Hello, world!\n");
    return 0;
}

Compilation: gcc hello.c -o hello Execution: ./hello

Example of running Python:

print("Hello, world!")

Execution: python hello.py