Timing 'Hello, world'
Here's a little unscientific chart showing the compile+run times of a "hello world" program in different languages:
Hello world timings
Bash <0.4s ■
C <0.4s ■
JavaScript <0.4s ■
Lua <0.4s ■
PHP <0.4s ■
Python <0.4s ■
Ruby <0.4s ■
Rust 0.5s ■■
V 0.5s ■■
R 0.5s ■■
Swift 0.6s ■■■
Go 0.6s ■■■
Haskell 0.8s ■■■■■
C++ 0.9s ■■■■■■
Zig 1.0s ■■■■■■■
Elixir 1.2s ■■■■■■■■■
C# 1.3s ■■■■■■■■■■
Java 1.7s ■■■■■■■■■■■■■■
Odin 1.7s ■■■■■■■■■■■■■■
Dart 1.9s ■■■■■■■■■■■■■■■■
Kotlin 8.4s ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■...■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
I had to shorten the Kotlin bar a bit to make it fit within 80 characters.
All measurements were done in single-core, containerized sandboxes on an ancient CPU, and the timings include the overhead of docker run. So the exact times aren't very interesting, especially for the top group (Bash to Ruby) — they all took about the same amount of time. But the difference in speed between different compilers is real: for example, Rust is actually faster than C++, C# is faster than Java, and everyone is faster than Kotlin by a large margin.
Here is the program source code in C:
#include <stdio.h>
void greet(const char* name) {
printf("Hello, %s!\n", name);
}
int main() {
greet("World");
}
Hello, World!
Other languages: Bash · C# · C++ · Dart · Elixir · Go · Haskell · Java · JavaScript · Kotlin · Lua · Odin · PHP · Python · R · Ruby · Rust · Swift · V · Zig
Of course, this ranking will be different for real-world projects with lots of code and dependencies. Still, it makes a lot of sense for my use case (I run small snippets of untrusted code in one-off dockerized sandboxes), so I decided to share it.
★ Subscribe to keep up with new posts.