Comment by dminik
6 months ago
Well, unfortunately I don't have an exact answer for you, but I do have the next best thing: speculation.
I had a quick look and found this article that compares a partial port of a C++ codebase (at around 17kloc). https://quick-lint-js.com/blog/cpp-vs-rust-build-times/
The resulting rust code apparently ended up slightly larger. This isn't entirely unsurprising to me despite the 25:1 figure from above. Certain things are much more macro-able than others (like de/serialization). Note that C++ is actually well positioned to level the field here with C++26 reflection.
Despite the slightly larger size, the compile times seem roughly equal. With rust scaling worse as the size increases. As a side-note, I did find this part relevant to some of my thoughts from above:
> For example, proc macros would let me replace three different code generators
Now, I know that C isn't C++. But, I think that when restricting yourself to a mostly C-like subset (no proc-macros, mostly no generics outside Option/Result) the result would likely mirror the one above. Depending on the domain and work needed, either language could be much shorter or longer. For example, anything involving text would likely be much shorter in rust as the stdlib has UTF-8 handling built-in. On the other hand, writing custom data structures would likely favor C.
I am interested to see if TRACTOR could help here. Being able to port C code to Rust and then observe the compile times would be pretty interesting. https://www.darpa.mil/research/programs/translating-all-c-to...
No comments yet
Contribute on Hacker News ↗