Hacker News new | ask | show | jobs
by Cyther606 4187 days ago
Nim is like writing C at the speed of Python, and running Python at the speed of C.

If you took Python but made it perform blazingly fast, and made it suitable for the most demanding of embedded and systems programming applications, in addition to game dev, you'd get Nim.

If on the other hand you're satisfied with Python, then keep using it. It was trivial for me to port a Python elliptic curve implementation to Nim. I'd certainly recommend it over Cython, because Nim is simply designed as one complete system built for writing high performance applications with a sane syntax.

Statistics (on an x86_64 Intel Core2Quad Q9300):

    Lang    Time [ms]  Memory [KB]  Compile Time [ms]  Compressed Code [B]
    Nim          1400         1460                893                  486
    C++          1478         2717                774                  728
    D            1518         2388               1614                  669
    Rust         1623         2632               6735                  934
    Java         1874        24428                812                  778
    OCaml        2384         4496                125                  782
    Go           3116         1664                596                  618
    Haskell      3329         5268               3002                 1091
    LuaJit       3857         2368                  -                  519
    Lisp         8219        15876               1043                 1007
    Racket       8503       130284              24793                  741
https://github.com/def-/LPATHBench/blob/master/nim.nim

https://github.com/Araq/Nim/wiki/Nim-for-C-programmers

1 comments

Thank's for the explanation! Then I know Nim isn't for me because "winning the benchmark game" isn't important to me -- even Python is fast enough for almost everything I write. But I understand why it is appealing to others.

Are there any other up-to-date benchmarks of Nim? In larger programs, performance is often dominated by allocating and garbage collecting memory. It would be interesting to know if Nim performs as well in that discipline as in raw number crunching.