<s>
In	O
computer	B-General_Concept
programming	I-General_Concept
,	O
an	O
entry	B-Language
point	I-Language
is	O
the	O
place	O
in	O
a	O
program	O
where	O
the	O
execution	B-General_Concept
of	O
a	O
program	O
begins	O
,	O
and	O
where	O
the	O
program	O
has	O
access	O
to	O
command	B-Application
line	I-Application
arguments	O
.	O
</s>
<s>
To	O
start	O
a	O
program	O
's	O
execution	B-General_Concept
,	O
the	O
loader	B-Operating_System
or	O
operating	B-General_Concept
system	I-General_Concept
passes	O
control	O
to	O
its	O
entry	B-Language
point	I-Language
.	O
</s>
<s>
(	O
During	O
booting	B-Operating_System
,	O
the	O
operating	B-General_Concept
system	I-General_Concept
itself	O
is	O
the	O
program	O
)	O
.	O
</s>
<s>
This	O
marks	O
the	O
transition	O
from	O
load	B-Operating_System
time	I-Operating_System
(	O
and	O
dynamic	O
link	B-Application
time	I-Application
,	O
if	O
present	O
)	O
to	O
run	B-Library
time	I-Library
.	O
</s>
<s>
For	O
some	O
operating	B-General_Concept
systems	I-General_Concept
and	O
programming	O
languages	O
,	O
the	O
entry	B-Language
point	I-Language
is	O
in	O
a	O
runtime	B-Library
library	I-Library
,	O
a	O
set	O
of	O
support	O
functions	O
for	O
the	O
language	O
.	O
</s>
<s>
In	O
other	O
cases	O
,	O
the	O
program	O
may	O
initialize	O
the	O
runtime	B-Library
library	I-Library
itself	O
.	O
</s>
<s>
In	O
simple	O
systems	O
,	O
execution	B-General_Concept
begins	O
at	O
the	O
first	O
statement	O
,	O
which	O
is	O
common	O
in	O
interpreted	B-Application
languages	I-Application
,	O
simple	O
executable	B-Application
formats	I-Application
,	O
and	O
boot	B-Application
loaders	I-Application
.	O
</s>
<s>
In	O
other	O
cases	O
,	O
the	O
entry	B-Language
point	I-Language
is	O
at	O
some	O
other	O
known	O
memory	B-General_Concept
address	I-General_Concept
which	O
can	O
be	O
an	O
absolute	O
address	O
or	O
relative	B-General_Concept
address	I-General_Concept
(	O
offset	B-General_Concept
)	O
.	O
</s>
<s>
Alternatively	O
,	O
execution	B-General_Concept
of	O
a	O
program	O
can	O
begin	O
at	O
a	O
named	O
point	O
,	O
either	O
with	O
a	O
conventional	O
name	O
defined	O
by	O
the	O
programming	O
language	O
or	O
operating	B-General_Concept
system	I-General_Concept
or	O
at	O
a	O
caller-specified	O
name	O
.	O
</s>
<s>
In	O
many	O
C-family	B-Language
languages	I-Language
,	O
this	O
is	O
a	O
function	O
called	O
main	O
;	O
as	O
a	O
result	O
,	O
the	O
entry	B-Language
point	I-Language
is	O
often	O
known	O
as	O
the	O
main	B-Language
function	I-Language
.	O
</s>
<s>
In	O
JVM	B-Language
languages	I-Language
such	O
as	O
Java	B-Language
the	O
entry	B-Language
point	I-Language
is	O
a	O
static	O
method	B-Language
called	O
main	O
;	O
in	O
CLI	B-Language
languages	I-Language
such	O
as	O
C#	B-Application
the	O
entry	B-Language
point	I-Language
is	O
a	O
static	O
method	B-Language
named	O
Main	O
.	O
</s>
<s>
Entry	B-Language
points	I-Language
apply	O
both	O
to	O
source	O
code	O
and	O
to	O
executable	B-Application
files	I-Application
.	O
</s>
<s>
However	O
,	O
in	O
day-to-day	O
software	O
development	O
,	O
programmers	O
specify	O
the	O
entry	B-Language
points	I-Language
only	O
in	O
source	O
code	O
,	O
which	O
makes	O
them	O
much	O
better	O
known	O
.	O
</s>
<s>
Entry	B-Language
points	I-Language
in	O
executable	B-Application
files	I-Application
depend	O
on	O
the	O
application	B-Operating_System
binary	I-Operating_System
interface	I-Operating_System
(	O
ABI	O
)	O
of	O
the	O
actual	O
operating	B-General_Concept
system	I-General_Concept
,	O
and	O
are	O
generated	O
by	O
the	O
compiler	O
or	O
linker	O
(	O
if	O
not	O
fixed	O
by	O
the	O
ABI	O
)	O
.	O
</s>
<s>
Other	O
linked	O
object	B-Application
files	I-Application
may	O
also	O
have	O
entry	B-Language
points	I-Language
,	O
which	O
are	O
used	O
later	O
by	O
the	O
linker	O
when	O
generating	O
entry	B-Language
points	I-Language
of	O
an	O
executable	B-Application
file	I-Application
.	O
</s>
<s>
Entry	B-Language
points	I-Language
are	O
capable	O
of	O
passing	O
on	O
command	O
arguments	O
,	O
variables	O
,	O
or	O
other	O
information	O
as	O
a	O
local	O
variable	O
used	O
by	O
the	O
Main( )	O
method	B-Language
.	O
</s>
<s>
This	O
way	O
,	O
specific	O
options	O
may	O
be	O
set	O
upon	O
execution	B-General_Concept
of	O
the	O
program	O
,	O
and	O
then	O
interpreted	O
by	O
the	O
program	O
.	O
</s>
<s>
In	O
most	O
of	O
today	O
's	O
popular	O
programming	O
languages	O
and	O
operating	B-General_Concept
systems	I-General_Concept
,	O
a	O
computer	B-Application
program	I-Application
usually	O
only	O
has	O
a	O
single	O
entry	B-Language
point	I-Language
.	O
</s>
<s>
In	O
C	B-Language
,	O
C++	B-Language
,	O
D	B-Application
,	O
Zig	B-Application
,	O
Rust	B-Application
and	O
Kotlin	B-Language
programs	O
this	O
is	O
a	O
function	O
named	O
main	O
;	O
in	O
Java	B-Language
it	O
is	O
a	O
static	O
method	B-Language
named	O
main	O
(	O
although	O
the	O
class	O
must	O
be	O
specified	O
at	O
the	O
invocation	O
time	O
)	O
,	O
and	O
in	O
C#	B-Application
it	O
is	O
a	O
static	O
method	B-Language
named	O
Main	O
.	O
</s>
<s>
In	O
many	O
major	O
operating	B-General_Concept
systems	I-General_Concept
,	O
the	O
standard	O
executable	B-Application
format	I-Application
has	O
a	O
single	O
entry	B-Language
point	I-Language
.	O
</s>
<s>
In	O
the	O
Executable	B-Application
and	O
Linkable	O
Format	O
(	O
ELF	O
)	O
,	O
used	O
in	O
Unix	B-Application
and	O
Unix-like	B-Operating_System
systems	I-Operating_System
such	O
as	O
Linux	B-Application
,	O
the	O
entry	B-Language
point	I-Language
is	O
specified	O
in	O
the	O
e_entry	O
field	O
of	O
the	O
ELF	O
header	O
.	O
</s>
<s>
In	O
the	O
GNU	B-Application
Compiler	I-Application
Collection	I-Application
(	O
gcc	B-Application
)	O
,	O
the	O
entry	B-Language
point	I-Language
used	O
by	O
the	O
linker	O
is	O
the	O
_start	O
symbol	O
.	O
</s>
<s>
Similarly	O
,	O
in	O
the	O
Portable	O
Executable	B-Application
format	I-Application
,	O
used	O
in	O
Microsoft	B-Application
Windows	I-Application
,	O
the	O
entry	B-Language
point	I-Language
is	O
specified	O
by	O
the	O
AddressOfEntryPoint	O
field	O
,	O
which	O
is	O
inherited	O
from	O
COFF	O
.	O
</s>
<s>
In	O
COM	O
files	O
,	O
the	O
entry	B-Language
point	I-Language
is	O
at	O
the	O
fixed	O
offset	B-General_Concept
of	O
0100h	O
.	O
</s>
<s>
One	O
exception	O
to	O
the	O
single-entry-point	O
paradigm	O
is	O
Android	B-Application
.	O
</s>
<s>
Android	B-Application
applications	I-Application
do	O
not	O
have	O
a	O
single	O
entry	B-Language
point	I-Language
there	O
is	O
no	O
special	O
main	B-Language
function	I-Language
.	O
</s>
<s>
An	O
occasionally	O
used	O
technique	O
is	O
the	O
fat	O
binary	O
,	O
which	O
consists	O
of	O
several	O
executables	B-Application
for	O
different	O
targets	O
packaged	O
in	O
a	O
single	O
file	O
.	O
</s>
<s>
Most	O
commonly	O
,	O
this	O
is	O
implemented	O
by	O
a	O
single	O
overall	O
entry	B-Language
point	I-Language
,	O
which	O
is	O
compatible	O
with	O
all	O
targets	O
and	O
branches	O
to	O
the	O
target-specific	O
entry	B-Language
point	I-Language
.	O
</s>
<s>
Alternative	O
techniques	O
include	O
storing	O
separate	O
executables	B-Application
in	O
separate	O
forks	B-Application
,	O
each	O
with	O
its	O
own	O
entry	B-Language
point	I-Language
,	O
which	O
is	O
then	O
selected	O
by	O
the	O
operating	B-General_Concept
system	I-General_Concept
.	O
</s>
<s>
Historically	O
,	O
and	O
in	O
some	O
contemporary	O
legacy	B-Device
systems	I-Device
,	O
such	O
as	O
VMS	B-Operating_System
and	O
OS/400	B-Application
,	O
computer	B-Application
programs	I-Application
have	O
a	O
multitude	O
of	O
entry	B-Language
points	I-Language
,	O
each	O
corresponding	O
to	O
the	O
different	O
functionalities	O
of	O
the	O
program	O
.	O
</s>
<s>
The	O
usual	O
way	O
to	O
denote	O
entry	B-Language
points	I-Language
,	O
as	O
used	O
system-wide	O
in	O
VMS	B-Operating_System
and	O
in	O
PL/I	B-Language
and	O
MACRO	O
programs	O
,	O
is	O
to	O
append	O
them	O
at	O
the	O
end	O
of	O
the	O
name	O
of	O
the	O
executable	B-Application
image	O
,	O
delimited	O
by	O
a	O
dollar	O
sign	O
( $	O
)	O
,	O
e.g.	O
</s>
<s>
The	O
Apple	B-Device
I	I-Device
computer	I-Device
also	O
used	O
this	O
to	O
some	O
degree	O
.	O
</s>
<s>
For	O
example	O
,	O
an	O
alternative	O
entry	B-Language
point	I-Language
in	O
Apple	B-Device
I	I-Device
's	O
BASIC	O
would	O
keep	O
the	O
BASIC	O
program	O
useful	O
when	O
the	O
reset	O
button	O
was	O
accidentally	O
pushed	O
.	O
</s>
<s>
In	O
general	O
,	O
programs	O
can	O
exit	O
at	O
any	O
time	O
by	O
returning	O
to	O
the	O
operating	B-General_Concept
system	I-General_Concept
or	O
crashing	B-General_Concept
.	O
</s>
<s>
Programs	O
in	O
interpreted	B-Application
languages	I-Application
return	O
control	O
to	O
the	O
interpreter	B-Application
,	O
but	O
programs	O
in	O
compiled	O
languages	O
must	O
return	O
to	O
the	O
operating	B-General_Concept
system	I-General_Concept
,	O
otherwise	O
the	O
processor	O
will	O
simply	O
continue	O
executing	O
beyond	O
the	O
end	O
of	O
the	O
program	O
,	O
resulting	O
in	O
undefined	B-Language
behavior	I-Language
.	O
</s>
<s>
However	O
,	O
in	O
other	O
cases	O
runtimes	B-Library
ensure	O
that	O
programs	O
always	O
terminate	O
in	O
a	O
structured	O
way	O
via	O
a	O
single	O
exit	O
point	O
,	O
which	O
is	O
guaranteed	O
unless	O
the	O
runtime	B-Library
itself	O
crashes	B-General_Concept
;	O
this	O
allows	O
cleanup	O
code	O
to	O
be	O
run	O
,	O
such	O
as	O
atexit	O
handlers	O
.	O
</s>
<s>
This	O
can	O
be	O
done	O
by	O
either	O
requiring	O
that	O
programs	O
terminate	O
by	O
returning	O
from	O
the	O
main	B-Language
function	I-Language
,	O
by	O
calling	O
a	O
specific	O
exit	O
function	O
,	O
or	O
by	O
the	O
runtime	B-Library
catching	O
exceptions	O
or	O
operating	B-General_Concept
system	I-General_Concept
signals	O
.	O
</s>
<s>
In	O
many	O
programming	O
languages	O
,	O
the	O
main	B-Language
function	I-Language
is	O
where	O
a	O
program	O
starts	O
its	O
execution	B-General_Concept
.	O
</s>
<s>
The	O
main	B-Language
function	I-Language
is	O
generally	O
the	O
first	O
programmer-written	O
function	O
that	O
runs	O
when	O
a	O
program	O
starts	O
,	O
and	O
is	O
invoked	O
directly	O
from	O
the	O
system-specific	O
initialization	O
contained	O
in	O
the	O
runtime	B-Device
environment	I-Device
(	O
crt0	B-Language
or	O
equivalent	O
)	O
.	O
</s>
<s>
However	O
,	O
some	O
languages	O
can	O
execute	O
user-written	O
functions	O
before	O
main	O
runs	O
,	O
such	O
as	O
the	O
constructors	O
of	O
C++	B-Language
global	O
objects	O
.	O
</s>
<s>
In	O
other	O
languages	O
,	O
notably	O
many	O
interpreted	B-Application
languages	I-Application
,	O
execution	B-General_Concept
begins	O
at	O
the	O
first	O
statement	O
in	O
the	O
program	O
.	O
</s>
<s>
A	O
non-exhaustive	O
list	O
of	O
programming	O
languages	O
follows	O
,	O
describing	O
their	O
way	O
of	O
defining	O
the	O
main	O
entry	B-Language
point	I-Language
:	O
</s>
<s>
In	O
APL	B-Language
,	O
when	O
a	O
workspace	O
is	O
loaded	O
,	O
the	O
contents	O
of	O
"	O
quad	O
LX	O
"	O
(	O
latent	O
expression	O
)	O
variable	O
is	O
interpreted	O
as	O
an	O
APL	B-Language
expression	O
and	O
executed	O
.	O
</s>
<s>
In	O
C	B-Language
and	O
C++	B-Language
,	O
the	O
function	O
prototype	O
of	O
the	O
main	B-Language
function	I-Language
looks	O
like	O
one	O
of	O
the	O
following	O
:	O
</s>
<s>
Main	B-Language
function	I-Language
looks	O
like	O
entry	B-Language
point	I-Language
for	O
application	O
programmers	O
(	O
the	O
application	O
's	O
entry	B-Language
point	I-Language
or	O
main	O
entry	B-Language
point	I-Language
)	O
.	O
</s>
<s>
System	O
programming	O
reveals	O
more	O
information	O
about	O
the	O
program	O
,	O
and	O
specifies	O
the	O
entry	B-Language
point	I-Language
elsewhere	O
(	O
in	O
initialization	O
procedure	O
,	O
or	O
in	O
reset	O
interrupt	O
vector	O
for	O
standalone	O
programs	O
)	O
.	O
</s>
<s>
The	O
parameters	O
argc	O
,	O
argument	O
count	O
,	O
and	O
argv	O
,	O
argument	O
vector	O
,	O
respectively	O
give	O
the	O
number	O
and	O
values	O
of	O
the	O
program	O
's	O
command-line	B-Application
arguments	O
.	O
</s>
<s>
The	O
names	O
of	O
argc	O
and	O
argv	O
may	O
be	O
any	O
valid	O
identifier	O
in	O
C	B-Language
,	O
but	O
it	O
is	O
common	O
convention	O
to	O
use	O
these	O
names	O
.	O
</s>
<s>
In	O
C++	B-Language
,	O
the	O
names	O
are	O
to	O
be	O
taken	O
literally	O
,	O
and	O
the	O
"	O
void	O
"	O
in	O
the	O
parameter	O
list	O
is	O
to	O
be	O
omitted	O
,	O
if	O
strict	O
conformance	O
is	O
desired	O
.	O
</s>
<s>
Other	O
platform-dependent	O
formats	O
are	O
also	O
allowed	O
by	O
the	O
C	B-Language
and	O
C++	B-Language
standards	O
,	O
except	O
that	O
in	O
C++	B-Language
the	O
return	O
type	O
must	O
always	O
be	O
int	O
;	O
for	O
example	O
,	O
Unix	B-Application
(	O
though	O
not	O
POSIX.1	O
)	O
and	O
Windows	O
have	O
a	O
third	O
argument	O
giving	O
the	O
program	O
's	O
environment	O
,	O
otherwise	O
accessible	O
through	O
getenv	O
in	O
stdlib.h	B-Language
:	O
</s>
<s>
Darwin-based	O
operating	B-General_Concept
systems	I-General_Concept
,	O
such	O
as	O
macOS	B-Application
,	O
have	O
a	O
fourth	O
parameter	O
containing	O
arbitrary	O
OS-supplied	O
information	O
,	O
such	O
as	O
the	O
path	O
to	O
the	O
executing	O
binary	O
:	O
</s>
<s>
The	O
value	O
returned	O
from	O
the	O
main	B-Language
function	I-Language
becomes	O
the	O
exit	B-Operating_System
status	I-Operating_System
of	O
the	O
process	O
,	O
though	O
the	O
C	B-Language
standard	O
only	O
ascribes	O
specific	O
meaning	O
to	O
two	O
values	O
:	O
EXIT_SUCCESS	O
(	O
traditionally	O
0	O
)	O
and	O
EXIT_FAILURE	O
.	O
</s>
<s>
In	O
case	O
a	O
return	O
value	O
is	O
not	O
defined	O
by	O
the	O
programmer	O
,	O
an	O
implicit	O
return	O
0	O
;	O
at	O
the	O
end	O
of	O
the	O
main( )	O
function	O
is	O
inserted	O
by	O
the	O
compiler	O
;	O
this	O
behavior	O
is	O
required	O
by	O
the	O
C++	B-Language
standard	O
.	O
</s>
<s>
By	O
convention	O
,	O
the	O
command-line	B-Application
arguments	O
specified	O
by	O
argc	O
and	O
argv	O
include	O
the	O
name	O
of	O
the	O
program	O
as	O
the	O
first	O
element	O
if	O
argc	O
is	O
greater	O
than	O
0	O
;	O
if	O
a	O
user	O
types	O
a	O
command	O
of	O
"	O
rm	B-Application
file	O
"	O
,	O
the	O
shell	B-Operating_System
will	O
initialise	O
the	O
rm	B-Application
process	O
with	O
argc	O
=	O
2	O
and	O
argv	O
=	O
{	O
"	O
rm	B-Application
"	O
,	O
"	O
file	O
"	O
,	O
NULL}	O
.	O
</s>
<s>
As	O
argv[0]	O
is	O
the	O
name	O
that	O
processes	O
appear	O
under	O
in	O
ps	B-Application
,	O
top	B-Device
etc.	O
,	O
some	O
programs	O
,	O
such	O
as	O
daemons	B-Operating_System
or	O
those	O
running	O
within	O
an	O
interpreter	B-Application
or	O
virtual	B-Architecture
machine	I-Architecture
(	O
where	O
argv[0]	O
would	O
be	O
the	O
name	O
of	O
the	O
host	O
executable	B-Application
)	O
,	O
may	O
choose	O
to	O
alter	O
their	O
argv	O
to	O
give	O
a	O
more	O
descriptive	O
argv[0],	O
usually	O
by	O
means	O
of	O
the	O
exec	B-Operating_System
system	O
call	O
.	O
</s>
<s>
The	O
main( )	O
function	O
is	O
special	O
;	O
normally	O
every	O
C	B-Language
and	O
C++	B-Language
program	I-Language
must	O
define	O
it	O
exactly	O
once	O
.	O
</s>
<s>
In	O
C++	B-Language
,	O
main( )	O
must	O
be	O
in	O
the	O
global	O
namespace	O
(	O
i.e.	O
</s>
<s>
In	O
C++	B-Language
(	O
unlike	O
C	B-Language
)	O
main( )	O
cannot	O
be	O
called	O
recursively	O
and	O
cannot	O
have	O
its	O
address	O
taken	O
.	O
</s>
<s>
When	O
executing	O
a	O
program	O
written	O
in	O
C#	B-Application
,	O
the	O
CLR	O
searches	O
for	O
a	O
static	O
method	B-Language
marked	O
with	O
the	O
.entrypoint	O
IL	O
directive	O
,	O
which	O
takes	O
either	O
no	O
arguments	O
,	O
or	O
a	O
single	O
argument	O
of	O
type	O
string[],	O
and	O
has	O
a	O
return	O
type	O
of	O
void	O
or	O
int	O
,	O
and	O
executes	O
it	O
.	O
</s>
<s>
Command-line	B-Application
arguments	O
are	O
passed	O
in	O
args	B-Language
,	O
similar	O
to	O
how	O
it	O
is	O
done	O
in	O
Java	B-Language
.	O
</s>
<s>
For	O
versions	O
of	O
Main( )	O
returning	O
an	O
integer	O
,	O
similar	O
to	O
both	O
C	B-Language
and	O
C++	B-Language
,	O
it	O
is	O
passed	O
back	O
to	O
the	O
environment	O
as	O
the	O
exit	B-Operating_System
status	I-Operating_System
of	O
the	O
process	O
.	O
</s>
<s>
Since	O
C	B-Language
#7	O
.1	O
there	O
are	O
four	O
more	O
possible	O
signatures	O
of	O
the	O
entry	B-Language
point	I-Language
,	O
which	O
allow	O
asynchronous	O
execution	B-General_Concept
in	O
the	O
Main( )	O
Method	B-Language
.	O
</s>
<s>
async	O
is	O
required	O
to	O
allow	O
the	O
use	O
of	O
asynchrony	O
(	O
the	O
await	O
keyword	O
)	O
inside	O
the	O
method	B-Language
.	O
</s>
<s>
Clean	B-Operating_System
is	O
a	O
functional	O
programming	O
language	O
based	O
on	O
graph	B-Application
rewriting	I-Application
.	O
</s>
<s>
The	O
initial	O
node	O
is	O
named	O
Start	O
and	O
is	O
of	O
type	O
*	O
World	O
->	O
*	O
World	O
if	O
it	O
changes	O
the	O
world	O
or	O
some	O
fixed	O
type	O
if	O
the	O
program	O
only	O
prints	O
the	O
result	O
after	O
reducing	B-Application
Start	O
.	O
</s>
<s>
One	O
tells	O
the	O
compiler	O
which	O
option	O
to	O
use	O
to	O
generate	O
the	O
executable	B-Application
file	I-Application
.	O
</s>
<s>
ANSI	O
Common	O
Lisp	O
does	O
not	O
define	O
a	O
main	B-Language
function	I-Language
;	O
instead	O
,	O
the	O
code	O
is	O
read	O
and	O
evaluated	O
from	O
top	B-Device
to	O
bottom	O
in	O
a	O
source	O
file	O
.	O
</s>
<s>
However	O
,	O
the	O
following	O
code	O
will	O
emulate	B-Application
a	O
main	B-Language
function	I-Language
.	O
</s>
<s>
In	O
D	B-Application
,	O
the	O
function	O
prototype	O
of	O
the	O
main	B-Language
function	I-Language
looks	O
like	O
one	O
of	O
the	O
following	O
:	O
</s>
<s>
Command-line	B-Application
arguments	O
are	O
passed	O
in	O
args	B-Language
,	O
similar	O
to	O
how	O
it	O
is	O
done	O
in	O
C#	B-Application
or	O
Java	B-Language
.	O
</s>
<s>
For	O
versions	O
of	O
main( )	O
returning	O
an	O
integer	O
,	O
similar	O
to	O
both	O
C	B-Language
and	O
C++	B-Language
,	O
it	O
is	O
passed	O
back	O
to	O
the	O
environment	O
as	O
the	O
exit	B-Operating_System
status	I-Operating_System
of	O
the	O
process	O
.	O
</s>
<s>
Dart	B-Language
(	O
programming	O
language	O
)	O
is	O
a	O
General-purpose	B-Language
programming	O
languagethat	O
is	O
often	O
used	O
for	O
building	O
web	O
and	O
mobile	O
applications	O
.	O
</s>
<s>
Like	O
many	O
other	O
programming	O
languages	O
,	O
Dart	B-Language
has	O
an	O
entry	B-Language
point	I-Language
that	O
serves	O
as	O
the	O
starting	O
point	O
for	O
a	O
Dart	B-Language
program	O
.	O
</s>
<s>
The	O
entry	B-Language
point	I-Language
is	O
the	O
first	O
function	O
that	O
is	O
executed	O
when	O
a	O
program	O
runs	O
.	O
</s>
<s>
In	O
Dart	B-Language
,	O
the	O
entry	B-Language
point	I-Language
is	O
typically	O
a	O
function	O
named	O
main	O
.	O
</s>
<s>
When	O
a	O
Dart	B-Language
program	O
is	O
run	O
,	O
the	O
Dart	B-Language
runtime	B-Library
looks	O
for	O
a	O
function	O
named	O
main	O
and	O
executes	O
it	O
.	O
</s>
<s>
Any	O
Dart	B-Language
code	O
that	O
is	O
intended	O
to	O
be	O
executed	O
when	O
the	O
program	O
starts	O
should	O
be	O
included	O
in	O
the	O
main	B-Language
function	I-Language
.	O
</s>
<s>
Here	O
is	O
an	O
example	O
of	O
a	O
simple	O
main	B-Language
function	I-Language
in	O
Dart	B-Language
:	O
</s>
<s>
In	O
this	O
example	O
,	O
the	O
main	B-Language
function	I-Language
simply	O
prints	O
the	O
text	O
Hello	O
,	O
world	O
!	O
</s>
<s>
This	O
code	O
will	O
be	O
executed	O
automatically	O
when	O
the	O
Dart	B-Language
program	O
is	O
run	O
.	O
</s>
<s>
It	O
is	O
important	O
to	O
note	O
that	O
while	O
the	O
main	B-Language
function	I-Language
is	O
the	O
default	O
entry	B-Language
point	I-Language
for	O
a	O
Dart	B-Language
program	O
,	O
it	O
is	O
possible	O
to	O
specify	O
a	O
different	O
entry	B-Language
point	I-Language
if	O
needed	O
.	O
</s>
<s>
This	O
can	O
be	O
done	O
using	O
the	O
@pragma	O
(	O
"	O
vm:entry-point	O
"	O
)	O
annotation	O
in	O
Dart	B-Language
.	O
</s>
<s>
However	O
,	O
in	O
most	O
cases	O
,	O
the	O
main	B-Language
function	I-Language
is	O
the	O
entry	B-Language
point	I-Language
that	O
should	O
be	O
used	O
for	O
Dart	B-Language
programs	O
.	O
</s>
<s>
FORTRAN	B-Application
does	O
not	O
have	O
a	O
main	O
subroutine	O
or	O
function	O
.	O
</s>
<s>
Instead	O
a	O
PROGRAM	O
statement	O
as	O
the	O
first	O
line	O
can	O
be	O
used	O
to	O
specify	O
that	O
a	O
program	O
unit	O
is	O
a	O
main	B-Language
program	I-Language
,	O
as	O
shown	O
below	O
.	O
</s>
<s>
Some	O
versions	O
of	O
Fortran	B-Application
,	O
such	O
as	O
those	O
on	O
the	O
IBM	B-Application
System/360	I-Application
and	O
successor	O
mainframes	O
,	O
do	O
not	O
support	O
the	O
PROGRAM	O
statement	O
.	O
</s>
<s>
Many	O
compilers	O
from	O
other	O
software	O
manufacturers	O
will	O
allow	O
a	O
fortran	B-Application
program	O
to	O
be	O
compiled	O
without	O
a	O
PROGRAM	O
statement	O
.	O
</s>
<s>
In	O
these	O
cases	O
,	O
whatever	O
module	O
that	O
has	O
any	O
non-comment	O
statement	O
where	O
no	O
SUBROUTINE	O
,	O
FUNCTION	O
or	O
BLOCK	O
DATA	O
statement	O
occurs	O
,	O
is	O
considered	O
to	O
be	O
the	O
Main	B-Language
program	I-Language
.	O
</s>
<s>
Using	O
GNAT	B-Language
,	O
the	O
programmer	O
is	O
not	O
required	O
to	O
write	O
a	O
function	O
named	O
main	O
;	O
a	O
source	O
file	O
containing	O
a	O
single	O
subprogram	O
can	O
be	O
compiled	O
to	O
an	O
executable	B-Application
.	O
</s>
<s>
The	O
binder	O
will	O
however	O
create	O
a	O
package	O
ada_main	O
,	O
which	O
will	O
contain	O
and	O
export	O
a	O
C-style	O
main	B-Language
function	I-Language
.	O
</s>
<s>
There	O
is	O
no	O
way	O
to	O
access	O
arguments	O
or	O
a	O
return	O
code	O
outside	O
of	O
the	O
standard	O
library	O
in	O
Go	B-Application
.	O
</s>
<s>
These	O
can	O
be	O
accessed	O
via	O
os.Args	O
and	O
os.Exit	O
respectively	O
,	O
both	O
of	O
which	O
are	O
included	O
in	O
the	O
"	O
os	O
"	O
package	O
.	O
</s>
<s>
A	O
Haskell	B-Language
program	O
must	O
contain	O
a	O
name	O
main	O
bound	O
to	O
a	O
value	O
of	O
type	O
IO	B-Application
t	O
,	O
for	O
some	O
type	O
t	O
;	O
which	O
is	O
usually	O
IO	B-Application
(	O
)	O
.	O
</s>
<s>
IO	B-Application
is	O
a	O
monad	O
,	O
which	O
organizes	O
side-effects	O
in	O
terms	O
of	O
purely	B-Application
functional	I-Application
code	O
.	O
</s>
<s>
The	O
result	O
of	O
the	O
computation	O
represented	O
by	O
main	O
is	O
discarded	O
;	O
that	O
is	O
why	O
main	O
usually	O
has	O
type	O
IO	B-Application
(	O
)	O
,	O
which	O
indicates	O
that	O
the	O
type	O
of	O
the	O
result	O
of	O
the	O
computation	O
is	O
(	O
)	O
,	O
the	O
unit	O
type	O
,	O
which	O
contains	O
no	O
information	O
.	O
</s>
<s>
Command	B-Application
line	I-Application
arguments	O
are	O
not	O
given	O
to	O
main	O
;	O
they	O
must	O
be	O
fetched	O
using	O
another	O
IO	B-Application
action	O
,	O
such	O
as	O
System.Environment.getArgs	O
.	O
</s>
<s>
Java	B-Language
programs	O
start	O
executing	O
at	O
the	O
main	O
method	B-Language
of	O
a	O
class	O
,	O
which	O
has	O
one	O
of	O
the	O
following	O
method	B-Language
headings	I-Language
:	O
</s>
<s>
Command-line	B-Application
arguments	O
are	O
passed	O
in	O
args	B-Language
.	O
</s>
<s>
As	O
in	O
C	B-Language
and	O
C++	B-Language
,	O
the	O
name	O
"	O
main( )	O
"	O
is	O
special	O
.	O
</s>
<s>
Java	B-Language
's	O
main	O
methods	O
do	O
not	O
return	O
a	O
value	O
directly	O
,	O
but	O
one	O
can	O
be	O
passed	O
by	O
using	O
the	O
System.exit( )	O
method	B-Language
.	O
</s>
<s>
Unlike	O
C	B-Language
,	O
the	O
name	O
of	O
the	O
program	O
is	O
not	O
included	O
in	O
args	B-Language
,	O
because	O
it	O
is	O
the	O
name	O
of	O
the	O
class	O
that	O
contains	O
the	O
main	O
method	B-Language
,	O
so	O
it	O
is	O
already	O
known	O
.	O
</s>
<s>
Also	O
unlike	O
C	B-Language
,	O
the	O
number	O
of	O
arguments	O
need	O
not	O
be	O
included	O
,	O
since	O
arrays	O
in	O
Java	B-Language
have	O
a	O
field	O
that	O
keeps	O
track	O
of	O
how	O
many	O
elements	O
there	O
are	O
.	O
</s>
<s>
The	O
main	B-Language
function	I-Language
must	O
be	O
included	O
within	O
a	O
class	O
.	O
</s>
<s>
This	O
is	O
because	O
in	O
Java	B-Language
everything	O
has	O
to	O
be	O
contained	O
within	O
a	O
class	O
.	O
</s>
<s>
For	O
instance	O
,	O
a	O
hello	O
world	O
program	O
in	O
Java	B-Language
may	O
look	O
like	O
:	O
</s>
<s>
To	O
run	O
this	O
program	O
,	O
one	O
must	O
call	O
java	B-Language
HelloWorld	O
in	O
the	O
directory	O
where	O
the	O
compiled	O
class	B-Language
file	I-Language
HelloWorld.class	O
)	O
exists	O
.	O
</s>
<s>
Alternatively	O
,	O
executable	B-Application
JAR	B-Language
files	I-Language
use	O
a	O
manifest	O
file	O
to	O
specify	O
the	O
entry	B-Language
point	I-Language
in	O
a	O
manner	O
that	O
is	O
filesystem-independent	O
from	O
the	O
user	O
's	O
perspective	O
.	O
</s>
<s>
In	O
FMSLogo	B-Device
,	O
the	O
procedures	O
when	O
loaded	O
do	O
not	O
execute	O
.	O
</s>
<s>
OCaml	B-Language
has	O
no	O
main	B-Language
function	I-Language
.	O
</s>
<s>
Programs	O
are	O
evaluated	O
from	O
top	B-Device
to	O
bottom	O
.	O
</s>
<s>
Command-line	B-Application
arguments	O
are	O
available	O
in	O
an	O
array	O
named	O
Sys.argv	O
and	O
the	O
exit	B-Operating_System
status	I-Operating_System
is	O
0	O
by	O
default	O
.	O
</s>
<s>
In	O
Pascal	B-Application
,	O
the	O
main	O
procedure	O
is	O
the	O
only	O
unnamed	O
block	O
in	O
the	O
program	O
.	O
</s>
<s>
Because	O
Pascal	B-Application
programs	O
define	O
procedures	O
and	O
functions	O
in	O
a	O
more	O
rigorous	O
bottom-up	O
order	O
than	O
C	B-Language
,	O
C++	B-Language
or	O
Java	B-Language
programs	O
,	O
the	O
main	O
procedure	O
is	O
usually	O
the	O
last	O
block	O
in	O
the	O
program	O
.	O
</s>
<s>
Pascal	B-Application
does	O
not	O
have	O
a	O
special	O
meaning	O
for	O
the	O
name	O
"	O
main	O
"	O
or	O
any	O
similar	O
name	O
.	O
</s>
<s>
Command-line	B-Application
arguments	O
are	O
counted	O
in	O
ParamCount	O
and	O
accessible	O
as	O
strings	O
by	O
ParamStr(n )	O
,	O
with	O
n	O
between	O
0	O
and	O
ParamCount	O
.	O
</s>
<s>
Versions	O
of	O
Pascal	B-Application
that	O
support	O
units	O
or	O
modules	O
may	O
also	O
contain	O
an	O
unnamed	O
block	O
in	O
each	O
,	O
which	O
is	O
used	O
to	O
initialize	O
the	O
module	O
.	O
</s>
<s>
These	O
blocks	O
are	O
executed	O
before	O
the	O
main	B-Language
program	I-Language
entry	B-Language
point	I-Language
is	O
called	O
.	O
</s>
<s>
In	O
Perl	B-Language
,	O
there	O
is	O
no	O
main	B-Language
function	I-Language
.	O
</s>
<s>
Statements	O
are	O
executed	O
from	O
top	B-Device
to	O
bottom	O
,	O
although	O
statements	O
in	O
a	O
BEGIN	O
block	O
are	O
executed	O
before	O
normal	O
statements	O
.	O
</s>
<s>
Command-line	B-Application
arguments	O
are	O
available	O
in	O
the	O
special	O
array	O
@ARGV	O
.	O
</s>
<s>
Unlike	O
C	B-Language
,	O
@ARGV	O
does	O
not	O
contain	O
the	O
name	O
of	O
the	O
program	O
,	O
which	O
is	O
$0	O
.	O
</s>
<s>
In	O
Pike	O
syntax	O
is	O
similar	O
to	O
that	O
of	O
C	B-Language
and	O
C++	B-Language
.	O
</s>
<s>
The	O
execution	B-General_Concept
begins	O
at	O
main	O
.	O
</s>
<s>
Python	B-Language
programs	I-Language
are	O
evaluated	O
top-to-bottom	O
,	O
as	O
is	O
usual	O
in	O
scripting	O
languages	O
:	O
the	O
entry	B-Language
point	I-Language
is	O
the	O
start	O
of	O
the	O
source	O
code	O
.	O
</s>
<s>
Since	O
definitions	O
must	O
precede	O
use	O
,	O
programs	O
are	O
typically	O
structured	O
with	O
definitions	O
at	O
the	O
top	B-Device
and	O
the	O
code	O
to	O
execute	O
at	O
the	O
bottom	O
(	O
unindented	O
)	O
,	O
similar	O
to	O
code	O
for	O
a	O
one-pass	B-Language
compiler	I-Language
,	O
such	O
as	O
in	O
Pascal	B-Application
.	O
</s>
<s>
Alternatively	O
,	O
a	O
program	O
can	O
be	O
structured	O
with	O
an	O
explicit	O
main	B-Language
function	I-Language
containing	O
the	O
code	O
to	O
be	O
executed	O
when	O
a	O
program	O
is	O
executed	O
directly	O
,	O
but	O
which	O
can	O
also	O
be	O
invoked	O
by	O
importing	O
the	O
program	O
as	O
a	O
module	O
and	O
calling	O
the	O
function	O
.	O
</s>
<s>
In	O
this	O
idiom	O
,	O
the	O
call	O
to	O
the	O
named	O
entry	B-Language
point	I-Language
main	O
is	O
explicit	O
,	O
and	O
the	O
interaction	O
with	O
the	O
operating	B-General_Concept
system	I-General_Concept
(	O
receiving	O
the	O
arguments	O
,	O
calling	O
system	O
exit	O
)	O
are	O
done	O
explicitly	O
by	O
library	O
calls	O
,	O
which	O
are	O
ultimately	O
handled	O
by	O
the	O
Python	B-Language
runtime	B-Library
.	O
</s>
<s>
This	O
contrast	O
with	O
C	B-Language
,	O
where	O
these	O
are	O
done	O
implicitly	O
by	O
the	O
runtime	B-Library
,	O
based	O
on	O
convention	O
.	O
</s>
<s>
The	O
QB64	B-Application
language	O
has	O
no	O
main	B-Language
function	I-Language
,	O
the	O
code	O
that	O
is	O
not	O
within	O
a	O
function	O
,	O
or	O
subroutine	O
is	O
executed	O
first	O
,	O
from	O
top	B-Device
to	O
bottom	O
:	O
</s>
<s>
Command	B-Application
line	I-Application
arguments	O
(	O
if	O
any	O
)	O
can	O
be	O
read	O
using	O
the	O
COMMAND$	O
function	O
:	O
</s>
<s>
In	O
Ruby	B-Language
,	O
there	O
is	O
no	O
distinct	O
main	B-Language
function	I-Language
.	O
</s>
<s>
The	O
number	O
and	O
values	O
of	O
command-line	B-Application
arguments	O
can	O
be	O
determined	O
using	O
the	O
ARGV	O
constant	O
array	O
:	O
</s>
<s>
The	O
first	O
element	O
of	O
ARGV	O
,	O
ARGV[0],	O
contains	O
the	O
first	O
command-line	B-Application
argument	O
,	O
not	O
the	O
name	O
of	O
program	O
executed	O
,	O
as	O
in	O
C	B-Language
.	O
The	O
name	O
of	O
program	O
is	O
available	O
using	O
$0	O
or	O
$PROGRAM_NAME	O
.	O
</s>
<s>
Similar	O
to	O
Python	B-Language
,	O
one	O
could	O
use	O
:	O
</s>
<s>
to	O
execute	O
some	O
code	O
only	O
if	O
its	O
file	O
was	O
specified	O
in	O
the	O
ruby	B-Language
invocation	O
.	O
</s>
<s>
In	O
Rust	B-Application
,	O
the	O
entry	B-Language
point	I-Language
of	O
a	O
program	O
is	O
a	O
function	O
named	O
main	O
.	O
</s>
<s>
Additionally	O
,	O
as	O
of	O
Rust	B-Application
1.26.0	O
,	O
the	O
main	B-Language
function	I-Language
may	O
return	O
a	O
Result	O
:	O
</s>
<s>
When	O
run	O
in	O
an	O
Xcode	B-Operating_System
Playground	O
,	O
Swift	B-Application
behaves	O
like	O
a	O
scripting	O
language	O
,	O
executing	O
statements	O
from	O
top	B-Device
to	O
bottom	O
;	O
top-level	O
code	O
is	O
allowed.Cocoa	O
-	O
and	O
Cocoa	B-Operating_System
Touch-based	O
applications	O
written	O
in	O
Swift	B-Application
are	O
usually	O
initialized	O
with	O
the	O
@NSApplicationMain	O
and	O
@UIApplicationMain	O
attributes	O
,	O
respectively	O
.	O
</s>
<s>
Those	O
attributes	O
are	O
equivalent	O
in	O
their	O
purpose	O
to	O
the	O
main.m	O
file	O
in	O
Objective-C	B-Language
projects	O
:	O
they	O
implicitly	O
declare	O
the	O
main	B-Language
function	I-Language
that	O
calls	O
UIApplicationMain( 	O
_:_:_:_	O
:	O
)	O
which	O
creates	O
an	O
instance	O
of	O
UIApplication	O
.	O
</s>
<s>
The	O
following	O
code	O
is	O
the	O
default	O
way	O
to	O
initialize	O
a	O
Cocoa	O
Touch-based	O
iOS	B-Application
app	O
and	O
declare	O
its	O
application	O
delegate	O
.	O
</s>
<s>
In	O
Visual	B-Language
Basic	I-Language
,	O
when	O
a	O
project	O
contains	O
no	O
forms	O
,	O
the	O
startup	O
object	O
may	O
be	O
the	O
Main( )	O
procedure	O
.	O
</s>
<s>
The	O
Command$	O
function	O
can	O
be	O
optionally	O
used	O
to	O
access	O
the	O
argument	O
portion	O
of	O
the	O
command	B-Application
line	I-Application
used	O
to	O
launch	O
the	O
program	O
:	O
</s>
<s>
In	O
Xojo	B-Application
,	O
there	O
are	O
two	O
different	O
project	O
types	O
,	O
each	O
with	O
a	O
different	O
main	O
entry	B-Language
point	I-Language
.	O
</s>
<s>
In	O
both	O
instances	O
,	O
the	O
main	B-Language
function	I-Language
is	O
automatically	O
generated	O
,	O
and	O
cannot	O
be	O
removed	O
from	O
the	O
project	O
.	O
</s>
