C++ vs. Rust Build Times

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

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.
www.influxdata.com
featured
SaaSHub - Software Alternatives and Reviews
SaaSHub helps you find the best software and product alternatives
www.saashub.com
featured
  • cpp-vs-rust

  • > the default automated Rust formating tool is very eager to adds lot of lines by basically keeping only one word per line.

    This is not my experience.

    Lifetime and '&mut self' noise (and four-space indentation) did cause rustfmt to sometimes split function signatures across multiple lines, but overall, I think rustfmt did a good job.

    C++: https://github.com/quick-lint/cpp-vs-rust/blob/f8d31341f5cac...

        lexer::parsed_identifier lexer::parse_identifier(const char8* input,

  • rust

    Empowering everyone to build reliable and efficient software.

  • > Rust borrow checking is quick, as shown by cargo check.

    Looks like monomorphization part is not caught during cargo check according to https://github.com/rust-lang/rust/issues/49292

    Reporter of the bug says:

    > All of those happens somewhere inside librustc_mir, most of them being monomorphization. This corresponds to translation item collection pass, which takes nontrivial amount of time.

    Which essentially means that cargo check is not doing all the checks that cargo build will do, so the comparison seems to be a bit off, at least for the time being. And consequently this inconsistency can easily lead to the hypothesis of LLVM backend being the bottleneck.

    I guess the only reasonable way to know for sure where are the biggest bottlenecks in build times is to have something similar to clang's -ftime-trace but I couldn't find anything similar existing in Rust.

    From what I understand, monomorphization and rust macros are essentially C++ templates in a nutshell, and probably less than, yet C++ is compiled much faster. Given that both clang and rust share the same LLVM backend, this seems like an indication to me that the bottleneck is rather in the frontend and not in the backend. It also could be that Rust frontend pipeline is not quite optimized yet so that it puts more pressure to LLVM backend than what the clang does but seems like we can't really know that for sure.

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

    Sccache is a ccache-like tool. It is used as a compiler wrapper and avoids compilation when possible. Sccache has the capability to utilize caching in remote storage environments, including various cloud storage options, or alternatively, in local storage.

  • quote

    Rust quasi-quoting

  • A surprising source of slow compile times can be declarative macros in Rust [0].

    I believe the core of the problem is that it has to reparse the code to pattern match for the macro.

    One egregious patter is tt-munchers [1] where your macro is implemented recursively, requiring it to reparse the source on each call [2].

    In one of my projects, someone decided to wrap a lot of core functions in simple macros (ie nt tt-munchers) to simplify the signatures. Unlike most macros which are used occasionally and have small inputs, this was a lot of input. When I refactored the code, I suspect dropping the macros is the reason CI times were cut in half and a clean `cargo check` went from 3s to 0.5s.

    [0]: https://nnethercote.github.io/2022/04/12/how-to-speed-up-the...

    [1]: https://veykril.github.io/tlborm/decl-macros/patterns/tt-mun...

    [2]: https://github.com/dtolnay/quote/blob/31c3be473d0457e29c4f47...

  • hylo

    The Hylo programming language

  • Well, for languages that are now touting interop with C++, and the emergence of a mainstream memory safe language like Rust, Carbon seems like a retrograde step to me.

    Val is probably the next language that fleeing C++ developers should get behind.

    https://www.val-lang.dev/

    There's even science behind it: https://www.jot.fm/issues/issue_2022_02/article2.pdf

  • RaytracingWeekend-CPP

    Peter Shirley's raytracing One Weekend tutorial updated with C++20 features

  • v-mode

    🌻 An Emacs major mode for the V programming language.

  • Would love to hear your opinion about V too especially since one of its main selling points is fast build times:

    https://vlang.io/#:~:text=Small%20and%20easy%20to%20build%20...

  • SaaSHub

    SaaSHub - Software Alternatives and Reviews. SaaSHub helps you find the best software and product alternatives

    SaaSHub 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

  • The V Programming Language 0.4

    6 projects | news.ycombinator.com | 28 Aug 2023
  • Seed7 version 2023-05-29 released on GitHub and SF

    2 projects | /r/seed7 | 31 May 2023
  • Carbon - an experimental C++ successor language

    17 projects | /r/programming | 19 Jul 2022
  • New embedded programming language with C as a host language

    7 projects | news.ycombinator.com | 25 Jul 2022
  • Ask HN: Vlang vs. Zig vs. Dlang vs. Assemblyscript vs. Haxe vs. EC

    2 projects | news.ycombinator.com | 3 Jul 2022