Article illustration 1

When running isolated code snippets in secure environments, every millisecond of startup time matters. Developer Anton Zhiyanov recently benchmarked execution times for a simple "Hello World" program across 20 programming languages, revealing unexpected performance hierarchies in containerized environments.

Methodology Matters

The tests ran in single-core Docker containers on older hardware, measuring the full docker run lifecycle from launch to output. While absolute times (0.4s to 8.4s) reflect this constrained environment, the relative differences expose compiler and runtime characteristics:

#include <stdio.h>

void greet(const char* name) {
    printf("Hello, %s!
", name);
}

int main() {
    greet("World");
}

Performance Tiers Emerge

  • Elite Cluster (≤0.4s): Bash, C, JavaScript, Lua, PHP, Python, Ruby
  • Efficient Contenders (0.5-0.6s): Rust, V, R, Swift, Go
  • Moderate Startup (0.8-1.3s): Haskell, C++, Zig, Elixir, C#
  • Heavyweight (≥1.7s): Java, Odin, Dart
  • Outlier: Kotlin at 8.4s

Notably, Rust outperformed C++ (0.5s vs 0.9s), C# trounced Java (1.3s vs 1.7s), and Kotlin’s JVM dependency showed dramatic overhead.

Why Context Is King

Zhiyanov emphasizes these metrics reflect specialized needs: "For my use case—executing small untrusted code in sandboxes—startup efficiency is paramount." Real-world applications with dependencies would yield different results, but these findings illuminate:

  1. JVM/CLR languages pay initialization taxes
  2. Native compilers (Rust, Go) minimize runtime overhead
  3. Interpreted languages leverage pre-existing environments

"The gap between Kotlin and others is particularly instructive," notes a runtime engineer familiar with the study. "It demonstrates how toolchain choices cascade into performance characteristics, especially in ephemeral compute contexts."

While not prescriptive for complex systems, these benchmarks underscore how language selection impacts latency-sensitive operations like serverless functions, CI pipelines, and microservices—where milliseconds compound at scale.

_Source: Anton Zhiyanov_