3 ms·
Only if you have no dependencies and interact in no way with any platform-specified services. Now certainly there are platform-specific things with Rust as wel
by garmaine 6y ago
Only if you have no dependencies and interact in no way with any platform-specified services.
Now certainly there are platform-specific things with Rust as well, but the defaults are structured in such a way that exposed APIs are more likely than not to be platform independent--you have to go out of your way to break compatibility, rather than it being the default.
And once you get your binary to compile, the static linking means there isn't runtime dependencies that might break either.
The net result is that given a piece of rust code, it is far more likely than its C equivalent to compile on a new platform. And once it does compile, it can be run in any context without concern for differences in the runtime environment. The Rust compiler may target fewer platforms, and therefore be "less portable" in that sense, but if it is a supported backend then it is going to be easier to get the code working.
- kazinator 6y agoStatic linking means that if a security flaw is found in a dependent component, you're responsible for shipping a whole new application binary to the end users; they can't just pick up some new shared libs from upstream of you.
- pdimitar 6y agoThis goes both ways: if an embarrassing security vulnerability is found in a system library, your users will be safe due to static linking. Both sides are fair points and it depends on a plethora of other factors which should be chosen for any given project.