Skip to content
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

Proposal for Goals #51

Merged
merged 56 commits into from
Jul 20, 2020
Merged

Proposal for Goals #51

merged 56 commits into from
Jul 20, 2020

Conversation

jonmeow
Copy link
Contributor

@jonmeow jonmeow commented Jun 3, 2020

@jonmeow jonmeow added proposal A proposal WIP labels Jun 3, 2020
@jonmeow jonmeow marked this pull request as draft June 3, 2020 21:04
Copy link

@hfinkel hfinkel left a comment

Choose a reason for hiding this comment

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

Some comments inline...

unnecessarily complex code, and that is okay. We should instead focus on helping
reduce the rate that this occurs accidentally, and enabling tooling and
diagnostics that warn about dangerous or surprising patterns. This takes the
language out of the business of legislating these types of issues.
Copy link

Choose a reason for hiding this comment

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

There area subtlety that might be worth acknowledging here. To what extent does disallowing "bad" code patterns overlap with semantic restrictions designed to enable optimization or enable tooling to detect errors?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How about rephrasing this as "The language should stay out of the business of legislating bad code patterns except where it affects detecting logic or performance errors."?

@chandlerc (FYI)

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, I lik ethe direction here, but I think it might require a bit more of a change. Fundamentally, I think the thing Hal is pointing out that erroneous patterns should still be in-scope to restrict. This section is talking about "bad" things that in some way aren't fundamentally errors, and that's the subtlety that I think Hal is driving at here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just noting: I'm not clear what kind of different wording you might be suggesting. It's been adjusted a little, and if you still have concerns, explicit suggestions may help.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'll suggest an update to this section that I think gets more deeply at the issue raised by Hal here.

write it naturally in Carbon.

**Possible to mechanically source-to-source migrate large segments of
large-scale idiomatic C++ code bases with high fidelity.** We will prioritize
Copy link

Choose a reason for hiding this comment

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

I'm concerned that this goal seems at odds with the goals related to bounded-look-ahead parsing and simple name-lookup rules (which are very important goals). How would we migrate templates that "work" because of ADL or other aspects of C++ name-lookup rules? Do we have some idea that this is a very-small percentage of the overall code of interest? Is it not idiomatic?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There's an aspect here that gets to the prioritization of language goals. Higher priorities may preempt if there are conflicts, or we may find more complex workarounds to make migration work, especially where it does not impact code outside of migration/interop code.

For the case of name lookups, I can imagine migration tooling identifying which C++ APIs a caller is using and, as those APIs are translated to Carbon (or vice-versa), inserts extra wrapper code if default name-lookup would yield a different API being called.

i.e., translating some C++ behavior may result in more complex Carbon code in order to achieve the same logic, possibly leaving it for humans to improve style later if so desired.

We do expect some code won't be possible to migrate automatically, which is where the 2% comes in (albeit as a somewhat arbitrary threshold). Minimally, I'd hope we can get warnings if migrated code should be expected to behave differently, although we probably won't be able to catch every case.

Copy link
Contributor

Choose a reason for hiding this comment

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

FWIW, my stance is that code that happens to work via ADL is very likely non-idiomatic.

But I think there may also be some fallback translation options here, perhaps at a loss of readability.

I do agree that the ranking starts to show a bit of its importance here -- we shouldn't be complicating the name lookup rules just to make the automated translation somewhat cleaner unless this is a massive practical problem... Which I think is unlikely, but I suppose possible. I would at least want to have very clear evidence to support taking on the cost of more complexity in name lookup or similar.

- PPC64LE (Power ISA, 64-bit, Little Endian)
- RV64I (RISC-V 64-bit)

We believe Carbon should strive to support some GPUs, other restricted
Copy link

Choose a reason for hiding this comment

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

We say something here about GPUs, but we don't really say anything about parallelism in general.Talking about the ability to express parallelism, semantically, is perhaps even more important than GPUs in particular. We should aim to allow the expression, semantically, of computational patterns that naturally map onto common accelerator hardware. Then we'll need to decide how to express data movement and locality - work scheduling and placement.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree parallelism should be addressed in some way, although I think the "Code should perform predictably" paragraph above may partly address your concern without addressing common accelerator hardware directly.

What about something like "Common yet complex tasks, e.g., parallel code, should be well-supported in ways that are easy to reason about.", under "Code that is easy to read, understand, and write"? (see changes) Do you have suggestions for other ways to phrase this? I do wonder if that section got a little too abstract in its phrasing.

@chandlerc (FYI)

Copy link
Contributor

Choose a reason for hiding this comment

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

I lean a bit more toward Hal's phrasing, but I'm not sure where to embed that within the document.

Does it make sense to try to add thsi clarity in a follow-up, or to do it here? If here, I'll try to think more precisely to make a constructive suggestion of where it might fit best.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd rather not call out specific software structures, because it seems like a slippery slope (e.g. why only parallelism, and not concurrency or asynchrony?). In any event, doesn't the goal of supporting performance-critical software imply support for parallelism?

Copy link
Contributor

Choose a reason for hiding this comment

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

The performance section doesn't really talk about hardware, and in large part because that's largely covered here.

I'd lean towards calling out the specific software structures that are necessary to program modern, major hardware. This, for example, would differ significantly from language that relies on compilation techniques to translate one programming model into another. Instead, I think this goal needs to anchor Carbon into fairly direct support for the necessary set of programming models to directly target the relevant hardware.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Spoke with Chandler about this, added paragraph mentioning SIMD (may be easiest to comment on the latest revision, may iterate too)

@googlebot googlebot added the cla: yes PR meets CLA requirements according to bot. label Jun 19, 2020
@jonmeow jonmeow added proposal rfc Proposal with request-for-comment sent out and removed WIP labels Jun 22, 2020
@jonmeow jonmeow marked this pull request as ready for review June 24, 2020 18:17
docs/project/goals.md Outdated Show resolved Hide resolved
docs/project/goals.md Outdated Show resolved Hide resolved
docs/project/goals.md Outdated Show resolved Hide resolved
docs/project/goals.md Outdated Show resolved Hide resolved
docs/project/goals.md Outdated Show resolved Hide resolved
docs/project/goals.md Outdated Show resolved Hide resolved
docs/project/goals.md Outdated Show resolved Hide resolved
docs/project/goals.md Outdated Show resolved Hide resolved
docs/project/goals.md Outdated Show resolved Hide resolved
proposals/p0051.md Outdated Show resolved Hide resolved
Copy link
Contributor

@chandlerc chandlerc left a comment

Choose a reason for hiding this comment

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

I'm really happy with the current state I think going into a decision. My comments and suggestions below are mostly minor. I've also tried to go back and resolve everything that I seemed to be in the critical path of resolving.

For what it's worth, I plan to affirm with a rationale that having the explicit exposition of our goals, how we make tradeoffs between them within the language design, and some indications of success will be necessary for the project to remain cohesive and effective at charting out a viable future path for C++.

docs/project/goals.md Outdated Show resolved Hide resolved

Our priority OS platforms are:

- Linux
Copy link
Contributor

Choose a reason for hiding this comment

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

FWIW, I would agree with "Common Linux distributions" but I'm not sure that the distinction between that and "Linux", or the fact that "Android" is in some senses a Linux-derived OS, really matters much to most readers. I'd be happy either way there.

Actually, what about something more direct:

"Linux (including common distributions, Android, and ChromeOS)"?

In particular this would be nicer IMO as it gives a single entry for the family, similar to the Apple-based OSes.

docs/project/principles/success_criteria.md Outdated Show resolved Hide resolved
docs/project/principles/success_criteria.md Outdated Show resolved Hide resolved
Comment on lines 127 to 128
likely be expanded by automation.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd not say "Carbon will not support C++ exceptions". I think the interop and migration layer might have a story around exceptions. But I agree w/ the rest of this, maybe just focus there.

@chandlerc chandlerc changed the base branch from master to trunk July 2, 2020 03:21
jonmeow and others added 4 commits July 6, 2020 14:18
Co-authored-by: Chandler Carruth <chandlerc@gmail.com>
Co-authored-by: austern <austern@google.com>
@sidney13 sidney13 added needs decision and removed proposal rfc Proposal with request-for-comment sent out labels Jul 6, 2020
docs/project/goals.md Outdated Show resolved Hide resolved
Co-authored-by: Richard Smith <richard@metafoo.co.uk>

Our goal is to support software where its performance with respect to some set
of resource constraints is critical to its successful operation. This
overarching goal can be decomposed into a few specific aspects.
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want to say anything about "reasonably fast by default" or "favors constructs that can be compiled to efficient code" or something like that? It was the sort of statement I just assumed was in the goals until I reread this section. The way this is written now, we could create a slow language as long as it was predictable and had an inline assembly escape hatch that was painful to use and hence rarely used.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

TODO in #106

Note though, I don't think this is an issue right now due to "leave no room for a lower level language" -- inline ASM is still breaking the "rules and structure of Carbon". Arguably it may be unavoidable, but I think the implications should address most of your concern, could maybe just be more explicit.

Comment on lines +327 to +328
> new tools has a higher cost than many people
> appreciate."—[John Carmack](https://twitter.com/id_aa_carmack/status/989951283900514304)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
> new tools has a higher cost than many people
> appreciate."[John Carmack](https://twitter.com/id_aa_carmack/status/989951283900514304)
> new tools has a higher cost than many people appreciate."
> [John Carmack](https://twitter.com/id_aa_carmack/status/989951283900514304)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is an emdash, so the current setup is appropriate per style. There's been a suggestion to change project style to deviate from the developer guide, but same as there, I'd rather handle style deviations separate from the proposal, to avoid ratholing on style.

Copy link
Contributor

Choose a reason for hiding this comment

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

Comment on lines +330 to +340
**Focus on encouraging appropriate usage of features rather than restricting
misuse.** Adding arbitrary restrictions to prevent misuse of otherwise general
features of the language can create problems when they end up interfering with
unexpected or rare but still appropriate usages. Instead, Carbon should focus on
enabling appropriate and effective usage of features, and creating incentives
around those. What seems initially like a "misuse" of a feature may be critical
for some rare or future use case. Put differently, we will not always be able to
prevent developers from misusing features or writing unnecessarily complex code,
and that is okay. We should instead focus on helping reduce the rate that this
occurs accidentally, and enabling tooling and diagnostics that warn about
dangerous or surprising patterns.
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this arguing for uniform & general language rules instead of trying to add exceptions and edge cases? Perhaps some of the argument is that usability includes making the language "simple" in the sense of "less to know to understand"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't view the argument that way. I view it as more based in a concern that Carbon could identify "bad code" structures, and block them, to the loss of complex code that actually needs the structures for performance.

An example might be templates vs generics. We expect generics to be simpler. Rather than blocking use of templates in places we deem inappropriate, we should focus on encouraging use of generics. This is actually the opposite of arguing for simplicity, as the other structures exist and users implicitly need to know when to (or particularly not to) use them.

Simple code is better addressed by the next item, "clearly and simply specified"

Copy link
Contributor

Choose a reason for hiding this comment

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

In general, I find this paragraph among the weakest in this whole document, and I struggle to make sense of what it is trying to say or how it would be applied.

docs/project/goals.md Outdated Show resolved Hide resolved
Comment on lines +363 to +364
manageable. This reduces bugs, and will in most cases make the features easier
to understand.
Copy link
Contributor

Choose a reason for hiding this comment

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

"... and the resulting performance more predictable"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Adding as a TODO; #106

docs/project/goals.md Show resolved Hide resolved
reproducing exact C++ semantics even if bizarre, even this is not guaranteed and
improving on it is not a goal. Migration support will prioritize code that
adheres to reasonable C++ best practices, such as avoiding undefined behavior,
and having reasonable test coverage that passes under sanitizers.
Copy link
Contributor

Choose a reason for hiding this comment

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

Wording nit: tests are the thing that pass under sanitizers, not coverage

Copy link
Contributor Author

Choose a reason for hiding this comment

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

TODO work on phrasing; #106

docs/project/goals.md Outdated Show resolved Hide resolved
docs/project/goals.md Outdated Show resolved Hide resolved
proposals/p0051.md Outdated Show resolved Hide resolved
jonmeow and others added 2 commits July 8, 2020 15:36
Co-authored-by: josh11b <josh11b@users.noreply.github.com>
Co-authored-by: josh11b <josh11b@users.noreply.github.com>
@sidney13 sidney13 self-requested a review July 16, 2020 03:55
@jonmeow jonmeow added proposal accepted Decision made, proposal accepted and removed needs decision labels Jul 20, 2020
@jonmeow jonmeow dismissed stale reviews from geoffromer and chandlerc July 20, 2020 21:05

Proposal accepted, and believe concerns have been addressed.

@jonmeow jonmeow merged commit f536945 into carbon-language:trunk Jul 20, 2020
@jonmeow jonmeow deleted the proposal-goals branch July 20, 2020 21:15
jonmeow added a commit that referenced this pull request Jul 20, 2020
chandlerc pushed a commit that referenced this pull request Jun 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes PR meets CLA requirements according to bot. proposal accepted Decision made, proposal accepted proposal A proposal
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants