-
Notifications
You must be signed in to change notification settings - Fork 12.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
Add Steve Klabnik's 'A 30-minute Introduction to Rust' #13416
Conversation
Some things I don't love:
|
I took a big liberty changing RWLocks to Mutex, thinking Mutexes are probably more common. This way may not be better though. |
The diff leaves a lot to be desired. I'll add linebreaks to the md. |
also thank you @stevekbl |
-kblnik |
Haha! I also agree that the C++ example could be better. |
I think it should be done in |
FWIW, I had originally written some |
I agree that in general, we should stay Rust only, but this is a special case. |
What's the advantage of using C instead of |
I think that "You've used systems languages, here are their pitfalls. Now see how Rust fixes that!" is significantly better than "Here's the bad way of writing Rust. Now here's good Rust!" The audience of this piece are C and C++ programmers who have heard something about Rust, and want to see if it makes sense for them. Directly comparing against what they currently use is a great way to demonstrate the value of Rust. |
I don't think the generic documentation should be targeted specifically at C programmers. It makes sense to have documentation aimed at specific groups of people, but not as the general introduction to the language. It also needs to cater to the audience it's aimed at. The documentation comparing against C and C++ would need to be quite different, because raw pointers in C++ are viewed in a similar light to how we view |
IMO, pretending that C and C++ are in the same situation is only going to drive away C++ programmers before they give the language a chance. They'll just assume it's solving the same problems as C++ with the same mechanisms and lose interest. Rust has an unsafe subset that's nearly identical to C too, but yet we don't talk about it as having those problems. |
I, too, dislike "C/C++": you're right that they're very, very different. That's why I'd been saying C++. I'm not opposed to making the example in C as opposed to C++. |
Well, the first thing one often wants to see when learning about a new language is a simple working program ("how does the language look?"), and ideally one they can copy&paste to start writing their own program ("how do I start using it?"). I think a simple version of the Unix "sort" utility (shows how to read and write files, and how to store stuff in a vector and sort it), and a HTTP server returning the current time in response to GET /time (shows how to write a web service, how to get the time, how to format strings) could be suitable for it. Then, one can start with the "why should I use it?" (which the user may already know, since that might be why he started looking at the language in the first place). |
By Steve Klabnik.
I've reformatted the markdown for editing, so now you can see the real diff. |
I don't want to get too much in the weeds on the issue of the C++ example. It's not an unreasonable way to introduce Rust, though if we can find a better way to begin then great. |
I like this. 2014-04-10 8:33 GMT+08:00 bill-myers notifications@github.com:
by Liigo, http://blog.csdn.net/liigo/ |
Another problem with C++ is it's hard to get an example with a problem that can be easily explained to non-C++ users, but is also convincing to C++ users. Anything too simplistic is basically a strawman, and will cause ridicule/questioning from experienced C++-ers (and did; a while ago someone sent an email to the mailing list). Anything too complicated is probably pointless, it's just wasted space for people who don't know C++ (or it would require inflating the document with a detailed explanation about the problem(s) in the C++, wasting the "30 minute" time budget on things that are not Rust). On C++ specifically, there's the Rust for C++ programmers guide, which could be "upgraded" to include a little on how Rust addresses some common memory-safety problems in C++ (and moved in tree: #12100. I would do this myself, but I don't think I know enough C++ to update it effectively). |
I will also say that this is (from my own metrics) far and away the most popular thing about Rust I've ever written. |
I should have sold this better in the OP. This is an excellent piece of introductory writing about Rust that is simple and intriguing, with a goal of giving the new user an idea of whether Rust is appropriate to them. It hints that there's a lot of cool stuff to learn if they just keep diving deeper. I'm particularly happy with the sequence of concurrency examples. There may be improvements to be made yet, and we can do that later, but this is a great start. Here's what I'm planning to do with Rust's introductory documentation:
|
👍 😍 |
I'm in favour of landing this as is, although maybe a disclaimer about the C++ examples wouldn't go amiss (even just "these examples are a work-in-progress & are known to not be idiomatic C++" or something, to try to avoid people getting upset about them... although maybe this will just attract attention and have the opposite effect). |
@@ -7,6 +7,7 @@ | |||
li {list-style-type: none; } | |||
</style> | |||
|
|||
* [A 30-minute Intro to Rust](intro.html) (read this first) |
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.
read this first
is probably unnecessary since a/ it's the first thing in the list b/ it is named "intro".
Addressed @adrientetar and @huonw's comments in followup. |
This is intended to be the first thing somebody new to the language reads about Rust. It is supposed to be simple and intriguing, to give the user an idea of whether Rust is appropriate for them, and to hint that there's a lot of cool stuff to learn if they just keep diving deeper. I'm particularly happy with the sequence of concurrency examples.
😍 |
This is intended to be the first thing somebody new to the language reads about Rust. It is supposed to be simple and intriguing, to give the user an idea of whether Rust is appropriate for them, and to hint that there's a lot of cool stuff to learn if they just keep diving deeper.
I'm particularly happy with the sequence of concurrency examples.