2 ms·
Great explanation! Although I have to wonder, why did the author choose to use Rust for this project? As far as I can see, it didn't really use any of Rust's ad
by kccqzy 7y ago
Great explanation! Although I have to wonder, why did the author choose to use Rust for this project? As far as I can see, it didn't really use any of Rust's advanced features not available in C or C++, like tagged unions, pattern matching, advanced type system, traits, borrow checking…
For what it's worth, I translated the whole code into C++. And it's essentially the same: https://gist.github.com/kccqzy/c404b8614f39f854f137dcc9284b0b87 https://gist.github.com/kccqzy/c404b8614f39f854f137dcc9284b0... And it runs correctly on macOS and Linux when compiled with clang.
- kasane 7y agoWhy would one pick C or C++ over Rust for this project?
- sim_card_map 7y agoMuch easier to build, for me at least. I tried installing Rust and building the example, but then it complained about nightly features, and I didn't have time to figure that out. C/C++ are mainstream languages, and building is as simple as g++ test.cpp.
- eridius 7y agoUsing nightly features is as simple as inserting +nightly as the first argument to rustc or cargo (assuming rust was installed with rustup, which is the default way to install it). So in this case, it's just `rustc +nightly green_threads.rs`
- kccqzy 7y agoIf the point is to explain how green threads work, it is better to use a common language so people can simply try to understand the concept and not try to understand both the concept and the language at the same time.
- sim_card_map 7y agoThanks a lot for this!