So I have written a very simple program in 8 different programming languages:

C, C++, Rust, Java, Javascript, Python, C#, F#

All it does is to simply sort input text line by line and writes to an output file. Then I recorded the # instructions and time it takes to run for different sizes of input. Here is the result (legend intentionally cut out):

Just from the graphs, we can get some insights

  • in general, # instructions and runtime show very good alignment, i.e, the fewer the # instructions, the faster it runs
  • some languages are quite stable with respect to input size, while some languages fluctuate a lot. This can be of a concern if stability/predictability is requirement
  • Some language (e.g., brown) has a huge startup cost. Extrapolating the first graph, it seems around 2.5B instructions just to start the program!
  • The slowest and the fastest differs by 10x in # instructions and 6x in runtime

Can you guess which program corresponds to which color? Answer

Some interesting findings

  • C# and F# exhibit quite different behavior. This is surprising given that both use .NET framework. I expected the two to be almost identical
  • Python is fast, probably b/c most of the heavy-duty work is done by the library, which is implemented in C
  • Why is C++ slower than C? Isn’t C++ supposed to be as fast as C?
  • Why does Rust run so fast?
  • no wonder why web-browsing feels so sluggish!