Skip to content

Guide: articulate the advantages of ownership over garbage collection. #18176

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 1 commit into from
Oct 25, 2014

Conversation

jkleint
Copy link

@jkleint jkleint commented Oct 20, 2014

Explain the primary disadvantage of garbage collection is runtime
overhead and unpredictable pauses. Elucidate where the name "race
condition" comes from. Emphasize that Rust can guarantee your code is
free of race conditions and other memory errors, with no runtime
overhead.

cc @steveklabnik

borrowed from you, you must not have lent out that pointer to anyone else.
is immutable, then there are no problems. But if it's mutable, the result of
changing it can vary unpredictably depending on who happens to access it first,
called a **race condition**. To avoid this, if someone wants to mutate
Copy link
Member

Choose a reason for hiding this comment

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

can we make this 'which is called', please?

@steveklabnik
Copy link
Member

Thank you! Just one or two little nits.

Explain the primary disadvantage of garbage collection is runtime
overhead and unpredictable pauses.  Elucidate where the name "race
condition" comes from.  Emphasize that Rust can guarantee your code is
free of race conditions and other memory errors, with no runtime
overhead.
@jkleint jkleint force-pushed the guide-borrow-wording branch from 4f07eff to f0b7065 Compare October 21, 2014 13:10
@jkleint
Copy link
Author

jkleint commented Oct 21, 2014

Good point! Here you go.

@alexcrichton
Copy link
Member

r? @steveklabnik

@steveklabnik
Copy link
Member

I am on mobile so this will get screwed up, r=me

bors added a commit that referenced this pull request Oct 25, 2014
Explain the primary disadvantage of garbage collection is runtime
overhead and unpredictable pauses.  Elucidate where the name "race
condition" comes from.  Emphasize that Rust can guarantee your code is
free of race conditions and other memory errors, with no runtime
overhead.

cc @steveklabnik
rules are broken. If our program compiles successfully, Rust can guarantee it
is free of data races and other memory errors, and there is no runtime overhead
for any of this. The borrow checker works only at compile time. If the borrow
checker did find a problem, it will report a **lifetime error**, and your
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this is correct (cc @nikomatsakis).
"Lifetime errors" come from regionck, which infers appropriate lifetimes and enforces their coherence.
The borrowck produces, well, borrow errors.

Copy link
Member

Choose a reason for hiding this comment

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

I don't think it is particularly important to be too pedantic about the internal compiler passes, but maybe this sentence could be rephrased to just "it will report an error and your program will refuse to compile".

Copy link
Member

Choose a reason for hiding this comment

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

Well, they are two different compiler passes because they have different jobs, and produce different errors.
Calling borrow errors "lifetime errors" is plain wrong, AFAIK they don't even mention lifetimes, the only conceptual link is that borrows are determined by lifetimes.
And it propagates the misconception that the borrow checker assigns lifetimes or gives errors about them - does not help explaining errors or tracking them down at all.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think it is particularly important to be too pedantic about the internal compiler passes, but maybe this sentence could be rephrased to just "it will report an error and your program will refuse to compile".

Agreed.

@bors bors closed this Oct 25, 2014
@bors bors merged commit f0b7065 into rust-lang:master Oct 25, 2014
@jkleint jkleint deleted the guide-borrow-wording branch October 26, 2014 20:36
steveklabnik added a commit to steveklabnik/rust that referenced this pull request Oct 27, 2014
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.

7 participants