4 ms·
Can any code written in rust be transpiled to c++ without losing something?
by postalrat 6y ago
Can any code written in rust be transpiled to c++ without losing something?
- codewiz 6y agoIf "something" includes safety and maintainability, then no.
- postalrat 6y agoMaintainability doesn't matter in this case. I would assume all the safety features of rust could be implemented in the transpiled code.
- doteka 6y agoIf maintainability doesn’t matter, what are we even talking about though? If a solution is maintainable in Rust and an utter nightmare in C++, the answer to the question is “nope” for all practical purposes.
- smitop 6y agoNo. There is no version of the env! or include_str! macro! in C++ (they are implemented in the compiler for Rust). These macros can be used to the get the values of environment variables or the contents of arbitrary files at compile time. You could of course implement them within a build system, but there isn't a way to replicate these macros with just pure C++ being passed to a compiler, even with pre-processor macros.
- slavik81 6y agoFile embedding seems to have been a low priority for the standard, perhaps because there's always been workarounds, but it has gotten some attention recently with the std::embed proposal: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p1040r0.html http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p104...