The Computer Language
24.11 Benchmarks Game

more-similar less-idiosyncratic


When programs are idiomatic someone will say they are not comparable.

Are they similar-enough to be comparable for your purposes? Will someone then say the programs are not idiomatic.

If only more-idiomatic was not less-comparable!


Here are a few naive un-optimised single-thread #8 programs transliterated lowest-common-denominator style into different programming languages from the same original —

elapsed secs / fastest insignificant io
 
× source  
1.0 C# aot spectral-norm
1.0 C gcc n-body
1.0 Swift spectral-norm
1.0 Go spectral-norm
1.0 Swift fannkuch-redux
1.0 C gcc spectral-norm
1.0 Java spectral-norm
1.1 C gcc fannkuch-redux
1.2 Swift n-body
1.2 Node.js spectral-norm
1.3 C# aot n-body
1.3 C# aot fannkuch-redux
1.3 Java fannkuch-redux
1.3 Go fannkuch-redux
1.4 Dart n-body
1.4 Java n-body
1.7 Node.js fannkuch-redux
1.7 Node.js n-body
1.7 Go n-body
2.0 Dart fannkuch-redux
2.0 Dart spectral-norm
12 PHP n-body
15 Java -Xint spectral-norm
16 PHP spectral-norm
20 Java -Xint fannkuch-redux
29 Java -Xint n-body
32 Ruby yjit spectral-norm
43 PHP fannkuch-redux
56 Ruby yjit fannkuch-redux
64 Python 3 fannkuch-redux
70 Ruby yjit n-body
71 Python 3 spectral-norm
94 Python 3 n-body
314 Matz's Ruby spectral-norm
586 Matz's Ruby n-body

Seemingly similar programs behave differently when the language implementations behave differently. Do they have the same default stdio buffering? Do the programs need to be written differently and run differently to make them behave the same.


To be less similar so they are more comparable!

elapsed secs / fastest significant io
 
× source  
1.0 C gcc mandelbrot
1.0 PHP k-nucleotide
1.0 C gcc fasta
1.0 C# aot mandelbrot
1.0 Swift mandelbrot
1.1 Go mandelbrot
1.1 Java mandelbrot
1.3 C# aot k-nucleotide
1.4 Java k-nucleotide
2.6 C# aot fasta
2.9 Node.js mandelbrot
3.2 PHP mandelbrot
3.3 Swift k-nucleotide
3.3 Java fasta
4.0 Go fasta
4.3 Python 3 k-nucleotide
8.0 Dart mandelbrot
10 Dart k-nucleotide
14 Ruby yjit k-nucleotide
23 Swift fasta
25 Java -Xint mandelbrot
56 Python 3 fasta
57 PHP fasta
58 Ruby yjit fasta
60 Ruby yjit mandelbrot
61 Python 3 mandelbrot
115 Node.js fasta
146 Java -Xint fasta
197 Dart fasta
Such comparisons raise a nest of issues all their own: for example, is it really the same program when written in the two compared languages? (Will Partain, 1992.)
elapsed secs / fastest Geometric Mean
1.0 C gcc  
1.3 C# aot  
1.4 Java  
1.6 Go  
2.1 Swift  
4.1 Node.js  
6.7 Dart  
11 PHP  
32 Java -Xint  
43 Ruby yjit  
43 Python 3  
429 Matz's Ruby