The blog post is 7 years old obviously which could mean different things for 
both Nim and Rust, but Nim has changed a lot more since, notice there is a nil 
seq in there. So the results today might be different but not sure how much. 
For all I know LLVM could have been vectorizing conway's game of life for Rust.

The benchmark game clone on the other hand is weird. Compare this benchmark 
between 
[Nim](https://github.com/hanabi1224/Programming-Language-Benchmarks/blob/main/bench/algorithm/lru/1.nim)
 and 
[Rust](https://github.com/hanabi1224/Programming-Language-Benchmarks/blob/main/bench/algorithm/lru/1.rs).
 Nim is reimplemented from some language like JS and Rust is hand written, 
seemingly because the creator of the repo is familiar with Rust and not with 
Nim.

`OrderedTableRef` instead of `OrderedTable` \+ `var`, `method` instead of 
`proc`, `lcg` being a double-closure are some obvious things, but there is the 
real bottleneck that Rust can do `let Some(&v) = table.get(k)` while Nim does 
`if k in table: let v = table.get(k)`. There is already `withValue` for this in 
`tables` but it only seems to be overloaded for `Table`. There is even 
`lru.tbl[key] = v` and then immediately after `lru.tbl[key] = value` in `put` 
which I'm pretty sure is meaningless even for OrderedTable.

A lot of this boils down to different languages providing different APIs. 
Otherwise system languages usually perform about the same, only when things 
like GC or dynamic typing get in the way do things change, which is the minimal 
case at this point for Nim (that benchmark does not need the GC).

Reply via email to