🏎️ Prime Sieve Runtime Dynamics
Episode 01 Data Context
Empirical Computer Language Drag Race Analysis

Comparative Empirical Analysis of Programming Language Runtime Dynamics

This interactive analysis examines empirical runtime performance across 45+ programming languages, based on the foundational benchmark created by Microsoft systems engineer Dave Plummer (Dave's Garage). By isolating single-threaded execution on the Sieve of Eratosthenes algorithm ($N = 1,000,000$), we evaluate how compiler code generation, runtime safety checks, and memory representations dictate raw CPU execution speed.

Algorithmic Workload
Sieve of Eratosthenes
Limit $N = 1,000,000$
Primary Focus Languages
Ada, Pascal, Delphi
Vs. Native AOT & Dynamic Runtimes
Packed Bitwise Footprint
61.04 KiB
Fits within CPU L2 Cache
Execution Harness Calibration
~5.0 Seconds
Normalized Passes / Second

1. Algorithmic Framework & Benchmark Harness

To maintain scientific integrity across radically disparate language paradigms—from bare-metal compiled code to dynamic bytecode interpreters—the benchmark harness imposes strict execution constraints. The section below details how the prime sieve is computed and validated to isolate micro-architectural CPU performance.

1

Dynamic Buffer Allocation

Candidate memory buffer must be dynamically allocated at runtime. Prevents compilers from precomputing prime tables or hardcoding static global offset addresses.

Rule: Dynamic Heap / Stack Buffer
2

Strict Sieve Execution

Sequential elimination of composite numbers for all odd factors up to $\sqrt{N}$. Mathematical bypasses or wheel factorizations are strictly prohibited.

Complexity: O(N log log N)
3

Mathematical Validation

Upon completing a pass, the engine verifies total primes against mathematical ground truth ($78,498$ primes below $1,000,000$). Invalid passes are discarded.

Check: 78,498 Primes Found
4

Time Normalization

The pipeline loops continuously over a 5-second window. Performance is measured as normalized **Passes per Second**, establishing high resolution.

Metric: Passes / Second

2. Cross-Paradigm Performance Spectrum

This section presents empirical performance throughput across execution paradigms. Use the filter controls below to isolate Ahead-of-Time (AOT) compiled systems languages, Just-In-Time (JIT) managed runtimes, and dynamic bytecode interpreters. Select any language bar to inspect memory models and execution bottlenecks.

3. Systems Systems Deep Dive: Ada, Pascal, and Delphi

While modern benchmarking discussions often focus on C++ vs. Rust, standard structured languages like Ada, Pascal, and Delphi share a rich heritage of high performance. This section explores how their safety profiles, compiler backends, and array representations impact machine code generation.

Interactive Safety Flag Simulator

Toggle runtime safety checks (array bounds verification, range checks, and invariant assertions) to observe their effect on compiled native code throughput.

Runtime Safety Checks:
Branch Instruction Density
High (Check on every write)

Inserts comparison branches inside tight loops, disturbing pipeline speculation.

Compiler Directives Applied
Ada default assertions / {$R+} {$Q+}

Ensures safety against buffer overflows and type range violations.

Estimated Throughput Penalty
-60% to -65% vs Unrestricted C

Suppression under -O3 brings performance back to parity with C/C++.

Language / Dialect Compiler Infrastructure Type & Safety Profile Memory Strategy Primary Code Generation Vector
Ada (GNAT) GNAT Backend built upon GCC optimization pipeline Strict subtype ranges & invariant validation checks Packed bit array or dynamic boolean buffer Scalar evolution, dead-code elimination, aggressive interprocedural inlining
Pascal (Free Pascal) Free Pascal Compiler (FPC) native code generator Strongly typed procedural paradigm with modular units Dynamic continuous byte-boolean array Register variable allocation, loop invariant hoisting, suppressible range checking
Delphi (Embarcadero) Proprietary Embarcadero Delphi Object Pascal Compiler Object Pascal with component encapsulation Heap-allocated dynamic buffer wrappers Whole-program link-time code generation, fastcall register passing convention

4. Micro-Architectural Memory & Cache Simulator

A key trade-off highlighted in Episode 01 is data representation density. A packed bit array drastically reduces memory footprint to fit inside high-speed L1/L2 CPU cache, but requires extra bitwise shift (`SHR`/`SHL`) and mask (`AND`/`OR`) instructions per operation. A byte-boolean array allows single byte writes, but expands the working set 8-fold.

100K 1.0M (Standard) 5.0M
Candidate Odd Integers: 500,000
Calculated Buffer Footprint: 61.04 KiB
CPU Ops Per Factor Clear: 4 Ops (SHR, AND, OR, Write)

CPU Cache Level Alignment Map

L1 Data Cache (32 KiB Target Limit) 100%+ (Exceeded)
L2 Cache (512 KiB Target Limit) 11.9% (Fits Comfortably)
⚡
L2 Cache Resident: Buffer fits entirely in high-speed CPU L2 cache, eliminating DRAM latency bottlenecks during inner loop traversal.

Formula applied: Footprint = $\frac{N}{2 \times 8 \text{ bits/byte}}$ for packed bitwise arrays vs $\frac{N}{2 \text{ bytes}}$ for byte arrays. Small footprints prevent external DRAM bus stalls, but trade off against ALU cycle costs for bitwise masking.

5. Engineering Synthesis & Architectural Takeaways

The empirical results of Dave Plummer's prime sieve benchmark debunk several common software engineering myths regarding execution speed, safety overhead, and language design. Use the interactive priority matcher below to evaluate language selection based on real-world constraints.

🏷️

The Syntax Speed Myth

A programming language is an abstract syntax specification, not an intrinsic execution speed. Performance is determined by compiler optimization backend maturity (GCC, LLVM), memory layout flexibility, and runtime overhead.

🛡️

Safety vs. Speed Fallacy

Languages like Ada and Pascal demonstrate that strong typing and safety assertions do not permanently cap performance. Production release builds with optimized safety suppression match unrestricted C/C++ throughput.

🏢

Micro-Benchmark vs Macro Reality

An in-memory sieve measures tight, CPU-cache-bound loops. Enterprise software throughput is typically bound by asynchronous network I/O and database operations, making managed runtimes economically preferable.

System Design Priority Selector

Select a system priority above

Click one of the design priority buttons to see recommended languages based on the empirical study findings.