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

Name of application entry point #2265

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 82 additions & 0 deletions proposals/p2265.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# Name of application entry point

<!--
Part of the Carbon Language project, under the Apache License v2.0 with LLVM
Exceptions. See /LICENSE for license information.
SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-->

[Pull request](https:/carbon-language/carbon-lang/pull/2265)

<!-- toc -->

## Table of contents

- [Abstract](#abstract)
- [Problem](#problem)
- [Background](#background)
- [Proposal](#proposal)
- [Rationale](#rationale)
- [Alternatives considered](#alternatives-considered)
- [Use the name `Run`](#use-the-name-run)

zygoloid marked this conversation as resolved.
Show resolved Hide resolved
<!-- tocstop -->

## Abstract

This proposal presents a bit of background information on entry point names from
other languages and draws the conclusion that Carbon should adopt `Main` as its
entry point name from the little objective information and trends that can be
deduced.

## Problem

While it isn't a pressing need, a standardization on the name of the entry point
will be necessary as execution starts from a consistent and known place.

## Background

Within Carbon community based discussions, the two names that have merited
discussion so far have been `Main` and `Run`.

Overwhelmingly, the majority of mainstream programming languages use a version
of `Main` as their entry point (although capitalization varies based on the
language's standards). Some of the most prominent examples are C, C++, D, Zig,
Rust, Kotlin, Java, C#, Go, and Haskell.

Meanwhile, `Run` seems to be far less common as an application entry point,
although it does see more use as a framework entry point, likely aided by its
place in the English language as a "command" word. Notably it is also used by
Docker to begin running a container process.

## Proposal

Carbon officially adopts the name `Main` for its application entry point.

## Rationale

By going with `Main` the entry point both
[adheres to the principle of least surprise](https:/carbon-language/carbon-lang/blob/trunk/docs/project/goals.md#code-that-is-easy-to-read-understand-and-write)
and provides
[familiarity for experienced C++ developers with a gentle learning curve](https:/carbon-language/carbon-lang/blob/trunk/docs/project/goals.md#interoperability-with-and-migration-from-existing-c-code).

## Alternatives considered

Options for alternatives are limitless although few others are as standardized
or likely to receive support due to familiarity and convention.

Additionally, options representing a more dramatic paradigm shift such as (a)
user defined entry point(s) or similar structural changes have not been
discussed as they are outside of the scope of this proposal.
zygoloid marked this conversation as resolved.
Show resolved Hide resolved

### Use the name `Run`

We considered using the name `Run` instead of `Main`. One motivation for this is
that we typically want function names to be verb phrases rather than noun
phrases. Another is that the entry point function is seldom the main, or most
important, function in the program, so the name `Main` is an anachronism from a
time when programs were much smaller.

However, the benefits of selecting a new name are minor, and the benefits of
following established conventions are more significant, especially given our
goal of familiarity for experienced C++ developers.