DEV Community

Cover image for What Is a Programming Language? Compilers, Interpreters, AST, and Runtime
Emirhan Uluksar for Digital HAT Software

Posted on Originally published at dgtalhat.com

What Is a Programming Language? Compilers, Interpreters, AST, and Runtime

What Is a Programming Language? Compilers, Interpreters, AST, and Runtime

In Part 1, we saw that CPU cores only execute binary machine instructions (0 and 1). That leads to the next fundamental engineering question: "If processors only understand binary numbers, how does the computer understand C#, TypeScript, or Python when we write if (balance >= total) in VS Code?"

In this comprehensive guide, we open the black box of Programming Languages , Compilers (Roslyn, LLVM), Interpreters , and the .NET Common Language Runtime (CLR).

What You Will Master in This Guide:

  1. The 3 generations of languages: Machine Code → Assembly → High-Level Languages.
  2. Inside a Compiler: Lexer (Tokens) → Parser (Abstract Syntax Tree / AST) → Semantic Type Checker → Code Generator.
  3. Comparing the 3 execution models: AOT Compiled vs. Interpreted vs. Managed JIT (.NET CLR RyuJIT).
  4. Static vs. Dynamic Type Systems in production enterprise software.
  5. Engineering decision matrix: Which programming language fits which problem domain?

Compiler Pipeline: Source Code, Lexer, Abstract Syntax Tree (AST), Compiler and Runtime

1. Inside a Compiler: The 4-Stage Pipeline

When you click "Build" or run dotnet build, the compiler transforms your source text through four deterministic stages. Let's trace this single line of C#:

decimal total = price + tax * 0.20m;
Enter fullscreen mode Exit fullscreen mode

Stage 1: Lexical Analysis (Lexer / Tokenizer)

The Lexer scans raw characters, strips whitespace and comments, and groups characters into meaningful Tokens :

[Token 1: Keyword -> "decimal"]
[Token 2: Identifier -> "total"]
[Token 3: Operator -> "="]
[Token 4: Identifier -> "price"]
[Token 5: Operator -> "+"]
[Token 6: Identifier -> "tax"]
[Token 7: Operator -> "*"]
[Token 8: Literal -> "0.20m"]
[Token 9: Semicolon -> ";"]
Enter fullscreen mode Exit fullscreen mode

Stage 2: Syntax Analysis (Parser) & Abstract Syntax Tree (AST)

The Parser validates the tokens against the language grammar and constructs a hierarchical Abstract Syntax Tree (AST) respecting operator precedence (multiplication binds tighter than addition):

          [= (Assign)]
          / \
     [total] [+ (Add)]
                    / \
               [price] [* (Multiply)]
                           / \
                        [tax] [0.20m]
Enter fullscreen mode Exit fullscreen mode

Stage 3: Semantic Analysis & Static Type Checking

Even if syntax is valid, types might conflict. If you write decimal total = "Hello" * 5;, the Semantic Type Checker halts compilation immediately—preventing a runtime crash from ever reaching production.

Stage 4: Code Generation & Optimization

Finally, the compiler emits optimized Intermediate Language (IL) bytecode or native machine instructions.

2. The 3 Execution Models: AOT vs. Interpreter vs. Managed JIT (.NET CLR)

MODEL 1: AHEAD-OF-TIME (AOT) COMPILED (C, C++, Rust, Go, .NET Native AOT, HADID)
[Source Code] ──(Compiler)──> [Native Machine Binary] ──> [CPU Executes Directly]

MODEL 2: INTERPRETED (Python, PHP, Classic JS)
[Source Code] ──(Line-by-Line Interpreter at Runtime)──> [Executed Dynamically]

MODEL 3: MANAGED JIT (C# / .NET 9 CLR, Java / JVM)
[C# Source] ──(Roslyn Compiler)──> [IL Bytecode (.dll)] ──(.NET CLR RyuJIT)──> [CPU Machine Code]
Enter fullscreen mode Exit fullscreen mode

3. Engineering Language Selection Matrix

Language Type System & Execution Best Production Use Cases
C# (.NET 9) Statically Typed · JIT & Native AOT Enterprise Backends, REST/gRPC Web APIs, B2B SaaS, ERP/CRM, Microservices, Finance, Unity Games.
TypeScript Statically Typed · V8 JIT Modern Web Frontends (React, Next.js), Full-Stack SSR Web Platforms, Design Systems.
C / C++ / Rust Statically Typed · Native AOT OS Kernels, Embedded Firmware (STM32/ESP32), Game Engines, Cryptography, High-Frequency Systems.
Python Dynamically Typed · Interpreted AI / Machine Learning pipelines, Data Science, Computer Vision, Automation Scripting.
Go (Golang) Statically Typed · Native AOT Cloud Infrastructure (Docker, Kubernetes), Network Proxies, High-Concurrency CLI/Daemon tools.

Top comments (0)