Skip to content

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

Merged
merged 17 commits into from
Jun 27, 2014
Merged

Hello cargo #15183

merged 17 commits into from
Jun 27, 2014

Conversation

steveklabnik
Copy link
Member

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.


## Hello, world!

Now that you have Rust installed, let's write your first Rust program. It's
Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member

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. :)

Copy link
Member Author

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.'

@sinistersnare
Copy link
Contributor

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.

@sinistersnare
Copy link
Contributor

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...

@steveklabnik
Copy link
Member Author

@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:

  1. I thought reviews from people other than @huonw would come much more quickly, and that the previous ones would be waiting on bors or merged already.
  2. Small iterations lead to better feedback. If this was one 'guide' PR that didn't get merged for months, the discussion would be impossible to follow.

@emberian
Copy link
Member

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!
Copy link
Contributor

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

Copy link
Member Author

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.

@sinistersnare
Copy link
Contributor

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.
Copy link
Contributor

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)

Copy link
Member Author

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.

@steveklabnik
Copy link
Member Author

I was wondering about the multiples thing myself. I had planned on pinging the team again tomorrow to talk about it.

@huonw
Copy link
Member

huonw commented Jun 26, 2014

I do not agree that Rust is visited by newbies, maybe people without low level experience, but people who understand what "Hello, World" is

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.

@steveklabnik
Copy link
Member Author

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/staticly/statically/

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 00ae648

How could I forsake `rustdoc`? 😅

Thanks @huonw.
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 ❤️
@steveklabnik
Copy link
Member Author

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

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.

Copy link
Member Author

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.

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.

Copy link
Member Author

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

@brson
Copy link
Contributor

brson commented Jun 27, 2014

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.

@steveklabnik
Copy link
Member Author

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. 😄

@steveklabnik steveklabnik mentioned this pull request Jun 27, 2014
@huonw
Copy link
Member

huonw commented Jun 27, 2014

(Travis failed.)

@steveklabnik
Copy link
Member Author

But only on one version of LLVM?

---- _7 stdout ----

<anon>:7:5: 7:9 error: expected one of `;`, `}` but found `name`

<anon>:7 name = "hello_world"

^~~~

task '_7' failed at 'Box<Any>', /home/travis/build/rust-lang/rust/src/libsyntax/diagnostic.rs:86

It looks like this is in 'docs intro'?


Put this inside:

```
Copy link
Member

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

@huonw
Copy link
Member

huonw commented Jun 27, 2014

Re the LLVM versions:

[11:56:12] <huon> acrichto: what's LLVM 3.3 travis thing for? AFAICT it's building no code?
[11:56:29] <acrichto> huon: look at the master builds instead of PRs
[11:56:40] <acrichto> only 3.4 runs with PRs
[11:56:48] <acrichto> merges into master run 3.3 and 3.4

@steveklabnik
Copy link
Member Author

@huonw updated.

@brson can I get another r? I'm assuming @bors will fail on that other one.

bors added a commit that referenced this pull request Jun 27, 2014
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.
@bors bors closed this Jun 27, 2014
@bors bors merged commit 6bfbc35 into rust-lang:master Jun 27, 2014
@steveklabnik steveklabnik deleted the hello_cargo branch June 27, 2014 09:24
bors added a commit that referenced this pull request Jun 27, 2014
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.