Live data from Hacker News

Benchmarking 20 programming languages on N-queens and matrix multiplication

github.com

141–150 of 194 posts

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

#141

These are not the best benchmarks, but Python is indeed as slow as Perl, which I find insane considering that Python has 100-1000 more people working on the interpreter and performance has been a big emphasis the last few years.

Well, for a long time speed was not a priority at all for the team developing cpython. In fact, Python 3 was still a bit slower than Python 2 until a few versions ago.

Recently there have been some decent improvements to CPython's speed, but there are real upper limits to how fast you can make an interpreter. CPython will need JIT compilation if it is ever to break out of its current speed bracket.

JavaScript has had a feature complete JIT reference implementation since 2008 which is a major part of the reason JS applications exploded so much in the 2010s.

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

#143

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.

The state of PHP 8.3 and especially 8.4 is a lot better than HHVM. They have diverged quite a lot to a point that it's no longer a drop-in replacement.

PHP added JIT in 8.0, and these math-heavy tasks can take advantage of it. It's not trivial to fine tine JIT configuration though.

In PHP 8.4 (scheduled Nov 2024), there is a major upgrade to JIT as well.

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

#144

Earlier quoted context omitted.

Why would uncompressed bytes be better? Using a good compression algorithm better approximates the statistical entropy of the code which is at least correlated with e.g., Kolmogorov complexity.

Because humans read and write the uncompressed code. Gzip will hide problems like copy paste.

And hide differences due to label-length personal-preferences.

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

#145
post #82

Earlier quoted context omitted.

Kolmogorov complexity is absolutely the wrong metric. It doesn't account for big-O, timing, and many other production requirements. You'll never have a perfect metric here, but human readable size of code base is well justified. Do you write minified javascript?

What I'm asking about is how much energy and time (computation) by a human brain it takes to emit or ingest each program because a human working 40 hour weeks from 18-65 will have 100,000 hours of working time, which at a typing speed of 250 characters per minute and a reading rate of 1500 characters per minute is a total career budget of like a billion characters emitted and 10 billion characters ingested. For emitt…

https://benchmarksgame-team.pages.debian.net/benchmarksgame/...

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

#147

Why is c# so slow for Matmul compared to java?

I believe because the C# version has been written using rectangular arrays. This requires every array access to use a multiplication. The Java version uses array-of-arrays and hoisting the inner array out before accessing it in the inner loop.

C# also has arrays-of-arrays, and could (should) be written in the same manner.

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

#148

Earlier quoted context omitted.

No, creating a binary blob is not a realistic option, and it's still not a Python/Java/C++ whatever solution. It would be handwritten assembly that you use the FFI facilities to call into. So, it's not fair game in any honest benchmark. And even if using a C library is idiomatic Python, it still has no place in a language benchmark. It's a C library, not a Python implementation.

> No, creating a binary blob is not a realistic option, and it's still not a Python/Java/C++ whatever solution. Once again, "realistic" is subjective and I would say no "realistic" user will try to multiply arbitrarily-sized matrices in pure Python. (I can see small enough matrices, like 3x3 or 4x4, might be different.) And... > So, it's not fair game in any honest benchmark. And even if using a C library is idiomati…

[deleted]

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

#149

Earlier quoted context omitted.

> Generally, the point of language benchmarks is to show how the languages compare at solving the same problem, without external libraries. If this were the only concern, it should be valid to create a blob of binary and call that function for the optimal performance. (Python's ctypes makes this very easy, for example.) So you want an idiomatic solution instead, and Numpy for matrix computation is considered idiomati…

No, creating a binary blob is not a realistic option, and it's still not a Python/Java/C++ whatever solution. It would be handwritten assembly that you use the FFI facilities to call into. So, it's not fair game in any honest benchmark. And even if using a C library is idiomatic Python, it still has no place in a language benchmark. It's a C library, not a Python implementation.

How else would you find the difference between using that library from C and using that library from Python?

pidigits gcc #1

https://benchmarksgame-team.pages.debian.net/benchmarksgame/...

pidigits Python3 #3

https://benchmarksgame-team.pages.debian.net/benchmarksgame/...

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

#150
This is an area where "solvers" are heavily under utilized. For the absolute fastest solution, bespoke implementations are almost certainly required.

However, translating Sudoku and N-Queens into a similar problem that you can feed into a solver can get you a long way. Even better, you can move that solver into whatever language gives you the best optimizations that you can work. Even better, there are almost certainly optimizations in common solvers that you don't want to deal with implementing on your on.

Post reply on HN