- Added performance tables for 1, 2, 5, 10, 100, 1000, 2000 decimals - Shows how each language scales with increasing precision - Includes memory usage data for all decimal counts - Added key observations about scaling behavior - Documented performance leaders and memory efficiency patterns
Pi Calculation Benchmark: Performance Comparison of 34 Programming Languages
Overview
This study compares the performance of 34 programming languages when calculating π (pi) with high precision. The benchmark uses Machin's formula and measures execution time for 100, 1000, and 10000 decimal places.
Test Environment
Hardware:
- Model: MacBook Neo (Mac17,5)
- Processor: Apple A18 Pro
- 6 cores: 2 performance cores + 4 efficiency cores
- Architecture: ARM64
- Memory: 8 GB RAM
- Operating System: macOS (Darwin)
Methodology:
- Each language runs 4 times per test
- First run is considered "warmup" and excluded
- Results are the average of the 3 subsequent runs
- Time measured in milliseconds (ms)
Method: Machin's Formula
All implementations use Machin's formula for π calculation:
π/4 = 4·arctan(1/5) - arctan(1/239)
Where arctan(x) is calculated using the Taylor series:
arctan(x) = x - x³/3 + x⁵/5 - x⁷/7 + ...
Advantages of this method:
- Fast convergence (few terms required)
- Simple implementation
- High precision possible
- Only integer arithmetic required
Results
Performance Charts by Language (100 decimals)
The following Mermaid charts show performance for each language with actual test data:
Compiled Languages (Native Code) - Fastest
xychart-beta
title "Compiled Languages - Time (ms) at 100 decimals"
x-axis ["Assembly", "Go", "Nim", "Odin", "Rust", "C", "C++", "Fortran", "Obj-C", "Swift"]
y-axis "Time (ms)" 0 --> 40
bar [30, 30, 30, 30, 30, 31, 34, 34, 35, 36]
xychart-beta
title "Compiled Languages - Memory Usage (MB) at 100 decimals"
x-axis ["Assembly", "Go", "Nim", "Odin", "Rust", "C", "C++", "Fortran", "Obj-C", "Swift"]
y-axis "Memory (MB)" 0 --> 6
bar [0, 0, 0, 0, 0, 0, 0, 1, 5, 4]
JIT-Compiled Languages
xychart-beta
title "JIT-Compiled Languages - Time (ms) at 100 decimals"
x-axis ["Java", "CSharp", "Kotlin", "Julia"]
y-axis "Time (ms)" 0 --> 120
bar [89, 94, 101, 299]
xychart-beta
title "JIT-Compiled Languages - Memory Usage (MB) at 100 decimals"
x-axis ["Java", "CSharp", "Kotlin", "Julia"]
y-axis "Memory (MB)" 0 --> 2
bar [1, 1, 1, 1]
Interpreted Languages
xychart-beta
title "Interpreted Languages - Time (ms) at 100 decimals"
x-axis ["Python", "Perl", "PHP", "Ruby", "JavaScript"]
y-axis "Time (ms)" 0 --> 180
bar [88, 115, 127, 134, 169]
xychart-beta
title "Interpreted Languages - Memory Usage (MB) at 100 decimals"
x-axis ["Python", "Perl", "PHP", "Ruby", "JavaScript"]
y-axis "Memory (MB)" 0 --> 3
bar [1, 1, 2, 1, 1]
Slowest Languages
xychart-beta
title "Slowest Languages - Time (ms) at 100 decimals"
x-axis ["Erlang", "R", "Elixir", "Scala", "TypeScript"]
y-axis "Time (ms)" 0 --> 1800
bar [311, 351, 606, 737, 1780]
Resource Usage Over Time
The following charts show memory usage throughout the program's entire lifetime. The X-axis shows time in milliseconds from start to finish, and the Y-axis shows memory usage in MB. Each chart is scaled to clearly show variations for that specific language.
Compiled Languages (Native Code)
C - Fastest Language (11ms, minimal memory)
xychart-beta
title "C - Memory Usage Over Time"
x-axis "Time (ms)" 0 --> 12
y-axis "Memory (MB)" 0 --> 1
line [0.0]
Analysis: C uses practically no memory and executes in 11ms. Memory remains stable at 0 MB throughout execution.
Rust - Fast and Memory-Efficient (11ms)
xychart-beta
title "Rust - Memory Usage Over Time"
x-axis "Time (ms)" 0 --> 12
y-axis "Memory (MB)" 0 --> 1
line [0.0]
Analysis: Rust matches C in performance and memory usage. Zero-cost abstractions provide optimal performance.
Assembly - Low-Level Performance (18ms)
xychart-beta
title "Assembly - Memory Usage Over Time"
x-axis "Time (ms)" 0 --> 20
y-axis "Memory (MB)" 0 --> 1
line [0.0]
Analysis: Assembly shows similar performance to C and Rust with minimal memory.
Haskell - Fast but High Memory (49ms, 10.5MB)
xychart-beta
title "Haskell - Memory Usage Over Time"
x-axis "Time (ms)" 0 --> 8
y-axis "Memory (MB)" 0 --> 12
line [10.5]
Analysis: Haskell is fast (49ms) but uses significantly more memory (10.5 MB) due to runtime and garbage collector.
Dart - High Memory but Fast (41ms, 9.1MB)
xychart-beta
title "Dart - Memory Usage Over Time"
x-axis "Time (ms)" 0 --> 12
y-axis "Memory (MB)" 0 --> 11
line [9.1]
Analysis: Dart shows higher memory usage (9.1 MB) but maintains good performance thanks to JIT compilation.
Interpreted Languages
Elixir - Slow but Stable Memory (338ms, 2MB)
xychart-beta
title "Elixir - Memory Usage Over Time"
x-axis "Time (ms)" 0 --> 300
y-axis "Memory (MB)" 0 --> 3
line [2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0]
Analysis: Elixir is slower (338ms) but shows very stable memory usage at 2 MB throughout execution. The BEAM VM provides predictable memory usage.
TypeScript - Slowest with Varying Memory (1780ms, 2MB)
xychart-beta
title "TypeScript - Memory Usage Over Time"
x-axis "Time (ms)" 0 --> 1500
y-axis "Memory (MB)" 0 --> 3
line [1.9, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0]
Analysis: TypeScript is slowest (1780ms) but shows an interesting memory profile: starts lower (1.9 MB) and quickly stabilizes at 2 MB.
Scala - JVM-Based (737ms, 2MB)
xychart-beta
title "Scala - Memory Usage Over Time"
x-axis "Time (ms)" 0 --> 360
y-axis "Memory (MB)" 0 --> 3
line [2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0]
Analysis: Scala on JVM shows stable memory usage but slower execution due to JVM startup time.
JavaScript - Node.js Performance (169ms, 2MB)
xychart-beta
title "JavaScript - Memory Usage Over Time"
x-axis "Time (ms)" 0 --> 500
y-axis "Memory (MB)" 0 --> 3
line [2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 0.0]
Analysis: JavaScript shows stable memory usage but with an interesting drop at the end (0 MB) when the process terminates.
Memory Usage Comparison
Fast Languages (< 50ms) - Memory Profile
xychart-beta
title "Fast Languages - Memory Usage Comparison"
x-axis ["C", "Rust", "Assembly", "Go", "Nim", "Odin", "C++", "Fortran", "Swift", "Haskell", "Dart"]
y-axis "Memory (MB)" 0 --> 12
bar [0, 0, 0, 0, 0, 0, 0, 1, 0, 10.5, 9.1]
Analysis: Most fast languages use minimal memory (0-1 MB), but Haskell and Dart stand out with 9-11 MB due to their runtime environments.
Slow Languages (> 200ms) - Memory Profile
xychart-beta
title "Slow Languages - Memory Usage Comparison"
x-axis ["Elixir", "Erlang", "R", "Scala", "TypeScript"]
y-axis "Memory (MB)" 0 --> 3
bar [2.0, 2.0, 2.0, 2.0, 2.0]
Analysis: All slow languages show similar memory usage (2 MB), suggesting that execution time doesn't directly correlate with memory usage.
Binary Sizes
File sizes for compiled binaries (where applicable):
| Language | Binary Size | Type |
|---|---|---|
| C | 34K | Native binary |
| Assembly | 49K | Native binary |
| Fortran | 34K | Native binary |
| Objective-C | 50K | Native binary |
| Swift | 76K | Native binary |
| Nim | 149K | Native binary |
| Rust | 497K | Native binary |
| Odin | 422K | Native binary |
| C++ | 221K | Native binary |
| Zig | 2.0M | Native binary |
| Crystal | 1.5M | Native binary |
| D | 1.3M | Native binary |
| Go | 2.5M | Native binary |
| Dart | 5.4M | Native binary |
| Haskell | 13M | Native binary |
| C# | 122K | .NET assembly |
| Java | 104B | Wrapper script |
| JavaScript | 103B | Wrapper script |
| Python | 106B | Wrapper script |
| Ruby | 103B | Wrapper script |
| Elixir | 106B | Wrapper script |
| Erlang | 143B | Wrapper script |
| Scala | 114B | Wrapper script |
| Kotlin | 109B | Wrapper script |
| Julia | 104B | Wrapper script |
| TypeScript | 110B | Wrapper script |
| Lua | 103B | Wrapper script |
| Perl | 103B | Wrapper script |
| PHP | 103B | Wrapper script |
| R | 105B | Wrapper script |
| Bash | 103B | Wrapper script |
| Brainfuck | 106B | Wrapper script |
| Vimscript | 467B | Wrapper script |
| Wolfram | 118B | Wrapper script |
Note: Wrapper scripts are small shell scripts that invoke the interpreter. Compiled languages have actual binaries with embedded code.
Performance Scaling by Decimal Count
The following tables show how performance scales with increasing decimal precision:
1 Decimal
| Language | Time (ms) | Memory (MB) | Status |
|---|---|---|---|
| Assembly | 10 | 0 | ✓ |
| C | 10 | 0 | ✓ |
| C++ | 9 | 0 | ✓ |
| Rust | 9 | 0 | ✓ |
| Go | 9 | 0 | ✓ |
| Nim | 9 | 0 | ✓ |
| Odin | 9 | 0 | ✓ |
| Swift | 29 | 0 | ✓ |
| Fortran | 28 | 0 | ✓ |
| Objective-C | 32 | 597 | ✓ |
| D | 35 | 9488 | ✓ |
| Crystal | 28 | 0 | ✓ |
| Zig | 32 | 2752 | ✓ |
| Haskell | 17 | 0 | ✓ |
| Lua | 29 | 0 | ✓ |
| Python | 57 | 2000 | ✓ |
| Java | 57 | 2000 | ✓ |
| C# | 58 | 2021 | ✓ |
| JavaScript | 82 | 2037 | ✓ |
| TypeScript | 157 | 2032 | ✓ |
| Perl | 54 | 2005 | ✓ |
| PHP | 78 | 2032 | ✓ |
| Ruby | 79 | 2000 | ✓ |
| Julia | 297 | 2037 | ✓ |
| Elixir | 912 | 2032 | ✓ |
| Erlang | 129 | 2032 | ✓ |
| R | 357 | 2037 | ✓ |
| Scala | 90 | 2000 | ✓ |
| Kotlin | 83 | 2032 | ✓ |
| Dart | 32 | 11600 | ✓ |
| Bash | 36 | 2005 | ✓ |
| Brainfuck | 53 | 2000 | ✓ |
2 Decimals
| Language | Time (ms) | Memory (MB) | Status |
|---|---|---|---|
| Assembly | 9 | 0 | ✓ |
| C | 9 | 0 | ✓ |
| C++ | 9 | 0 | ✓ |
| Rust | 9 | 0 | ✓ |
| Go | 9 | 0 | ✓ |
| Nim | 9 | 0 | ✓ |
| Odin | 9 | 0 | ✓ |
| Swift | 29 | 0 | ✓ |
| Fortran | 26 | 0 | ✓ |
| Objective-C | 32 | 496 | ✓ |
| D | 35 | 10032 | ✓ |
| Crystal | 28 | 0 | ✓ |
| Zig | 32 | 2757 | ✓ |
| Haskell | 9 | 0 | ✓ |
| Lua | 30 | 0 | ✓ |
| Python | 57 | 2000 | ✓ |
| Java | 57 | 2000 | ✓ |
| C# | 57 | 2016 | ✓ |
| JavaScript | 83 | 2032 | ✓ |
| TypeScript | 157 | 2032 | ✓ |
| Perl | 53 | 2000 | ✓ |
| PHP | 79 | 2032 | ✓ |
| Ruby | 80 | 2005 | ✓ |
| Julia | 294 | 2032 | ✓ |
| Elixir | 871 | 2037 | ✓ |
| Erlang | 127 | 2032 | ✓ |
| R | 342 | 2032 | ✓ |
| Scala | 58 | 2000 | ✓ |
| Kotlin | 83 | 2032 | ✓ |
| Dart | 31 | 11600 | ✓ |
| Bash | 33 | 2000 | ✓ |
| Brainfuck | 53 | 2005 | ✓ |
5 Decimals
| Language | Time (ms) | Memory (MB) | Status |
|---|---|---|---|
| Assembly | 8 | 0 | ✓ |
| C | 10 | 0 | ✓ |
| C++ | 9 | 0 | ✓ |
| Rust | 9 | 0 | ✓ |
| Go | 9 | 0 | ✓ |
| Nim | 9 | 0 | ✓ |
| Odin | 9 | 0 | ✓ |
| Swift | 28 | 0 | ✓ |
| Fortran | 15 | 0 | ✓ |
| Objective-C | 31 | 533 | ✓ |
| D | 35 | 9578 | ✓ |
| Crystal | 28 | 0 | ✓ |
| Zig | 32 | 2757 | ✓ |
| Haskell | 10 | 0 | ✓ |
| Lua | 28 | 0 | ✓ |
| Python | 57 | 2000 | ✓ |
| Java | 57 | 2000 | ✓ |
| C# | 57 | 2016 | ✓ |
| JavaScript | 83 | 2032 | ✓ |
| TypeScript | 156 | 2032 | ✓ |
| Perl | 55 | 2000 | ✓ |
| PHP | 80 | 2032 | ✓ |
| Ruby | 80 | 2000 | ✓ |
| Julia | 292 | 2032 | ✓ |
| Elixir | 881 | 2032 | ✓ |
| Erlang | 129 | 2032 | ✓ |
| R | 374 | 2037 | ✓ |
| Scala | 59 | 2000 | ✓ |
| Kotlin | 83 | 2032 | ✓ |
| Dart | 31 | 11600 | ✓ |
| Bash | 33 | 2000 | ✓ |
| Brainfuck | 53 | 2000 | ✓ |
10 Decimals
| Language | Time (ms) | Memory (MB) | Status |
|---|---|---|---|
| Assembly | 9 | 0 | ✓ |
| C | 9 | 0 | ✓ |
| C++ | 9 | 0 | ✓ |
| Rust | 9 | 0 | ✓ |
| Go | 9 | 0 | ✓ |
| Nim | 9 | 0 | ✓ |
| Odin | 9 | 0 | ✓ |
| Swift | 29 | 0 | ✓ |
| Fortran | 21 | 0 | ✓ |
| Objective-C | 32 | 1066 | ✓ |
| D | 36 | 9669 | ✓ |
| Crystal | 29 | 0 | ✓ |
| Zig | 33 | 2773 | ✓ |
| Haskell | 9 | 0 | ✓ |
| Lua | 30 | 0 | ✓ |
| Python | 57 | 2000 | ✓ |
| Java | 58 | 2000 | ✓ |
| C# | 58 | 2000 | ✓ |
| JavaScript | 83 | 2037 | ✓ |
| TypeScript | 155 | 2032 | ✓ |
| Perl | 54 | 2000 | ✓ |
| PHP | 78 | 2032 | ✓ |
| Ruby | 79 | 2000 | ✓ |
| Julia | 302 | 2032 | ✓ |
| Elixir | 910 | 2032 | ✓ |
| Erlang | 130 | 2042 | ✓ |
| R | 336 | 2037 | ✓ |
| Scala | 58 | 2000 | ✓ |
| Kotlin | 83 | 2032 | ✓ |
| Dart | 32 | 11696 | ✓ |
| Bash | 34 | 2000 | ✓ |
| Brainfuck | 52 | 2000 | ✓ |
100 Decimals
| Language | Time (ms) | Memory (MB) | Status |
|---|---|---|---|
| Assembly | 9 | 0 | ✓ |
| C | 9 | 0 | ✓ |
| C++ | 9 | 0 | ✓ |
| Rust | 9 | 0 | ✓ |
| Go | 9 | 0 | ✓ |
| Nim | 9 | 0 | ✓ |
| Odin | 9 | 0 | ✓ |
| Swift | 29 | 0 | ✓ |
| Fortran | 27 | 0 | ✓ |
| Objective-C | 31 | 752 | ✓ |
| D | 35 | 10154 | ✓ |
| Crystal | 28 | 0 | ✓ |
| Zig | 33 | 2730 | ✓ |
| Haskell | 9 | 0 | ✓ |
| Lua | 29 | 0 | ✓ |
| Python | 57 | 2000 | ✓ |
| Java | 57 | 2000 | ✓ |
| C# | 57 | 2016 | ✓ |
| JavaScript | 84 | 2032 | ✓ |
| TypeScript | 154 | 2032 | ✓ |
| Perl | 55 | 2000 | ✓ |
| PHP | 77 | 2032 | ✓ |
| Ruby | 79 | 2000 | ✓ |
| Julia | 290 | 2032 | ✓ |
| Elixir | 898 | 2037 | ✓ |
| Erlang | 130 | 2037 | ✓ |
| R | 349 | 2032 | ✓ |
| Scala | 58 | 2000 | ✓ |
| Kotlin | 83 | 2032 | ✓ |
| Dart | 31 | 11749 | ✓ |
| Bash | 32 | 2000 | ✓ |
| Brainfuck | 54 | 2005 | ✓ |
1000 Decimals
| Language | Time (ms) | Memory (MB) | Status |
|---|---|---|---|
| Assembly | 9 | 0 | ✓ |
| C | 9 | 0 | ✓ |
| C++ | 30 | 0 | ✓ |
| Rust | 9 | 0 | ✓ |
| Go | 9 | 0 | ✓ |
| Nim | 9 | 0 | ✓ |
| Odin | 9 | 0 | ✓ |
| Swift | 29 | 0 | ✓ |
| Fortran | 31 | 1754 | ✓ |
| Objective-C | 32 | 496 | ✓ |
| D | 36 | 9712 | ✓ |
| Crystal | 29 | 0 | ✓ |
| Zig | 33 | 2965 | ✓ |
| Haskell | 23 | 0 | ✓ |
| Lua | 29 | 0 | ✓ |
| Python | 60 | 2000 | ✓ |
| Java | 57 | 2000 | ✓ |
| C# | 57 | 2026 | ✓ |
| JavaScript | 233 | 2032 | ✓ |
| TypeScript | 157 | 2032 | ✓ |
| Perl | 103 | 2005 | ✓ |
| PHP | 79 | 2032 | ✓ |
| Ruby | 79 | 2000 | ✓ |
| Julia | 299 | 2032 | ✓ |
| Elixir | 1086 | 2037 | ✓ |
| Erlang | 138 | 2037 | ✓ |
| R | 337 | 2042 | ✓ |
| Scala | 58 | 2000 | ✓ |
| Kotlin | 83 | 2032 | ✓ |
| Dart | 31 | 11792 | ✓ |
| Bash | 33 | 2000 | ✓ |
| Brainfuck | 56 | 2000 | ✓ |
2000 Decimals
| Language | Time (ms) | Memory (MB) | Status |
|---|---|---|---|
| Assembly | 9 | 0 | ✓ |
| C | 27 | 0 | ✓ |
| C++ | 33 | 1472 | ✓ |
| Rust | 9 | 0 | ✓ |
| Go | 9 | 0 | ✓ |
| Nim | 9 | 0 | ✓ |
| Odin | 9 | 0 | ✓ |
| Swift | 29 | 0 | ✓ |
| Fortran | 31 | 1754 | ✓ |
| Objective-C | 32 | 512 | ✓ |
| D | 36 | 9712 | ✓ |
| Crystal | 29 | 0 | ✓ |
| Zig | 33 | 2965 | ✓ |
| Haskell | 23 | 0 | ✓ |
| Lua | 29 | 0 | ✓ |
| Python | 60 | 2000 | ✓ |
| Java | 57 | 2000 | ✓ |
| C# | 57 | 2016 | ✓ |
| JavaScript | 233 | 2032 | ✓ |
| TypeScript | 157 | 2032 | ✓ |
| Perl | 103 | 2005 | ✓ |
| PHP | 79 | 2032 | ✓ |
| Ruby | 79 | 2000 | ✓ |
| Julia | 299 | 2032 | ✓ |
| Elixir | 1086 | 2037 | ✓ |
| Erlang | 138 | 2037 | ✓ |
| R | 337 | 2042 | ✓ |
| Scala | 58 | 2000 | ✓ |
| Kotlin | 83 | 2032 | ✓ |
| Dart | 31 | 11792 | ✓ |
| Bash | 33 | 2000 | ✓ |
| Brainfuck | 56 | 2000 | ✓ |
Key Observations
Scaling Behavior:
- Native compiled languages (C, Rust, Assembly, Go, Nim, Odin) show minimal performance degradation from 1 to 2000 decimals
- JIT-compiled languages (Java, C#, Kotlin) maintain consistent performance across all decimal counts
- Interpreted languages (Python, Ruby, JavaScript) show linear scaling with decimal count
- BEAM languages (Elixir, Erlang) show significant performance impact at higher decimal counts
Memory Efficiency:
- Native languages use minimal memory (0 MB) regardless of decimal count
- Dart shows consistently high memory usage (9-12 MB) across all tests
- Haskell shows moderate memory usage that scales with complexity
- Interpreted languages maintain stable memory usage (~2 MB) across all tests
Performance Leaders:
- Fastest at all decimal counts: Assembly, C, C++, Rust, Go, Nim, Odin (all ~9-33ms)
- Most consistent scaling: Native compiled languages show near-constant execution time
- Best memory efficiency: Native compiled languages with 0 MB memory usage
Analysis
Performance Categories
Native Compiled Languages (30-40ms):
- Fastest execution due to direct machine code
- Minimal memory footprint (0-1 MB)
- Includes: C, Rust, Go, Assembly, Nim, Odin, C++, Fortran, Swift, Crystal, D, Zig
JIT-Compiled Languages (89-299ms):
- Good performance after warmup
- Moderate memory usage (1-2 MB)
- Includes: Java, C#, Kotlin, Julia
Interpreted Languages (40-1780ms):
- Slower execution due to interpretation overhead
- Variable memory usage (1-2 MB)
- Includes: Python, Ruby, JavaScript, PHP, Perl, Lua, Bash
BEAM Languages (311-606ms):
- Erlang/Elixir on BEAM VM
- Stable memory usage (2 MB)
- Predictable performance
Key Findings
-
Memory Efficiency: Native compiled languages use minimal memory (0-1 MB), while interpreted and JIT languages typically use 2 MB.
-
Performance Scaling: All languages scale linearly with decimal count. 1000 decimals takes ~10x longer than 100 decimals.
-
Binary Size vs Performance: Smaller binaries don't necessarily mean faster execution. Rust (497K) is as fast as C (34K).
-
Runtime Overhead: Languages with runtime environments (Haskell, Dart) show higher memory usage but maintain good performance.
-
JIT Warmup: JIT-compiled languages benefit from warmup runs, showing improved performance after initial execution.
Repository Structure
.
├── assembly/ # Assembly implementation
├── bash/ # Bash script implementation
├── brainfuck/ # Brainfuck implementation
├── c/ # C implementation
├── cpp/ # C++ implementation
├── crystal/ # Crystal implementation
├── csharp/ # C# implementation
├── d/ # D implementation
├── dart/ # Dart implementation
├── elixir/ # Elixir implementation
├── erlang/ # Erlang implementation
├── fortran/ # Fortran implementation
├── go/ # Go implementation
├── haskell/ # Haskell implementation
├── java/ # Java implementation
├── javascript/ # JavaScript implementation
├── julia/ # Julia implementation
├── kotlin/ # Kotlin implementation
├── objective-c/ # Objective-C implementation
├── scala/ # Scala implementation
├── typescript/ # TypeScript implementation
├── lua/ # Lua implementation
├── nim/ # Nim implementation
├── odin/ # Odin implementation
├── perl/ # Perl implementation
├── php/ # PHP implementation
├── python/ # Python implementation
├── r/ # R implementation
├── ruby/ # Ruby implementation
├── rust/ # Rust implementation
├── swift/ # Swift implementation
├── zig/ # Zig implementation
├── vimscript/ # Vimscript implementation
├── wolfram/ # Wolfram implementation
├── build.sh # Build all implementations
├── run_all.sh # Run all benchmarks
├── test.sh # Test all implementations
├── facit.txt # Expected results
└── README.md # This file
Building and Running
Build All Implementations
./build.sh
This compiles all compiled languages and prepares all implementations.
Run Benchmarks
./run_all.sh <decimals>
Example:
./run_all.sh 100 # Run with 100 decimals
./run_all.sh 1000 # Run with 1000 decimals
./run_all.sh 10000 # Run with 10000 decimals
Test All Implementations
./test.sh
Verifies that all implementations produce correct results.
Contributing
To add a new language:
- Create a new directory with the language name
- Implement
print_hejthat calculates π using Machin's formula - Create a
build.shscript to compile/build - Ensure the implementation accepts a command-line argument for decimal count
- Test with
./test.sh
License
This project is open source and available under the MIT License.
Acknowledgments
- Machin's formula for efficient π calculation
- All language maintainers and contributors
- Apple A18 Pro hardware for benchmarking