-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Discussion on section 3: Primitive Rust #9
Comments
Unless I'm missing something obvious, there's no chapter or section on pattern matching and Rust's pattern syntax! You briefly introduce pattern matching in 3.1, and show an example of a |
It's going to end up in the section on match. Remember, everything after The Basics (currently) is just whatever the text in the old chapter was; it's likely incoherent and doesn't necessarily represent what the chapter will end up as once I take a look. Good eye though! On Dec 19, 2015, 00:51 -0500, [email protected], wrote:
|
I'll post notes on each subsection as I review them. Here's the first. The basicsWe should work on the title. We need something more narrow than "The
How about: We’ll start our journey with Rust by talking about the absolute
Maybe say: none of the concepts presented are unique to Rust, but Variable bindingsGood opener. The basics of bindingsI think you want I'd start more narrowly and then forward-reference the generalization
Note:
Need to more clearly say: each instance of let x = 2 + 3;
let y = x + 5;
println!("The value of x is {}, and the value of y is {}", x, y); Multiple assignmentI'd change the title from "assignment" to "binding". The word This subsection is interesting, because you can understand it as a I think it's fine to have the section here, as is, but I think when we Type annotationsVery good. InitializationRename to: Delayed initialization. I think it's important to mention why you'd ever want this. Just a Otherwise, great. Mutable bindingsGreat! I especially loved the use of tuple patterns to show the nuance ShadowingSo good! |
More: FunctionsMight mention that snake case is used for variable names as well. Function argumentsI think the syntax you want for arguments is Return valuesPerfect. Statements and expressions
I think this can be dropped entirely. After all, you repeat the same It's probably helpful to say that "expressions compute something; Otherwise, great, and nice choice of examples. Expression statementsProbably good to say that the most common case here is when calling a
You should tie back into: most blocks involve a bunch of steps of
Leave this out, it's not adding much :) Multiple return valuesNice. I like the running use of tuples as a simple way to show a bit |
Ah, but we haven't talked about expressions yet. I believe that I later update this when we do. |
👍 to basically everything else, I'm gonna try "primitive rust" to see how that feels |
We haven't talked about |
Shipped all the changes except for the custom initialization. |
Re: talking about |
General
Variable bindings
Primitive types
Comments
if
I'm not entirely what kind of feedback you are looking for, let me know if this is ok and i'll do more chapters |
@Keats In a sense, the examples are runnable in the playpen when you click the link on the right however the document style isn't really setup for examples like rustbyexample's. It's very common for an example to only include the necessary new syntax whereas rustbyexample would have to include all the background info to actually make the example work. Compare this book example with this rustbyexample example. Even if the examples were the same (and I don't think they are), the book examines each part piecemeal requiring the reader to put all the pieces together. Rustbyexample must lay it all out at once. Neither style is wrong but they are different and each lends itself to a slightly different approach. I think they are complementary and neither necessarily must be viewed as entirely better than the other. |
@Keats thanks!
Well, the book has never had it like RustByExample, but linking to the playpen would at least stop it from being a regression. https://github.com/azerupi/mdBook/issues/29 is tracking this generally.
This is true, but 1) repetition is okay, it's a part of learning and 2) I expect a lot of people to skip that section, so it's repeated here. That said, a callback to that might be nice.
The issue is that cargo doesn't support
This is just a style issue. A lot of people love it, some people hate it. It's how I write, though, and we've generally taken that docs will have a conversational tone.
Thanks, would you mind filing a separate bug for this? I'll look into it.
Yes please! I thought this one was already fixed by another PR.
It is not ideal, but we can't really skip it. If you have any direct suggestions, that'd be great, it's certainly something that I don't feel spectacular about.
Because the only real use of inner doc comments is to document modules, and we haven't talked about them yet.
I am willing to err on the side of too much explaining, generally speaking.
In general, we try not to refer to features Rust doesn't have, as this gets really endless. This is a book about writing Rust, not necessarily "how to write your fave feature from $LANGUAGE" in Rust.
This is generally great! Some of it just comes down to things I haven't written down, exactly, or choices we've made, but I'd rather have too much feedback than not enough. I would say that any chapter tagged |
For the examples I agree that it's not too suitable to some examples or would require rewriting quite a bit, I just found all the "Create a cargo project.." a bit distracting. I was sure Cargo had a way of explaining an error, I must have dreamt it. I'm reading the book hosted on github so i guess that depends how often you update it, I will do PRs/continue tomorrow |
I find "The Basics" more welcoming than "Primitive Rust", 'primitive' may even sound pejorative. In "Variable Bindings", I found "Reassignment, not mutation" part very confusing, perhaps because it's lacking the rest of the explanation in the "Functions" section. Still I think it should be removed and the difference should be explained when it matters. |
I had wondered about this, but wasn't sure. |
Here's some feedback on Primitive Types, leaving out functions and arrays for now: Primitive TypesI'm not sure that the most important split here is between built-in
I'd suggest breaking the "primitive types" subsections into two -- one I would leave Why move those out?
General point: the sub-sections are inconsistently named. Some use Integers
Floating pointSeems fine to not spend a lot of time on this. Same thing about syntax TuplesI think you want a slightly longer intro here, because you haven't In fact, I'd start out by saying exactly that:
Tuple indexingWith the above suggested text, you can now say: "In addition to FunctionsLet's come back to this, after deciding where it should live. BooleansRather than "That's really all ... " -- say something like: "The main CharThis is fine, but as with all the other sections it'd be good to list strI've already given you my basic feeling here. I think it's fine to say |
re: "Primitive Rust", I agree that the title isn't ideal. But I think "The Basics" is problematic, because the chapter definitely doesn't cover the basics of Rust. |
This seems good. I am torn about |
@steveklabnik Yeah -- I think something like what you have now is probably fine, if bolstered with a more explicit forward-ref to the material that's ahead. |
Arrays"So far, we’ve only represented single values in a binding." This is We need to say that in these examples, the arrays are allocated I'd shorten the panic section somewhat -- drop the mention of the
The |
It feels weird to introduce This is going to confuse a lot of people, like it is introduced here people might think panic an debug are types (I hesitated when I read it). |
@azerupi In the printed version of the book I'm expecting these would be clearly marked sidebars -- I wonder if we can do something similar for the online version? I do agree that these are a digression from the main text, but including them early is countering another source of confusion -- trying to index out of bounds or print an array, and getting surprising results. If we can't do an explicit sidebar here, maybe we can find some other placement early on? |
We can get some sidebar stuff with CSS, at least... I'm just really bad at it. |
You can't add classes to the markdown directly (limitation of the markdown parser) but you can insert raw html. So you can basically add whatever you want. I totally agree that those concepts should be introduced early on (at least briefly). But they should probably not be associated with types at all. Maybe you could add a sub-chapter, to the primitive types chapter, called "simple debugging" that would explain printing to the console, format and debug, panics, ...? |
If you always preface the sidebar section headings with something predictable ("Sidebar:"?) we can dynamically add in a div with a class to style it however. |
I like this idea! Hmm |
The comments section looks good, but I think we should drop the inner doc comments bit and only introduce it when we talk about modules. |
ifOverall, solid, quick read. As I said in a different bit of feedback, I think we should consistently title I like the opening, but I think it ends up quite belabored. I'd suggest dropping
|
Or simply "if statement" ? |
I mean, it's not required, it's only required if you're doing anything useful. Otherwise you always get |
|
I've just pushed a series of commits which take into account all the feedback before this comment 👍 Well, still unsure about 'primitive' |
You're right; I stand corrected! |
I still ended up just eliminating it. It's too deep in the weeds to bother with. |
I read the |
Is there any reason to cover setup via cargo if it's covered in the intro "hello world" section?
I don't know what a humble pattern means. I don't think patterns possess a state of humility or arrogance. [EDIT] I suppose it should be interpreted as simple. The variable bindings The basics of bindings is slightly unwieldy and unfocused. Of the 6 possible subsections it covers, only 1 actually talks about bindings. All the others are basically background info:
This isn't a big issue since single bindings are simple but if say you separated it into a prelim and a single/multiple bindings section (or two sections back to back as it is currently), you would avoid that issue (if you consider it a problem). |
In general, it's better to go really, really slow at the start of a book. Like, slower than you'd expect. It's accessible to a much wider audience than this way. It's also why, at this stage, I'm still showing full examples with a
Hmmm yeah, this might be worthwhile. |
I've done one or two more little tweaks; mostly removing my own home directory from the example paths :) I'm going to send this draft to No Starch today. |
Spanish translation ch03-03-how-functions-work.md
See discution about that in rust-lang#9 (@joeljpresent reply).
Translating ch00-00-introduction.md
No description provided.
The text was updated successfully, but these errors were encountered: