-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mention both static and dynamic dispatch in the introduction to traits. #376
Conversation
@@ -25,7 +25,19 @@ impl Greet for Cat { | |||
} | |||
} | |||
|
|||
// Generic function (more in the next chapter). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you try enabling the "aspect-ratio helper" preprocessor here: https://github.com/google/comprehensive-rust/blob/main/book.toml#L24. I think you'll quickly see that there is not enough space on the page for such a long code example.
I don't disagree 😄 We will need to reorder the slides a bit and make the whole things more streamlined. However, I'm afraid of putting more stuff onto the pages. When I did the course last, I was constantly running out of time and as a result, the course felt rushed to me. So I think we need to go the other way and trim away unnecessary stuff (or rebalance the pages some other way). |
So after teaching the first 3 days, the session on traits and generics was by far the most dense, because it's introducing a lot of new concepts (traits, generics, dynamic/trait objects), of new syntax (trait bounds, where clauses, impl Trait, dyn Trait, closures), as well as important traits from the standard library. It would IMO make sense to prioritize what to teach, and focus on that first. In terms of streamlining this session, I'd see the following fundamentals to focus on, because they are the foundation for everything else:
I'd leave the other topics to a lower priority for the following reasons:
|
You are quite right! Thanks for the ideas about restructuring this — I completely agree that we should turn this into something better. I've run into many of the same problems with the flow as you mention (cc @gribozavr). |
I find it weird to start the introduction to traits with dynamic dispatch only, which comes at a runtime cost. Not mentioning any static dispatch might give a wrong impression that traits are not a zero-cost abstraction.
I anticipate the question anyway, so better have the answer on the slide already.