News for hackers. Stuff that matters.
Re:Benchmarking 20 programming languages on N-queens and mat... by theteapot on Wednesday January 03, 2024 @12:06AM (#38850957)
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 do 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 mat... by habibur on Wednesday January 03, 2024 @12:26AM (#38851058)
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.
Re:Benchmarking 20 programming languages on N-queens and mat... by brrrrrm on Wednesday January 03, 2024 @01:31AM (#38851375)
doesn't look that easy... zend_parse_parameters? pre-baked configure + make scripts?

check out how a modern language deals with this stuff https://bun.sh/docs/api/ffi#usage

Re:Benchmarking 20 programming languages on N-queens and mat... by rafark on Wednesday January 03, 2024 @03:45AM (#38851998)
Checkout what? PHP also has support for FFI. Or am I missing something?
Re:Benchmarking 20 programming languages on N-queens and mat... by geek_at on Wednesday January 03, 2024 @03:01AM (#38851763)
Also since PHP was built for web requests it builds The cache on the First run. would be interesting to see All languages of the benchmark with a second run
Re:Benchmarking 20 programming languages on N-queens and mat... by EmberTwin on Wednesday January 03, 2024 @01:17PM (#38857538)
HHVM is not a drop-in replacement for a PHP interpreter. The semantics of Hack and PHP have diverged, typically in the direction of eliminating dynamic behavior from Hack that existed in PHP (examples: string -> function coercion, the PHP dual vector-hash-table array type, and non-throwing out-of-bounds array accesses are all gone from Hack). The semantics changes both simplify static analysis and make it easier to JIT fast code.
Re:Benchmarking 20 programming languages on N-queens and mat... by Ayesh on Wednesday January 03, 2024 @01:53PM (#38858069)
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.