Sebastian Scholz
๐ค SpeakerAppearances Over Time
Podcast Appearances
But we are constantly fighting that.
For example, in cases where we do need a buffer for certain things and we know beforehand that we need a certain size,
You can add certain trade bounds using the unstable const generic features that prevent you from needing to use unwrap and then just giving you the actual value that you want without using a result or an option.
And that's only possible because you let the compiler validate these preconditions at compile time.
flattening the learning curve, that's a big kind of issue in Rust, I would say, compared to Python, for example.
I think just learning, trying things out and learning by example is the easiest way to do.
Unfortunately, I don't have a fix, like a solution for everyone.
But the thing is, you're struggling a bit with the compiler, right?
is a bit frustrating in the beginning, but it's a very valuable learning experience.
So if you start out using Rust and you're having trouble with lifetimes, with borrowing, whatever, it is the compiler trying to help you.
And once you realize this, once you understand that the structures and the ways you did it before
are a little bit flawed in regard.
Once you understand this, it does help you.
Unfortunately, it is a hard pill to swallow sometimes, but it's very useful.
I myself, after learning Rust this way, have come back to various Python projects and found out that code that I thought was perfectly fine, that I wrote many years ago,
actually had subtle problems that could occur under some circumstances, not all of the time, but sometimes.
And so these, for example, if you have multiple threads and you access certain variables for multiple threads in Python, there's very little help for you to avoid
accessing a variable at the same time.
In fact, there's none.
You need to do that yourself.