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

It's not that foreign.

The Pragmatic Engineer
Why Rust is different, with Alice Ryhl

I think the most tricky thing people run into is how should you put together your data structure?

The Pragmatic Engineer
Why Rust is different, with Alice Ryhl

I mean, for your code, you can mostly do the same things as you can in other languages.

The Pragmatic Engineer
Why Rust is different, with Alice Ryhl

I mean, that's not entirely true, but the big thing is really the data structures.

The Pragmatic Engineer
Why Rust is different, with Alice Ryhl

So if you have, I don't know what would be a good example, let's say some sort, okay, let's just say you have an object for a book, and it has an array of pages, and then you have an object for each page.

The Pragmatic Engineer
Why Rust is different, with Alice Ryhl

If I was writing TypeScript, I would probably have a book field in the page that references the book, and then the book, of course, also references the page.

The Pragmatic Engineer
Why Rust is different, with Alice Ryhl

Right, so it's cyclic.

The Pragmatic Engineer
Why Rust is different, with Alice Ryhl

So the book goes to the page, goes back to the book.

The Pragmatic Engineer
Why Rust is different, with Alice Ryhl

And in Rust, you usually have to design your objects so that they're not cyclic.

The Pragmatic Engineer
Why Rust is different, with Alice Ryhl

It has to be a tree or a deck, if you know what that means.

The Pragmatic Engineer
Why Rust is different, with Alice Ryhl

So if you go out and actually start to use reference counting, it becomes possible to have cyclic objects.

The Pragmatic Engineer
Why Rust is different, with Alice Ryhl

with some cavities like you mentioned, but what people end up doing when they're learning the language is that they try to make cyclic objects without anything like that.

The Pragmatic Engineer
Why Rust is different, with Alice Ryhl

And then it just doesn't work.

The Pragmatic Engineer
Why Rust is different, with Alice Ryhl

and they're going to run into all sorts of problems in their code while they're constructing, they're maybe creating their thing, and then they get a compiler error, and then they try to change the code, and they get a compiler error again.

The Pragmatic Engineer
Why Rust is different, with Alice Ryhl

But the thing that a lot of people struggle with is that they keep trying to change the code when the solution is to change the struct.

The Pragmatic Engineer
Why Rust is different, with Alice Ryhl

The ownership is just the idea that if you have a variable,

The Pragmatic Engineer
Why Rust is different, with Alice Ryhl

containing some object, then the object is only there.

The Pragmatic Engineer
Why Rust is different, with Alice Ryhl

It's kind of exclusive.

The Pragmatic Engineer
Why Rust is different, with Alice Ryhl

So for example, if you have a variable, let A equals your string or whatever, and then you do let B equal to A, then this is a move.

The Pragmatic Engineer
Why Rust is different, with Alice Ryhl

And so this means that using A afterwards is now a compiler error because its contents have been moved away.