4 ms·
This is not at all specific to rust: OP is just grateful for the compiler to find lots of problems one would have to write tests for in dynamic languages.
by jlg23 9y ago
This is not at all specific to rust: OP is just grateful for the compiler to find lots of problems one would have to write tests for in dynamic languages.
- icebraining 9y agoIt's not even specific to compilers; it's any type-checker. Compilers just happen to include one.
- simias 9y agoWell it's more of a feature of the language really. The type of static type checking provided by Rust would be impossible to achieve in C or Python for instance, unless you add specific annotations to augment the language's type system.
- pjmlp 9y agoThe advantage is that it not possible to forget to use it.
- simias 9y agoI agree with you if we replace "dynamic language" by "not as strongly typed". C is not exactly dynamic but its type system is prehistoric compared to Rust. For instance C's equivalent of Rust's enum would be tagged unions, however the compiler cannot enforce the semantics of tagged unions and will gladly let you access random members regardless of the tag. Same story with the borrow checker compared to C's "whatever you say chief" approach to resource management. Rust is definitely not the only one to offer these guarantees and some languages even go further (such as Idris for instance). The reason Rust stands out is that it can be used basically anywhere you'd use C or C++, something few other languages can claim.
- jlg23 9y agoI agree, just did not consider it worth anyone's time to go into details the OP does not even touch. The article compares rust with js and ruby....
- epage 9y agoI think that assessment is more black and white than the situation. There are gradations to how much the compiler and static analysis help you. Coming from C++, I've been blown away by how much confidence Rust gives me in my code. The borrow checker is the primary reason I feel this way. A smaller aspect is how easy it is to write white box unit tests. I can have an equivalent of a C++ static function in Rust and run unit tests on it. For C++, I'd either have to hack up the source files for when building my unit tests or make turn the function from static to being exposed in a header so my tests can access it.