Empty program: Difference between revisions

From Rosetta Code
Content added Content deleted
 
(34 intermediate revisions by 22 users not shown)
Line 12: Line 12:
=={{header|360 Assembly}}==
=={{header|360 Assembly}}==
Return to caller
Return to caller
<lang 360 Assembly> BR 14
<syntaxhighlight lang="360 assembly"> BR 14
END</lang>
END</syntaxhighlight>
=={{header|6502 Assembly}}==
=={{header|6502 Assembly}}==
===Commodore 64===
===Commodore 64===
<lang 6502asm>org $0801 ;start assembling at this address
<syntaxhighlight lang="6502asm">org $0801 ;start assembling at this address
db $0E,$08,$0A,$00,$9E,$20,$28,$32,$30,$36,$34,$29,$00,$00,$00 ;required init code
db $0E,$08,$0A,$00,$9E,$20,$28,$32,$30,$36,$34,$29,$00,$00,$00 ;required init code
rts ;return to basic</lang>
rts ;return to basic</syntaxhighlight>


===Nintendo Entertainment System===
===Nintendo Entertainment System===
Without an infinite loop the program counter will execute undefined behavior, depending on how "empty" bytes are padded. If we're generous and assume that empty bytes are padded with <code>NOP</code>, eventually the program counter will attempt to execute the interrupt vectors as executable code. If we assume that an "empty program" needs to not crash (even though you really can't tell the difference with nothing on screen), we need a way to "trap" the program counter.
Without an infinite loop the program counter will execute undefined behavior, depending on how "empty" bytes are padded. If we're generous and assume that empty bytes are padded with <code>NOP</code>, eventually the program counter will attempt to execute the interrupt vectors as executable code. If we assume that an "empty program" needs to not crash (even though you really can't tell the difference with nothing on screen), we need a way to "trap" the program counter.


<lang 6502asm>.org $8000 ;usually $8000 but it depends on the mapper.
<syntaxhighlight lang="6502asm">.org $8000 ;usually $8000 but it depends on the mapper.
RESET: ;execution starts here
RESET: ;execution starts here
JMP RESET
JMP RESET
Line 37: Line 37:
dw NMI ;FFFA-FFFB
dw NMI ;FFFA-FFFB
dw RESET ;FFFC-FFFD ;this has to be defined or else the program counter will jump to an unknown location
dw RESET ;FFFC-FFFD ;this has to be defined or else the program counter will jump to an unknown location
dw IRQ ;FFFE-FFFF</lang>
dw IRQ ;FFFE-FFFF</syntaxhighlight>


=={{header|68000 Assembly}}==
=={{header|68000 Assembly}}==
Line 45: Line 45:
After you get to the main program, you'll need to kick the watchdog every frame to prevent the BIOS from resetting the machine. This is done by writing any byte to memory address 0x00300001. Other than that, an endless loop will suffice (assuming you have a proper cartridge header and a vBlank routine that does nothing except check for bios vblank and return.)
After you get to the main program, you'll need to kick the watchdog every frame to prevent the BIOS from resetting the machine. This is done by writing any byte to memory address 0x00300001. Other than that, an endless loop will suffice (assuming you have a proper cartridge header and a vBlank routine that does nothing except check for bios vblank and return.)


<lang 68000devpac>forever:
<syntaxhighlight lang="68000devpac">forever:
MOVE.B D0,$300001
MOVE.B D0,$300001
JMP forever</lang>
JMP forever</syntaxhighlight>


=={{header|8051 Assembly}}==
=={{header|8051 Assembly}}==
Continuously loops.
Continuously loops.
<lang asm>ORG RESET
<syntaxhighlight lang="asm">ORG RESET
jmp $</lang>
jmp $</syntaxhighlight>


=={{header|8086 Assembly}}==
=={{header|8086 Assembly}}==
===Boot Sector Program===
===Boot Sector Program===
<lang asm>main segment
<syntaxhighlight lang="asm">main segment
start:
start:
jmp start ;2 bytes
jmp start ;2 bytes
padding byte 508 dup (90h)
padding byte 508 dup (90h)
bootcode byte 55h,0AAh
bootcode byte 55h,0AAh
main ends</lang>
main ends</syntaxhighlight>


If your assembler assembles the code above as an EXE file, you'll need to use a hex editor to strip the EXE header so that it fits exactly into 512 bytes.
If your assembler assembles the code above as an EXE file, you'll need to use a hex editor to strip the EXE header so that it fits exactly into 512 bytes.
Line 68: Line 68:


===16-Bit x86 for EXE Files===
===16-Bit x86 for EXE Files===
<lang asm>.model small ;.exe file
<syntaxhighlight lang="asm">.model small ;.exe file
.stack 1024 ;this value doesn't matter, I chose this arbitrarily
.stack 1024 ;this value doesn't matter, I chose this arbitrarily
.data
.data
Line 74: Line 74:
.code
.code
mov ax,4C00h
mov ax,4C00h
int 21h ;exit this program and return to MS-DOS</lang>
int 21h ;exit this program and return to MS-DOS</syntaxhighlight>


===32-Bit x86===
===32-Bit x86===
<lang asm>end</lang>
<syntaxhighlight lang="asm">end</syntaxhighlight>


However, if the program needs to exit with an exit code of zero:
However, if the program needs to exit with an exit code of zero:


<lang asm> segment .text
<syntaxhighlight lang="asm"> segment .text
global _start
global _start


Line 88: Line 88:
xor edi, edi
xor edi, edi
syscall
syscall
end</lang>
end</syntaxhighlight>


=={{header|AArch64 Assembly}}==
=={{header|AArch64 Assembly}}==
Simulates system call exit(0). In AArch64, the system call number is passed via x8, and the syscall number for exit is 93.
Simulates system call exit(0). In AArch64, the system call number is passed via x8, and the syscall number for exit is 93.
<syntaxhighlight lang="arm_assembly">.text
<lang ARM_Assembly>.text
.global _start
.global _start


Line 98: Line 98:
mov x0, #0
mov x0, #0
mov x8, #93
mov x8, #93
svc #0</lang>
svc #0</syntaxhighlight>


=={{header|ABAP}}==
=={{header|ABAP}}==
Note that the statement "start-of-selection." is implicitly added. This event block needs to be present in executable programs, it's comparable to the main function in other programming languages.
Note that the statement "start-of-selection." is implicitly added. This event block needs to be present in executable programs, it's comparable to the main function in other programming languages.


<syntaxhighlight lang="abap">
<lang ABAP>
report z_empty_program.
report z_empty_program.
</syntaxhighlight>
</lang>


=={{header|Action!}}==
=={{header|Action!}}==
<syntaxhighlight lang="action!"></syntaxhighlight>
<lang Action!></lang>
{{out}}
{{out}}
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/Empty_program.png Screenshot from Atari 8-bit computer]
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/Empty_program.png Screenshot from Atari 8-bit computer]
Line 114: Line 114:
=={{header|Ada}}==
=={{header|Ada}}==
{{works with|GCC|4.1.2}}
{{works with|GCC|4.1.2}}
<lang ada>procedure Empty is
<syntaxhighlight lang="ada">procedure Empty is
begin
begin
null;
null;
end;</lang>
end;</syntaxhighlight>


=={{header|Agena}}==
=={{header|Agena}}==
Actually nothing is valid code, too.
Actually nothing is valid code, too.
<lang agena></lang>
<syntaxhighlight lang="agena"></syntaxhighlight>


=={{header|Aime}}==
=={{header|Aime}}==
The nil input is a valid program.
The nil input is a valid program.
<lang aime></lang>
<syntaxhighlight lang="aime"></syntaxhighlight>


=={{header|ALGOL 60}}==
=={{header|ALGOL 60}}==
<lang algol60>'BEGIN' 'END'</lang>
<syntaxhighlight lang="algol60">'BEGIN' 'END'</syntaxhighlight>


=={{header|ALGOL 68}}==
=={{header|ALGOL 68}}==
=== Brief form ===
=== Brief form ===
<lang algol68>~</lang>
<syntaxhighlight lang="algol68">~</syntaxhighlight>
=== BOLD form ===
=== BOLD form ===
<lang algol68>SKIP</lang>
<syntaxhighlight lang="algol68">SKIP</syntaxhighlight>


=={{header|ALGOL W}}==
=={{header|ALGOL W}}==
In Algol W, a blank statement is a valid statement and a program is a statement followed by a dot. Hence "." is the smallest valid program.
In Algol W, a blank statement is a valid statement and a program is a statement followed by a dot. Hence "." is the smallest valid program.
<lang algolw>.</lang>
<syntaxhighlight lang="algolw">.</syntaxhighlight>


=={{header|AmigaE}}==
=={{header|AmigaE}}==
<lang amigae>PROC main()
<syntaxhighlight lang="amigae">PROC main()
ENDPROC</lang>
ENDPROC</syntaxhighlight>


=={{header|AppleScript}}==
=={{header|AppleScript}}==
An empty .scpt file is considered the smallest runnable code, but the following would also be acceptable.
An empty .scpt file is considered the smallest runnable code, but the following would also be acceptable.
<lang applescript>return</lang>
<syntaxhighlight lang="applescript">return</syntaxhighlight>


=={{header|Argile}}==
=={{header|Argile}}==
The empty string or file are valid and do nothing.
The empty string or file are valid and do nothing.
<syntaxhighlight lang="argile"></syntaxhighlight>
<lang Argile></lang>


=={{header|ARM Assembly}}==
=={{header|ARM Assembly}}==
===GNU/Linux RaspberryPi===
===GNU/Linux RaspberryPi===
<syntaxhighlight lang="arm_assembly">.text
<lang ARM_Assembly>.text
.global _start
.global _start
_start:
_start:
mov r0, #0
mov r0, #0
mov r7, #1
mov r7, #1
svc #0 </lang>
svc #0 </syntaxhighlight>


===Game Boy Advance===
===Game Boy Advance===
Line 166: Line 166:
The first four bytes of the cartridge header are an unconditional branch instruction to the program's start. Simply duplicate this instruction at that address and voila:
The first four bytes of the cartridge header are an unconditional branch instruction to the program's start. Simply duplicate this instruction at that address and voila:


<lang ARM_Assembly>ProgramStart:
<syntaxhighlight lang="arm_assembly">ProgramStart:
b ProgramStart ;don't do this on a real game boy, you'll drain the batteries faster than usual.</lang>
b ProgramStart ;don't do this on a real game boy, you'll drain the batteries faster than usual.</syntaxhighlight>


Hardware interrupts will not occur if you never enable them, so there is no need to store the interrupt service procedure's address in address $03FFFFFC to prevent a crash. The Game Boy Advance has no "exit" <code>SWI</code> call (the closest is the undocumented hard reset) so this is as close as you can get.
Hardware interrupts will not occur if you never enable them, so there is no need to store the interrupt service procedure's address in address $03FFFFFC to prevent a crash. The Game Boy Advance has no "exit" <code>SWI</code> call (the closest is the undocumented hard reset) so this is as close as you can get.


=={{header|ArnoldC}}==
=={{header|ArnoldC}}==
<lang ArnoldC>IT'S SHOWTIME
<syntaxhighlight lang="arnoldc">IT'S SHOWTIME
YOU HAVE BEEN TERMINATED</lang>
YOU HAVE BEEN TERMINATED</syntaxhighlight>


=={{header|Arturo}}==
=={{header|Arturo}}==
Line 179: Line 179:
A completely empty script is a valid Arturo program.
A completely empty script is a valid Arturo program.


<lang rebol></lang>
<syntaxhighlight lang="rebol"></syntaxhighlight>


=={{header|Asymptote}}==
=={{header|Asymptote}}==
<syntaxhighlight lang="asymptote"></syntaxhighlight>
<lang Asymptote></lang>


=={{header|AutoHotkey}}==
=={{header|AutoHotkey}}==
An empty script would be enough. Adding "#Persistent" makes it persistent.
An empty script would be enough. Adding "#Persistent" makes it persistent.
<lang AutoHotkey>#Persistent</lang>
<syntaxhighlight lang="autohotkey">#Persistent</syntaxhighlight>


=={{header|AutoIt}}==
=={{header|AutoIt}}==
A single comment can be considered a valid program that does nothing.
A single comment can be considered a valid program that does nothing.
<lang AutoIt>;nothing</lang>
<syntaxhighlight lang="autoit">;nothing</syntaxhighlight>


=={{header|Avail}}==
=={{header|Avail}}==
Avail files require a header block (that is generally omitted from the examples here). The shortest valid header would only include the module name, which can be reduced to 1 character, assuming the filename is set to match. For "a.avail", this gives the empty program:
Avail files require a header block (that is generally omitted from the examples here). The shortest valid header would only include the module name, which can be reduced to 1 character, assuming the filename is set to match. For "a.avail", this gives the empty program:
<lang Avail>Module "a"
<syntaxhighlight lang="avail">Module "a"
Body</lang>
Body</syntaxhighlight>
This can be further shortened by removing unambiguous whitespace to:
This can be further shortened by removing unambiguous whitespace to:
<lang Avail>Module"a"Body</lang>
<syntaxhighlight lang="avail">Module"a"Body</syntaxhighlight>
For all practical purposes, this header is useless in any other program. It does not import the standard library "Avail" (or any alternatives), so it has access to no methods, types, or values. Here's a short program capable of output:
For all practical purposes, this header is useless in any other program. It does not import the standard library "Avail" (or any alternatives), so it has access to no methods, types, or values. Here's a short program capable of output:
<lang Avail>Module"a"Uses"Avail"Body Print:"!";</lang>
<syntaxhighlight lang="avail">Module"a"Uses"Avail"Body Print:"!";</syntaxhighlight>
Or with more traditional spacing:
Or with more traditional spacing:
<lang Avail>Module "a"
<syntaxhighlight lang="avail">Module "a"
Uses "Avail"
Uses "Avail"
Body
Body
Print:"!";</lang>
Print:"!";</syntaxhighlight>
Note however that this output is only available as a ''compile-time'' side effect. A program defining a run-time entry point would include an <code>Entries</code> header section, or export its content for an entry point in another module to run.
Note however that this output is only available as a ''compile-time'' side effect. A program defining a run-time entry point would include an <code>Entries</code> header section, or export its content for an entry point in another module to run.


Line 211: Line 211:


The program
The program
<lang awk> 1</lang>
<syntaxhighlight lang="awk"> 1</syntaxhighlight>
is the simplest useful program, equivalent to
is the simplest useful program, equivalent to
<lang awk>// {print}</lang>
<syntaxhighlight lang="awk">// {print}</syntaxhighlight>
I.e. match every input-line, and print it. <br>
I.e. match every input-line, and print it. <br>
Like the UNIX command 'cat', it prints every line of the files given as arguments,
Like the UNIX command 'cat', it prints every line of the files given as arguments,
Line 220: Line 220:
=={{header|Axe}}==
=={{header|Axe}}==
Most Axe examples omit the executable name, but it is shown in this example for completeness.
Most Axe examples omit the executable name, but it is shown in this example for completeness.
<lang axe>:.PRGMNAME
<syntaxhighlight lang="axe">:.PRGMNAME
:</lang>
:</syntaxhighlight>


=={{header|BASIC}}==
=={{header|BASIC}}==
Line 229: Line 229:
{{works with|uBasic/4tH}}
{{works with|uBasic/4tH}}
An empty file is a correct program. It won't be near empty as an executable file, though.
An empty file is a correct program. It won't be near empty as an executable file, though.
<lang qbasic></lang>
<syntaxhighlight lang="qbasic"></syntaxhighlight>
{{works with|ZX Spectrum Basic}}
{{works with|ZX Spectrum Basic}}
On the ZX Spectrum, we can have a completely empty program with no lines. Here we attempt to run the empty program:
On the ZX Spectrum, we can have a completely empty program with no lines. Here we attempt to run the empty program:
<lang basic>RUN</lang>
<syntaxhighlight lang="basic">RUN</syntaxhighlight>
0 OK, 0:1
0 OK, 0:1


==={{header|Applesoft BASIC}}===
==={{header|Applesoft BASIC}}===
<syntaxhighlight lang="applesoftbasic"></syntaxhighlight>
<lang ApplesoftBasic></lang>


=={{header|Batch File}}==
=={{header|Batch File}}==
On Windows XP and older, an empty batch file is syntactically correct and does nothing.
On Windows XP and older, an empty batch file is syntactically correct and does nothing.
<lang dos></lang>
<syntaxhighlight lang="dos"></syntaxhighlight>
But on Windows 7, an empty .bat file is not recognized and thus a character must exist in it. Some valid characters are <code>: @ %</code>
But on Windows 7, an empty .bat file is not recognized and thus a character must exist in it. Some valid characters are <code>: @ %</code>
<lang dos>:</lang>
<syntaxhighlight lang="dos">:</syntaxhighlight>


=={{header|BaCon}}==
=={{header|BaCon}}==
In BaCon an empty program is a valid program.
In BaCon an empty program is a valid program.
<lang bacon></lang>
<syntaxhighlight lang="bacon"></syntaxhighlight>


=={{header|BASIC256}}==
=={{header|BASIC256}}==
<lang freebasic></lang>
<syntaxhighlight lang="freebasic"></syntaxhighlight>


=={{header|BBC BASIC}}==
=={{header|BBC BASIC}}==
In BBC BASIC an empty program is syntactically correct.
In BBC BASIC an empty program is syntactically correct.
<lang bbcbasic></lang>
<syntaxhighlight lang="bbcbasic"></syntaxhighlight>


=={{header|bc}}==
=={{header|bc}}==
An empty file is a valid program.
An empty file is a valid program.

=={{header|Binary Lambda Calculus}}==

At 4 bits, or half a byte, the smallest BLC program is `cat' :

<pre>00 10</pre>

corresponding to the smallest valid lambda term, the identity function \x.x

=={{header|Beef}}==
<syntaxhighlight lang="csharp">using System;
class Program
{
public static void Main()
{
}
}
</syntaxhighlight>


=={{header|Beeswax}}==
=={{header|Beeswax}}==


<lang beeswax>*</lang>
<syntaxhighlight lang="beeswax">*</syntaxhighlight>
(create 6 bees moving in all 6 cardinal directions)
(create 6 bees moving in all 6 cardinal directions)
or
or
<lang beeswax>\</lang>
<syntaxhighlight lang="beeswax">\</syntaxhighlight>
(create 2 bees moving in “northwest” and “southeast” directions)
(create 2 bees moving in “northwest” and “southeast” directions)
or
or
<lang beeswax>_</lang>
<syntaxhighlight lang="beeswax">_</syntaxhighlight>
(create 2 bees moving left and right)
(create 2 bees moving left and right)
or
or
<lang beeswax>/</lang>
<syntaxhighlight lang="beeswax">/</syntaxhighlight>
(create 2 bees moving in “northeast” and “southwest” directions)
(create 2 bees moving in “northeast” and “southwest” directions)


Line 280: Line 298:


=={{header|bootBASIC}}==
=={{header|bootBASIC}}==
<syntaxhighlight lang="bootbasic"></syntaxhighlight>
<lang bootBASIC></lang>


=={{header|BQN}}==
=={{header|BQN}}==
Line 287: Line 305:
Any valid literal works to make a program run. The shortest way is to use a single digit, or a predefined constant, like <code>π</code> or <code>∞</code>.
Any valid literal works to make a program run. The shortest way is to use a single digit, or a predefined constant, like <code>π</code> or <code>∞</code>.


<lang bqn>∞</lang>
<syntaxhighlight lang="bqn">∞</syntaxhighlight>
[https://mlochbaum.github.io/BQN/try.html#code=4oie Try It!]
[https://mlochbaum.github.io/BQN/try.html#code=4oie Try It!]
=={{header|Bracmat}}==
=={{header|Bracmat}}==
An empty file is a valid program. However you need to load it, which requires a statement. In a Linux terminal, you could do
An empty file is a valid program. However you need to load it, which requires a statement. In a Linux terminal, you could do
<lang bracmat>touch empty
<syntaxhighlight lang="bracmat">touch empty
bracmat 'get$empty'</lang>
bracmat 'get$empty'</syntaxhighlight>


In DOS, you can do
In DOS, you can do
<lang dos>touch empty
<syntaxhighlight lang="dos">touch empty
bracmat get$empty</lang>
bracmat get$empty</syntaxhighlight>


If we drop the requirement that the shortest program is stored in a file, we can do
If we drop the requirement that the shortest program is stored in a file, we can do
<lang bash>bracmat ''</lang>
<syntaxhighlight lang="bash">bracmat ''</syntaxhighlight>
(Linux)
(Linux)
or
or
<lang dos>bracmat ""</lang>
<syntaxhighlight lang="dos">bracmat ""</syntaxhighlight>
(Windows)
(Windows)


Line 319: Line 337:
=={{header|Brlcad}}==
=={{header|Brlcad}}==
Pressing enter from the mged prompt, just returns another prompt, so I suppose that is the smallest possible program. However, before we can draw anything we at least need to open a database:
Pressing enter from the mged prompt, just returns another prompt, so I suppose that is the smallest possible program. However, before we can draw anything we at least need to open a database:
<lang mged>opendb empty.g y</lang>
<syntaxhighlight lang="mged">opendb empty.g y</syntaxhighlight>

=={{header|Bruijn}}==
The smallest program in bruijn is the identity function (\x.x) and returns its input:

<syntaxhighlight>main [0]</syntaxhighlight>


=={{header|C}}==
=={{header|C}}==
{{works with|C89}}
{{works with|C89}}
<lang c>main()
<syntaxhighlight lang="c">main()
{
{
return 0;
return 0;
}</lang>
}</syntaxhighlight>


As of C99 the return type is required, but the return statement is not.
As of C99 the return type is required, but the return statement is not.
{{works with|C99}}
{{works with|C99}}
<lang c>int main() { }</lang>
<syntaxhighlight lang="c">int main() { }</syntaxhighlight>


This is technically undefined behavior but on 8086 compatible processors <code>195</code> corresponds to the <code>ret</code> assembly instruction.
This is technically undefined behavior but on 8086 compatible processors <code>195</code> corresponds to the <code>ret</code> assembly instruction.
{{works with|C on 8086 compatible processors}}
{{works with|C on 8086 compatible processors}}
<lang c>const main = 195;</lang>
<syntaxhighlight lang="c">const main = 195;</syntaxhighlight>


=={{header|C sharp|C#}}==
=={{header|C sharp|C#}}==
Line 341: Line 364:
=={{header|C++}}==
=={{header|C++}}==
{{works with|g++|4.8.1}}
{{works with|g++|4.8.1}}
<lang cpp>int main(){}</lang>
<syntaxhighlight lang="cpp">int main(){}</syntaxhighlight>


=={{header|Clean}}==
=={{header|Clean}}==
<lang clean>module Empty
<syntaxhighlight lang="clean">module Empty


Start world = world</lang>
Start world = world</syntaxhighlight>
Compile the project with ''No Console'' or ''No Return Type'' to suppress printing of the value of the world.
Compile the project with ''No Console'' or ''No Return Type'' to suppress printing of the value of the world.

==={{header|Chipmunk Basic}}===
An empty text file is a correct Chipmunk Basic program that does nothing.


=={{header|Clojure}}==
=={{header|Clojure}}==
Line 355: Line 381:
This is the shortest program that actually produces a working executable (that does nothing).
This is the shortest program that actually produces a working executable (that does nothing).


<lang>start_up = proc ()
<syntaxhighlight lang="text">start_up = proc ()
end start_up</lang>
end start_up</syntaxhighlight>


[[Portable CLU]] will compile the empty file without complaint, but not produce an
[[Portable CLU]] will compile the empty file without complaint, but not produce an
Line 363: Line 389:
=={{header|COBOL}}==
=={{header|COBOL}}==
{{works with|OpenCOBOL|2.0}}
{{works with|OpenCOBOL|2.0}}
<lang cobol></lang>
<syntaxhighlight lang="cobol"></syntaxhighlight>


=={{header|CoffeeScript}}==
=={{header|CoffeeScript}}==
<lang coffeescript></lang>
<syntaxhighlight lang="coffeescript"></syntaxhighlight>


=={{header|Common Lisp}}==
=={{header|Common Lisp}}==


<lang lisp>()</lang>
<syntaxhighlight lang="lisp">()</syntaxhighlight>


<lang lisp>.</lang>
<syntaxhighlight lang="lisp">.</syntaxhighlight>


=={{header|Component Pascal}}==
=={{header|Component Pascal}}==
BlackBox Component Builder;
BlackBox Component Builder;
<lang oberon2>
<syntaxhighlight lang="oberon2">
MODULE Main;
MODULE Main;
END Main.
END Main.
</syntaxhighlight>
</lang>


=={{header|Computer/zero Assembly}}==
=={{header|Computer/zero Assembly}}==
The smallest legal program is a single Stop instruction.
The smallest legal program is a single Stop instruction.
<lang czasm> STP</lang>
<syntaxhighlight lang="czasm"> STP</syntaxhighlight>


=={{header|Crystal}}==
=={{header|Crystal}}==
<lang crystal></lang>
<syntaxhighlight lang="crystal"></syntaxhighlight>


=={{header|D}}==
=={{header|D}}==
<lang d>void main() {}</lang>
<syntaxhighlight lang="d">void main() {}</syntaxhighlight>


=={{header|Dart}}==
=={{header|Dart}}==
<lang dart>main() {}</lang>
<syntaxhighlight lang="dart">main() {}</syntaxhighlight>


=={{header|dc}}==
=={{header|dc}}==
Line 407: Line 433:
Dyalect is not very happy with a completely empty source code file, however a pair of curly brackets would do:
Dyalect is not very happy with a completely empty source code file, however a pair of curly brackets would do:


<lang dyalect>{}</lang>
<syntaxhighlight lang="dyalect">{}</syntaxhighlight>


This program would evaluate and return "nil".
This program would evaluate and return "nil".


=={{header|Déjà Vu}}==
=={{header|Déjà Vu}}==
<lang dejavu></lang>
<syntaxhighlight lang="dejavu"></syntaxhighlight>
Shortest module that works with <code>!import</code>:
Shortest module that works with <code>!import</code>:
<lang dejavu>{}</lang>
<syntaxhighlight lang="dejavu">{}</syntaxhighlight>


=={{header|E}}==
=={{header|E}}==
Line 420: Line 446:
<pre></pre>
<pre></pre>
This is equivalent to:
This is equivalent to:
<lang e>null</lang>
<syntaxhighlight lang="e">null</syntaxhighlight>

=={{header|EasyLang}}==
<syntaxhighlight>
#
</syntaxhighlight>


=={{header|eC}}==
=={{header|eC}}==
<pre></pre>
<pre></pre>
or
or
<lang ec>class EmptyApp : Application
<syntaxhighlight lang="ec">class EmptyApp : Application
{
{
void Main()
void Main()
Line 431: Line 462:


}
}
}</lang>
}</syntaxhighlight>


=={{header|EchoLisp}}==
=={{header|EchoLisp}}==
<lang scheme>
<syntaxhighlight lang="scheme">
</syntaxhighlight>
</lang>

=={{header|Ecstasy}}==
<syntaxhighlight lang="java">
module EmptyProgram {
void run() {
}
}
</syntaxhighlight>


=={{header|EDSAC order code}}==
=={{header|EDSAC order code}}==
The smallest program that will load and run without error. Apart from <tt>ZF</tt>, the 'stop' order, it consists solely of directives to the loader.
The smallest program that will load and run without error. Apart from <tt>ZF</tt>, the 'stop' order, it consists solely of directives to the loader.
<lang edsac>T64K [ set load point ]
<syntaxhighlight lang="edsac">T64K [ set load point ]
GK [ set base address ]
GK [ set base address ]
ZF [ stop ]
ZF [ stop ]
EZPF [ begin at load point ]</lang>
EZPF [ begin at load point ]</syntaxhighlight>


=={{header|Egel}}==
=={{header|Egel}}==
The smallest program contains nothing.
The smallest program contains nothing.
<syntaxhighlight lang="egel">
<lang Egel>
</syntaxhighlight>
</lang>


=={{header|EGL}}==
=={{header|EGL}}==
General program
General program
<syntaxhighlight lang="egl">
<lang EGL>
package programs;
package programs;


Line 458: Line 497:
end
end
end
end
</syntaxhighlight>
</lang>
Rich UI handler (but also without 'initialUI = [ ui ], onConstructionFunction = start' it would have been valid.)
Rich UI handler (but also without 'initialUI = [ ui ], onConstructionFunction = start' it would have been valid.)
<pre>
<pre>
Line 475: Line 514:
=={{header|Eiffel}}==
=={{header|Eiffel}}==
A file called root.e:
A file called root.e:
<lang eiffel>class
<syntaxhighlight lang="eiffel">class
ROOT
ROOT


Line 486: Line 525:
end
end
end</lang>
end</syntaxhighlight>


=={{header|Elena}}==
=={{header|Elena}}==
ELENA 4.x
ELENA 4.x
<lang elena>public program()
<syntaxhighlight lang="elena">public program()
{
{
}</lang>
}</syntaxhighlight>


=={{header|Elixir}}==
=={{header|Elixir}}==
<lang elixir></lang>
<syntaxhighlight lang="elixir"></syntaxhighlight>


=={{header|Elm}}==
=={{header|Elm}}==
<lang elm>
<syntaxhighlight lang="elm">
--Language prints the text in " "
--Language prints the text in " "
import Html
import Html
main =
main =
Html.text"empty"
Html.text"empty"
</syntaxhighlight>
</lang>

=={{header|EMal}}==
The empty script is valid and does nothing.


=={{header|Erlang}}==
=={{header|Erlang}}==
An empty module:
An empty module:
<lang erlang>-module(empty).</lang>
<syntaxhighlight lang="erlang">-module(empty).</syntaxhighlight>
An empty Erlang script file (escript):
An empty Erlang script file (escript):
<lang erlang>main(_) -> 1.</lang>
<syntaxhighlight lang="erlang">main(_) -> 1.</syntaxhighlight>


=={{header|ERRE}}==
=={{header|ERRE}}==
<lang>
<syntaxhighlight lang="text">
PROGRAM EMPTY
PROGRAM EMPTY
BEGIN
BEGIN
END PROGRAM
END PROGRAM
</syntaxhighlight>
</lang>


=={{header|eSQL}}==
=={{header|eSQL}}==
<lang sql>CREATE COMPUTE MODULE ESQL_Compute
<syntaxhighlight lang="sql">CREATE COMPUTE MODULE ESQL_Compute
CREATE FUNCTION Main() RETURNS BOOLEAN
CREATE FUNCTION Main() RETURNS BOOLEAN
BEGIN
BEGIN
RETURN TRUE;
RETURN TRUE;
END;
END;
END MODULE;</lang>
END MODULE;</syntaxhighlight>


=={{header|Euphoria}}==
=={{header|Euphoria}}==
<syntaxhighlight lang="euphoria"></syntaxhighlight>
<lang Euphoria></lang>


=={{header|F_Sharp|F#}}==
=={{header|F_Sharp|F#}}==
F# has an interactive mode and a compiled mode. The interactive interpreter will accept an empty file so the shortest valid program is an empty zero-length file with the .fsx extension.
F# has an interactive mode and a compiled mode. The interactive interpreter will accept an empty file so the shortest valid program is an empty zero-length file with the .fsx extension.
<lang fsharp></lang>
<syntaxhighlight lang="fsharp"></syntaxhighlight>
An empty compiled program is:
An empty compiled program is:
<lang fsharp>[<EntryPoint>]
<syntaxhighlight lang="fsharp">[<EntryPoint>]
let main args = 0</lang>
let main args = 0</syntaxhighlight>


=={{header|Factor}}==
=={{header|Factor}}==
<lang factor></lang>
<syntaxhighlight lang="factor"></syntaxhighlight>
If you want to deploy a stand-alone application, that doesn't suffice though. Here's another version.
If you want to deploy a stand-alone application, that doesn't suffice though. Here's another version.
<lang factor>IN: rosetta.empty
<syntaxhighlight lang="factor">IN: rosetta.empty
: main ( -- ) ;
: main ( -- ) ;
MAIN: main</lang>
MAIN: main</syntaxhighlight>


=={{header|Falcon}}==
=={{header|Falcon}}==
Line 551: Line 593:


=={{header|FALSE}}==
=={{header|FALSE}}==
<lang false></lang>
<syntaxhighlight lang="false"></syntaxhighlight>


=={{header|Fantom}}==
=={{header|Fantom}}==
<lang fantom>class Main
<syntaxhighlight lang="fantom">class Main
{
{
public static Void main () {}
public static Void main () {}
}</lang>
}</syntaxhighlight>


=={{header|FBSL}}==
=={{header|FBSL}}==
Line 594: Line 636:


=={{header|Fermat}}==
=={{header|Fermat}}==
<lang fermat>;</lang>
<syntaxhighlight lang="fermat">;</syntaxhighlight>


=={{header|Fish}}==
=={{header|Fish}}==
Actually the shortest valid program is a space (not empty file!), which is an infinite loop, though. (It keeps looping around)
Actually the shortest valid program is a space (not empty file!), which is an infinite loop, though. (It keeps looping around)
<lang Fish> </lang>
<syntaxhighlight lang="fish"> </syntaxhighlight>
An empty program is invalid; the interpreter will give an error.<br/>
An empty program is invalid; the interpreter will give an error.<br/>
The shortest program that will actually finish is a <tt>;</tt>, which will end the program immediately:
The shortest program that will actually finish is a <tt>;</tt>, which will end the program immediately:
<lang Fish>;</lang>
<syntaxhighlight lang="fish">;</syntaxhighlight>


=={{header|Forth}}==
=={{header|Forth}}==
<lang forth></lang>
<syntaxhighlight lang="forth"></syntaxhighlight>
For a Forth script to be used from a shell, you usually want the last command to be BYE in order to exit the interpreter when finished.
For a Forth script to be used from a shell, you usually want the last command to be BYE in order to exit the interpreter when finished.
<lang forth>bye</lang>
<syntaxhighlight lang="forth">bye</syntaxhighlight>


=={{header|Fortran}}==
=={{header|Fortran}}==
<lang fortran> end</lang>
<syntaxhighlight lang="fortran"> end</syntaxhighlight>


=={{header|FreeBASIC}}==
=={{header|FreeBASIC}}==
A completely empty program compiles and runs fine:
A completely empty program compiles and runs fine:
<lang freebasic></lang>
<syntaxhighlight lang="freebasic"></syntaxhighlight>


=={{header|friendly interactive shell}}==
=={{header|friendly interactive shell}}==
Empty programs are valid, but are useless.
Empty programs are valid, but are useless.
<lang fishshell></lang>
<syntaxhighlight lang="fishshell"></syntaxhighlight>


=={{header|Frink}}==
=={{header|Frink}}==
Empty programs are valid.
Empty programs are valid.
<lang frink></lang>
<syntaxhighlight lang="frink"></syntaxhighlight>


=={{header|FunL}}==
=={{header|FunL}}==
An empty text file is a valid FunL program that does nothing.
An empty text file is a valid FunL program that does nothing.
<lang funl></lang>
<syntaxhighlight lang="funl"></syntaxhighlight>


=={{header|Futhark}}==
=={{header|Futhark}}==
Line 631: Line 673:
Any Futhark program must have a <code>main</code> function. Alternatively, a Futhark library can be an empty file.
Any Futhark program must have a <code>main</code> function. Alternatively, a Futhark library can be an empty file.


<syntaxhighlight lang="futhark">
<lang Futhark>
let main = 0
let main = 0
</syntaxhighlight>
</lang>


=={{header|FutureBasic}}==
=={{header|FutureBasic}}==
<lang futurebasic>HandleEvents</lang>
<syntaxhighlight lang="futurebasic">HandleEvents</syntaxhighlight>


=={{header|Fōrmulæ}}==
=={{header|Fōrmulæ}}==


{{FormulaeEntry|page=https://formulae.org/?script=examples/Empty_program}}
Fōrmulæ programs are not textual, visualization/edition of programs is done showing/manipulating structures but not text. Moreover, there can be multiple visual representations of the same program. Even though it is possible to have textual representation &mdash;i.e. XML, JSON&mdash; they are intended for storage and transfer purposes more than visualization and edition.


'''Solution'''
Programs in Fōrmulæ are created/edited online in its [https://formulae.org website], However they run on execution servers. By default remote servers are used, but they are limited in memory and processing power, since they are intended for demonstration and casual use. A local server can be downloaded and installed, it has no limitations (it runs in your own computer). Because of that, example programs can be fully visualized and edited, but some of them will not run if they require a moderate or heavy computation/memory resources, and no local server is being used.


The following is the simplest expression: the Null expression. When it is run, it does not reduce to anything else, because there should not be rewriting rules for a null expression:
In '''[https://formulae.org/?example=Empty_program this]''' page you can see the program(s) related to this task and their results.

[[File:Fōrmulæ - Empty program 01.png]]

[[File:Fōrmulæ - Empty program 02.png]]


=={{header|Gambas}}==
=={{header|Gambas}}==
<lang gambas>
<syntaxhighlight lang="gambas">
Public Sub Main()
Public Sub Main()
End
End
</syntaxhighlight>
</lang>


=={{header|Gecho}}==
=={{header|Gecho}}==
Empty programs are valid.
Empty programs are valid.
<lang gecho></lang>
<syntaxhighlight lang="gecho"></syntaxhighlight>


=={{header|Gema}}==
=={{header|Gema}}==
An empty program will copy input stream to output stream unchanged.
An empty program will copy input stream to output stream unchanged.
<lang gema></lang>
<syntaxhighlight lang="gema"></syntaxhighlight>


=={{header|Genyris}}==
=={{header|Genyris}}==
Line 665: Line 711:
=={{header|Global Script}}==
=={{header|Global Script}}==
This program is intended for use with the [[HS Global Script]] and uses its syntax for imperative programs.
This program is intended for use with the [[HS Global Script]] and uses its syntax for imperative programs.
<lang Global Script>λ _. impunit 〈〉</lang>
<syntaxhighlight lang="global script">λ _. impunit 〈〉</syntaxhighlight>


=={{header|Go}}==
=={{header|Go}}==
<lang go>package main
<syntaxhighlight lang="go">package main
func main() { }</lang>
func main() { }</syntaxhighlight>


=={{header|Groovy}}==
=={{header|Groovy}}==
<lang groovy></lang>
<syntaxhighlight lang="groovy"></syntaxhighlight>

==={{header|GW-BASIC}}===
An empty text file is a correct GW-BASIC program that does nothing.

=={{header|Hare}}==
<syntaxhighlight lang="hare">export fn main() void = void;</syntaxhighlight>


=={{header|Haskell}}==
=={{header|Haskell}}==
Line 678: Line 730:


The simplest possible program is a single module using the implicit module header "<tt>module Main(main) where</tt>", and defining the action <tt>main</tt> to do nothing:
The simplest possible program is a single module using the implicit module header "<tt>module Main(main) where</tt>", and defining the action <tt>main</tt> to do nothing:
<lang haskell>main = return ()</lang>
<syntaxhighlight lang="haskell">main = return ()</syntaxhighlight>
The simplest possible module other than Main is one which contains no definitions:
The simplest possible module other than Main is one which contains no definitions:
<lang haskell>module X where {}</lang>
<syntaxhighlight lang="haskell">module X where {}</syntaxhighlight>


=={{header|Haxe}}==
=={{header|Haxe}}==
<lang haxe>class Program {
<syntaxhighlight lang="haxe">class Program {
static function main() {
static function main() {
}
}
}</lang>
}</syntaxhighlight>
Unlike most languages Haxe doesn't have arguments in the main function because it targets different platforms (some which don't support program arguments, eg: Flash or Javascript). You need to use the specific libraries of the platform you are targeting to get those.
Unlike most languages Haxe doesn't have arguments in the main function because it targets different platforms (some which don't support program arguments, eg: Flash or Javascript). You need to use the specific libraries of the platform you are targeting to get those.


=={{header|HicEst}}==
=={{header|HicEst}}==
<lang hicest>END ! looks better, but is not really needed</lang>
<syntaxhighlight lang="hicest">END ! looks better, but is not really needed</syntaxhighlight>


=={{header|HolyC}}==
=={{header|HolyC}}==
Line 700: Line 752:
=={{header|HTML}}==
=={{header|HTML}}==
HTML 5, [http://www.whatwg.org/specs/web-apps/current-work/multipage/syntax.html#optional-tags section 12.1.2.4 Optional tags], allows to omit ''html'', ''head'' and ''body'' tags. The implicit ''body'' element can be empty, but the implicit ''head'' element must contain a ''title'' element, says [http://www.whatwg.org/specs/web-apps/current-work/multipage/semantics.html#the-head-element section 4.2.1 The head element]. There seems no rule against an empty title. Therefore, the shortest correct HTML document is:
HTML 5, [http://www.whatwg.org/specs/web-apps/current-work/multipage/syntax.html#optional-tags section 12.1.2.4 Optional tags], allows to omit ''html'', ''head'' and ''body'' tags. The implicit ''body'' element can be empty, but the implicit ''head'' element must contain a ''title'' element, says [http://www.whatwg.org/specs/web-apps/current-work/multipage/semantics.html#the-head-element section 4.2.1 The head element]. There seems no rule against an empty title. Therefore, the shortest correct HTML document is:
<lang html5><!DOCTYPE html><title></title></lang>
<syntaxhighlight lang="html5"><!DOCTYPE html><title></title></syntaxhighlight>


The shortest correct XHTML document is:
The shortest correct XHTML document is:
<lang html5><html xmlns="http://www.w3.org/1999/xhtml"><head><title /></head><body /></html></lang>
<syntaxhighlight lang="html5"><html xmlns="http://www.w3.org/1999/xhtml"><head><title /></head><body /></html></syntaxhighlight>


=={{header|Huginn}}==
=={{header|Huginn}}==
<lang huginn>main(){}</lang>
<syntaxhighlight lang="huginn">main(){}</syntaxhighlight>


=={{header|i}}==
=={{header|i}}==
<lang i>software{}</lang>
<syntaxhighlight lang="i">software{}</syntaxhighlight>


=={{header|Icon}} and {{header|Unicon}}==
=={{header|Icon}} and {{header|Unicon}}==
<lang Icon>procedure main() # a null file will compile but generate a run-time error for missing main
<syntaxhighlight lang="icon">procedure main() # a null file will compile but generate a run-time error for missing main
end</lang>
end</syntaxhighlight>


=={{header|IDL}}==
=={{header|IDL}}==
<lang idl>end</lang>
<syntaxhighlight lang="idl">end</syntaxhighlight>


=={{header|Inform 7}}==
=={{header|Inform 7}}==
<lang inform7>X is a room</lang>
<syntaxhighlight lang="inform7">X is a room</syntaxhighlight>
Inform 7 is a language built for making interactive fiction, so a room needs to be defined for the player to start in.
Inform 7 is a language built for making interactive fiction, so a room needs to be defined for the player to start in.


=={{header|Intercal}}==
=={{header|Intercal}}==
<lang intercal>PLEASE GIVE UP</lang>
<syntaxhighlight lang="intercal">PLEASE GIVE UP</syntaxhighlight>


=={{header|Io}}==
=={{header|Io}}==
Line 729: Line 781:


=={{header|J}}==
=={{header|J}}==
<lang j>''</lang>
<syntaxhighlight lang="j">''</syntaxhighlight>
It returns itself:
It returns itself:
<lang j> '' -: ". ''
<syntaxhighlight lang="j"> '' -: ". ''
1</lang>
1</syntaxhighlight>


=={{header|Java}}==
=={{header|Java}}==
{{works with|Java|1.5+}}
{{works with|Java|1.5+}}
<lang java>public class EmptyApplet extends java.applet.Applet {
<syntaxhighlight lang="java">public class EmptyApplet extends java.applet.Applet {
@Override public void init() {
@Override public void init() {
}
}
}</lang>
}</syntaxhighlight>


<lang java>public class EmptyMainClass {
<syntaxhighlight lang="java">public class EmptyMainClass {
public static void main(String... args) {
public static void main(String... args) {
}
}
}</lang>
}</syntaxhighlight>


The "..." basically means "as many of these as the programmer wants." Java will put multiple arguments into an array with the given name. This will work for any method where an array is an argument, but with a twist. A call can be made like this:
The "..." basically means "as many of these as the programmer wants." Java will put multiple arguments into an array with the given name. This will work for any method where an array is an argument, but with a twist. A call can be made like this:


<lang java>method(arg0, arg1, arg2, arg3)</lang>
<syntaxhighlight lang="java">method(arg0, arg1, arg2, arg3)</syntaxhighlight>


All of the args will be put into an array in the order they were in the call.
All of the args will be put into an array in the order they were in the call.


{{works with|Java|1.0+}}
{{works with|Java|1.0+}}
<lang java>public class EmptyMainClass {
<syntaxhighlight lang="java">public class EmptyMainClass {
public static void main(String[] args) {
public static void main(String[] args) {
}
}
}</lang>
}</syntaxhighlight>


<lang java>public class EmptyApplet extends java.applet.Applet {
<syntaxhighlight lang="java">public class EmptyApplet extends java.applet.Applet {
public void init() {
public void init() {
}
}
}</lang>
}</syntaxhighlight>


@Override - Indicates that a method declaration is intended to override a method declaration in a superclass. If a method is annotated with this annotation type but does not override a superclass method, compilers are required to generate an error message. It's present from JDK 5.0 (1.5.0) and up.
@Override - Indicates that a method declaration is intended to override a method declaration in a superclass. If a method is annotated with this annotation type but does not override a superclass method, compilers are required to generate an error message. It's present from JDK 5.0 (1.5.0) and up.
Line 772: Line 824:


=={{header|Joy}}==
=={{header|Joy}}==
<lang joy>.</lang>
<syntaxhighlight lang="joy">.</syntaxhighlight>
A program in Joy is a sequence of zero or more factors followed by a full stop.


=={{header|Jq}}==
=={{header|Jq}}==
The “empty” filter ignores its input and outputs nothing.
The “empty” filter ignores its input and outputs nothing.


<lang jq>empty</lang>
<syntaxhighlight lang="jq">empty</syntaxhighlight>


=={{header|Julia}}==
=={{header|Julia}}==
Julia accepts an empty file as a program.
Julia accepts an empty file as a program.
<syntaxhighlight lang="julia"></syntaxhighlight>
<lang Julia></lang>


{{out}}
{{out}}
Line 792: Line 845:


=={{header|K}}==
=={{header|K}}==
<syntaxhighlight lang="text"></syntaxhighlight>
<lang></lang>


=={{header|KonsolScript}}==
=={{header|KonsolScript}}==
<lang KonsolScript>function main() {
<syntaxhighlight lang="konsolscript">function main() {
}</lang>
}</syntaxhighlight>


=={{header|Kotlin}}==
=={{header|Kotlin}}==
<lang scala>fun main(a: Array<String>) {}</lang>
<syntaxhighlight lang="kotlin">fun main() {}</syntaxhighlight>


=={{header|Lambdatalk}}==
=={{header|Lambdatalk}}==
An empty string is a valid program.
An empty string is a valid program.
<lang scheme></lang>
<syntaxhighlight lang="scheme"></syntaxhighlight>

=={{header|Lang}}==
The empty file is a valid program.
<pre></pre>


=={{header|Lang5}}==
=={{header|Lang5}}==
<lang Lang5>exit</lang>
<syntaxhighlight lang="lang5">exit</syntaxhighlight>


=={{header|Lasso}}==
=={{header|Lasso}}==
Lasso will parse any file thrown at it. It will ignore everything except what's inside specific Lasso delimiters. Thus a valid program that did nothing, could be an empty file. Perhaps more correct would be a file that had the specific delimiters and then nothing inside them.
Lasso will parse any file thrown at it. It will ignore everything except what's inside specific Lasso delimiters. Thus a valid program that did nothing, could be an empty file. Perhaps more correct would be a file that had the specific delimiters and then nothing inside them.
<lang Lasso>[]</lang>
<syntaxhighlight lang="lasso">[]</syntaxhighlight>
<lang Lasso><?lasso ?></lang>
<syntaxhighlight lang="lasso"><?lasso ?></syntaxhighlight>
<lang Lasso><?= ?></lang>
<syntaxhighlight lang="lasso"><?= ?></syntaxhighlight>


=={{header|LaTeX}}==
=={{header|LaTeX}}==
<lang latex>\documentclass{minimal}
<syntaxhighlight lang="latex">\documentclass{minimal}
\begin{document}
\begin{document}
\end{document}</lang>
\end{document}</syntaxhighlight>


=={{header|LC3 Assembly}}==
=={{header|LC3 Assembly}}==
The only thing you absolutely need is a directive telling the assembler to stop assembling code (which in this case it has not actually started doing).
The only thing you absolutely need is a directive telling the assembler to stop assembling code (which in this case it has not actually started doing).
<lang lc3asm> .END</lang>
<syntaxhighlight lang="lc3asm"> .END</syntaxhighlight>


=={{header|Liberty BASIC}}==
=={{header|Liberty BASIC}}==
<lang lb>end</lang>
<syntaxhighlight lang="lb">end</syntaxhighlight>


=={{header|Lilypond}}==
=={{header|Lilypond}}==
According to the manual, all lilypond programs should contain a version statement expressing the minimum version number. If this is missing then a warning will be emitted.
According to the manual, all lilypond programs should contain a version statement expressing the minimum version number. If this is missing then a warning will be emitted.
<lang lilypond>\version "2.6.12"</lang>
<syntaxhighlight lang="lilypond">\version "2.6.12"</syntaxhighlight>


An input file should really have a basic structure as follows. The compiler automatically adds some of the structure components if they are not present in the source code. However, explicit definition should be used to prevent the compiler from creating unwanted contexts (which can cause side effects):
An input file should really have a basic structure as follows. The compiler automatically adds some of the structure components if they are not present in the source code. However, explicit definition should be used to prevent the compiler from creating unwanted contexts (which can cause side effects):


<lang lilypond>\version "2.16.2"
<syntaxhighlight lang="lilypond">\version "2.16.2"


\header {
\header {
Line 850: Line 907:
}
}
}
}
}</lang>
}</syntaxhighlight>


=={{header|Lingo}}==
=={{header|Lingo}}==
"Program" doesn't really apply to Lingo. A Director projector (exe/app) doesn't have to contain any scripts/code. For scripts, the shortest possible code is:
"Program" doesn't really apply to Lingo. A Director projector (exe/app) doesn't have to contain any scripts/code. For scripts, the shortest possible code is:
<lang lingo></lang>
<syntaxhighlight lang="lingo"></syntaxhighlight>


=={{header|Lisp}}==
=={{header|Lisp}}==
Most Lisp dialects, including Common Lisp, will accept no text (no forms) as a valid program.
Most Lisp dialects, including Common Lisp, will accept no text (no forms) as a valid program.
<lang lisp></lang>
<syntaxhighlight lang="lisp"></syntaxhighlight>


=={{header|Little Man Computer}}==
=={{header|Little Man Computer}}==
Line 864: Line 921:


'''Assembly'''
'''Assembly'''
<syntaxhighlight lang="little man computer"></syntaxhighlight>
<lang Little Man Computer></lang>


'''Machine code'''
'''Machine code'''
<syntaxhighlight lang="little man computer"></syntaxhighlight>
<lang Little Man Computer></lang>


=={{header|Logo}}==
=={{header|Logo}}==
<lang logo></lang>
<syntaxhighlight lang="logo"></syntaxhighlight>
or end a standalone script with "bye"
or end a standalone script with "bye"
<lang logo>#! /usr/local/bin/logo
<syntaxhighlight lang="logo">#! /usr/local/bin/logo


bye</lang>
bye</syntaxhighlight>


=={{header|LSE}}==
=={{header|LSE}}==
<syntaxhighlight lang="lse"></syntaxhighlight>
<lang LSE></lang>


=={{header|LSE64}}==
=={{header|LSE64}}==
Line 884: Line 941:


=={{header|Lua}}==
=={{header|Lua}}==
<syntaxhighlight lang="lua"></syntaxhighlight>
<lang Lua></lang>


=={{header|M2000 Interpreter}}==
=={{header|M2000 Interpreter}}==
Line 894: Line 951:


File saved as:
File saved as:
<syntaxhighlight lang="m2000 interpreter">
<lang M2000 Interpreter>
MODULE GLOBAL A {
MODULE GLOBAL A {
}
}
</syntaxhighlight>
</lang>
Because we make it in "level 0" (from console) this is a global module. A global module which loaded from console, or was a module loaded from a file at command line, when opening the environment, erased with an End, or a New, or a Start statement (reset of environment by software), or a Break by keyboard (although a dialog ask for proceed the breaking, the reset of environment) , or in some situation by using End Process from Task Manager.
Because we make it in "level 0" (from console) this is a global module. A global module which loaded from console, or was a module loaded from a file at command line, when opening the environment, erased with an End, or a New, or a Start statement (reset of environment by software), or a Break by keyboard (although a dialog ask for proceed the breaking, the reset of environment) , or in some situation by using End Process from Task Manager.


If we wish to run it from command line (by clicking the file in explorer, and let m2000.exe open gsb files), we have to consider the first that this file not contain an execute statement, and that if we didn't use an input statement/function which need console, then console stay hide. To be sure that console open we have to use Show statement. To run A we have to include A at the last line (or append a line and write A). So we write in first line Show (press Esc to return to prompt) and save the file as Save Empty, A so we get this:
If we wish to run it from command line (by clicking the file in explorer, and let m2000.exe open gsb files), we have to consider the first that this file not contain an execute statement, and that if we didn't use an input statement/function which need console, then console stay hide. To be sure that console open we have to use Show statement. To run A we have to include A at the last line (or append a line and write A). So we write in first line Show (press Esc to return to prompt) and save the file as Save Empty, A so we get this:


<syntaxhighlight lang="m2000 interpreter">
<lang M2000 Interpreter>
MODULE GLOBAL A {Show
MODULE GLOBAL A {Show
}
}
A
A
</syntaxhighlight>
</lang>
We can open it with Edit "empty.gsb" add some statements between A and block of module, to make some globals, say a DIM a(10) which stay there until the end of current interpreter run (interpreter may run multiple times simultaneously). All globals are globals for current interpreter only.
We can open it with Edit "empty.gsb" add some statements between A and block of module, to make some globals, say a DIM a(10) which stay there until the end of current interpreter run (interpreter may run multiple times simultaneously). All globals are globals for current interpreter only.


Line 917: Line 974:
Finally this is the code in a file (say Empty.gsb) to open, display something, waiting for a key (now a Show automatic happen) and then finish. We have to write it, in M2000 editor, and save it using Save Empty, A or in any editor and save it as empty.gsb in your desired folder.
Finally this is the code in a file (say Empty.gsb) to open, display something, waiting for a key (now a Show automatic happen) and then finish. We have to write it, in M2000 editor, and save it using Save Empty, A or in any editor and save it as empty.gsb in your desired folder.
sav
sav
<syntaxhighlight lang="m2000 interpreter">
<lang M2000 Interpreter>
MODULE GLOBAL A {
MODULE GLOBAL A {
Print "Hello World"
Print "Hello World"
Line 924: Line 981:
}
}
A
A
</syntaxhighlight>
</lang>


We can save it scrabbled text using Save "empty" @, A (not readable, but environment can revert the process using a unique key)
We can save it scrabbled text using Save "empty" @, A (not readable, but environment can revert the process using a unique key)
Line 931: Line 988:


=={{header|M4}}==
=={{header|M4}}==
<syntaxhighlight lang="m4"></syntaxhighlight>
<lang M4></lang>


=={{header|Maple}}==
=={{header|Maple}}==
<syntaxhighlight lang="maple"></syntaxhighlight>
<lang Maple></lang>


=={{header|Mathematica}} / {{header|Wolfram Language}}==
=={{header|Mathematica}} / {{header|Wolfram Language}}==
<syntaxhighlight lang="mathematica"></syntaxhighlight>
<lang Mathematica></lang>


=={{header|MATLAB}}==
=={{header|MATLAB}}==
<lang Matlab> function [varargout] = emptyprogram(varargin) </lang>
<syntaxhighlight lang="matlab"> function [varargout] = emptyprogram(varargin) </syntaxhighlight>


=={{header|Maxima}}==
=={{header|Maxima}}==


<lang maxima>block()$</lang>
<syntaxhighlight lang="maxima">block()$</syntaxhighlight>


=={{header|MAXScript}}==
=={{header|MAXScript}}==
Line 950: Line 1,007:


=={{header|MelonBasic}}==
=={{header|MelonBasic}}==
<syntaxhighlight lang="melonbasic"></syntaxhighlight>
<lang MelonBasic></lang>


=={{header|Metafont}}==
=={{header|Metafont}}==
<lang metafont>end</lang>
<syntaxhighlight lang="metafont">end</syntaxhighlight>


=={{header|Microsoft Small Basic}}==
=={{header|Microsoft Small Basic}}==
<lang smallbasic></lang>
<syntaxhighlight lang="smallbasic"></syntaxhighlight>
{{out}}<pre></pre>
{{out}}<pre></pre>


=={{header|min}}==
=={{header|min}}==
{{works with|min|0.19.3}}
{{works with|min|0.19.3}}
<lang min></lang>
<syntaxhighlight lang="min"></syntaxhighlight>


=={{header|MiniScript}}==
=={{header|MiniScript}}==
<syntaxhighlight lang="miniscript"></syntaxhighlight>
<lang MiniScript></lang>


=={{header|MIPS Assembly}}==
=={{header|MIPS Assembly}}==
===Linux===
This just exits the program with exit code 0 (exit_success)
This just exits the program with exit code 0 (exit_success)
<lang mips>
<syntaxhighlight lang="mips">
.text
.text
main: li $v0, 10
main: li $v0, 10
syscall
syscall
</syntaxhighlight>
</lang>
===Nintendo 64===
In addition to a proper cartridge header, [[wp:Cyclic_redundancy_check|CRCs]], and footer, you'll need to write a value of <tt>8</tt> to address <tt>0xBFC007FC</tt> so that the cartridge can boot correctly. (Nintendo 64 is big-endian, so the 8 is actually stored at <tt>0xBFC007FF</tt>, but every example I've seen stores the value as a <code>uint32</code> so that's what I'm going with.)

After that, just enter an infinite loop and you're done.

<syntaxhighlight lang="mips">la $t0,0xBFC007FC
li $t1,8
sw $t1,0($t0)

halt:
nop ;not actually needed by real hardware, but Project 64 doesn't like infinite loops.
b halt
nop</syntaxhighlight>


=={{header|МК-61/52}}==
=={{header|МК-61/52}}==
<lang>С/П</lang>
<syntaxhighlight lang="text">С/П</syntaxhighlight>


=={{header|ML/I}}==
=={{header|ML/I}}==
<lang ML/I></lang>
<syntaxhighlight lang="ml/i"></syntaxhighlight>


=={{header|MMIX}}==
=={{header|MMIX}}==
<lang mmix> LOC #100
<syntaxhighlight lang="mmix"> LOC #100
Main TRAP 0,Halt,0 // main (argc, argv) {}</lang>
Main TRAP 0,Halt,0 // main (argc, argv) {}</syntaxhighlight>


=={{header|Modula-2}}==
=={{header|Modula-2}}==
<lang modula2>MODULE Main;
<syntaxhighlight lang="modula2">MODULE Main;


BEGIN
BEGIN
END Main.</lang>
END Main.</syntaxhighlight>


=={{header|Modula-3}}==
=={{header|Modula-3}}==
<lang modula3>MODULE Main;
<syntaxhighlight lang="modula3">MODULE Main;


BEGIN
BEGIN
END Main.</lang>
END Main.</syntaxhighlight>


=={{header|MUMPS}}==
=={{header|MUMPS}}==
The empty file is a valid program.
The empty file is a valid program.
<pre></pre>
<pre></pre>

==={{header|MSX Basic}}===
<syntaxhighlight lang="basic">10 rem</syntaxhighlight>


=={{header|N/t/roff}}==
=={{header|N/t/roff}}==


{{works with|All implementations of TROFF}}
{{works with|All implementations of TROFF}}
<lang N/t/roff></lang>
<syntaxhighlight lang="n/t/roff"></syntaxhighlight>


An empty input file is valid, but if the output is Postscript or PDF, most PDF viewers will suffer. However, that's the PDF viewer's fault; the typesetter is still okay with an empty file. If one wants grace for the PDF viewers, import a macro that, at the very least, defines some proper margins and pagination as in the following code:
An empty input file is valid, but if the output is Postscript or PDF, most PDF viewers will suffer. However, that's the PDF viewer's fault; the typesetter is still okay with an empty file. If one wants grace for the PDF viewers, import a macro that, at the very least, defines some proper margins and pagination as in the following code:


{{works with|GNU TROFF|1.22.2}}
{{works with|GNU TROFF|1.22.2}}
<lang N/t/roff>.mso me.tmac</lang>
<syntaxhighlight lang="n/t/roff">.mso me.tmac</syntaxhighlight>


=={{header|Nanoquery}}==
=={{header|Nanoquery}}==
Empty files are valid Nanoquery programs that do nothing.
Empty files are valid Nanoquery programs that do nothing.
<syntaxhighlight lang="nanoquery"></syntaxhighlight>
<lang Nanoquery></lang>


=={{header|Nemerle}}==
=={{header|Nemerle}}==
Compiles with warnings:
Compiles with warnings:
<lang Nemerle>null</lang>
<syntaxhighlight lang="nemerle">null</syntaxhighlight>
Compiles without warnings (so, more correct):
Compiles without warnings (so, more correct):
<lang Nemerle>module Program
<syntaxhighlight lang="nemerle">module Program
{
{
Main() : void
Main() : void
{
{
}
}
}</lang>
}</syntaxhighlight>


=={{header|NetRexx}}==
=={{header|NetRexx}}==
Line 1,029: Line 1,103:


This minimal example requires that the file be named to match the class:
This minimal example requires that the file be named to match the class:
<lang NetRexx>class empty</lang>
<syntaxhighlight lang="netrexx">class empty</syntaxhighlight>


This example will generate its class based on the file name:
This example will generate its class based on the file name:
<lang NetRexx>method main(args = String[]) static</lang>
<syntaxhighlight lang="netrexx">method main(args = String[]) static</syntaxhighlight>


=={{header|NewLISP}}==
=={{header|NewLISP}}==
<lang NewLISP>; </lang>
<syntaxhighlight lang="newlisp">; </syntaxhighlight>


=={{header|Nim}}==
=={{header|Nim}}==
Line 1,045: Line 1,119:


=={{header|NS-HUBASIC}}==
=={{header|NS-HUBASIC}}==
<syntaxhighlight lang="ns-hubasic"></syntaxhighlight>
<lang NS-HUBASIC></lang>

=={{header|Oberon-2}}==
<syntaxhighlight lang="oberon2">MODULE Main;

BEGIN
END Main.
</syntaxhighlight>


=={{header|Objeck}}==
=={{header|Objeck}}==
<lang objeck>bundle Default {
<syntaxhighlight lang="objeck">bundle Default {
class Empty {
class Empty {
function : Main(args : String[]) ~ Nil {
function : Main(args : String[]) ~ Nil {
}
}
}</lang>
}</syntaxhighlight>


=={{header|Objective-C}}==
=={{header|Objective-C}}==
{{works with|gcc|4.0.1}}
{{works with|gcc|4.0.1}}
<lang objc>int main(int argc, const char **argv) {
<syntaxhighlight lang="objc">int main(int argc, const char **argv) {
return 0;
return 0;
}</lang>
}</syntaxhighlight>


The minimal ''empty'' Cocoa/OpenStep application, useful as life-support for many examples given at RosettaCode, is
The minimal ''empty'' Cocoa/OpenStep application, useful as life-support for many examples given at RosettaCode, is
<lang objc>#import <Cocoa/Cocoa.h>
<syntaxhighlight lang="objc">#import <Cocoa/Cocoa.h>


int main( int argc, const char *argv[] )
int main( int argc, const char *argv[] )
Line 1,069: Line 1,150:
}
}
return 0;
return 0;
}</lang>
}</syntaxhighlight>


=={{header|OCaml}}==
=={{header|OCaml}}==
{{works with|Ocaml|3.09}}
{{works with|Ocaml|3.09}}
<lang ocaml>;;</lang>
<syntaxhighlight lang="ocaml">;;</syntaxhighlight>


Actually, the smallest possible correct program in OCaml is an empty source file.
Actually, the smallest possible correct program in OCaml is an empty source file.
Line 1,079: Line 1,160:
=={{header|Octave}}==
=={{header|Octave}}==
An empty text file can be a valid empty program, but since Octave has the concept of "function file" (a file containing a single function; the file is automatically loaded when a function with the same name of the file, save for the extension, is called, and the first function present in the file is used), the name of the empty file matters. E.g. calling an empty file as <tt>isempty.m</tt> makes unusable the builtin <tt>isempty</tt> function.
An empty text file can be a valid empty program, but since Octave has the concept of "function file" (a file containing a single function; the file is automatically loaded when a function with the same name of the file, save for the extension, is called, and the first function present in the file is used), the name of the empty file matters. E.g. calling an empty file as <tt>isempty.m</tt> makes unusable the builtin <tt>isempty</tt> function.
=={{header|Odin}}==
<syntaxhighlight lang="odin">
package main
main :: proc() {}
</syntaxhighlight>


=={{header|Oforth}}==
=={{header|Oforth}}==
Line 1,084: Line 1,170:
An empty file is a valid oforth file
An empty file is a valid oforth file


<lang Oforth>oforth empty.of</lang>
<syntaxhighlight lang="oforth">oforth empty.of</syntaxhighlight>


Without file, interpreter can just evaluate bye :
Without file, interpreter can just evaluate bye :
<lang Oforth>oforth --P"bye"</lang>
<syntaxhighlight lang="oforth">oforth --P"bye"</syntaxhighlight>


=={{header|Ol}}==
=={{header|Ol}}==
Line 1,096: Line 1,182:
A file with any one-digit number ("0", "1", .. "9") or one-character function like "+", "-", etc.) is smallest non empty runnable code.
A file with any one-digit number ("0", "1", .. "9") or one-character function like "+", "-", etc.) is smallest non empty runnable code.


<lang scheme>
<syntaxhighlight lang="scheme">
0</lang>
0</syntaxhighlight>


=={{header|OOC}}==
=={{header|OOC}}==
The Compiler will accept an empty file:
The Compiler will accept an empty file:
<lang ooc></lang>
<syntaxhighlight lang="ooc"></syntaxhighlight>


=={{header|OpenLisp}}==
=={{header|OpenLisp}}==
Line 1,108: Line 1,194:
This is for the Linux version of OpenLisp.
This is for the Linux version of OpenLisp.


<lang openlisp>
<syntaxhighlight lang="openlisp">
#!/openlisp/uxlisp -shell
#!/openlisp/uxlisp -shell
()
()
</syntaxhighlight>
</lang>


=={{header|Openscad}}==
=={{header|Openscad}}==
<lang openscad></lang>
<syntaxhighlight lang="openscad"></syntaxhighlight>


=={{header|OxygenBasic}}==
=={{header|OxygenBasic}}==
The smallest possible program is a single space character:
The smallest possible program is a single space character:
<lang oxygenbasic>
<syntaxhighlight lang="oxygenbasic">
</syntaxhighlight>
</lang>


=={{header|Oz}}==
=={{header|Oz}}==
=== Accepted by compiler ===
=== Accepted by compiler ===
The simplest 'program' that can be compiled is a file which contains a single expression.
The simplest 'program' that can be compiled is a file which contains a single expression.
<lang oz>unit</lang>
<syntaxhighlight lang="oz">unit</syntaxhighlight>
Such a 'program' cannot be executed, though.
Such a 'program' cannot be executed, though.
=== Standalone ===
=== Standalone ===
The simplest standalone program is a root functor that does not define anything. ("Functors" are first-class modules.)
The simplest standalone program is a root functor that does not define anything. ("Functors" are first-class modules.)
<lang oz>functor
<syntaxhighlight lang="oz">functor
define
define
skip
skip
end</lang>
end</syntaxhighlight>


=={{header|PARI/GP}}==
=={{header|PARI/GP}}==
<lang parigp></lang>
<syntaxhighlight lang="parigp"></syntaxhighlight>


=={{header|Pascal}}==
=={{header|Pascal}}==
<lang pascal>program ProgramName;
<syntaxhighlight lang="pascal">program ProgramName;


begin
begin
end.</lang>
end.</syntaxhighlight>
The first line is not necessary in modern Pascal dialects. With today's most compilers, the empty program is just:
The first line is not necessary in modern Pascal dialects. With today's most compilers, the empty program is just:
<lang pascal>begin end.</lang>
<syntaxhighlight lang="pascal">begin end.</syntaxhighlight>


=={{header|PepsiScript}}==
=={{header|PepsiScript}}==
For typing:
For typing:
<lang PepsiScript>#include default-libraries
<syntaxhighlight lang="pepsiscript">#include default-libraries


#author .
#author .


class .:</lang>
class .:</syntaxhighlight>
For importing:
For importing:


Line 1,157: Line 1,243:


•dl◘.◙
•dl◘.◙

=={{header|Peri}}==

In the Peri language, a text file with a length of zero bytes is a correct program, but it does nothing.
Similarly, a text file that consists of all whitespace characters is also a correct program that does nothing.


=={{header|Perl}}==
=={{header|Perl}}==
Line 1,162: Line 1,253:
The empty program is valid and does nothing but return a successful exit code:
The empty program is valid and does nothing but return a successful exit code:


<lang perl></lang>
<syntaxhighlight lang="perl"></syntaxhighlight>


Of course, this then requires you to specify the interpreter on the command line (i.e. <code>perl empty.pl</code>). So slightly more correct as a stand-alone program, is:
Of course, this then requires you to specify the interpreter on the command line (i.e. <code>perl empty.pl</code>). So slightly more correct as a stand-alone program, is:


<lang perl>#!/usr/bin/perl</lang>
<syntaxhighlight lang="perl">#!/usr/bin/perl</syntaxhighlight>


The smallest possible Perl one-liner is <code>perl -e0</code>.
The smallest possible Perl one-liner is <code>perl -e0</code>.
Line 1,173: Line 1,264:
{{libheader|Phix/basics}}
{{libheader|Phix/basics}}
An empty file is a valid program. When compiled however, it is far from empty as it contains most of the VM and a full run-time diagnostics kit (together about 202K).
An empty file is a valid program. When compiled however, it is far from empty as it contains most of the VM and a full run-time diagnostics kit (together about 202K).
<!--<lang Phix>(phixonline)--><!--</lang>-->
<!--<syntaxhighlight lang="phix">(phixonline)--><!--</syntaxhighlight>-->


=={{header|PHP}}==
=={{header|PHP}}==
Line 1,180: Line 1,271:
=={{header|Picat}}==
=={{header|Picat}}==
By default, Picat calls the <code>main/0</code> predicate:
By default, Picat calls the <code>main/0</code> predicate:
<lang Picat>main.</lang>
<syntaxhighlight lang="picat">main.</syntaxhighlight>


{{out}}
{{out}}
Line 1,188: Line 1,279:


An shorter way is this program
An shorter way is this program
<lang Picat>x.</lang>
<syntaxhighlight lang="picat">x.</syntaxhighlight>
but then an explicit goal at command line (<code>-g x</code>) must be given.
but then an explicit goal at command line (<code>-g x</code>) must be given.


Line 1,197: Line 1,288:


=={{header|PicoLisp}}==
=={{header|PicoLisp}}==
<lang PicoLisp>(de foo ())</lang>
<syntaxhighlight lang="picolisp">(de foo ())</syntaxhighlight>


=={{header|Pike}}==
=={{header|Pike}}==
<lang pike>int main(){}</lang>
<syntaxhighlight lang="pike">int main(){}</syntaxhighlight>


=={{header|PIR}}==
=={{header|PIR}}==
The ''':main''' pragma indicates that a subroutine is the program's entry point. However, if a subroutine is the first (or only, which would also have the effect of making it the first) routine in the program, Parrot will use that. So we may comfortably omit it in this case.
The ''':main''' pragma indicates that a subroutine is the program's entry point. However, if a subroutine is the first (or only, which would also have the effect of making it the first) routine in the program, Parrot will use that. So we may comfortably omit it in this case.
<lang pir>.sub empty_program
<syntaxhighlight lang="pir">.sub empty_program
.end</lang>
.end</syntaxhighlight>


=={{header|Pixilang}}==
=={{header|Pixilang}}==
Any text longer than 0 characters is valid, otherwise resulting in a "The file is empty or does not exist" error. In this example, a space character is used.
Any text longer than 0 characters is valid, otherwise resulting in a "The file is empty or does not exist" error. In this example, a space character is used.
<syntaxhighlight lang="pixilang"> </syntaxhighlight>
<lang Pixilang> </lang>


=={{header|PL/I}}==
=={{header|PL/I}}==
<lang PL/I>s: proc options (main);
<syntaxhighlight lang="pl/i">s: proc options (main);
end;</lang>
end;</syntaxhighlight>


=={{header|PL/SQL}}==
=={{header|PL/SQL}}==
<lang sql>BEGIN
<syntaxhighlight lang="sql">BEGIN
NULL;
NULL;
END;</lang>
END;</syntaxhighlight>


=={{header|Plain English}}==
=={{header|Plain English}}==
<syntaxhighlight lang="text">To run:</syntaxhighlight>
<lang plainenglish>To run:
Start up.
Shut down.</lang>


=={{header|plainTeX}}==
=={{header|plainTeX}}==
<lang tex>\bye</lang>
<syntaxhighlight lang="tex">\bye</syntaxhighlight>


=={{header|Pony}}==
=={{header|Pony}}==
<lang pony>actor Main new create(e: Env) => ""</lang>
<syntaxhighlight lang="pony">actor Main new create(e: Env) => ""</syntaxhighlight>


=={{header|Pop11}}==
=={{header|Pop11}}==
Pop11 has two compilers, incremental and batch compiler. For the incremental compiler one can use just empty program text (empty file), or a file containing nothing but a comment, e.g.
Pop11 has two compilers, incremental and batch compiler. For the incremental compiler one can use just empty program text (empty file), or a file containing nothing but a comment, e.g.
<lang pop11>;;; This is a valid Pop11 program that does absolutely nothing.</lang>
<syntaxhighlight lang="pop11">;;; This is a valid Pop11 program that does absolutely nothing.</syntaxhighlight>
The batch compiler generates an executable which starts at a given entry point, so one should provide an empty function. If one wants program that works the same both with incremental compiler and batch compiler the following may be useful:
The batch compiler generates an executable which starts at a given entry point, so one should provide an empty function. If one wants program that works the same both with incremental compiler and batch compiler the following may be useful:
<lang pop11>compile_mode :pop11 +strict;
<syntaxhighlight lang="pop11">compile_mode :pop11 +strict;
define entry_point();
define entry_point();
enddefine;
enddefine;


#_TERMIN_IF DEF POPC_COMPILING
#_TERMIN_IF DEF POPC_COMPILING
entry_point();</lang>
entry_point();</syntaxhighlight>
Here the batch compiler will stop reading source before call to entry_point while incremental compiler will execute the call, ensuring that in both cases execution will start from the function entry_point.
Here the batch compiler will stop reading source before call to entry_point while incremental compiler will execute the call, ensuring that in both cases execution will start from the function entry_point.


Line 1,247: Line 1,336:


Following good programming practice, however, and to ensure that a PostScript printer will interpret a file correctly, one should make the first 4 characters of the file be
Following good programming practice, however, and to ensure that a PostScript printer will interpret a file correctly, one should make the first 4 characters of the file be
<lang postscript>%!PS</lang>
<syntaxhighlight lang="postscript">%!PS</syntaxhighlight>


If a particular version of the PS interpreter is needed, this would be included right there:
If a particular version of the PS interpreter is needed, this would be included right there:
<lang postscript>%!PS-2.0
<syntaxhighlight lang="postscript">%!PS-2.0
% ...or...
% ...or...
%!PS-3.0
%!PS-3.0
% etc</lang>
% etc</syntaxhighlight>


=={{header|PowerShell}}==
=={{header|PowerShell}}==
An empty script block. A script block is a nameless (lamda) function.
An empty script block. A script block is a nameless (lamda) function.
<syntaxhighlight lang="powershell">
<lang PowerShell>
&{}
&{}
</syntaxhighlight>
</lang>


{{Out}}
{{Out}}
Line 1,268: Line 1,357:
=={{header|Processing}}==
=={{header|Processing}}==
An empty .pde sketch file.
An empty .pde sketch file.
<syntaxhighlight lang="processing"></syntaxhighlight>
<lang Processing></lang>
When run this will produce a 200x200 inactive default gray canvas.
When run this will produce a 200x200 inactive default gray canvas.


=={{header|ProDOS}}==
=={{header|ProDOS}}==
This is an acceptable program:
This is an acceptable program:
<lang ProDOS>IGNORELINE</lang>
<syntaxhighlight lang="prodos">IGNORELINE</syntaxhighlight>
But also you could include a delimiter character recognized by the compiler/interpreter:
But also you could include a delimiter character recognized by the compiler/interpreter:
<syntaxhighlight lang="prodos">;</syntaxhighlight>
<lang ProDOS>;</lang>


=={{header|Programming Language}}==
=={{header|Programming Language}}==
For typing:
For typing:
<syntaxhighlight lang="programming language"></syntaxhighlight>
<lang Programming Language></lang>
For importing:
For importing:


Line 1,287: Line 1,376:


=={{header|PSQL}}==
=={{header|PSQL}}==
<lang sql>EXECUTE BLOCK
<syntaxhighlight lang="sql">EXECUTE BLOCK
AS
AS
BEGIN
BEGIN
END</lang>
END</syntaxhighlight>


=={{header|PureBasic}}==
=={{header|PureBasic}}==
An empty file is a correct PureBasic program that does nothing.
An empty file is a correct PureBasic program that does nothing.
<syntaxhighlight lang="purebasic"></syntaxhighlight>
<lang PureBasic></lang>


=={{header|Python}}==
=={{header|Python}}==
Line 1,302: Line 1,391:


=={{header|QUACKASM}}==
=={{header|QUACKASM}}==
<lang quackasm>1
<syntaxhighlight lang="quackasm">1
QUIT</lang>
QUIT</syntaxhighlight>


=={{header|Quackery}}==
=={{header|Quackery}}==
Line 1,309: Line 1,398:
An empty string or text file is a valid Quackery program that does nothing.
An empty string or text file is a valid Quackery program that does nothing.


<syntaxhighlight lang="quackery"></syntaxhighlight>
<lang Quackery></lang>


{{out}}
{{out}}
Line 1,316: Line 1,405:


=={{header|Quite BASIC}}==
=={{header|Quite BASIC}}==
<syntaxhighlight lang="quite basic"></syntaxhighlight>
<lang Quite BASIC></lang>


=={{header|R}}==
=={{header|R}}==
Line 1,323: Line 1,412:
=={{header|Racket}}==
=={{header|Racket}}==
The following shows an empty program in Racket's default language. Other Racket languages may impose different conditions on the empty program.
The following shows an empty program in Racket's default language. Other Racket languages may impose different conditions on the empty program.
<lang racket>
<syntaxhighlight lang="racket">
#lang racket
#lang racket
</syntaxhighlight>
</lang>


=={{header|Raku}}==
=={{header|Raku}}==
Line 1,331: Line 1,420:


The empty program is valid and does nothing but return a successful exit code:
The empty program is valid and does nothing but return a successful exit code:
<syntaxhighlight lang="raku" line></syntaxhighlight>
<lang perl6></lang>


It is also possible to just specify that the program is written in Raku:
It is also possible to just specify that the program is written in Raku:
<lang perl6>use v6;</lang>
<syntaxhighlight lang="raku" line>use v6;</syntaxhighlight>


or even:
or even:
<lang perl6>v6;</lang>
<syntaxhighlight lang="raku" line>v6;</syntaxhighlight>


=={{header|Raven}}==
=={{header|Raven}}==
Line 1,344: Line 1,433:
=={{header|REBOL}}==
=={{header|REBOL}}==
The header section is mandatory if you want it to be recognized as a REBOL program. It doesn't have to be filled in though:
The header section is mandatory if you want it to be recognized as a REBOL program. It doesn't have to be filled in though:
<lang REBOL>REBOL []</lang>
<syntaxhighlight lang="rebol">REBOL []</syntaxhighlight>


=={{header|Retro}}==
=={{header|Retro}}==
An empty file is the smallest valid program.
An empty file is the smallest valid program.


<syntaxhighlight lang="retro"></syntaxhighlight>
<lang Retro></lang>


=={{header|REXX}}==
=={{header|REXX}}==
Line 1,360: Line 1,449:
===version 1===
===version 1===
This program can be empty (no characters), &nbsp; or a program with (only) one or more blanks.
This program can be empty (no characters), &nbsp; or a program with (only) one or more blanks.
<lang rexx></lang>
<syntaxhighlight lang="rexx"></syntaxhighlight>


===version 2===
===version 2===
REXX on MVS/TSO requires REXX to be within a REXX comment that begins on the first line:
REXX on MVS/TSO requires REXX to be within a REXX comment that begins on the first line:
<lang rexx>/*REXX*/</lang>
<syntaxhighlight lang="rexx">/*REXX*/</syntaxhighlight>


=={{header|Rhope}}==
=={{header|Rhope}}==
Line 1,372: Line 1,461:


=={{header|Ring}}==
=={{header|Ring}}==
<lang ring></lang>
<syntaxhighlight lang="ring"></syntaxhighlight>


=={{header|Robotic}}==
=={{header|Robotic}}==
<lang robotic></lang>
<syntaxhighlight lang="robotic"></syntaxhighlight>

=={{header|RPL}}==
≪ ≫


=={{header|Ruby}}==
=={{header|Ruby}}==
An empty file is a valid Ruby program. However, in order to make it runnable on *nix systems, a shebang line is necessary:
An empty file is a valid Ruby program. However, in order to make it runnable on *nix systems, a shebang line is necessary:
<lang ruby>#!/usr/bin/env ruby</lang>
<syntaxhighlight lang="ruby">#!/usr/bin/env ruby</syntaxhighlight>


=={{header|Run BASIC}}==
=={{header|Run BASIC}}==
<lang runbasic>end ' actually a blank is ok</lang>
<syntaxhighlight lang="runbasic">end ' actually a blank is ok</syntaxhighlight>


=={{header|Rust}}==
=={{header|Rust}}==
<lang rust>fn main(){}</lang>
<syntaxhighlight lang="rust">fn main(){}</syntaxhighlight>


=={{header|Scala}}==
=={{header|Scala}}==
===Scala 2===
<lang scala>object emptyProgram extends App {}</lang>
<syntaxhighlight lang="scala">object emptyProgram extends App {}</syntaxhighlight>
===Scala 3===
<syntaxhighlight lang="scala">@main def a = ()</syntaxhighlight>


=={{header|Scheme}}==
=={{header|Scheme}}==
<lang scheme></lang>
<syntaxhighlight lang="scheme"></syntaxhighlight>


=={{header|Scilab}}==
=={{header|Scilab}}==
<lang scilab></lang>
<syntaxhighlight lang="scilab"></syntaxhighlight>


=={{header|ScratchScript}}==
=={{header|ScratchScript}}==
An empty program is invalid because it gives an [Err: Undefined] error. This behaviour still applies when the program isn't running. Due to this error, a program containing only an empty comment is the smallest possible valid program.
An empty program is invalid because it gives an [Err: Undefined] error. This behaviour still applies when the program isn't running. Due to this error, a program containing only an empty comment is the smallest possible valid program.
<syntaxhighlight lang="scratchscript">//</syntaxhighlight>
<lang ScratchScript>//</lang>

=={{header|sed}}==
A totally empty program is valid, and just copies the input unmodified. The same effect can be achieved with a single ''b'' command (which might be more convenient when called from the command line).
<syntaxhighlight lang="sh">sed "" input.txt
# vs
sed b input.txt</syntaxhighlight>


=={{header|Seed7}}==
=={{header|Seed7}}==
<lang seed7>$ include "seed7_05.s7i";
<syntaxhighlight lang="seed7">$ include "seed7_05.s7i";
const proc: main is noop;</lang>
const proc: main is noop;</syntaxhighlight>


=={{header|Set lang}}==
=={{header|Set lang}}==
<syntaxhighlight lang="set_lang"></syntaxhighlight>
<lang Set_lang></lang>


=={{header|Sidef}}==
=={{header|Sidef}}==
<lang ruby></lang>
<syntaxhighlight lang="ruby"></syntaxhighlight>


=={{header|SimpleCode}}==
=={{header|SimpleCode}}==
<syntaxhighlight lang="simplecode"></syntaxhighlight>
<lang SimpleCode></lang>


=={{header|Simula}}==
=={{header|Simula}}==
{{works with|SIMULA-67}}
{{works with|SIMULA-67}}
<lang simula>BEGIN
<syntaxhighlight lang="simula">BEGIN
END</lang>
END</syntaxhighlight>


=={{header|Slate}}==
=={{header|Slate}}==
<lang slate></lang>
<syntaxhighlight lang="slate"></syntaxhighlight>


=={{header|Smalltalk}}==
=={{header|Smalltalk}}==
<lang smalltalk>[]</lang>
<syntaxhighlight lang="smalltalk">[]</syntaxhighlight>


=={{header|SNOBOL4}}==
=={{header|SNOBOL4}}==
A valid program requires an '''end''' label. The shortest (virtually empty) program is then:
A valid program requires an '''end''' label. The shortest (virtually empty) program is then:
<lang snobol>end</lang>
<syntaxhighlight lang="snobol">end</syntaxhighlight>


=={{header|SNUSP}}==
=={{header|SNUSP}}==
Line 1,434: Line 1,535:


=={{header|Sparkling}}==
=={{header|Sparkling}}==
<syntaxhighlight lang="sparkling"></syntaxhighlight>
<lang Sparkling></lang>


=={{header|SQL PL}}==
=={{header|SQL PL}}==
{{works with|Db2 LUW}}
{{works with|Db2 LUW}}
With SQL only:
With SQL only:
<lang sql pl>
<syntaxhighlight lang="sql pl">
SELECT 1 FROM sysibm.sysdummy1;
SELECT 1 FROM sysibm.sysdummy1;
</syntaxhighlight>
</lang>
Output:
Output:
<pre>
<pre>
Line 1,455: Line 1,556:
{{works with|Db2 LUW}}
{{works with|Db2 LUW}}
With SQL PL:
With SQL PL:
<lang sql pl>
<syntaxhighlight lang="sql pl">
--#SET TERMINATOR @
--#SET TERMINATOR @


Line 1,461: Line 1,562:
BEGIN
BEGIN
END @
END @
</syntaxhighlight>
</lang>
Output:
Output:
<pre>
<pre>
Line 1,472: Line 1,573:
{{works with|Db2 LUW}} version 9.7 or higher.
{{works with|Db2 LUW}} version 9.7 or higher.
With SQL PL:
With SQL PL:
<lang sql pl>
<syntaxhighlight lang="sql pl">
BEGIN
BEGIN
END;
END;
</syntaxhighlight>
</lang>
Output:
Output:
<pre>
<pre>
Line 1,486: Line 1,587:
=={{header|SSEM}}==
=={{header|SSEM}}==
A completely empty program—all store bits clear, just power the machine up and hit Run—is meaningful in SSEM code and even does something, although not something desirable:
A completely empty program—all store bits clear, just power the machine up and hit Run—is meaningful in SSEM code and even does something, although not something desirable:
<lang ssem>00000000000000000000000000000000 0. 0 to CI jump to store(0) + 1
<syntaxhighlight lang="ssem">00000000000000000000000000000000 0. 0 to CI jump to store(0) + 1
00000000000000000000000000000000 1. 0 to CI jump to store(0) + 1</lang>
00000000000000000000000000000000 1. 0 to CI jump to store(0) + 1</syntaxhighlight>
Since the number in address 0 is 0, this is equivalent to
Since the number in address 0 is 0, this is equivalent to
<pre> goto 1;
<pre> goto 1;
Line 1,494: Line 1,595:


The smallest program that will terminate is:
The smallest program that will terminate is:
<lang ssem>00000000000001110000000000000000 0. Stop</lang>
<syntaxhighlight lang="ssem">00000000000001110000000000000000 0. Stop</syntaxhighlight>


=={{header|Standard ML}}==
=={{header|Standard ML}}==
<lang sml>;</lang>
<syntaxhighlight lang="sml">;</syntaxhighlight>


Actually, the smallest possible correct program in Standard ML is an empty source file.
Actually, the smallest possible correct program in Standard ML is an empty source file.
Line 1,504: Line 1,605:
Stata does not accept an empty program, so we have to do something. Here we only declare the minimum [http://www.stata.com/help.cgi?version version] of the interpreter for the program.
Stata does not accept an empty program, so we have to do something. Here we only declare the minimum [http://www.stata.com/help.cgi?version version] of the interpreter for the program.


<lang stata>program define nop
<syntaxhighlight lang="stata">program define nop
version 15
version 15
end</lang>
end</syntaxhighlight>


It's also possible to define an empty function in Mata.
It's also possible to define an empty function in Mata.


<lang stata>function nop() {}</lang>
<syntaxhighlight lang="stata">function nop() {}</syntaxhighlight>


=={{header|Suneido}}==
=={{header|Suneido}}==
<lang Suneido>function () { }</lang>
<syntaxhighlight lang="suneido">function () { }</syntaxhighlight>


=={{header|Swift}}==
=={{header|Swift}}==
<syntaxhighlight lang="swift"></syntaxhighlight>
<lang Swift></lang>


=={{header|Symsyn}}==
=={{header|Symsyn}}==
<syntaxhighlight lang="symsyn"></syntaxhighlight>
<lang Symsyn></lang>


=={{header|Tcl}}==
=={{header|Tcl}}==
Nothing is mandatory in Tcl, so an empty file named <tt>nothing.tcl</tt> would be a valid "empty program".
Nothing is mandatory in Tcl, so an empty file named <tt>nothing.tcl</tt> would be a valid "empty program".
<lang tcl></lang>
<syntaxhighlight lang="tcl"></syntaxhighlight>


=={{header|TI-83 BASIC}}==
=={{header|TI-83 BASIC}}==
<syntaxhighlight lang="ti-basic"></syntaxhighlight>
<lang TI-BASIC></lang>
Displays "Done". If an empty program isn't valid, there are numerous other one-byte solutions:
Displays "Done". If an empty program isn't valid, there are numerous other one-byte solutions:
:
:
Line 1,537: Line 1,638:


=={{header|TI-83 Hex Assembly}}==
=={{header|TI-83 Hex Assembly}}==
<lang TI-BASIC>PROGRAM:EMPTY
<syntaxhighlight lang="ti-basic">PROGRAM:EMPTY
:AsmPrgmC9</lang>
:AsmPrgmC9</syntaxhighlight>


=={{header|TI-89 BASIC}}==
=={{header|TI-89 BASIC}}==
Line 1,546: Line 1,647:
=={{header|Tiny BASIC}}==
=={{header|Tiny BASIC}}==
An empty program works just fine.
An empty program works just fine.
<syntaxhighlight lang="tiny basic"></syntaxhighlight>
<lang Tiny BASIC></lang>


=={{header|Toka}}==
=={{header|Toka}}==
Line 1,565: Line 1,666:


=={{header|Trith}}==
=={{header|Trith}}==
<lang trith></lang>
<syntaxhighlight lang="trith"></syntaxhighlight>


=={{header|True BASIC}}==
=={{header|True BASIC}}==
<lang qbasic>END</lang>
<syntaxhighlight lang="qbasic">END</syntaxhighlight>


=={{header|TUSCRIPT}}==
=={{header|TUSCRIPT}}==
<lang tuscript>$$ MODE TUSCRIPT</lang>
<syntaxhighlight lang="tuscript">$$ MODE TUSCRIPT</syntaxhighlight>


=={{header|UNIX Shell}}==
=={{header|UNIX Shell}}==
{{works with|Bourne Shell}}
{{works with|Bourne Shell}}
<lang bash>#!/bin/sh</lang>
<syntaxhighlight lang="bash">#!/bin/sh</syntaxhighlight>
{{works with|Bourne Again SHell}}
{{works with|Bourne Again SHell}}
<lang bash>#!/bin/bash</lang>
<syntaxhighlight lang="bash">#!/bin/bash</syntaxhighlight>
{{works with|Korn SHell}}
{{works with|Korn SHell}}
<lang ksh>#!/bin/ksh</lang>
<syntaxhighlight lang="ksh">#!/bin/ksh</syntaxhighlight>


=={{header|Unlambda}}==
=={{header|Unlambda}}==
Line 1,587: Line 1,688:
=={{header|Ursa}}==
=={{header|Ursa}}==
The Cygnus/X Ursa interpreter has no problems with empty files, so the shortest program is an empty file.
The Cygnus/X Ursa interpreter has no problems with empty files, so the shortest program is an empty file.
<lang ursa></lang>
<syntaxhighlight lang="ursa"></syntaxhighlight>


=={{header|Vala}}==
=={{header|Vala}}==
<lang Vala>void main() {} </lang>
<syntaxhighlight lang="vala">void main() {} </syntaxhighlight>


=={{header|VAX Assembly}}==
=={{header|VAX Assembly}}==
<lang VAX Assembly>0000 0000 1 .entry main,0 ;register save mask
<syntaxhighlight lang="vax assembly">0000 0000 1 .entry main,0 ;register save mask
04 0002 2 ret ;return from main procedure
04 0002 2 ret ;return from main procedure
0003 3 .end main ;start address for linker</lang>
0003 3 .end main ;start address for linker</syntaxhighlight>


=={{header|VBA}}==
=={{header|VBA}}==
Same as Visual Basic, VB6, etc.
Same as Visual Basic, VB6, etc.
<lang vb>Sub Demo()
<syntaxhighlight lang="vb">Sub Demo()
End Sub</lang>
End Sub</syntaxhighlight>


=={{header|VBScript}}==
=={{header|VBScript}}==
An empty .vbs file is considered the smallest runnable code, but the following (a single apostrophe as comment marker) would also be acceptable (along with other non-executing instructions like <code>option explicit</code>.)
An empty .vbs file is considered the smallest runnable code, but the following (a single apostrophe as comment marker) would also be acceptable (along with other non-executing instructions like <code>option explicit</code>.)
<lang vb>'</lang>
<syntaxhighlight lang="vb">'</syntaxhighlight>


=={{header|Verbexx}}==
=={{header|Verbexx}}==
An empty file is the smallest valid script, but running it does nothing.
An empty file is the smallest valid script, but running it does nothing.
<lang verbexx></lang>
<syntaxhighlight lang="verbexx"></syntaxhighlight>


=={{header|Verilog}}==
=={{header|Verilog}}==
<lang Verilog>module main;
<syntaxhighlight lang="verilog">module main;
endmodule</lang>
endmodule</syntaxhighlight>


=={{header|VHDL}}==
=={{header|VHDL}}==
Compiled and simulated by Modelsim:
Compiled and simulated by Modelsim:
<lang VHDL>entity dummy is
<syntaxhighlight lang="vhdl">entity dummy is
end;
end;


architecture empty of dummy is
architecture empty of dummy is
begin
begin
end;</lang>
end;</syntaxhighlight>


=={{header|Vim Script}}==
=={{header|Vim Script}}==
Line 1,628: Line 1,729:
=={{header|Visual Basic}}==
=={{header|Visual Basic}}==
'''Works with:''' VB6
'''Works with:''' VB6
<lang vb>Sub Main()
<syntaxhighlight lang="vb">Sub Main()
End Sub</lang>
End Sub</syntaxhighlight>


=={{header|Visual Basic .NET}}==
=={{header|Visual Basic .NET}}==
{{works with|Visual Basic .NET|2005}}
{{works with|Visual Basic .NET|2005}}
<lang vbnet>Module General
<syntaxhighlight lang="vbnet">Module General
Sub Main()
Sub Main()
End Sub
End Sub
End Module</lang>
End Module</syntaxhighlight>


=={{header|Vlang}}==
=={{header|V (Vlang)}}==
'''V''' can compile a 0 length, or whitespace only file as "empty", and "correct".
'''V (Vlang)''' can compile a 0 length, or whitespace only file as "empty", and "correct".
<pre></pre>
<pre></pre>
{{out}}
{{out}}
Line 1,649: Line 1,750:


A more reasonable example, that someone might guess was a V program, and not just an emptiness:
A more reasonable example, that someone might guess was a V program, and not just an emptiness:
<lang go>{}</lang>
<syntaxhighlight lang="go">{}</syntaxhighlight>


For an even better chance at guessing that the file is meant as V source code:
For an even better chance at guessing that the file is meant as V source code:


<lang go>module main
<syntaxhighlight lang="go">module main
pub fn main() {}</lang>
pub fn main() {}</syntaxhighlight>


=={{header|Wart}}==
=={{header|Wart}}==
Line 1,666: Line 1,767:


{{libheader|WASI}}
{{libheader|WASI}}
<lang webassembly>(module
<syntaxhighlight lang="webassembly">(module
;;The entry point for WASI is called _start
;;The entry point for WASI is called _start
(func $main (export "_start")
(func $main (export "_start")
Line 1,672: Line 1,773:
)
)
)
)
</syntaxhighlight>
</lang>


=={{header|Wee Basic}}==
=={{header|Wee Basic}}==
<syntaxhighlight lang="wee basic"></syntaxhighlight>
<lang Wee Basic></lang>


=={{header|Wren}}==
=={{header|Wren}}==
<syntaxhighlight lang="wren"></syntaxhighlight>
<lang ecmascript></lang>


=={{header|X86 Assembly}}==
=={{header|X86 Assembly}}==
{{works with|NASM|Linux}}
{{works with|NASM|Linux}}
<lang asm>section .text
<syntaxhighlight lang="asm">section .text
global _start
global _start
Line 1,688: Line 1,789:
mov eax, 1
mov eax, 1
int 0x80
int 0x80
ret</lang>
ret</syntaxhighlight>
{{works with|MASM}}
{{works with|MASM}}
<lang asm>.386
<syntaxhighlight lang="asm">.386
.model flat, stdcall
.model flat, stdcall
option casemap:none
option casemap:none
Line 1,697: Line 1,798:
start:
start:
ret
ret
end start</lang>
end start</syntaxhighlight>

=={{header|XBasic}}==
{{works with|Windows XBasic}}
{{works with|Linux XBasic}}
<syntaxhighlight lang="qbasic">PROGRAM "Empty program"

DECLARE FUNCTION Entry ()

FUNCTION Entry ()

END FUNCTION
END PROGRAM</syntaxhighlight>


=={{header|XPL0}}==
=={{header|XPL0}}==
Line 1,704: Line 1,817:


=={{header|XQuery}}==
=={{header|XQuery}}==
<lang xquery>.</lang>
<syntaxhighlight lang="xquery">.</syntaxhighlight>
The dot selects the current context node and returns it unchanged.
The dot selects the current context node and returns it unchanged.


=={{header|XSLT}}==
=={{header|XSLT}}==
<lang xslt><?xml version="1.0" encoding="utf-8"?>
<syntaxhighlight lang="xslt"><?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<!-- code goes here -->
<!-- code goes here -->
</xsl:stylesheet></lang>
</xsl:stylesheet></syntaxhighlight>


Add other namespaces to the stylesheet attributes (like xmlns:fo="http://www.w3.org/1999/XSL/Format") if you use them.
Add other namespaces to the stylesheet attributes (like xmlns:fo="http://www.w3.org/1999/XSL/Format") if you use them.


Since XSLT is XML, and <code>transform</code> is a synonym for <code>stylesheet</code>, the example above can be minified to:
Since XSLT is XML, and <code>transform</code> is a synonym for <code>stylesheet</code>, the example above can be minified to:
<lang xslt><transform xmlns="http://www.w3.org/1999/XSL/Transform" version="1.0"/></lang>
<syntaxhighlight lang="xslt"><transform xmlns="http://www.w3.org/1999/XSL/Transform" version="1.0"/></syntaxhighlight>


This stylesheet echoes the text content of an XML file. The shortest stylesheet without any output would be
This stylesheet echoes the text content of an XML file. The shortest stylesheet without any output would be
<lang xslt><transform xmlns="http://www.w3.org/1999/XSL/Transform" version="1.0">
<syntaxhighlight lang="xslt"><transform xmlns="http://www.w3.org/1999/XSL/Transform" version="1.0">
<template match="/" />
<template match="/" />
</transform></lang>
</transform></syntaxhighlight>


=={{header|xTalk}}==
=={{header|xTalk}}==
Line 1,730: Line 1,843:


=={{header|XUL}}==
=={{header|XUL}}==
<lang xul>
<syntaxhighlight lang="xul">
<?xml version="1.0"?>
<?xml version="1.0"?>
</syntaxhighlight>
</lang>


=={{header|Yabasic}}==
=={{header|Yabasic}}==
<lang yabasic></lang>
<syntaxhighlight lang="yabasic"></syntaxhighlight>


=={{header|Yorick}}==
=={{header|Yorick}}==
Line 1,745: Line 1,858:
Most 8-bit computers work in a similar fashion: The BASIC interpreter acts as an operating system, and your entire program is essentially a subroutine that BASIC will <code>CALL</code>. If you "return" from your program the computer will go back to BASIC.
Most 8-bit computers work in a similar fashion: The BASIC interpreter acts as an operating system, and your entire program is essentially a subroutine that BASIC will <code>CALL</code>. If you "return" from your program the computer will go back to BASIC.


<lang z80>ret</lang>
<syntaxhighlight lang="z80">ret</syntaxhighlight>


===Game Boy===
===Game Boy===
Line 1,752: Line 1,865:
The beginning of the cartridge header is a jump to the program's start.
The beginning of the cartridge header is a jump to the program's start.


<lang z80>ProgramStart:
<syntaxhighlight lang="z80">ProgramStart:
nop ;not sure if this is needed but Game Boy is somewhat buggy at times and the tutorials I used all did it
nop ;not sure if this is needed but Game Boy is somewhat buggy at times and the tutorials I used all did it
di ;disable interrupts
di ;disable interrupts
foo:
foo:
jp foo ;trap the program counter here. (Don't do this on a real Game Boy, you'll drain the batteries much faster than usual.)</lang>
jp foo ;trap the program counter here. (Don't do this on a real Game Boy, you'll drain the batteries much faster than usual.)</syntaxhighlight>


=={{header|Zig}}==
=={{header|Zig}}==
<lang zig>pub fn main() void {}</lang>
<syntaxhighlight lang="zig">pub fn main() void {}</syntaxhighlight>


=={{header|zkl}}==
=={{header|zkl}}==
An empty file/string is valid.
An empty file/string is valid.
<pre></pre>
<pre></pre>
<lang zkl>c:=Compiler.Compiler.compileText("");
<syntaxhighlight lang="zkl">c:=Compiler.Compiler.compileText("");
c() //--> Class(RootClass#)</lang>
c() //--> Class(RootClass#)</syntaxhighlight>


=={{header|Zoea}}==
=={{header|Zoea}}==
<syntaxhighlight lang="zoea">
<lang Zoea>
program: empty
program: empty
</syntaxhighlight>
</lang>


=={{header|Zoea Visual}}==
=={{header|Zoea Visual}}==
Line 1,777: Line 1,890:
=={{header|Zoomscript}}==
=={{header|Zoomscript}}==
For typing:
For typing:
<syntaxhighlight lang="zoomscript"></syntaxhighlight>
<lang Zoomscript></lang>
For importing:
For importing:



Latest revision as of 18:00, 1 March 2024

Task
Empty program
You are encouraged to solve this task according to the task description, using any language you may know.
Task

Create the simplest possible program that is still considered "correct."

11l

An empty text file is a correct 11l program that does nothing.

360 Assembly

Return to caller

         BR    14           
         END

6502 Assembly

Commodore 64

org $0801                                                      ;start assembling at this address
db $0E,$08,$0A,$00,$9E,$20,$28,$32,$30,$36,$34,$29,$00,$00,$00 ;required init code
rts                                                            ;return to basic

Nintendo Entertainment System

Without an infinite loop the program counter will execute undefined behavior, depending on how "empty" bytes are padded. If we're generous and assume that empty bytes are padded with NOP, eventually the program counter will attempt to execute the interrupt vectors as executable code. If we assume that an "empty program" needs to not crash (even though you really can't tell the difference with nothing on screen), we need a way to "trap" the program counter.

.org $8000                                                     ;usually $8000 but it depends on the mapper.
RESET:                                                         ;execution starts here
JMP RESET  


NMI:                                                           ;NMI can't happen if the screen is off. No need for RTI

IRQ:                                                           ;this will never occur without a CLI command.

.org $FFFA 
;all 6502 based hardware uses this section of memory to hold the addresses of interrupt routines
;as well as the entry point.
dw NMI   ;FFFA-FFFB
dw RESET ;FFFC-FFFD ;this has to be defined or else the program counter will jump to an unknown location
dw IRQ   ;FFFE-FFFF

68000 Assembly

This mostly depends on the implementation, but JMP * will typically suffice for embedded hardware.

NEOGEO

After you get to the main program, you'll need to kick the watchdog every frame to prevent the BIOS from resetting the machine. This is done by writing any byte to memory address 0x00300001. Other than that, an endless loop will suffice (assuming you have a proper cartridge header and a vBlank routine that does nothing except check for bios vblank and return.)

forever:
MOVE.B D0,$300001
JMP forever

8051 Assembly

Continuously loops.

ORG RESET 
jmp $

8086 Assembly

Boot Sector Program

main segment
start:
jmp start        ;2 bytes
padding byte 508 dup (90h)
bootcode byte 55h,0AAh
main ends

If your assembler assembles the code above as an EXE file, you'll need to use a hex editor to strip the EXE header so that it fits exactly into 512 bytes.


16-Bit x86 for EXE Files

.model small  ;.exe file
.stack 1024   ;this value doesn't matter, I chose this arbitrarily
.data
              ;not needed in an empty program
.code
mov ax,4C00h
int 21h       ;exit this program and return to MS-DOS

32-Bit x86

end

However, if the program needs to exit with an exit code of zero:

    segment .text
    global _start

_start:
    mov eax, 60
    xor edi, edi
    syscall
    end

AArch64 Assembly

Simulates system call exit(0). In AArch64, the system call number is passed via x8, and the syscall number for exit is 93.

.text
.global _start

_start:
        mov x0, #0
        mov x8, #93
        svc #0

ABAP

Note that the statement "start-of-selection." is implicitly added. This event block needs to be present in executable programs, it's comparable to the main function in other programming languages.

report z_empty_program.

Action!

Output:

Screenshot from Atari 8-bit computer

Ada

Works with: GCC version 4.1.2
procedure Empty is 
begin 
   null; 
end;

Agena

Actually nothing is valid code, too.

Aime

The nil input is a valid program.

ALGOL 60

'BEGIN' 'END'

ALGOL 68

Brief form

~

BOLD form

SKIP

ALGOL W

In Algol W, a blank statement is a valid statement and a program is a statement followed by a dot. Hence "." is the smallest valid program.

.

AmigaE

PROC main()
ENDPROC

AppleScript

An empty .scpt file is considered the smallest runnable code, but the following would also be acceptable.

return

Argile

The empty string or file are valid and do nothing.

ARM Assembly

GNU/Linux RaspberryPi

.text
    .global _start
_start:
    mov r0, #0
    mov r7, #1
    svc #0

Game Boy Advance

The Nintendo logo is loaded from the cartridge, and the Game Boy Advance's firmware won't boot the game without it. So an empty program can't be run at all. Thus a minimum of a valid cartridge header is required for an empty program that the Game Boy Advance can actually run. The first four bytes of the cartridge header are an unconditional branch instruction to the program's start. Simply duplicate this instruction at that address and voila:

ProgramStart:
b ProgramStart ;don't do this on a real game boy, you'll drain the batteries faster than usual.

Hardware interrupts will not occur if you never enable them, so there is no need to store the interrupt service procedure's address in address $03FFFFFC to prevent a crash. The Game Boy Advance has no "exit" SWI call (the closest is the undocumented hard reset) so this is as close as you can get.

ArnoldC

IT'S SHOWTIME
YOU HAVE BEEN TERMINATED

Arturo

A completely empty script is a valid Arturo program.

Asymptote

AutoHotkey

An empty script would be enough. Adding "#Persistent" makes it persistent.

#Persistent

AutoIt

A single comment can be considered a valid program that does nothing.

;nothing

Avail

Avail files require a header block (that is generally omitted from the examples here). The shortest valid header would only include the module name, which can be reduced to 1 character, assuming the filename is set to match. For "a.avail", this gives the empty program:

Module "a"
Body

This can be further shortened by removing unambiguous whitespace to:

Module"a"Body

For all practical purposes, this header is useless in any other program. It does not import the standard library "Avail" (or any alternatives), so it has access to no methods, types, or values. Here's a short program capable of output:

Module"a"Uses"Avail"Body Print:"!";

Or with more traditional spacing:

Module "a"
Uses "Avail"
Body
Print:"!";

Note however that this output is only available as a compile-time side effect. A program defining a run-time entry point would include an Entries header section, or export its content for an entry point in another module to run.

AWK

The empty string (or file) is recognised as valid program that does nothing.

The program

    1

is the simplest useful program, equivalent to

// {print}

I.e. match every input-line, and print it.
Like the UNIX command 'cat', it prints every line of the files given as arguments, or (if no arguments are given) the standard input.

Axe

Most Axe examples omit the executable name, but it is shown in this example for completeness.

:.PRGMNAME
:

BASIC

Works with: QBASIC
Works with: Quick BASIC
Works with: FreeBASIC
Works with: uBasic/4tH

An empty file is a correct program. It won't be near empty as an executable file, though.

Works with: ZX Spectrum Basic

On the ZX Spectrum, we can have a completely empty program with no lines. Here we attempt to run the empty program:

RUN
0 OK, 0:1

Applesoft BASIC

Batch File

On Windows XP and older, an empty batch file is syntactically correct and does nothing.

But on Windows 7, an empty .bat file is not recognized and thus a character must exist in it. Some valid characters are : @ %

:

BaCon

In BaCon an empty program is a valid program.

BASIC256

BBC BASIC

In BBC BASIC an empty program is syntactically correct.

bc

An empty file is a valid program.

Binary Lambda Calculus

At 4 bits, or half a byte, the smallest BLC program is `cat' :

00 10

corresponding to the smallest valid lambda term, the identity function \x.x

Beef

using System;
class Program
{
  public static void Main()
  {
  }
}

Beeswax

*

(create 6 bees moving in all 6 cardinal directions) or

\

(create 2 bees moving in “northwest” and “southeast” directions) or

_

(create 2 bees moving left and right) or

/

(create 2 bees moving in “northeast” and “southwest” directions)

A valid beeswax program needs at least one of these bee spawning symbols, as a program without bees is not executable. All bees that step off the honeycomb (program area) are automatically deleted, and the program ends if no bees are left.

Befunge

@

The halt command @ is required because code wraps around. An empty file would be an infinite loop.

bootBASIC

BQN

An empty program in BQN produces an error. There must be at least one line which returns a value.

Any valid literal works to make a program run. The shortest way is to use a single digit, or a predefined constant, like π or .


Try It!

Bracmat

An empty file is a valid program. However you need to load it, which requires a statement. In a Linux terminal, you could do

touch empty
bracmat 'get$empty'

In DOS, you can do

touch empty
bracmat get$empty

If we drop the requirement that the shortest program is stored in a file, we can do

bracmat ''

(Linux) or

bracmat ""

(Windows)

If two quotes to demarcate an empty string are counted as bigger than a single undemarcated non-empty expression, we can do

 bracmat .

The dot is a binary operator. So the input consists of three nodes: the operator and its lhs and rhs, both empty strings in this case. If three nodes is too much, consider a slightly bigger glyph, such as the hyphen, which is a prefix, not a binary operator:

 bracmat -

You also can start Bracmat without arguments, in which case it will run in interactive mode. Now press the Enter key. You have just run the shortest valid Bracmat program.

Brainf***

Empty program

Note: this works as all non-instruction characters are considered comments. Alternatively, a zero-byte file also works.

Brlcad

Pressing enter from the mged prompt, just returns another prompt, so I suppose that is the smallest possible program. However, before we can draw anything we at least need to open a database:

opendb empty.g y

Bruijn

The smallest program in bruijn is the identity function (\x.x) and returns its input:

main [0]

C

Works with: C89
main()
{
  return 0;
}

As of C99 the return type is required, but the return statement is not.

Works with: C99
int main() { }

This is technically undefined behavior but on 8086 compatible processors 195 corresponds to the ret assembly instruction.

const main = 195;

C#

As of C# 9.0, an empty text file is a correct C# program that does nothing.

C++

Works with: g++ version 4.8.1
int main(){}

Clean

module Empty

Start world = world

Compile the project with No Console or No Return Type to suppress printing of the value of the world.

Chipmunk Basic

An empty text file is a correct Chipmunk Basic program that does nothing.

Clojure

An empty file is the simplest valid Clojure program.

CLU

This is the shortest program that actually produces a working executable (that does nothing).

start_up = proc () 
end start_up

Portable CLU will compile the empty file without complaint, but not produce an object file.

COBOL

Works with: OpenCOBOL version 2.0

CoffeeScript

Common Lisp

()
.

Component Pascal

BlackBox Component Builder;

MODULE Main;
END Main.

Computer/zero Assembly

The smallest legal program is a single Stop instruction.

        STP

Crystal

D

void main() {}

Dart

main() {}

dc

An empty file is a valid program.

DCL

An empty file is a valid program.

Delphi

See Pascal

Dyalect

Dyalect is not very happy with a completely empty source code file, however a pair of curly brackets would do:

{}

This program would evaluate and return "nil".

Déjà Vu

Shortest module that works with !import:

{}

E

The shortest possible program:


This is equivalent to:

null

EasyLang

#

eC


or

class EmptyApp : Application
{
    void Main()
    {

    }
}

EchoLisp

Ecstasy

module EmptyProgram {
    void run() {
    }
}

EDSAC order code

The smallest program that will load and run without error. Apart from ZF, the 'stop' order, it consists solely of directives to the loader.

T64K  [ set load point ]
GK    [ set base address ]
ZF    [ stop ]
EZPF  [ begin at load point ]

Egel

The smallest program contains nothing.

EGL

General program

package programs;

program Empty_program type BasicProgram {}
	function main()
	end
end

Rich UI handler (but also without 'initialUI = [ ui ], onConstructionFunction = start' it would have been valid.)

package ruihandlers;

import com.ibm.egl.rui.widgets.Div;

handler Empty_program type RUIhandler {initialUI = [ ui ], onConstructionFunction = start}
	ui Div{};
	
	function start()
	end	
end

Eiffel

A file called root.e:

class
    ROOT

create
    make

feature
    make
        do
           
        end
end

Elena

ELENA 4.x

public program()
{
}

Elixir

Elm

--Language prints the text in " "
import Html
main =
 Html.text"empty"

EMal

The empty script is valid and does nothing.

Erlang

An empty module:

-module(empty).

An empty Erlang script file (escript):

main(_) -> 1.

ERRE

PROGRAM EMPTY
BEGIN
END PROGRAM

eSQL

CREATE COMPUTE MODULE ESQL_Compute
  CREATE FUNCTION Main() RETURNS BOOLEAN
  BEGIN
    RETURN TRUE;
  END;
END MODULE;

Euphoria

F#

F# has an interactive mode and a compiled mode. The interactive interpreter will accept an empty file so the shortest valid program is an empty zero-length file with the .fsx extension.

An empty compiled program is:

[<EntryPoint>]
let main args = 0

Factor

If you want to deploy a stand-alone application, that doesn't suffice though. Here's another version.

IN: rosetta.empty
: main ( -- ) ;
MAIN: main

Falcon

>

Prints an empty line.

>>

Prints nothing.

FALSE

Fantom

class Main
{
  public static Void main () {}
}

FBSL

An empty string is a valid FBSL script in both uncompiled and compiled form. It won't however produce any visible output on the screen. The minimum implementations for the user to see the result are presented below:

Console mode:

#APPTYPE CONSOLE
PAUSE

Output:

Press any key to continue...

Graphics mode:

SHOW(ME) ' all FBSL scripts are #APPTYPE GUI on default
BEGIN EVENTS
END EVENTS

Output: GUI Form

Minimum empty Dynamic Assembler block:

DYNASM Foo()

RET ; mandatory

END DYNASM

Minimum empty Dynamic C block:

DYNC Foo()

void main(void)
{
return; // optional
}

END DYNC

Fermat

;

Fish

Actually the shortest valid program is a space (not empty file!), which is an infinite loop, though. (It keeps looping around)

An empty program is invalid; the interpreter will give an error.
The shortest program that will actually finish is a ;, which will end the program immediately:

;

Forth

For a Forth script to be used from a shell, you usually want the last command to be BYE in order to exit the interpreter when finished.

bye

Fortran

       end

FreeBASIC

A completely empty program compiles and runs fine:

friendly interactive shell

Empty programs are valid, but are useless.

Frink

Empty programs are valid.

FunL

An empty text file is a valid FunL program that does nothing.

Futhark

Any Futhark program must have a main function. Alternatively, a Futhark library can be an empty file.

let main = 0

FutureBasic

HandleEvents

Fōrmulæ

Fōrmulæ programs are not textual, visualization/edition of programs is done showing/manipulating structures but not text. Moreover, there can be multiple visual representations of the same program. Even though it is possible to have textual representation —i.e. XML, JSON— they are intended for storage and transfer purposes more than visualization and edition.

Programs in Fōrmulæ are created/edited online in its website.

In this page you can see and run the program(s) related to this task and their results. You can also change either the programs or the parameters they are called with, for experimentation, but remember that these programs were created with the main purpose of showing a clear solution of the task, and they generally lack any kind of validation.

Solution

The following is the simplest expression: the Null expression. When it is run, it does not reduce to anything else, because there should not be rewriting rules for a null expression:

Gambas

Public Sub Main()
End

Gecho

Empty programs are valid.

Gema

An empty program will copy input stream to output stream unchanged.

Genyris


Global Script

This program is intended for use with the HS Global Script and uses its syntax for imperative programs.

λ _. impunit 〈〉

Go

package main
func main() { }

Groovy

GW-BASIC

An empty text file is a correct GW-BASIC program that does nothing.

Hare

export fn main() void = void;

Haskell

Standard: Haskell 98

The simplest possible program is a single module using the implicit module header "module Main(main) where", and defining the action main to do nothing:

main = return ()

The simplest possible module other than Main is one which contains no definitions:

module X where {}

Haxe

class Program {
    static function main() {
    }
}

Unlike most languages Haxe doesn't have arguments in the main function because it targets different platforms (some which don't support program arguments, eg: Flash or Javascript). You need to use the specific libraries of the platform you are targeting to get those.

HicEst

END ! looks better, but is not really needed

HolyC

An empty file is the simplest valid HolyC program and returns 0.

HQ9+

An empty file is a valid HQ9+ program that does nothing.

HTML

HTML 5, section 12.1.2.4 Optional tags, allows to omit html, head and body tags. The implicit body element can be empty, but the implicit head element must contain a title element, says section 4.2.1 The head element. There seems no rule against an empty title. Therefore, the shortest correct HTML document is:

<!DOCTYPE html><title></title>

The shortest correct XHTML document is:

<html xmlns="http://www.w3.org/1999/xhtml"><head><title /></head><body /></html>

Huginn

main(){}

i

software{}

Icon and Unicon

procedure main()   # a null file will compile but generate a run-time error for missing main
end

IDL

end

Inform 7

X is a room

Inform 7 is a language built for making interactive fiction, so a room needs to be defined for the player to start in.

Intercal

PLEASE GIVE UP

Io


J

''

It returns itself:

   '' -: ". ''
1

Java

Works with: Java version 1.5+
public class EmptyApplet extends java.applet.Applet {
    @Override public void init() {
    }
}
public class EmptyMainClass {
    public static void main(String... args) {
    }
}

The "..." basically means "as many of these as the programmer wants." Java will put multiple arguments into an array with the given name. This will work for any method where an array is an argument, but with a twist. A call can be made like this:

method(arg0, arg1, arg2, arg3)

All of the args will be put into an array in the order they were in the call.

Works with: Java version 1.0+
public class EmptyMainClass {
    public static void main(String[] args) {
    }
}
public class EmptyApplet extends java.applet.Applet {
    public void init() {
    }
}

@Override - Indicates that a method declaration is intended to override a method declaration in a superclass. If a method is annotated with this annotation type but does not override a superclass method, compilers are required to generate an error message. It's present from JDK 5.0 (1.5.0) and up.

Actually this is not strictly correct. The smallest possible correct program in Java is an empty source file.

JavaScript

The empty file is a valid program.


Joy

.

A program in Joy is a sequence of zero or more factors followed by a full stop.

Jq

The “empty” filter ignores its input and outputs nothing.

empty

Julia

Julia accepts an empty file as a program.

Output:
$ wc empty_program.jl
0 0 0 empty_program.jl
$ julia empty_program.jl
$

K

KonsolScript

function main() {
  
}

Kotlin

fun main() {}

Lambdatalk

An empty string is a valid program.

Lang

The empty file is a valid program.


Lang5

exit

Lasso

Lasso will parse any file thrown at it. It will ignore everything except what's inside specific Lasso delimiters. Thus a valid program that did nothing, could be an empty file. Perhaps more correct would be a file that had the specific delimiters and then nothing inside them.

[]
<?lasso  ?>
<?=  ?>

LaTeX

\documentclass{minimal}
\begin{document}
\end{document}

LC3 Assembly

The only thing you absolutely need is a directive telling the assembler to stop assembling code (which in this case it has not actually started doing).

        .END

Liberty BASIC

end

Lilypond

According to the manual, all lilypond programs should contain a version statement expressing the minimum version number. If this is missing then a warning will be emitted.

\version "2.6.12"

An input file should really have a basic structure as follows. The compiler automatically adds some of the structure components if they are not present in the source code. However, explicit definition should be used to prevent the compiler from creating unwanted contexts (which can cause side effects):

\version "2.16.2"

\header {

}

\book {
  \score {
    \new Staff {
      \new Voice {

      }
    }
    \layout {

    }
  }
}

Lingo

"Program" doesn't really apply to Lingo. A Director projector (exe/app) doesn't have to contain any scripts/code. For scripts, the shortest possible code is:

Lisp

Most Lisp dialects, including Common Lisp, will accept no text (no forms) as a valid program.

Little Man Computer

V1.3 of Peter Higginson's implementation of Little Man Computer accepts an empty program. If it is assembled then ran in it, a single fetch cycle is performed, which adds 1 to the program counter, which was previously 0, then the address register then the instruction register, both of which were previously blank, are changed to 0. Similar behavior is seen in 101 Computing's implementation of Little Man Computer, in which all CPU registers start at 00, then the program counter changes to 1, the MAR to 0 and the MDR and CIR to 000.

Assembly

Machine code

or end a standalone script with "bye"

#! /usr/local/bin/logo

bye

LSE

LSE64

As with Forth, an empty file is the shortest program. To exit the interpreter at the end of a loaded file:

bye

Lua

M2000 Interpreter

Open M2000 Environment, type Edit A and place one space or insert a new line, then exit pressing Esc and write Save Empty (press enter). Now write New (press enter). Now write Load Empty (press enter) and execute it: write A (press enter). Now you can close environment: write End (press enter).

To open file Empty.gsb, as text file (without loading to list of modules) use Edit "Empty.Gsb". To open it in notepad, we can use this command from M2000 console: win "notepad", dir$+"empty.gsb"

We can open explorer for dir$ (the m2000 user directory) using Win Dir$ (we can use paths without quotes if no space includes, so win c:\ open explorer to c:)

File saved as:

MODULE GLOBAL A {
}

Because we make it in "level 0" (from console) this is a global module. A global module which loaded from console, or was a module loaded from a file at command line, when opening the environment, erased with an End, or a New, or a Start statement (reset of environment by software), or a Break by keyboard (although a dialog ask for proceed the breaking, the reset of environment) , or in some situation by using End Process from Task Manager.

If we wish to run it from command line (by clicking the file in explorer, and let m2000.exe open gsb files), we have to consider the first that this file not contain an execute statement, and that if we didn't use an input statement/function which need console, then console stay hide. To be sure that console open we have to use Show statement. To run A we have to include A at the last line (or append a line and write A). So we write in first line Show (press Esc to return to prompt) and save the file as Save Empty, A so we get this:

MODULE GLOBAL A {Show
}
A

We can open it with Edit "empty.gsb" add some statements between A and block of module, to make some globals, say a DIM a(10) which stay there until the end of current interpreter run (interpreter may run multiple times simultaneously). All globals are globals for current interpreter only.

We can run empty.gsb now (supposed we save it as Save Empty, A), from explorer or using a command in M2000 console which opens another interpreter (and can feed it with some numbers or and strings, but this is another story):

Use empty

So now we see environment again, with open console and at prompt (execution done, and stay open because no End statement executed after the A, or inside module as Set End). Set used to send commands to prompt by code.

Finally this is the code in a file (say Empty.gsb) to open, display something, waiting for a key (now a Show automatic happen) and then finish. We have to write it, in M2000 editor, and save it using Save Empty, A or in any editor and save it as empty.gsb in your desired folder. sav

MODULE GLOBAL A {
Print "Hello World"
a$=Key$
Set End
}
A

We can save it scrabbled text using Save "empty" @, A (not readable, but environment can revert the process using a unique key)

(m2000 is open source so key is not a mystery, but you can make your own clone, and use own key)

M4

Maple

Mathematica / Wolfram Language

MATLAB

 function [varargout] = emptyprogram(varargin)

Maxima

block()$

MAXScript

An empty MAXScript file returns "OK" on execution

MelonBasic

Metafont

end

Microsoft Small Basic

Output:

min

Works with: min version 0.19.3

MiniScript

MIPS Assembly

Linux

This just exits the program with exit code 0 (exit_success)

	.text
main: 	li 	$v0, 10
	syscall

Nintendo 64

In addition to a proper cartridge header, CRCs, and footer, you'll need to write a value of 8 to address 0xBFC007FC so that the cartridge can boot correctly. (Nintendo 64 is big-endian, so the 8 is actually stored at 0xBFC007FF, but every example I've seen stores the value as a uint32 so that's what I'm going with.)

After that, just enter an infinite loop and you're done.

la $t0,0xBFC007FC
li $t1,8
sw $t1,0($t0)

halt:
nop   ;not actually needed by real hardware, but Project 64 doesn't like infinite loops.
b halt
nop

МК-61/52

С/П

ML/I

MMIX

	LOC	#100
Main	TRAP	0,Halt,0	// main (argc, argv) {}

Modula-2

MODULE Main;

BEGIN
END Main.

Modula-3

MODULE Main;

BEGIN
END Main.

MUMPS

The empty file is a valid program.


MSX Basic

10 rem

N/t/roff

An empty input file is valid, but if the output is Postscript or PDF, most PDF viewers will suffer. However, that's the PDF viewer's fault; the typesetter is still okay with an empty file. If one wants grace for the PDF viewers, import a macro that, at the very least, defines some proper margins and pagination as in the following code:

Works with: GNU TROFF version 1.22.2
.mso me.tmac

Nanoquery

Empty files are valid Nanoquery programs that do nothing.

Nemerle

Compiles with warnings:

null

Compiles without warnings (so, more correct):

module Program
{
    Main() : void
    {
    }
}

NetRexx

The following two samples both generate valid programs.

This minimal example requires that the file be named to match the class:

class empty

This example will generate its class based on the file name:

method main(args = String[]) static

NewLISP

;

Nim


Nit

Although a Nit module (file) usually include a module declaration, an empty module is a valid Nit program.


NS-HUBASIC

Oberon-2

MODULE Main;

BEGIN
END Main.

Objeck

bundle Default {
  class Empty {
    function : Main(args : String[]) ~ Nil {
    }
}

Objective-C

Works with: gcc version 4.0.1
int main(int argc, const char **argv) {
    return 0;
}

The minimal empty Cocoa/OpenStep application, useful as life-support for many examples given at RosettaCode, is

#import <Cocoa/Cocoa.h>

int main( int argc, const char *argv[] )
{
  @autoreleasepool {
    [NSApplication sharedApplication];
  }
  return 0;
}

OCaml

Works with: Ocaml version 3.09
;;

Actually, the smallest possible correct program in OCaml is an empty source file.

Octave

An empty text file can be a valid empty program, but since Octave has the concept of "function file" (a file containing a single function; the file is automatically loaded when a function with the same name of the file, save for the extension, is called, and the first function present in the file is used), the name of the empty file matters. E.g. calling an empty file as isempty.m makes unusable the builtin isempty function.

Odin

package main
main :: proc() {}

Oforth

An empty file is a valid oforth file

oforth empty.of

Without file, interpreter can just evaluate bye :

oforth --P"bye"

Ol

An empty file is considered the smallest runnable code.

A single comment can be considered a valid program that does nothing.

A file with any one-digit number ("0", "1", .. "9") or one-character function like "+", "-", etc.) is smallest non empty runnable code.

0

OOC

The Compiler will accept an empty file:

OpenLisp

We can run OpenLisp in shell mode with an empty program as follows. This is for the Linux version of OpenLisp.

#!/openlisp/uxlisp -shell
()

Openscad

OxygenBasic

The smallest possible program is a single space character:

Oz

Accepted by compiler

The simplest 'program' that can be compiled is a file which contains a single expression.

unit

Such a 'program' cannot be executed, though.

Standalone

The simplest standalone program is a root functor that does not define anything. ("Functors" are first-class modules.)

functor
define
   skip
end

PARI/GP

Pascal

program ProgramName;

begin
end.

The first line is not necessary in modern Pascal dialects. With today's most compilers, the empty program is just:

begin end.

PepsiScript

For typing:

#include default-libraries

#author .

class .:

For importing:

While • is valid, the example below is the smallest possible "compiled" program that can be made normally.

•dl◘.◙

Peri

In the Peri language, a text file with a length of zero bytes is a correct program, but it does nothing. Similarly, a text file that consists of all whitespace characters is also a correct program that does nothing.

Perl

The empty program is valid and does nothing but return a successful exit code:

Of course, this then requires you to specify the interpreter on the command line (i.e. perl empty.pl). So slightly more correct as a stand-alone program, is:

#!/usr/bin/perl

The smallest possible Perl one-liner is perl -e0.

Phix

Library: Phix/basics

An empty file is a valid program. When compiled however, it is far from empty as it contains most of the VM and a full run-time diagnostics kit (together about 202K).

PHP

An empty text file is a correct PHP program that does nothing.

Picat

By default, Picat calls the main/0 predicate:

main.
Output:
$ picat empty_program.pi

An shorter way is this program

x.

but then an explicit goal at command line (-g x) must be given.

Output:
$ picat -g x empty_program2.pi

PicoLisp

(de foo ())

Pike

int main(){}

PIR

The :main pragma indicates that a subroutine is the program's entry point. However, if a subroutine is the first (or only, which would also have the effect of making it the first) routine in the program, Parrot will use that. So we may comfortably omit it in this case.

.sub empty_program
.end

Pixilang

Any text longer than 0 characters is valid, otherwise resulting in a "The file is empty or does not exist" error. In this example, a space character is used.

PL/I

s: proc options (main);
end;

PL/SQL

BEGIN
    NULL;
END;

Plain English

To run:

Plain TeX

\bye

Pony

actor Main new create(e: Env) => ""

Pop11

Pop11 has two compilers, incremental and batch compiler. For the incremental compiler one can use just empty program text (empty file), or a file containing nothing but a comment, e.g.

;;; This is a valid Pop11 program that does absolutely nothing.

The batch compiler generates an executable which starts at a given entry point, so one should provide an empty function. If one wants program that works the same both with incremental compiler and batch compiler the following may be useful:

compile_mode :pop11 +strict;
define entry_point();
enddefine;

#_TERMIN_IF DEF POPC_COMPILING
entry_point();

Here the batch compiler will stop reading source before call to entry_point while incremental compiler will execute the call, ensuring that in both cases execution will start from the function entry_point.

PostScript

An empty file is a valid PostScript program that does nothing.

Following good programming practice, however, and to ensure that a PostScript printer will interpret a file correctly, one should make the first 4 characters of the file be

%!PS

If a particular version of the PS interpreter is needed, this would be included right there:

%!PS-2.0
% ...or...
%!PS-3.0
% etc

PowerShell

An empty script block. A script block is a nameless (lamda) function.

&{}
Output:

Processing

An empty .pde sketch file.

When run this will produce a 200x200 inactive default gray canvas.

ProDOS

This is an acceptable program:

IGNORELINE

But also you could include a delimiter character recognized by the compiler/interpreter:

;

Programming Language

For typing:

For importing:

At best, the code can have one line, which is empty. The smallest way to achieve this is to type nothing. However, this is the smallest possible "compiled" program that can be generated via the compiler:

[

PSQL

EXECUTE BLOCK
AS
BEGIN
END

PureBasic

An empty file is a correct PureBasic program that does nothing.

Python

An empty text file is a correct Python program that does nothing.

An empty file named __init__.py even has a structural purpose in Python of declaring that a directory is a Package.

QUACKASM

1
QUIT

Quackery

An empty string or text file is a valid Quackery program that does nothing.

Output:

Quite BASIC

R

An empty text file is a valid empty program

Racket

The following shows an empty program in Racket's default language. Other Racket languages may impose different conditions on the empty program.

#lang racket

Raku

(formerly Perl 6)

The empty program is valid and does nothing but return a successful exit code:

It is also possible to just specify that the program is written in Raku:

use v6;

or even:

v6;

Raven

An empty text file is an empty program.

REBOL

The header section is mandatory if you want it to be recognized as a REBOL program. It doesn't have to be filled in though:

REBOL []

Retro

An empty file is the smallest valid program.

REXX

An empty (or blank) file is a valid REXX program.

Some REXX implementations require a special comment   [1st word in the comment must be   REXX   (in upper/lower/mixed) case]
to distinguish from other types of scripting languages,   and the comment must be the 1st line as well as the   REXX   word.


But a null program (or a program with only blanks in it)   in those other scripting languages is also considered a valid program.

version 1

This program can be empty (no characters),   or a program with (only) one or more blanks.

version 2

REXX on MVS/TSO requires REXX to be within a REXX comment that begins on the first line:

/*REXX*/

Rhope

Works with: Rhope version alpha 1
Main(0,0)
|: :|

Ring

Robotic

RPL

≪  ≫

Ruby

An empty file is a valid Ruby program. However, in order to make it runnable on *nix systems, a shebang line is necessary:

#!/usr/bin/env ruby

Run BASIC

end  ' actually a blank is ok

Rust

fn main(){}

Scala

Scala 2

object emptyProgram extends App {}

Scala 3

@main def a = ()

Scheme

Scilab

ScratchScript

An empty program is invalid because it gives an [Err: Undefined] error. This behaviour still applies when the program isn't running. Due to this error, a program containing only an empty comment is the smallest possible valid program.

//

sed

A totally empty program is valid, and just copies the input unmodified. The same effect can be achieved with a single b command (which might be more convenient when called from the command line).

sed "" input.txt
# vs
sed b input.txt

Seed7

$ include "seed7_05.s7i";
 
const proc: main is noop;

Set lang

Sidef

SimpleCode

Simula

Works with: SIMULA-67
BEGIN
END

Slate

Smalltalk

[]

SNOBOL4

A valid program requires an end label. The shortest (virtually empty) program is then:

end

SNUSP

$#

$ sets the instruction pointer (going right), and # halts the program (empty stack).

Sparkling

SQL PL

Works with: Db2 LUW

With SQL only:

SELECT 1 FROM sysibm.sysdummy1;

Output:

db2 -t
db2 => SELECT 1 FROM sysibm.sysdummy1;

1        
------------
           1

  1 record(s) selected.
Works with: Db2 LUW

With SQL PL:

--#SET TERMINATOR @

CREATE PROCEDURE myProc ()
 BEGIN
 END @

Output:

db2 -td@
db2 => CREATE PROCEDURE myProc ()
...
db2 (cont.) =>  END @
DB20000I  The SQL command completed successfully.
Works with: Db2 LUW

version 9.7 or higher.

With SQL PL:

BEGIN
END;

Output:

db2 -t
db2 => BEGIN
db2 (cont.) => END;
DB20000I  The SQL command completed successfully.

SSEM

A completely empty program—all store bits clear, just power the machine up and hit Run—is meaningful in SSEM code and even does something, although not something desirable:

00000000000000000000000000000000   0. 0 to CI    jump to store(0) + 1
00000000000000000000000000000000   1. 0 to CI    jump to store(0) + 1

Since the number in address 0 is 0, this is equivalent to

    goto 1;
1:  goto 1;

and has the effect of putting the machine into an infinite loop.

The smallest program that will terminate is:

00000000000001110000000000000000   0. Stop

Standard ML

;

Actually, the smallest possible correct program in Standard ML is an empty source file.

Stata

Stata does not accept an empty program, so we have to do something. Here we only declare the minimum version of the interpreter for the program.

program define nop
        version 15
end

It's also possible to define an empty function in Mata.

function nop() {}

Suneido

function () { }

Swift

Symsyn

Tcl

Nothing is mandatory in Tcl, so an empty file named nothing.tcl would be a valid "empty program".

TI-83 BASIC

Displays "Done". If an empty program isn't valid, there are numerous other one-byte solutions:

:
Disp
Return
Stop

TI-83 Hex Assembly

PROGRAM:EMPTY
:AsmPrgmC9

TI-89 BASIC

Prgm
EndPrgm

Tiny BASIC

An empty program works just fine.

Toka

For interpreted code, nothing is required, although bye is necessary for an empty script to exit (rather than wait for the user to exit the listener). Hence:

bye

Or, for a directly runnable script:

#! /usr/bin/toka
bye

For compiled code, the simplest program is an empty quote:

 [ ]

Again, to exit the listener, you will still need user input if this is not followed with bye.

Trith

True BASIC

END

TUSCRIPT

$$ MODE TUSCRIPT

UNIX Shell

Works with: Bourne Shell
#!/bin/sh
Works with: Bourne Again SHell
#!/bin/bash
Works with: Korn SHell
#!/bin/ksh

Unlambda

i

(See how i plays so many roles in unlambda?)

Ursa

The Cygnus/X Ursa interpreter has no problems with empty files, so the shortest program is an empty file.

Vala

void main() {}

VAX Assembly

0000  0000     1 .entry	main,0	;register save mask
  04  0002     2 	ret	;return from main procedure
      0003     3 .end	main	;start address for linker

VBA

Same as Visual Basic, VB6, etc.

Sub Demo()
End Sub

VBScript

An empty .vbs file is considered the smallest runnable code, but the following (a single apostrophe as comment marker) would also be acceptable (along with other non-executing instructions like option explicit.)

'

Verbexx

An empty file is the smallest valid script, but running it does nothing.

Verilog

module main;
endmodule

VHDL

Compiled and simulated by Modelsim:

entity dummy is
end;

architecture empty of dummy is
begin
end;

Vim Script

An empty file is a valid program.

Visual Basic

Works with: VB6

Sub Main()
End Sub

Visual Basic .NET

Works with: Visual Basic .NET version 2005
Module General
    Sub Main()
    End Sub
End Module

V (Vlang)

V (Vlang) can compile a 0 length, or whitespace only file as "empty", and "correct".


Output:
prompt$ ls -s blank.v
0 blank.v
prompt$ v run blank.v
prompt$ echo $?
0

A more reasonable example, that someone might guess was a V program, and not just an emptiness:

{}

For an even better chance at guessing that the file is meant as V source code:

module main
pub fn main() {}

Wart


WDTE

An empty 'file' is a valid WDTE script. That being said, WDTE has no inherent concept of scripts being in files, so a zero-length input may be a better description.

WebAssembly

Library: WASI
(module
    ;;The entry point for WASI is called _start
    (func $main (export "_start")
    
    )
)

Wee Basic

Wren

X86 Assembly

Works with: NASM version Linux
section .text
	global _start
	
	_start:
		mov eax, 1
		int 0x80
		ret
Works with: MASM
.386
.model flat, stdcall
option casemap:none

.code
start:
ret
end start

XBasic

Works with: Windows XBasic
Works with: Linux XBasic
PROGRAM	"Empty program"

DECLARE FUNCTION  Entry ()

FUNCTION  Entry ()

END FUNCTION
END PROGRAM

XPL0

An empty file compiles and builds an EXE file with a single RET instruction, but of course does nothing when executed.


XQuery

.

The dot selects the current context node and returns it unchanged.

XSLT

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
   <!-- code goes here -->
</xsl:stylesheet>

Add other namespaces to the stylesheet attributes (like xmlns:fo="http://www.w3.org/1999/XSL/Format") if you use them.

Since XSLT is XML, and transform is a synonym for stylesheet, the example above can be minified to:

<transform xmlns="http://www.w3.org/1999/XSL/Transform" version="1.0"/>

This stylesheet echoes the text content of an XML file. The shortest stylesheet without any output would be

<transform xmlns="http://www.w3.org/1999/XSL/Transform" version="1.0">
   <template match="/" />
</transform>

xTalk

Works with: HyperCard
Works with: LiveCode
on startup
  
end startup

XUL

<?xml version="1.0"?>

Yabasic

Yorick

An empty file is valid and does nothing.


Z80 Assembly

Amstrad CPC, ZX Spectrum, etc.

Most 8-bit computers work in a similar fashion: The BASIC interpreter acts as an operating system, and your entire program is essentially a subroutine that BASIC will CALL. If you "return" from your program the computer will go back to BASIC.

ret

Game Boy

Translation of: Game Boy Advance

The Nintendo logo is loaded from the cartridge header, and the Game Boy's firmware won't boot the game without it. In addition, the firmware also reads a checksum of the cartridge contents and won't boot the game if it doesn't match the checksum stored in the header. So a truly "empty" program can't be run at all. Thus a minimum of a valid cartridge header is required for an empty program that the Game Boy can actually run. The beginning of the cartridge header is a jump to the program's start.

ProgramStart:
nop ;not sure if this is needed but Game Boy is somewhat buggy at times and the tutorials I used all did it
di  ;disable interrupts
foo:
jp foo ;trap the program counter here. (Don't do this on a real Game Boy, you'll drain the batteries much faster than usual.)

Zig

pub fn main() void {}

zkl

An empty file/string is valid.


c:=Compiler.Compiler.compileText("");
c() //--> Class(RootClass#)

Zoea

program: empty

Zoea Visual

Empty Program

Zoomscript

For typing:

For importing:

If nothing is entered into the "Import program" textbox, the code of the program that was already in the editor will remain.

¶0¶

ZX Spectrum Basic

See BASIC