Alice Ryhl
๐ค SpeakerAppearances Over Time
Podcast Appearances
TypeScript is actually kind of good on that front, but okay.
The other thing I think is quite good is error handling.
So on one hand, Rust doesn't really use exceptions.
So it actually returns the error as a value.
So you return a value that's either using an enum, either the result or the error.
And the way this is done is that there's an operator, question mark, which says, so you write my function and then question mark at the end.
And this means if this function fails, return the error.
So it's really easy to handle errors, but it's not zero characters like it is with exceptions, right?
So it's explicit.
On the other hand, and if you forget to put the question mark, that's a compilation error.
So you have to check it.
And of course, you can also handle it manually.
But the point is, it's this idea of there are these things where you write some code and there's some implicit error condition you didn't think of.
And now you just, you know, took down your server or something.
Another thing I quite like is how it handles documentation.
For one, when you have a comment, you make it into a documentation comment by having three slashes instead of two.
Now, the thing is, you can, of course, write examples in your documentation.
And Rust makes all examples into tests.