Ask HN: Which is the fastest programming language and why?
What's the best way to take any program and make it run as fast as possible? Feel free to go crazy on imagination here.
3 comments
Here are a few ideas:
Use an extensible compiler and targeted optimizations. https://mitpress.mit.edu/books/automatic-algorithm-recogniti... 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.
Use an extensible compiler and targeted optimizations. https://mitpress.mit.edu/books/automatic-algorithm-recogniti... 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.
(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...
Spectral-norm: http://benchmarksgame.alioth.debian.org/u64q/performance.php...
Digits of pi: http://benchmarksgame.alioth.debian.org/u64q/performance.php...
FASTA: http://benchmarksgame.alioth.debian.org/u64q/performance.php...
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...
Spectral-norm: http://benchmarksgame.alioth.debian.org/u64q/performance.php...
Digits of pi: http://benchmarksgame.alioth.debian.org/u64q/performance.php...
FASTA: http://benchmarksgame.alioth.debian.org/u64q/performance.php...
> 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".
Only with the qualifier "by someone who is smarter than a good compiler" and the qualifier "with unlimited time".