
Ask HN: Which is the fastest programming language and why? - notforgot
What&#x27;s the best way to take any program and make it run as fast as possible? Feel free to go crazy on imagination here.
======
tjalfi
Here are a few ideas:

Use an extensible compiler and targeted optimizations.
[https://mitpress.mit.edu/books/automatic-algorithm-
recogniti...](https://mitpress.mit.edu/books/automatic-algorithm-recognition-
and-replacement) is an excellent book on this topic.

Use a cluster to evolve the best settings for compile options, executable
layout, instruction scheduling, etc. There is a paper from a Google author
about doing this for prefetching.

Use an ILP solver for register allocation, instruction scheduling and other
problems that are normally solved with heuristics. The size of the program may
make this intractable. There was a startup that used this approach for a
custom programming language targeted at Intel's network processors.

------
imaginenore
(Assuming, we're not talking about distributed solutions)

The fastest way would be to create an ASIC: hardware designed to run your
algorithm specifically.

Something simpler and a bit slower would be an FPGA.

Below that is a GPU implementation of your code, assuming it can be
parallelized.

Below that is hand-crafted assembly by someone who is smarter than a good
compiler.

Below that is hand-crafted C/C++ or Fortran code.

Here are benchmarks of various languages for various problems:

N-body:
[https://benchmarksgame.alioth.debian.org/u64q/performance.ph...](https://benchmarksgame.alioth.debian.org/u64q/performance.php?test=nbody)

Spectral-norm:
[http://benchmarksgame.alioth.debian.org/u64q/performance.php...](http://benchmarksgame.alioth.debian.org/u64q/performance.php?test=spectralnorm)

Digits of pi:
[http://benchmarksgame.alioth.debian.org/u64q/performance.php...](http://benchmarksgame.alioth.debian.org/u64q/performance.php?test=pidigits)

FASTA:
[http://benchmarksgame.alioth.debian.org/u64q/performance.php...](http://benchmarksgame.alioth.debian.org/u64q/performance.php?test=fasta)

~~~
igouy
> Below that is hand-crafted C/C++ or Fortran code.

Only with the qualifier "by someone who is smarter than a good compiler" and
the qualifier "with unlimited time".

