Ask HN: What's the fastest programming language with a large standard library?

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

Our great sponsors
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • WorkOS - The modern identity platform for B2B SaaS
  • SaaSHub - Software Alternatives and Reviews
  • .NET Runtime

    .NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.

  • .NET's standard library is very heavily vectorized, vectorization is considered in all scenarios where it is applicable, the compiler will also apply it to copies of known length and string comparisons fully eliding and unrolling Memmove and SequenceEqual calls.

    The gives languages that run on top of .NET massive performance advantage in a variety of scenarios versus any other language - C++ and Rust stdlibs are far more conservatively vectorized because neither language has stable SIMD vector API and even then out of modularity constraints a lot of routines have to either rely on autovectorization which is fragile or manually vectorized with intrisics for each individual platform.

    A short non-exhaustive list of examples is

    - Shared SIMD helper for Aho-Corasick, Rabin-Karp and other text search algorithms https://github.com/dotnet/runtime/blob/main/src/libraries/Sy...

    - Bloom filter https://github.com/dotnet/runtime/blob/main/src/libraries/Sy...

    - Base64 encoding and decoding https://github.com/dotnet/runtime/blob/main/src/libraries/Sy...

    - Element search (memchr and the like) https://github.com/dotnet/runtime/blob/main/src/libraries/Sy...

    - UTF-8 transcoding https://github.com/dotnet/runtime/blob/main/src/libraries/Sy...

    The above are examples of 1% code that ends up used by 99% of other codebase in one way or another. Regex engine, JSON serialization and parsing, substringing and etc. all use these.

  • rust-memchr

    Optimized string search routines for Rust.

  • Rust has had a stable SIMD vector API[1] for a long time. But, it's architecture specific. The portable API[2] isn't stable yet, but you probably can't use the portable API for some of the more exotic uses of SIMD anyway. Indeed, that's true in .NET's case too[3].

    Rust does all this SIMD too. It just isn't in the standard library. But the regex crate does it. Indeed, this is where .NET got its SIMD approach for multiple substring search from in the first place[4]. ;-)

    You're right that Rust's standard library is conservatively vectorized though[5]. The main thing blocking this isn't the lack of SIMD availability. It's more about how the standard library is internally structured, and the fact that things like substring search are not actually defined in `std` directly, but rather, in `core`. There are plans to fix this[6].

    [1]: https://doc.rust-lang.org/std/arch/index.html

    [2]: https://doc.rust-lang.org/std/simd/index.html

    [3]: https://github.com/dotnet/runtime/blob/72fae0073b35a404f03c3...

    [4]: https://github.com/dotnet/runtime/pull/88394#issuecomment-16...

    [5]: https://github.com/BurntSushi/memchr#why-is-the-standard-lib...

    [6]: https://github.com/rust-lang/rfcs/pull/3469

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

    RFCs for changes to Rust

  • Rust has had a stable SIMD vector API[1] for a long time. But, it's architecture specific. The portable API[2] isn't stable yet, but you probably can't use the portable API for some of the more exotic uses of SIMD anyway. Indeed, that's true in .NET's case too[3].

    Rust does all this SIMD too. It just isn't in the standard library. But the regex crate does it. Indeed, this is where .NET got its SIMD approach for multiple substring search from in the first place[4]. ;-)

    You're right that Rust's standard library is conservatively vectorized though[5]. The main thing blocking this isn't the lack of SIMD availability. It's more about how the standard library is internally structured, and the fact that things like substring search are not actually defined in `std` directly, but rather, in `core`. There are plans to fix this[6].

    [1]: https://doc.rust-lang.org/std/arch/index.html

    [2]: https://doc.rust-lang.org/std/simd/index.html

    [3]: https://github.com/dotnet/runtime/blob/72fae0073b35a404f03c3...

    [4]: https://github.com/dotnet/runtime/pull/88394#issuecomment-16...

    [5]: https://github.com/BurntSushi/memchr#why-is-the-standard-lib...

    [6]: https://github.com/rust-lang/rfcs/pull/3469

  • aho-corasick

    A fast implementation of Aho-Corasick in Rust.

  • Right. I pointed it out because it isn't just about having portable SIMD that makes SIMD optimizations possible. Therefore, the lack of one in Rust doesn't have much explanatory power for why Rust's standard library doesn't contain SIMD. (It does have some.) It's good enough for things like memchr (well, kinda, NEON doesn't have `movemask`[1,2]), but not for things like Teddy that do multi-substring search. When you do want to write SIMD across platforms, it's not too hard to define your own bespoke portable API[3].

    I'm basically just pointing out that a portable API is somewhat oversold, because it's not uncommon to need to abandon it, especially for string related ops that make creative use of ISA extensions. And additionally, that Rust unfortunately has other reasons for why std doesn't make as much use of SIMD as it probably should (the core/alloc/std split).

    [1]: https://github.com/BurntSushi/memchr/blob/c6b885b870b6f1b9bf...

    [2]: https://github.com/BurntSushi/memchr/blob/c6b885b870b6f1b9bf...

    [3]: https://github.com/BurntSushi/aho-corasick/blob/f227162f7c56...

  • tmi-rs

  • Movemask keeps coming back. Rather than emulating it, it appears to be more efficient to separately handle IndexOfMatch, LastIndexOfMatch and GetMatchCount scenarios it is used for most of the time:

    - https://github.com/dotnet/runtime/pull/94472/files#diff-5824... (it's closed for now but I'm hoping to get back to it at some point)

    - https://github.com/jprochazk/tmi-rs/blob/ac3ce6aee8bbe038a98...

    It can account for good 30% performance variance depending on the use case (on Apple's M-series cores).

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