Menu
Sign In Search Podcasts Libraries Charts People & Topics Add Podcast API Blog Pricing

Alice Ryhl

๐Ÿ‘ค Speaker
505 total appearances

Appearances Over Time

Podcast Appearances

The Pragmatic Engineer
Why Rust is different, with Alice Ryhl

TypeScript is actually kind of good on that front, but okay.

The Pragmatic Engineer
Why Rust is different, with Alice Ryhl

The other thing I think is quite good is error handling.

The Pragmatic Engineer
Why Rust is different, with Alice Ryhl

So on one hand, Rust doesn't really use exceptions.

The Pragmatic Engineer
Why Rust is different, with Alice Ryhl

So it actually returns the error as a value.

The Pragmatic Engineer
Why Rust is different, with Alice Ryhl

So you return a value that's either using an enum, either the result or the error.

The Pragmatic Engineer
Why Rust is different, with Alice Ryhl

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.

The Pragmatic Engineer
Why Rust is different, with Alice Ryhl

And this means if this function fails, return the error.

The Pragmatic Engineer
Why Rust is different, with Alice Ryhl

So it's really easy to handle errors, but it's not zero characters like it is with exceptions, right?

The Pragmatic Engineer
Why Rust is different, with Alice Ryhl

So it's explicit.

The Pragmatic Engineer
Why Rust is different, with Alice Ryhl

On the other hand, and if you forget to put the question mark, that's a compilation error.

The Pragmatic Engineer
Why Rust is different, with Alice Ryhl

So you have to check it.

The Pragmatic Engineer
Why Rust is different, with Alice Ryhl

Yeah.

The Pragmatic Engineer
Why Rust is different, with Alice Ryhl

Right?

The Pragmatic Engineer
Why Rust is different, with Alice Ryhl

And of course, you can also handle it manually.

The Pragmatic Engineer
Why Rust is different, with Alice Ryhl

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.

The Pragmatic Engineer
Why Rust is different, with Alice Ryhl

And now you just, you know, took down your server or something.

The Pragmatic Engineer
Why Rust is different, with Alice Ryhl

Another thing I quite like is how it handles documentation.

The Pragmatic Engineer
Why Rust is different, with Alice Ryhl

For one, when you have a comment, you make it into a documentation comment by having three slashes instead of two.

The Pragmatic Engineer
Why Rust is different, with Alice Ryhl

Now, the thing is, you can, of course, write examples in your documentation.

The Pragmatic Engineer
Why Rust is different, with Alice Ryhl

And Rust makes all examples into tests.