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.
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.
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
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.
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.
If you need a test-case, rust-lodepng is a 1:1 translation of C lodepng. It’s even ABI-compatible with the original.
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.
Well, I did hear a lot of buzz regarding using Cranelift as a backend for fast debug builds..
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
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 linessrc/test
: 290,000 linessrc/libsyntax
: 41,000 linessrc/libstd
: 104,000 linessrc/libcore
: 87,000 linesThese 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.
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.
As context: tools is not only tooling around the compiler, it is the whole of rustfmt, cargo, clippy, our IDE tooling (rls), their testsuites…