Nim vs Rust Benchmarks

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

Our great sponsors
  • WorkOS - The modern identity platform for B2B SaaS
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • SaaSHub - Software Alternatives and Reviews
  • 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...

  • 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.

  • WorkOS

    The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.

    WorkOS logo
  • 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.

  • 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

  • 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.

  • 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.

  • 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.

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB 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