-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
What is the main entry point for execution? Main
or Run
?
#1869
Comments
Note, to offer trade-offs:
One reference: https://en.wikipedia.org/wiki/Entry_point |
Main because it's the main thread IMO. |
I think staying with 'Main' would be better. It is familiar to programmers migrating from C++. Plus, classes that have a 'Run' method aren't uncommon and could cause confusion. 'Main' is unambiguous, especially since in most programs, the 'Main'/'main' name isn't used for any other function. |
We would like to see a proposal discussing the options here and making a recommendation before the leads make a decision. @chandlerc has offered to write one. |
Filed #2004 to document the need for a proposal. |
This comment was marked as off-topic.
This comment was marked as off-topic.
I think main functionn would be better and intuitive as novice learners who have exposure to other languages like c c++, java know it is the entry point in that languages. Also the language influencing this(c ++) is using the same. |
In my opinion, I think the entry point should be either |
Hi all! We understand there are a lot of opinions about the best choice. However, because this is an issue for leads, we want discussion to focus on providing new information, such as advantages or disadvantages that have not yet been mentioned on this thread, or research that can help with a data-based decision. As noted in the second comment, we are aware of what other languages do. If you only want to comment in support of a name (e.g., |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
In Summary: To Counter:
If we already use the term Entry Point to describe the concept and main to reference it in code, should we make the language match the concept? Doing so will also make it more accessible to those new to the language. Propose: Consider:
|
These names suggest that the following exists as well:
Since they don't, these are not good names for the default entry point IMO. Further more, it is the entry-point of the main thread, not the entry-point of the application. Lots of things (can) happen before the entry-point is called. |
Beginners don't know the term "entry point". Beginner programs may contain only one single function (or in languages that insist on it, one single class which holds one single function.) The concept "how does the whatever-it-is-that-runs-your-code know which bit of the code to run?" is not a question that has occurred to them, any more than "which of your heads do you usually wear a hat on?". They may think "I want my application to run" but using that logic to insist that one part of the application be called "run" is not obvious. Words like Entry Point are used by people whose projects have lots of files with lots of classes and functions and understand that one of them should be designated as the starting point. To me the smart move is to be like the other languages they may know or have been exposed to. That argues for "main" to me. |
We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please comment or remove the |
I think the leads have arrived at a decision here. We considered both the name of the entry point for execution and the package name that contains it. Package name: I'll trying to document the rationale, but to be very clear I don't think there was an especially strong rationale for these names over some other alternatives. We had quite a few options that were all fine. Each one had a somewhat different set of tradeoffs, but on balance there wasn't a huge reason to pick this option over another. This is a place where we needed to pick something, and so we did. =] Should we have a named package with the entry point or an unnamed one? Slight preference for named:
Should we have a verb for the entry point? Slight preference for yes, which eliminated
Some other function names were considered but rejected:
Another package name considered was
I believe @zygoloid is working on a proposal that should document all of this. |
Make the preamble of simple programs more ergonomic, by removing the `package Main` from the main package and removing the `package` declaration entirely from the main source file. Imports within a single package no longer need to, and are not permitted to, specify the package name. Partially covers #2001 / #1136. Covers #1869. Supersedes #2265. Addresses design idea #2323. --------- Co-authored-by: Jon Ross-Perkins <[email protected]> Co-authored-by: josh11b <[email protected]>
Reading through the design documents and looking through the explorer implementation, I've noticed a disconnect between the explorer using
Main
versus the design docs usingRun
as the entry point for execution in a Carbon program. I asked in Discord and got some guidance in response:I think it would be great to see a decision made here to motivate cleaning up either the explorer and its test cases or the docs. 🙂
The text was updated successfully, but these errors were encountered: