Skip to content
This repository has been archived by the owner on Sep 30, 2020. It is now read-only.

RWIB Mission 7: FAQ fixes #181

Closed
brson opened this issue Aug 28, 2015 · 23 comments
Closed

RWIB Mission 7: FAQ fixes #181

brson opened this issue Aug 28, 2015 · 23 comments

Comments

@brson
Copy link
Contributor

brson commented Aug 28, 2015

Link.

The FAQs have
more-or-less been bitrotting since the inception of the project. They
are only slightly better than useless.

Start a thread on users.rlo asking for people to write boths Q's and
A's. Throw away the 3 existing FAQs and write a single new one. Put
this one on the website, linked from the doc
page
.

Q's

Why is the Rust [HashMap] so slow?

@alilleybrinker
Copy link
Contributor

One thing to note is that some of the material in the existing FAQs is likely worth preserving, although it should be restructured into an actual question-and-answer style. The material needs to be refreshed in many cases, but it shouldn't be removed completely.

I am happy to go through the existing material and update it if that's something we'd like to have done.

@brson
Copy link
Contributor Author

brson commented Aug 31, 2015

@AndrewBrinker yes, I agree. Some of the information is still useful, and refreshing what already exists would be a good starting point.

@alilleybrinker
Copy link
Contributor

Per the discussion here, I have begun work on a new FAQ page.

At the moment I am largely just moving over content from the existing FAQ pages. I will then go through and attempt to organize and improve what we have.

@Havvy
Copy link
Contributor

Havvy commented Sep 2, 2015

A good question I see asked frequently: What are the weaknesses of Rust?

@alilleybrinker
Copy link
Contributor

@Havvy: Absolutely. I'll add that to the list. The answer is going to be something to put serious thought into. It may be something to take to the community and solicit some thoughts on.

@alilleybrinker
Copy link
Contributor

Okay. All the usable questions and answers from the existing FAQs have been moved over and updated where necessary. A basic design has also been put together. As I see it, the things remaining to do are:

  • Solicit questions from the community (http://users.rust-lang.org and http://reddit.com/r/rust are the two places I intend to start).
  • Write answers to the most common questions.
  • Review all the answers in the FAQ and make sure they are correct for the latest version of Rust.

@Havvy
Copy link
Contributor

Havvy commented Sep 4, 2015

Asking on Hacker News and the Twitter account would also possibly help.

@alilleybrinker
Copy link
Contributor

Okay, a thread soliciting input for the new FAQ has been posted to:

It may also be good to solicit feedback on this through the official Rust Twitter account, which I believe @steveklabnik runs.

Let me know if there's anywhere else this should be posted.

@alilleybrinker
Copy link
Contributor

Based on the responses so far, here are the possible questions. I am not necessarily going to include all of these, but each of them will receive consideration for the FAQ:

  • Why is Rust's HashMap so slow?
  • Why doesn't Rust support try and catch / Why no exceptions? (3 votes)
  • Why can't I compare floats?
  • Why the split between Eq/PartialEq and Ord/PartialOrd?
  • Why curly braces? Why can't everything be like Haskell/Python?
  • Why lifetimes? (2 votes)
  • What's the deal with unwrap() everywhere?
  • I already write perfect C++. What does Rust give me?
  • Why is the lifetime syntax the way it is?
  • Why do I get an error when I try to run example code that uses the try! macro?
  • Can I use unstable features in the beta or stable channel?
  • Can I run benchmarks using test::Bencher on the beta or stable channel?
  • How can I convert a String or Vec<T> to a slice (&str and &[T])?
  • How can I convert from &str to String?
  • How can I join a Vec (or an array) of strings into a single string? (2 votes)
  • How can I convert a scalar value to a different numeric type?
  • How can I iterate over a Vec<T> without moving/consuming it?
  • How can I read or write numeric types like i32 or f64 in big-endian or little-endian format in a file or other byte stream?
  • How can I implement a graph or other data structure that contains cycles
  • How can I define a struct that contains a pointer to its owner, or to one of its own fields?
  • How can I convert a C-style enum to an integer, or vice-versa?
  • Where do I report issues in the Rust documentation?
  • How do I read a file into a String?
  • How do I split a String into lines?
  • How can I make an HTTP request?
  • How can I write a GUI application in Rust? (2 votes)
  • How can I parse JSON/XML? (2 votes)
  • What does it mean to "consume a value"?
  • What is the difference between consuming and moving/taking ownership?
  • How do I return a borrow to something I created from a function?
  • How do I return a closure from a function?
  • Who is using Rust?
  • In which projects is Mozilla using Rust?
  • Why when I pass a struct to a function the compiler says it's been moved and I can't use it anymore, when the same doesn't happen for integers?
  • When are lifetimes required to be defined?
  • Why can't the compiler find modules from an imported crate?
  • When is it possible to avoid writing *?
  • How do deref coercions work?
  • Can I override operators? Which ones and how?
  • How can I implement something like struct X { static int X; }; in Rust?
  • What examples are there of large Rust projects?
  • Why is there no literal syntax for dictionaries like in Python, Ruby, Swift, etc?
  • I can leave out parentheses on if conditions, why do I have to put brackets around single line blocks? Why is the C style not allowed?
  • Why does Rust not have the ? and ! like in Swift?
  • Why do I have to declare module files with mod at the top level of the crate, instead of just useing them?
  • Why does Rust not have an ABI like C does, and why do I have to annotate things with extern?
  • Why is my program compiled with cargo build slow?
  • How do I read file input efficiently?
  • How do I memcpy bytes?
  • How do I configure Cargo to use a proxy?
  • How are Go and Rust similar, and how are they different?
  • How can I detect when example code doesn't work because it's for an older version of the language (pre-1.0, usually)?
  • How can I detect when documentation of a library is outdated?
  • Why does storing trait objects in a struct give me a confusing error about Sized?
  • How do you deal with a "Use of moved value" error in match statement on an enum or Option?
  • Why can't the compiler find the method implementation as Trait even through I'm already useing the crate?
  • What are the differences between the different string types?
  • How do I map OO concepts to Rust?
  • What's the different between a function and a closure that doesn't capture any variables?
  • How do I debug Rust programs?
  • What is "monomorphisation" in Rust?
  • How do I view rustdoc documentation for a library my project depends on?
  • How do I build a Windows binary that doesn't display the console window?
  • How I make the console-less binary not crash on panic!?
  • What's the idiomatic way to express platform-specific behavior in Rust?
  • What projects are good examples of idiomatic Rust code?
  • Why can't the compiler infer use declarations for me?
  • rustc said a panic occurred in standard library code. How do I locate the mistake in my code?
  • Is there an easier way to do error handling than having Results everywhere?
  • What are the rules for using self, &self, or &mut self in a method declaration?
  • Should I default to using f32 or f64?
  • gofmt is great. Where's rustfmt?
  • How do I handle configuration of an object with optional parameters?
  • How do I do the equivalent of C++ template specialization in Rust?
  • Can Rust reasonably function without the standard library?
  • How do I do global variables in Rust?
  • Can Rust be used for Android/iOS programming?
  • Can I run my Rust program in a web browser?
  • Can I write a macro to generate identifiers?
  • What are higher-kinded types, why should I want them, and why doesn't Rust have them?
  • Can I write an operating system in Rust?
  • How do I do O(1) character access in a String?
  • How can I set compile-time constants that are defined procedurally (equivalent to constexpr in C++)?
  • Why do I need to type the array size in the array declaration?
  • Can I write a video game in Rust?
  • When is Rc useful?
  • How can I understand the borrow checker?
  • Can I run initialization code that happens before main?
  • How do I do dynamic Rust library loading?
  • Does Rust have type reflection?
  • When should I use an implicit return?
  • Is there a standard 2D+ dimensional vector and shape crate?
  • How do I write an OpenGL app in Rust?
  • Why can't I use f32 or f64 as HashMap keys?
  • How can I interoperate with C++ from Rust, or with Rust from C++?
  • How do I package and archive crates from http://crates.io?
  • What do named type parameters in generic types mean?
  • How does Rust's ownership system related to move semantics in C++?
  • How do Rust traits compare to Haskell typeclasses?
  • Why is Rust compilation slow?
  • Why has Rust changed so much over time?
  • How do I get command line arguments in Rust?
  • How do you write a linked list in Rust?
  • How do I get help with Rust issues?
  • How can I try Rust easily?
  • Why are so many Rust answers on StackOverflow wrong?
  • Why doesn't http://crates.io have namespaces?
  • Why are keywords and names in Rust so short?
  • Why doesn't Rust have inheritance?
  • How do I cross-compile in Rust?
  • What IDE should I use?

This is a lot of questions (112, actually). I am going to be tackling them over the next week or so.

@carols10cents
Copy link
Member

Hi, not sure if you're still watching the users/reddit/etc threads, but I just thought of another question so I'm adding it as a suggestion here; it gets asked about once a month on the subreddit:

  • What IDE should I use?

Given that IDE support will change over time, http://areweideyet.com/ might be a good place to link to as an answer?

@alilleybrinker
Copy link
Contributor

Yup, that's definitely an important question. I will add it to the list.

@alilleybrinker
Copy link
Contributor

Only 37 out of 132 questions left to be answered!

@brson
Copy link
Contributor Author

brson commented Oct 1, 2015

Wow! I didn't realize you had so much progress already. Where's your branch with the answers?

@alilleybrinker
Copy link
Contributor

Right here: https://github.com/andrewbrinker/rust-www/tree/faq 😄

For now I'm using JavaScript to generate the Table of Contents and make TODOs more noticeable. This is just to avoid having to reorganize the TOC whenever stuff gets reordered. I'll swap it out for straight HTML before anything gets merged.

There are also some styles I've added that will need some review and cleanup. They work well enough for now though.

@alilleybrinker
Copy link
Contributor

Okay, I think I've answered all the questions I can. There are 7 left which I am not sure how to answer:

  1. What projects are good examples of idiomatic Rust code?
  2. How do I package and archive crates from http://crates.io?
  3. Does Rust have type reflection?
  4. rustc said a panic occurred in standard library code. How do I locate the mistake in my code?
  5. How do I build a Windows binary that doesn't display the console window?
  6. How I make the console-less binary not crash on panic!?
  7. How do I do the equivalent of C++ template specialization in Rust?

Here are my thoughts on each:

  1. This may be a good candidate for soliciting answers from the community.
  2. The easiest way I could think of for this would be to periodically grab the latest published version of the crates listed in the index and archive them. If there is a better way, let me know.
  3. I found some material on the Reflect trait, but none of it was super clear, and I don't feel confident doing a write-up.
  4. I've never encountered this particular problem with Rust, and am not sure of the proper way of handling it.
  5. I've never used Rust on Windows, so I am not sure.
  6. Ditto.
  7. I found some material on coherence rules, but nothing that explicitly explained Rust's rules for specialization.

If anyone can point me in the right direction for these, I am happy to do the write-ups.

@eddyb
Copy link
Member

eddyb commented Oct 11, 2015

@AndrewBrinker:
3. The Reflect trait is merely a bound for Any (to prevent using Any on generic type parameters without requiring it in the signature).
All Any can do is type-equality-based downcasting (via TypeId), there is no introspection of types (which is what is usually regarded as "type reflection").
 
4. This is usually caused by .unwrap(). Enabling backtraces (setting the environment variable RUST_BACKTRACE=1) helps a lot, especially in debug mode.
Using an actual debugger can reveal more useful information.
 
7. Not currently possible in Rust, but specialization is coming (see rust-lang/rfcs#1210).

@alilleybrinker
Copy link
Contributor

Thanks! I've added answers for those questions to the FAQ.

@Havvy
Copy link
Contributor

Havvy commented Oct 18, 2015

Can we get the current state of this put up on the site?

@alilleybrinker
Copy link
Contributor

Yup! Sorry about that. I am doing some cleanup right now, and then I'll make a pull request.

@edunham
Copy link
Member

edunham commented Oct 27, 2015

Today I learned about https://old.etherpad-mozilla.org/rust-irc-faq , which might be of use in this mission.

@antoyo
Copy link

antoyo commented Nov 5, 2015

Can we get an answer to this question, please:

Thanks.

@mbrubeck
Copy link
Contributor

mbrubeck commented Nov 6, 2015

Another very frequent question that's not on the list yet:

  • Why does a tiny program like "Hello World" produce such a large executable file?

(Answer: Because rustc links the program statically by default. To link dynamically, use rustc -C prefer-dynamic.)

@brson
Copy link
Contributor Author

brson commented Jan 14, 2016

This is done. I've opened another issue for additional FAQs.

@brson brson closed this as completed Jan 14, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

8 participants