-
Notifications
You must be signed in to change notification settings - Fork 340
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @brson (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. The way Github handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
\o/ Woah! So much web site. Thanks. |
Some thoughts while reading through it:
|
Wonderful! This is exactly the input I'm looking for:
Ah, mistake during editing. Fixing now.
Good to know. I've updated my answer accordingly.
Do you know which crate?
Good point. Updated.
Do you have some example code that does this? I'd like to provide an example if I can.
You're right. Fixed.
I agree. I've clarified the language.
Good point. I've updated the answer.
Yup. I copied this answer verbatim from a much older FAQ on the Rust website. It may have been true at one point (I don't know), but you're right that it isn't now.
I've added an answer addressing this.
Good idea. Added.
Yup. Added.
Added, along with a small example of such a function. |
Before anything gets merged I do want to note that four questions remain unanswered and commented out in the source code. This does not necessarily need to block merging, but if someone can answer any of these questions before we merge that would be much appreciated. If not, then afterward works. |
https://crates.io/crates/ordered-float
|
Okay, I've updated it with that information. |
I think this is ready to merge, unless there are concerns about the specialized styling for the page. |
😍 |
|
||
As always, this question is difficult to answer. There's still a lot of work to do on speed, and depending on what you're benchmarking, Rust has variable performance. | ||
|
||
That said, it is an explicit goal of Rust to be as fast as C++ for most things. Language decisions are made with performance in mind, and we want Rust to be as fast as possible. Given that Rust is built on top of LLVM, any performance improvements in it also help Rust become faster. |
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.
"also helps" instead of "also help" I think.
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.
"C++" -> "idiomatic C++" I think.
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.
I’d say “at least as fast”. “as fast as” implies equality.
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.
@brson why is it important to mention "idiomatic"? Is it because on some benchmarks, people use non-idiomatic C++ to win?
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.
That's right. Pedants can easily write horrible C++ code that beats safe
Rust as a counter-argument to performance claims, so we typically qualify
them with 'idiomatic C++'.
On the other hand though, in many cases safe Rust can trounce even
horribly-unsafe C++, and its our prerogative to make strong claims to sell
Rust (I don't mind ruffling feathers a bit). I'll think about it.
On Wed, Nov 18, 2015 at 4:53 AM, Tshepang Lekhonkhobe <
notifications@github.com> wrote:
In faq.md
#202 (comment):
<li><a href="#cross-platform">Cross-Platform</a></li>
<li><a href="#design-patterns">Design Patterns</a></li>
<li><a href="#macros">Macros</a></li>
<li><a href="#other-languages">Other Languages</a></li>
<li><a href="#licensing">Licensing</a></li>
<li><a href="#naming">Naming</a></li>
+
+
+## Performance
+
+#### How fast is Rust?
+
+As always, this question is difficult to answer. There's still a lot of work to do on speed, and depending on what you're benchmarking, Rust has variable performance.
+
+That said, it is an explicit goal of Rust to be as fast as C++ for most things. Language decisions are made with performance in mind, and we want Rust to be as fast as possible. Given that Rust is built on top of LLVM, any performance improvements in it also help Rust become faster.@brson https://github.com/brson why is it important to mention
"idiomatic"? Is it because on some benchmarks, people use non-idiomatic C++
to win?—
Reply to this email directly or view it on GitHub
https://github.com/rust-lang/rust-www/pull/202/files#r45194937.
cc me. We need to advertise this PR very widely, get the whole community's eyes on it. |
Could this be formatted so each question has an anchor, and I can link to a specific section? I imagine needing to link particular questions to new users quite frequently, and it'd be better to include the section in the URL than to tell them "click here and scrolll" |
# Frequently Asked Questions | ||
|
||
This document exists to answer some common questions about the Rust programming language. It is not a complete guide to the language, nor is it a tool for teaching the language. Rather, it exists as a reference to answer oft-repeated questions people in the Rust community encounter, and to clarify some of the design and history of the language. | ||
|
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.
This para explains why this page 'exists' twice (first sentence and third). It's not bad but feels like it could be tightened up. No suggestions offhand.
Obviously things aren't quite done yet. I have some more direct feedback to go over, and I need to address @brson's previous points. But I just want to say that this has been a really great process, and I can't wait to get this thing polished and merged. Thanks for all the help and feedback, everyone. Oh, and no problem @steveklabnik. It's been my pleasure. |
|
||
Rust `for` loops call `into_iter()` (defined on the `IntoIterator` trait) for whatever they're iterating over. Anything implementing the `IntoIterator` trait may be looped over with a `for` loop. `IntoIterator` is implemented for `&Vec` and `&mut Vec`, causing the iterator from `into_iter()` to borrow the contents of the collection, rather than moving/consuming them. The same is true for other standard collections as well. | ||
|
||
If a moving/consuming iterator is desired, write the `for` loop without `&` or `&mut` on the collection. |
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.
You mean "without &
or &mut
in the iteration", right?
(Not "collection", that is)
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.
Yup. Thanks. I've fixed it.
(great job incorporating feedback @AndrewBrinker ; I was especially impressed by the places where I said "oh man this is wrong but I don't know how to fix it" (and I threw up my hands) and you subsequently found a solution, quite quickly!) |
Thanks @pnkfelix! I'm glad you like what I've done. It wouldn't have been possible without all the great feedback from everyone. The current version is much much better than my first draft. It'll be interesting to see how the document evolves over time, and to see what sort of feedback we get once it's up on the site. @brson, I know you have some style changes you'd like made, and that your plan is to wrap this up yourself (I'm guessing squash down all the commits in this PR). Should I incorporate the style changes here, or is that something you'd like to do? Also, I am still working on your big list of thoughts. The deref coercion and higher-kinded types answers have been updated, but the rest still need to be addressed properly. |
Also, I started adding a bunch of missing links to the API docs at @steveklabnik's suggestion, but I'm not finished yet. |
|
||
### When should I use an implicit return? | ||
|
||
Implicit returns are simply a coding style option, and can be used as the final line in a block expression. While early returns require an explicit `return` keyword, any other return can be made implicit according to your preferences or the preferences of your project. In the Rust project itself, the style guidelines lean toward preferring implicit returns. |
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.
I think an explanation of Rust's expression-oriented syntax and value flow would be good for this question. Implicit returns follow naturally from the normal evaluation rules, and mentioning only block expressions doesn't tell the whole story since the final expression might be, say, an if
expression which new users might not be aware is an expression at all. Maybe we could link to a place in the book that describes this.
On the style guideline side, you could note the benefit of using return
only for early returns, so you know normal control and value flow is being interrupted wherever you see it.
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.
Yeah, implicit returns are not mere style. They are a strong convention.
@AndrewBrinker rocks! |
|
||
### Can I use static values across threads without an `unsafe` block? | ||
|
||
Yes, if the type implements `Sync`, doesn't implement `Drop`, and you don't try to mutate the value. |
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.
Mutation is safe if it's synchronized (e.g. Mutex<T>
or AtomicUsize
in a static is fine). Currently you need something like the lazy_static
crate to initialize a Mutex<T>
in a static, but AtomicUsize
statics can be created and mutated in stable Rust with just libstd.
This is shaping up to be quite excellent! Thanks to everyone who's been working so hard on this. 😄 |
Okay, I've now made changes addressing all but the following points of @brson's:
I am also still going through the entire document adding links to the API docs. |
Okay, I've finished adding the links to the API docs, and I've made the correction suggested by @tsion. |
I'll take care of merging the styles. I am going to open one PR that contains all pending website changes. |
My previous points have been addressed to my satisfaction (for the most part, see below), and I'm intending to merge this with the other open PRs and my style changes into one fresh PR for landing. The only remaining big concerns I have about the FAQ are: HKT section, while better, in the first section makes it sound like Rust has HKT by saying that type constructors that exist are KHTs; there's still no Q&A for 'What does "Rust" mean'. I'm happy to address those in follow ups though. |
Thank you everybody for the amazing reviews and @AndrewBrinker for putting it all together. We're almost done. |
This commit is the first draft of a new Frequently Asked Questions (FAQ) page for the Rust website. It provides answers for all but 4 of the 130 questions asked by the community, which can be found on the tracking issue #181.
The answers could use some review, as could the design and organization. I've tried to provide clear, concise answers that more often than not point people to the relevant portion of the Rust book.
Thoughts? Changes?