blog.itcode.devblog.itcode.dev

Compiler & Interpreter

Ever since the days of punch cards, computer languages have undergone countless advances. Nowadays, synergies between developed languages have caused new languages and concepts to be created almost daily. But no matter how new the language used to build a piece of software, the entity that ultimately executes the program is the computer. No matter how much we fuss over new languages, frameworks, and technologies, in the end, it must be something the computer can understand in order to run. Fitting for a global era where even elementary school students speak more than one foreign language, unfortunately our computers have stubbornly stuck to machine language alone since their inception. Setting aside Korean or English, most of the programming languages we use for development — even assembly language, which is lower-level than C — are no different from alien language as far as the computer is concerned.

Compiler & Interpreter

Ever since the days of punch cards, computer languages have undergone countless advances. Nowadays, synergies between developed languages have caused new languages and concepts to be created almost daily. But no matter how new the language used to build a piece of software, the entity that ultimately executes the program is the computer. No matter how much we fuss over new languages, frameworks, and technologies, in the end, it must be something the computer can understand in order to run. Fitting for a global era where even elementary school students speak more than one foreign language, unfortunately our computers have stubbornly stuck to machine language alone since their inception. Setting aside Korean or English, most of the programming languages we use for development — even assembly language, which is lower-level than C — are no different from alien language as far as the computer is concerned.
RWB0104
@RWBwritten at 2021-06-03 08:25:23

Ever since the days of punch cards, computer languages have undergone countless advances. Nowadays, synergies between developed languages have caused new languages and concepts to be created almost daily.

But no matter how new the language used to build a piece of software, the entity that ultimately executes the program is the computer. No matter how much we fuss over new languages, frameworks, and technologies, in the end, it must be something the computer can understand in order to run.

Fitting for a global era where even elementary school students speak more than one foreign language, unfortunately our computers have stubbornly stuck to machine language alone since their inception. Setting aside Korean or English, most of the programming languages we use for development — even assembly language, which is lower-level than C — are no different from alien language as far as the computer is concerned.

When we encounter a foreign language in daily life, we use something called a translator to translate it into our own language so we can understand it relatively easily. If so, if these programming languages were translated into machine language that the computer can understand, the computer would be able to understand our code and execute it. To this end, every language is translated into machine language using a tool that can translate that language into machine language. These translators can be broadly divided into two types depending on their approach: compilers and interpreters.

A compiler is a tool that translates an entire source code into machine language. The result of the machine-language translation is generated, and when the program runs, the translated result is executed. Even if it's not strictly machine language, if it translates the entire original source code into object code (such as machine language), it can be called a compiler. The key point is converting the entire original source code into another form of code. A compiler has the following characteristics.

  1. Translates the entire source code
    Because of this characteristic, a separate compilation step is required, and even changing a single character of code requires recompilation. The larger the codebase, the longer the compilation time required.

  2. Fast speed
    Since the code has already been compiled and translated into machine language, at the time the program runs, the computer can understand the program without any additional work. In other words, its execution speed is generally faster than that of an interpreter.

  3. Platform dependency
    A compiler translates code into machine language corresponding to the CPU and OS of the computer on which it was compiled. In other words, correct operation cannot be guaranteed on a computer with a different CPU or OS architecture. Furthermore, in order to compile for a specific PC, you need a computer with that specific PC's CPU and OS.

  4. Strong security
    Since the result of the source code is an executable file translated into machine language, security is relatively strong. However, this is only relative — if the executable file is not encrypted or the source code is not obfuscated, the code can still be reverse-engineered through analysis techniques such as decompilation or hacking. Of course, this alone is a huge field in itself, requiring a great deal of technical skill.

Languages that use a compiler include the following.

  • C family (C, C++, C#)
  • FORTRAN
  • Go
  • JAVA (fundamentally uses a compiler approach)
  • Pascal
  • Rust
  • Visual Basic

For the most part, these are languages that were released early on and have a long history.

Unlike computers today, early computers had far lower specs. Ignoring the VGA shortage and taking into account that a typical high-end computer today costs about 2,000,000 KRW, a 1990s computer at that same price would have had an Intel Pentium 100 CPU, 8MB of RAM, and a 1GB HDD. Even if you convert the RAM unit to GB, it's still somewhat lacking — truly an enormous difference.

Given this, it's only natural that computer resources couldn't be wasted back then. That's why, no matter how long the preprocessing step took, running as fast and lightly as possible on the computer was the top priority. In such circumstances, it's only natural that early languages adopted compilers.

An interpreter is a tool that reads code line by line and translates it into machine language at execution time. Since it reads and executes line by line, no separate result file is produced, and the source code itself becomes the executable. Likewise, even if it's not strictly machine language, if it reads the original code line by line and converts it into intermediate code (such as machine language) for execution, it can be called an interpreter. The key point is reading and converting the source code line by line. An interpreter has the following characteristics.

  1. Translates the source code line by line
    Since the code is read and translated every time it runs, there is no separate compilation step. This results in very high productivity.

  2. Slow speed
    Instead of a compilation step, you can think of it as a small compilation step happening for every line of code when the program runs. Because of this, its execution speed is relatively slower compared to a compiler.

  3. Platform independence
    Since the program is run through the source code, it's unaffected by the computer's CPU or OS. As long as an environment that can run the source code is set up, the same behavior is guaranteed anywhere.

  4. Weak security
    Since the source code itself is the executable, the code can very easily leak. When handling important logic or information, obfuscation or encryption is essential. These security measures can further slow down the program's execution speed even more (due to added work such as decryption, etc.).

Languages that use an interpreter include the following.

  • HTML
  • JavaScript
  • PHP
  • Python
  • Ruby

Unlike compilers, relatively young languages dominate this category. As computer performance has rapidly improved in the modern era, computational speed has also increased. In addition, various technologies have been developed over time to resolve the speed issues of interpreters. As these efforts have offset the drawbacks of interpreters, the advantage of interpreters — high productivity — has become more prominent. For this reason, interpreter-based languages tend to be applied heavily to relatively modern languages.

# Compiler# Interpreter
ship
blog.itcode.dev

Notes from the π-th Alpaca

7.0.1
Developed by RWB since 2021.057th upgraded at 2026.08