4 ms·
main(argc, argv) char **argv; { for (;;) printf("%s\n", argc>1? argv[1]: "y"); } Is beautiful, readable, and minimal. The "optimized
by nodesocket 9y ago
main(argc, argv)
char **argv;
{
for (;;)
printf("%s\n", argc>1? argv[1]: "y");
}
Is beautiful, readable, and minimal. The "optimized" Rust version is complicated and over 50 lines of code. At what point does performance optimization go too far?
- 1_2__4 9y agoAs a non-Rust developer my first thought upon seeing the optimized version was “On the other hand let’s not visit Rust, ‘tis a silly place.”
- LEGOlord208 9y agoThere was a lot of things about Rust that made think it was weird before I actually gave in and tried it. Now I adore Rust. You should try it.
- azernik 9y agoSince it can be used to repeat arbitrary data, it is liable to be used in performance-sensitive tasks (mostly along the lines of pumping dummy data to a program or piece of hardware that's being benchmarked).
- trungaczne 9y agoThis is an unfair comparison. For starter this version too is unoptimized, so you need to compare this with the first Rust code, which is about the same size. Moreover a lot of the "bloat" that comes with Rust code isn't because it's more performant. Neither C++ and Rust try to be faster languages (after all, the optimization tricks you can do with your program is limited to what you can do with Assembly and its cousin, C), they try to be safer by providing more abstractions and restrictions (compile time checks).