5 ms·
Actually no. Rust will teach you. The difference is that errors do a great job and telling you what went wrong and how you can fix it. You just fix one error a
by cardanome 5y ago
Actually no. Rust will teach you.
The difference is that errors do a great job and telling you what went wrong and how you can fix it. You just fix one error after another and the borrow checker will guide you to the correct solution.
For example you get an error like:
error[E0433]: failed to resolve: use of undeclared type `Environment`
--> src/main.rs:9:19
|
| let mut env = Environment::new();
| ^^^^^^^^^^^ not found in this scope
|
help: consider importing this struct
|
| use foobar::test::Environment;
|
You could fix this error without knowing Rust.
You obviously need to know the basics of systems programming to effectively program in Rust and some type errors get tricky, still it is a more interactive experience and you can just jump in while in TS just jumping in does not really work and the level of type safety relies on your skills as a developer.
- 9dev 5y agoHah, let me just chime in with a recent TS error that almost drove me nuts[1]: Type 'Record<string, any>' is not assignable to type 'T'. 'Record<string, any>' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Record<string, any>'. (2322) Would you have figured out that the solution to the problem was to omit the - factually correct - return type of the method? Rust is not just better at error messages, it's playing an entirely different game. [1]: https://stackoverflow.com/q/67397978/2532203 https://stackoverflow.com/q/67397978/2532203
- azangru 5y ago> Would you have figured out that the solution to the problem was to omit the - factually correct - return type of the method? While I would not be able to figure out the solution to this problem from the error message alone, I would gather from it that typescript is telling me here that it cannot guarantee that it will satisfy the type contract, i.e. that the function will return a thing of the same generic type T as it received. This is useful information in debugging the type declaration of the function.