# Empty program

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

In this task, the goal is to create the simplest possible program that is still considered "correct."

# Programming Languages

## 8051 Assembly

Continuously loops.

ORG RESET jmp $ ## 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 68 ###  Brief form ~ ###  BOLD form SKIP ## 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 example. .text .global _start_start: mov r0, #0 mov r7, #1 svc #0  ## AutoHotkey An empty script would be enough. Adding "#Persistent" makes it persistent. #Persistent ## AutoIt An a single comment can be considered a valid program that does nothing. ;nothing ## AWK The empty string (or file) is recognised as valid program that does nothing. The program  1 is the simplest useful program: like the UNIX command 'cat', it prints every line of the files given as arguments, or (if no arguments are given) the standard input. ## BASIC Works with: QBasic 10 END 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 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: REM ## BBC BASIC In BBC BASIC an empty program is syntactically correct.   ## bc An empty file is a valid program. ## Befunge @  The halt command @ is required because code wraps around. An empty file would be an infinite loop. ## 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 emptybracmat 'get$empty'

In DOS, you can do

## MAXScript

An empty MAXScript file returns "OK" on execution

## Metafont

end

## МК-61/52

С/П

## ML/I



## MMIX

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

## Modula-2

MODULE Main; BEGINEND Main.

## Modula-3

MODULE Main; BEGINEND Main.

## MUMPS

The empty file is a valid program.

## 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

;

## 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.

## OOC

The Compiler will accept an empty file:



## 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.)

functordefine   skipend

## PARI/GP



## Pascal

program ProgramName; beginend.

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

begin end.

## Perl

Works with: Perl version 5.8.8
#!/usr/bin/perl1;
#!/usr/bin/perlexit;
#!/usr/bin/perl# A program without a body will work too
#!/usr/bin/perl

The smallest possible program is an empty file (zero length). This requires you to specify the interpreter instead of relying on the shell's shebang magic, thus: perl empty.pl.

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

## 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 Perl6:

use v6;

or, for relax mode (not yet implemented in rakudo, though):

v6;

or even:

6;

## PHP

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

## 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

## PL/I

s: proc options (main);end;

## PL/SQL

BEGIN    NULL;END;

## 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_COMPILINGentry_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 text file is a correct Powershell script that does nothing.

## ProDOS

This is an acceptable program:

IGNORELINE

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

;

## PSQL

EXECUTE BLOCKASBEGINEND

## 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.

## 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

## 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.



To save an application doing nothing, you need to do a bit more work though:

&bye is boot

## REXX

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

### version 0



### version 1

However, for some REXX implementations the first line has to begin with a REXX comment (that is,   /*   --- namely a slash followed by an asterisk)   in order to recognize that the file is a REXX script/EXEC/program:

/*comment*/

Some environments   (TSO under "MVS", certain IBM SAA environments, and possibly others)   require that the first line begin with a (REXX) comment, and the (four) letters   REXX   be somewhere on the first line (within the comment).
The   REXX   character string may be in any case (lower/upper/mixed) and cannot contain imbedded whitespace.

SAA:   (IBM's)   Systems Application Architecture

### version 2

/**/

### version 3

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

/*REXX*/
/*this REXX program calculates if a date is a workday for the XYZ Company.*/

## Rhope

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


## 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

## Rust

fn main(){}

## Scala

object emptyProgram extends App {}

## Scheme





## UNIX Shell

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

## Unlambda

i


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

## 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.)

'

## VHDL

Compiled and simulated by Modelsim:

entity dummy isend; architecture empty of dummy isbeginend;

## Vim Script

An empty file is a valid program.

## Visual Basic .NET

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

## X86 Assembly

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

## 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
on startup

end startup


## XUL

 <?xml version="1.0"?>

## Yorick

An empty file is valid and does nothing.

## zkl

An empty file/string is valid.

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

# Markup Languages

## 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>

## LaTeX

\documentclass{article}\begin{document}\end{document}

## plainTeX

\bye