Nim vs Rust Benchmarks

This page summarizes the projects mentioned and recommended in the original post on news.ycombinator.com

CodeRabbit: AI Code Reviews for Developers
Revolutionize your code reviews with AI. CodeRabbit offers PR summaries, code walkthroughs, 1-click suggestions, and AST-based analysis. Boost productivity and code quality across all major languages with each PR.
coderabbit.ai
featured
Nutrient - The #1 PDF SDK Library
Bad PDFs = bad UX. Slow load times, broken annotations, clunky UX frustrates users. Nutrient’s PDF SDKs gives seamless document experiences, fast rendering, annotations, real-time collaboration, 100+ features. Used by 10K+ devs, serving ~half a billion users worldwide. Explore the SDK for free.
nutrient.io
featured
  1. cosmopolitan

    build-once run-anywhere c library

    Why does hello world take 1.8ms to run? By my measurements with Actually Portable Executable the latency of vfork+execve+exit+wait4 on a physical computer should be 25µs. https://github.com/jart/cosmopolitan/blob/master/test/libc/s...

  2. CodeRabbit

    CodeRabbit: AI Code Reviews for Developers. Revolutionize your code reviews with AI. CodeRabbit offers PR summaries, code walkthroughs, 1-click suggestions, and AST-based analysis. Boost productivity and code quality across all major languages with each PR.

    CodeRabbit logo
  3. Programming-Language-Benchmarks

    Yet another implementation of computer language benchmarks game

    It appears helloworld is the only test with any repeats, and it only has 5 repeats. https://github.com/hanabi1224/Programming-Language-Benchmark...

    Here's the measurement code, it appears to be significantly more complicated than a simple fork/exec/wait loop but that could just be all the C# getting in the way: https://github.com/hanabi1224/Programming-Language-Benchmark... Nevertheless you are probably right that the bulk of this 1.8ms is in the executable under test, and it truly is just bloat. Running `hyperfine ./empty-main-function` from rustc on my Mac gives 0.8ms.

  4. It appears helloworld is the only test with any repeats, and it only has 5 repeats. https://github.com/hanabi1224/Programming-Language-Benchmark...

    Here's the measurement code, it appears to be significantly more complicated than a simple fork/exec/wait loop but that could just be all the C# getting in the way: https://github.com/hanabi1224/Programming-Language-Benchmark... Nevertheless you are probably right that the bulk of this 1.8ms is in the executable under test, and it truly is just bloat. Running `hyperfine ./empty-main-function` from rustc on my Mac gives 0.8ms.

  5. rust

    Empowering everyone to build reliable and efficient software.

    From my understanding, LLVM had or has many bugs around alias rules. I remember Rust emitted proper noalias IR to LLVM, only for it to be promptly ignored.

    https://github.com/rust-lang/rust/issues/54878

  6. Graal

    GraalVM compiles Java applications into native executables that start instantly, scale fast, and use fewer compute resources 🚀

    > By everyone's understanding of the words, C does not have a runtime

    What? But we both just agreed it did.

    The way I understand these words are that C is a language, and a language is different from its implementation, and implementation is dependent on hardware. I understand that a runtime is code that runs when a program starts to enable its execution. Is this not your understanding?

    Let me put it this way: if C is as fast as you can get as a language, why can you take the same C source, put it into two different compilers, and get two different binaries with different performance profiles?

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

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

    The answer is because the language itself has no bearing on speed, and it all comes down to how a language is compiled. So I still wouldn't say C is inherently fast, but I would say that C's design lends itself to compiling fast binaries for Von Neumann style machines. That of course doesn't preclude compiling just-as-fast or even faster binaries from other languages, e.g. Rust or C++.

    > You can play with definitions and hypotheticals; it does not change the facts.

    I'm not playing with hypotheticals. JPUs are a thing; I linked to the Wiki page. Natively compiled Java is basically GraalVM: https://www.graalvm.org, which I think pretty much proves the point -- it all comes down to the compiler. Garbage checking is also an implementation detail. You can even run a garbage collector for C if you want.

  7. weave

    A state-of-the-art multithreading runtime: message-passing based, fast, scalable, ultra-low overhead (by mratsim)

    In my benchmarks, Nim is faster than Rust:

    - multithreading runtime (i.e Rayon vs Weave https://github.com/mratsim/weave)

    - Cryptography: https://hackmd.io/@gnark/eccbench#Pairing

    - Scientific computing / matrix multiplication: https://github.com/bluss/matrixmultiply/issues/34#issuecomme...

    There is no inherent reason why a Nim program would be slower than Rust.

  8. matrixmultiply

    General matrix multiplication of f32 and f64 matrices in Rust. Supports matrices with general strides.

    In my benchmarks, Nim is faster than Rust:

    - multithreading runtime (i.e Rayon vs Weave https://github.com/mratsim/weave)

    - Cryptography: https://hackmd.io/@gnark/eccbench#Pairing

    - Scientific computing / matrix multiplication: https://github.com/bluss/matrixmultiply/issues/34#issuecomme...

    There is no inherent reason why a Nim program would be slower than Rust.

  9. Nutrient

    Nutrient - The #1 PDF SDK Library. Bad PDFs = bad UX. Slow load times, broken annotations, clunky UX frustrates users. Nutrient’s PDF SDKs gives seamless document experiences, fast rendering, annotations, real-time collaboration, 100+ features. Used by 10K+ devs, serving ~half a billion users worldwide. Explore the SDK for free.

    Nutrient logo
NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts

  • Enso 2.0 is out! (Visual programing in Enso, Java, Python, R, and JavaScript)

    5 projects | /r/ProgrammingLanguages | 13 Apr 2021
  • Live Objects All the Way Down: Removing the Barriers Between Apps and VMs

    1 project | news.ycombinator.com | 8 Jan 2024
  • Crash report and loading time

    1 project | /r/fabricmc | 15 Nov 2023
  • Java 21 Released

    4 projects | news.ycombinator.com | 19 Sep 2023
  • Leveraging Rust in our high-performance Java database

    3 projects | news.ycombinator.com | 20 Sep 2023