3 ms·
I believe this is one of the main promise of Rust, even if it is not stated like that, if it compiles it works and it is safe. But obviously for any other lang
by seren 10y ago
I believe this is one of the main promise of Rust, even if it is not stated like that, if it compiles it works and it is safe.
But obviously for any other language (C,Go,etc) you can use a compiler + static analysis + dynamic analysis to have the same confidence.
What I like with Rust is that implicitly you know that every one has to run the equivalent of analysis tool to release/deploy the code.
- vertex-four 10y ago> I believe this is one of the main promise of Rust, even if it is not stated like that, if it compiles it works and it is safe. Not quite. There's certain types of issue which its type system won't detect - you can, in fact, easily get into a race condition, just not what's known as a data race - and there's no promise that what you've written actually does what you expect it to do, just that it'll do something without use-after-free and other memory-related bugs, and if you've written your program well it's more likely than e.g. Python that it does what you intended (in my personal experience). Getting closer to "if it compiles, it works", but still not entirely there, there'd be the likes of Idris and other systems with proofs embedded into their type systems - but even then you still have to verify that the proof matches what you're actually trying to do in the real world.
- seren 10y agoI agree that "it works" is an overstatement. It is more akin to if it compiles it won't segfault. (Arguably this is not unique to Rust, but there is no overhead in runtime to achieve that).