Re:Benchmarking 20 programming languages on N-queens and mat...
by nrabulinski on Wednesday January 03, 2024 @02:59AM
(#38851754)
The rust code is very unidiomatic, not only because of the Vec of Vecs which I’d say, even if it’s the obvious naive approach, no one experienced wouldn’t choose over a flat slice, the implementation itself is very naive and unidiomatic.
[ Parent
| on HN ]
Re:Benchmarking 20 programming languages on N-queens and mat...
by hgomersall on Wednesday January 03, 2024 @03:35AM
(#38851947)
Also it's using checked indexing, which apart from being not idiomatic, is also going to slow things down. A fairer comparison would be to use the unchecked indexing variants.
Re:Benchmarking 20 programming languages on N-queens and mat...
by neonsunset on Wednesday January 03, 2024 @06:07AM
(#38852788)
Yeah, it's a similar problem in C# - ported code 1:1 is not representative since it now can't do out of bounds accesses and is therefore safe but comes at a cost of bounds checks which can be manually elided.
Re:Benchmarking 20 programming languages on N-queens and mat...
by vlovich123 on Wednesday January 03, 2024 @11:36AM
(#38856077)
Unchecked indexing is unidiomatic. A more fair comparison world be using iterators if possible but otherwise you have to live with that.