-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Hello cargo #15183
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
Hello cargo #15183
Conversation
|
||
## Hello, world! | ||
|
||
Now that you have Rust installed, let's write your first Rust program. It's |
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.
Just to get some understanding: who is this guide aimed at? People who haven't programmed at all?
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.
As I mentioned previously, no, it is not. However, setup is complex and text is hard. My hundreds of hours teaching has shown a little bit more depth during setup goes a very long way.
This will move faster, now that the next section is actually getting into the language itself.
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.
Ok, cool. I wasn't suggesting you need to change anything, I was just trying to get some understanding of your goals. :)
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.
👍 ❤️
There is such a thing as 'too newbie.'
I feel like Rust as a language is not for beginners so we do not need to baby them about what "Hello World" is and such. |
Also, why are you making different pull reqests or edits/creation of the same file? You can push changes to your branch and this PR will be updated... |
@sinistersnare we have many users who come from dynamically typed languages, and are basically newbies. Over explaining is always better than under explaining. And frankly, I'm making different pull requests for two reasons:
|
I really like the tone and style here, I think this is a good hello world document. |
This brings me to one other point: some people, and somewhat rightfully so, get | ||
very upset when we tell you to `curl | sudo sh`. And they should be! Basically, | ||
when you do this, you are trusting that the good people who maintain Rust | ||
aren't going to hack your computer and do bad things. That's a good instinct! |
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 already have to trust Rust -- there's worse things that could happen, like the update.sh getting half run because your internet connection flaked out.
See http://blog.existentialize.com/dont-pipe-to-your-shell.html
IMHO you should download then execute the script in this guide
curl https://www.rust-lang.org/rustup.sh -o rustup.sh
sudo sh rustup.sh
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.
Yes, we can argue about this kind of thing forever. I'm just following what we already recommend.
I guess if no one else minds the multiple PR thing then OK. I do not agree that Rust is visited by newbies, maybe people without low level experience, but people who understand what "Hello, World" is. Rust is a complex language, and should not be learned by beginners, at least that is how I see it. |
``` | ||
|
||
If you're on Windows and not using PowerShell, the `~` may not work. Consult | ||
the documentation for your shell for more details. |
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.
With all the detail above, throwing a "consult the documentation" in here seems sloppy, though that can be cleaned up later (I assume you aren't a Windows user by the focus of this doc)
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 am not, and would love guidance here. I know PowerShell is on newer Windows, but I'm not sure which ones.
I was wondering about the multiples thing myself. I had planned on pinging the team again tomorrow to talk about it. |
They may understand what Hello world is in their favourite languages, but not necessarily in a AOT compiled language like Rust, if they come from e.g. Python or Ruby. It seems like a perfectly good way to introduce those ideas and test the set-up to me. |
And, to be clear, I will lean MORE towards systems people as I explain the language, and link to concepts more. But in the setup, both audiences matter. |
means that you're calling a macro instead of a normal function. | ||
|
||
Next, `"Hello, world"` is a **string**. Strings are a surprisingly | ||
complicated topic in a systems programming language, and this is a **staticly |
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.
s/staticly/statically/
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.
Fixed in 00ae648
What's funny about this one is that spellcheck caught it, but for some reason didn't give me the right suggestion, so I assumed that it wasn't in my dictionary. Oh well. Thanks @P1start! ❤️
Death to `here`! Thanks @chris-morgan ❤️
Thanks @chris-morgan ❤️
Thanks @chris-morgan ❤️
Thanks @chris-morgan ❤️
Good call, @chris-morgan and @cmr!
Thanks @chris-morgan and @P1start! ❤️
Rebased now that master has those other branches, and a toooooon of little fix commits. Do we have anyone who knows Windows who can chime in here on those bits? |
@cmr rightfully points out that C macros are worse, and share the same name.
@@ -159,7 +160,7 @@ Save the file, and then type this into your terminal window: | |||
|
|||
```{bash} | |||
$ rustc hello_world.rs | |||
$ ./hello_world # on Windows, this is ./hello_world.exe |
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.
In general, in windows command prompt (cmd.exe and I think powershell as well), the current directory is always in the search path so the ./ is unnecessary. And it'd be a backslash instead of a / if you did need to put path components.
Also, the .exe is part of the filename but it (along with .bat and some other less used extensions) are implicit and don't need to be put on.
So from that directory, in cmd, you should just have to type hello_world
.
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.
Does the ./
work though? I've removed the comment, and if both work, we can just leave it the same.
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.
No, the slash would be interpreted very differently in cmd. I think, offhand, it'd treat it as . /hello_world
, which is pretty nonsensical since . is a directory.
In the DOS/Windows world, / is the usual character for the start of a command argument, and it's special cased as such so that you can do like dir/s
(lack of space intentional) to get a recursive directory listing.
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.
Great, thank you. Fixed in aee263c
Thank you, @stormbrew!
Great feedback, all. There's a lot going on here so let's merge and resume in another PR. If you feel some of your feedback hasn't been addressed, please follow up with a PR or in subsequent reviews. |
Right, since I'm doing this daily, we're going to make an effort to merge early, merge often, and we can keep refining, as needed. 😄 |
(Travis failed.) |
But only on one version of LLVM?
It looks like this is in 'docs intro'? |
|
||
Put this inside: | ||
|
||
``` |
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 needs to be
```ignore
or
```toml
Thanks @huonw
Re the LLVM versions:
|
Built on top of #15181. steveklabnik@e527192 is the only new commit, you may want to review that separately. I'm not sure if the car analogy is too glib.
This diff will look better once bors takes care of #15183 @brson and I talked about it, and, if I commit this skeleton, I can submit PRs for each portion, without doing this silly "builds on previous PRs" stuff, and it shouldn't cause conflicts. This lays out what I think the guide should cover, and in what order. I haven't picked a cohesive project yet that shows all this off, but I think this progression of concepts is appropriate.
Built on top of #15181. steveklabnik@e527192 is the only new commit, you may want to review that separately.
I'm not sure if the car analogy is too glib.