4 ms·
Any optimization that the Rust compiler might do can very likely be reproduced in C given sufficient time and effort.
by eutectic 10y ago
Any optimization that the Rust compiler might do can very likely be reproduced in C given sufficient time and effort.
- adrianN 10y agoI think you have to compare using equal programmer effort if you have two languages that in principle allow you to produce any instruction sequence you like. You don't see performance critical applications (the stuff supercomputers run for example) written in Assembly, even though in theory you might be able to squeeze out a little more performance when Fortran and a good compiler gets you almost as far for much less money.
- emn13 10y agoIn small programs like this, it might not even take a lot of effort. It's trivial to read a program like this and make a very good guess as to where bottlenecks are without even running it, let alone profiling it. That kind of simplicity gets lost quickly, however, when programs grow. Then again, I don't really believe that the optimization opportunities are likely to ever matter much. At least not at this level. Perhaps for much more complicated things, e.g. a kind of compile-time sql or string-matcher the greater safety and the symbolic nature of the macros will let programmers write libraries that practically reason about instructions you give them and choose optimal strategies where C would need to do so at run time or with unmaintainable and unusable macros, but if it's just aliasing and some threading gains - well, those aren't huge often, and where they are, C can use em unsafely too (and that's often quite doable too!). Safety and maintainability sound like more realistic selling points to me - it may never actually beat C in real-world performance; but it doesn't have to - it just needs to come close.