1. 20
  1.  

  2. 5

    It would be neat to see similar statistics statistics for clang compiling C or C++ as well, though. However, my experience has been that it is really quite difficult to compare Rust to C/C++ compilers, because it’s very difficult to find projects in both C/C++ and Rust that are close analogues of each other. Even when they do the same thing, they tend to do it in very different ways.

    If you need a test-case, rust-lodepng is a 1:1 translation of C lodepng. It’s even ABI-compatible with the original.

    1. 1

      Good start. There’s still potential failure in the comparison: the test shows Rust compiler’s performance on C-like Rust instead of whatever style Rust programmers normally code in. Still might show where Rust matches C or needs further improvements on that type of code, though.

    2. 4

      Did you know that rustc has most of the groundwork laid for supporting other backends besides LLVM?

      Well, I did hear a lot of buzz regarding using Cranelift as a backend for fast debug builds..

      1. 1

        I have a such a hard time conceptualizing how we end up needing 2 million lines of rust for the compiler. Surely a bunch of that is test code? It feels like a lot of stuff should flow into one another so nicely

        1. 4

          Author here. A lot of it isn’t the compiler itself but various libraries and other stuff that orbit around it:

          • src/tools: 312,000 lines
          • src/test: 290,000 lines
          • src/libsyntax: 41,000 lines
          • src/libstd: 104,000 lines
          • src/libcore: 87,000 lines

          These are, nonetheless, things that depend directly on the API of the compiler itself or vice versa, and so are built and maintained by the compiler team. It looks like the core code of the compiler itself is more like 360,000 lines. The same probably goes for most of the other compilers I compared against. Like I said, it’s a sloppy measurement to begin with.

          1. 1

            Thanks for the breakdown, pretty surprised that libstd wouldn’t be the biggest non-test chunk here, but I might be underestimating the amount of special case-ness that comes with writing a proper production compiler.

            Super interesting to establish a sense of scale to this project.

            1. 3

              As context: tools is not only tooling around the compiler, it is the whole of rustfmt, cargo, clippy, our IDE tooling (rls), their testsuites…