Closed clavin closed 1 year ago
Note, to offer trade-offs:
Main
is closer to C++, and may be more intuitive to developers. It also reflects main
use in Java, Python, Rust, and Go.
Run
I think was gaining some support because it's more the action ("run an application"). I'm not sure if much cross-language precedent exists: wikipedia notes Xojo.
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.
Main because it's the main thread IMO.
This by far is the best argument ever. How often have you renamed your thread handlers so in the debugger they appear as this. Main() MessageProcessing() StateProcessing()
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 main
like 90% of the languages or "no function at all" like NodeJS or C#.
It could be specified as an entry point at compile time, in a file or based on the file name like main.carbon
for example.
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., main
), please instead use an emoji reaction (e.g., 👍) on a message.
Call it 'master' for a perfect storm! It's PR...🤷♂️
Call it 'master' for a perfect storm! It's PR...🤷♂️
Is it? maybe it is the reckoning.
Metallica: Master of Puppets (Official Lyric Video) https://www.youtube.com/watch?v=6xjJ2XIbGRk
Sorry just saw a killer Metallica Cover Band.
main Main MAIN other stupid spellings.
Why familiarity? From very early on of coaching greens I have told many. Find the Main Entry Point where execution starts.
Why else Discussions of the main thread versus the other threads do not lose context. https://stackoverflow.com/questions/14593881/any-difference-between-main-thread-and-other-threads
run Run RUN
Be a little different and stand out.
execute Execute EXECUTE
Again mostly to be different
Master MASTER
To start fresh all discussions. What is the Master thread to all threads. Why is the Master thread always responsible for the UI.
The way I see it you either go with main() or something of a revolution. Or you could just go with main and provide a compile option for starters.
Good luck but I think people will continue to comment on this thread.
In Summary: The argument for using main is for historical reasons, similarity, ease of access etc and related to a thread based model. The argument for run is that we 'run' applications.
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: We select a word that is synonymous with the concept "Entry Point".
Consider:
- entry
- begin
- start
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 inactive
label. The long term
label can also be added for issues which are expected to take time.
This issue is labeled inactive
because the last activity was over 90 days ago.
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: Main
Entry function: Run
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 Main
as the function name:
Some other function names were considered but rejected:
Start
-- preferred a word that describes the entire action of the function.Entry
, Entrypoint
-- same problems as Start
combined with being less well discoverable and potentially longer.Exec
or Execute
-- worried about collision with executing some other program versus the current program and with the exec
system call.Another package name considered was Program
, but none of the technical differences were enough to lean in one direction or another. As painter I picked Main
with roughly the following rationale:
Main
for the function name, so it seemed available.main
functions in other languages.Program
.main.carbon
.main
function, it may help them find our version.I believe @zygoloid is working on a proposal that should document all of this.
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. 🙂