Behind the Scenes: Unveiling the Compilation Processes of Leading Programming Languages

Binoy Vijayan - Jan 26 - - Dev Community

The compilation/build process varies across different programming languages.

Here's a brief overview of the compilation/build process for Java, C#, C++, Swift, Kotlin, Python, and JavaScript:

1. Java

Source Code

  • Java source code is written in files with a .java extension.

Compilation

  • The Java Compiler (javac) is used to compile the source code.

  • The compiler translates Java source code into Java byte-code, which is a platform-independent intermediate representation.

  • Command - javac filename.java

  • Result - Generates bytecode in .class files.

Bytecode Execution

  • The Java Virtual Machine (JVM) interprets or Just-In-Time (JIT) compiles the byte-code to native machine code.

  • Command: java filename (without the .class extension)

  • The JVM handles the execution of the program.

Image description

2. C Sharp('C#'), VB, C++ (Micro Soft Platform)

Source Code:

  • C# source code is written in files with a .cs extension.

Compilation:

  • The C# Compiler (csc or Roslyn compiler) is used to compile the source code.

  • The compiler translates C# code into Intermediate Language (IL) code.

  • Command: csc filename.cs or dotnet build

  • Result: Generates .exe or .dll files containing IL code.

Execution:

  • The Common Language Runtime (CLR) translates IL code
    to native machine code during runtime.

  • The compiled executable is executed on the target system.

Image description

3. C++

Source Code:

C++ source code is written in files with a .cpp extension.

Compilation:

  • A C++ compiler (e.g., GCC, Visual C++, Clang) is used to compile the source code.

  • The compiler translates C++ code into machine code.

  • Command: g++ filename.cpp (for GCC)

  • Result: Generates an executable file (.exe on Windows or binary on Unix-based systems).

Execution:

  • The compiled executable is executed on the target system.

Image description

4. Swift

Source Code:

Swift source code is written in files with a .swift extension.

Compilation:

  • The Swift Compiler (swiftc) is used to compile the source code.

  • The compiler translates Swift code into Intermediate Representation (IR) and then to native machine code.

  • Command: swiftc filename.swift

  • Result: Generates an executable.

Execution:

The compiled executable is executed on the target system.

Image description

5. Kotlin:

Source Code:

  • Kotlin source code is written in files with a .kt extension.

Compilation:

  • The Kotlin Compiler (kotlinc) is used to compile the source code.

  • The compiler translates Kotlin code into Java byte-code (if targeting JVM) or native code.

  • Command: kotlinc filename.kt

  • Result: Generates .class files (if targeting JVM) or native binaries.

Execution:

  • For JVM: The Java Virtual Machine (JVM) interprets or JIT compiles the byte-code.

  • For Native: The compiled native code is executed on the target system.

Image description

6. Python:

Source Code:

  • Python source code is written in files with a .py extension.

Execution:

  • Python is an interpreted language, so there is no explicit compilation step.

  • The Python interpreter reads and executes the source code directly.

  • Command: python filename.py

Image description

7. JavaScript

Source Code:

  • JavaScript source code is written in files with a .js extension.

Interpretation/Compilation:

  • JavaScript is typically interpreted by web browsers.

  • Modern engines use Just-In-Time (JIT) compilation for improved performance.

  • There’s no explicit compilation step for developers in the traditional sense.

Execution:

  • Open the HTML file in a web browser to run JavaScript code.

  • Browsers handle the interpretation or compilation process.

Image description

Summary

In summary, the compilation/build process involves translating high-level source code into machine-executable code, and the specific steps and tools vary between programming languages. The resulting executable files or bytecode can then be run on the target system or virtual machine.

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Terabox Video Player