Live data from Hacker News

Benchmarking 20 programming languages on N-queens and matrix multiplication

github.com

1–10 of 194 posts

Re: Benchmarking 20 programming languages on N-queens and matrix multiplication

#4
PHP results: I was stupid enough to write some scientific code in PHP once so know how slow it can be - mostly around array access and manipulation. But if your going to try, use the HHVM interpreter. It's much faster and is a drop in replacement for the PHP interpreter. Hack (https://hacklang.org/) uses that under the hood by default.

Re: Benchmarking 20 programming languages on N-queens and matrix multiplication

#5
What is this supposed to demonstrate?

There appears to be roughly the same code structure, ported to every language, while for some languages, arbitrary optimizations are introduced (such as using `array` instead of `list` in Python).

But nobody working in Python uses matrix multiplication code written in Python. They use NumPy, which is a de facto standard library for people working in the relevant fields. It's as much part of "Python" as list comprehensions.

Without taking such real-world conventions into account, such comparisons say essentially nothing about the languages involved (and their all-important ecosystems).

Re: Benchmarking 20 programming languages on N-queens and matrix multiplication

#6
> It is obvious that c[i], b[k] and a[i][k] can be moved out of the inner loop to reduce the frequency of matrix access. [...] However, most other languages cannot optimize this nested loop. If we manually move a[i][k] to the loop above it, we can often improve their performance.

This is only true when three matrices are independent of each other, and also why C has a `restrict` qualifier that enables this assumption. The benchmark itself has no such assumption because all three variables are defined as `double **`, and it can be verified by assembly outputs. Clang's excellent performance in matmul is probably much more due to autovectorization.

Re: Benchmarking 20 programming languages on N-queens and matrix multiplication

#7
Doesn’t include Prolog which has decent constraint solver answers for n-queens and sudoku, which are pretty fast but I don’t know how they would compare in benchmarks:

https://www.metalevel.at/queens/

https://www.metalevel.at/sudoku/

Re: Benchmarking 20 programming languages on N-queens and matrix multiplication

#9

PHP results: I was stupid enough to write some scientific code in PHP once so know how slow it can be - mostly around array access and manipulation. But if your going to try, use the HHVM interpreter. It's much faster and is a drop in replacement for the PHP interpreter. Hack ( https://hacklang.org/ ) uses that under the hood by default.

I put the pure math codes in C extension of PHP. Building C extension for PHP is easier than most of the other high level languages. And then things get blazingly fast.
Post reply on HN