‹ BackHN Continuity

Thread

How to speed up the Rust compiler in September 2026

279 points · 171 comments · trickypr

  1. Surac · · focus · HN ↗
    Why is the compiler slow in the first place? I have no rust knowledge, how slow us slow, lets say in comparison to a c compiler?

    What is the performance killer?

    1. jerf · · focus · HN ↗
      Doing stuff isn't free. For instance, Go compiles relatively quickly for a modern language, but the biggest reason for that is that it does less stuff than most compilers... less optimization, less checking, and some stuff built into the language to avoid some of the problems with having to read lots of headers just to compile a file and other ways of doing less stuff, but mostly the key is it does less stuff, in both the good and bad senses of that.

      If you want something like Rust that offers guarantees and checks and cross-checks by the boatload, it adds up. Macros, monomorphization, implicit code generation with traits and all those other things add up too. And you can't always get O(n) or O(n log n) code to implement those checks. Maybe it can be sped up and maybe there's tricks here or there, but at the Pareto frontier, a language that has more checks will be slower to compile than one that has fewer.

      And that's not a bad thing or a deficit in Rust, it's just the nature of the beast.

      1. pjmlp · · focus · HN ↗
        Nah, the only reason is lack of tooling.

        Instead of Go, you could have reached out to complex languages with fast compilation times like D, OCaml, Haskell, Ada, Delphi, C++.

        All of them have alternative implementations with fast compilation times.

        D, use dmd for fast development workflows, gdc or ldc for the ultimate performance at the expense of compilation times.

        OCaml, use the REPL or bytecode interpreter for fast development times, the full blow compiler for ultimate performance.

        Haskell, use the REPL, GHCi for the fast development cycles, GHC for the release build.

        Ada and Delphi, have had fast implementations since forever, although Ada/SPARK is indeed somehow expensive.

        C++, yes it isn't a mistake. Use Live++, VS hot reload, coupled with binary libraries, or a REPL like CINT (nee ROOT), binary libraries for dependencies, incremental compilation and incremental linking for the development workflow.

        The problem with Rust isn't the language itself, rather the ecosystem currently lacking such kind of options being available.

        1. slopinthebag · · focus · HN ↗
          including c++ with all of those qualifiers would be like me saying rust is fast with sccache, subsecond, cranelift, and making every single module a separate crate.
          1. pjmlp · · focus · HN ↗
            The difference being the adoption culture across the ecosystem.

            C++ game engines also don't need Bevy like tutorials, because most studios aren't compiling them from scratch, and tools like Live++ or VC++ hot reload are relatively easy to use.

            1. slopinthebag · · focus · HN ↗
              unreal engine is compiled from scratch (depending on your definition of "from scratch") and has notoriously long compile times. heck you have to recompile the editor to make certain gameplay code changes. and it's by far the most popular AAA game engine on the planet. if it was so easy to fix with your suggestions they would have done it already.

              but hey, just add subsecond and switch to cranelift. problem solved :)

              1. pjmlp · · focus · HN ↗
                Unreal Engine has an installer, and they have done my suggestions, as they are the main customers of Live++ [0], advocates of tooling like Blueprints and now Verse for doing full games.

                Many studios have delivered games with little to no changes to the underlying C++ code.

                [0] - <a href="https:&#x2F;&#x2F;dev.epicgames.com&#x2F;documentation&#x2F;unreal-engine&#x2F;using-live-coding-to-recompile-unreal-engine-applications-at-runtime" rel="nofollow">https:&#x2F;&#x2F;dev.epicgames.com&#x2F;documentation&#x2F;unreal-engine&#x2F;using-...

                1. slopinthebag · · focus · HN ↗
                  so... c++ compile times are fast, because you can simply not compile c++ and instead use blueprints? seems odd since we&#x27;re talking about c++&#x2F;rust compile times. turns out you can make rust compile times infinitely faster by not compiling it too...

                  but when you do have to compile c++, it can be real slow. maybe not as slow as rust, but it&#x27;s not in the same league as eg. go, c#, zig, etc.

                  ue5&#x27;s hot reload is by no means perfect either - many gameplay code changes require recompiling the editor. exposing c++ properties on a blueprint? recompile. modify a constructor? recompile. changing parameters, return types, or adding&#x2F;removing UFUNCTION or UPROPERTY macros? recompile. you can simply search the web to read the experiences of thousands of ue devs complaining about slow compile times and workflows. it&#x27;s the same with unity btw, search &quot;reloading domain unity&quot;.

                  also verse is not in unreal engine. no studio is using verse for ue games. not sure why you threw that in.

                  i get you love c++ and dislike rust, but you aren&#x27;t really making a good case for c++ when you group it in with other languages that have fast compile times ootb, make arguments that involve not using c++ (like blueprints, lol), and rely on brittle third-party hot-reloading solutions.

                  1. pjmlp · · focus · HN ↗
                    I threw that in, because if you knew Unreal Engine, you would be aware of the roadmap for Unreal 6.

                    No one is saying that C++ compile times are anywhere close to Delphi or D, although they are much better when using modules actually.

                    Rather that C++ ecosystem has a developer culture and tools, that makes compiling from scratch and pure distribution of source code for what is a compiled language, something rare, thus despite its slowness, the average impact is less felt than on Rust projects.

                    1. slopinthebag · · focus · HN ↗
                      the roadmap for late 2027 for an experimental release? where studios will still be using C++ for gameplay code?

                      modules? you mean the thing where 2&#x2F;3 major compilers still only have partial support for? how many major c++ projects are using modules?

                      i get it, you hate rust.

                      1. pjmlp · · focus · HN ↗
                        C++ gameplay code doesn&#x27;t require a full engine build for the most part.

                        Office has been using C++ modules for a while now, I think they are major enough.

                        Nah, I hate lack of tooling, you missed my other examples from languages in the ML family.

Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.