Empty program: Difference between revisions
No edit summary |
|||
Line 497: | Line 497: | ||
=={{header|HolyC}}== |
=={{header|HolyC}}== |
||
An empty file is the simplest valid HolyC program and returns 0. |
An empty file is the simplest valid HolyC program and returns 0. |
||
=={{header|Huginn}}== |
|||
<lang huginn>main(){}</lang> |
|||
=={{header|I}}== |
=={{header|I}}== |
Revision as of 23:38, 2 February 2018
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."
Programming Languages
360 Assembly
Return to caller <lang 360 Assembly> BR 14
END</lang>
8051 Assembly
Continuously loops. <lang asm>ORG RESET jmp $</lang>
8086 Assembly
<lang asm>end</lang>
However, if the program needs to exit with an exit code of zero:
<lang asm> segment .text
global _start
_start:
mov eax, 60 xor edi, edi syscall end</lang>
Ada
<lang ada>procedure Empty is begin
null;
end;</lang>
Agena
Actually nothing is valid code, too. <lang agena></lang>
Aime
The nil input is a valid program. <lang aime></lang>
ALGOL 60
<lang algol60>'BEGIN' 'END'</lang>
ALGOL 68
Brief form
<lang algol68>~</lang>
BOLD form
<lang algol68>SKIP</lang>
ALGOL W
<lang algolw>. comment using the <empty statement>;</lang>
AmigaE
<lang amigae>PROC main() ENDPROC</lang>
AppleScript
An empty .scpt file is considered the smallest runnable code, but the following would also be acceptable. <lang applescript>return</lang>
Argile
The empty string or file are valid and do nothing. <lang Argile></lang>
ARM Assembly
GNU/Linux RaspberryPi example. <lang ARM_Assembly>.text
.global _start
_start:
mov r0, #0 mov r7, #1 svc #0 </lang>
AutoHotkey
An empty script would be enough. Adding "#Persistent" makes it persistent. <lang AutoHotkey>#Persistent</lang>
AutoIt
A single comment can be considered a valid program that does nothing. <lang AutoIt>;nothing</lang>
AWK
The empty string (or file) is recognised as valid program that does nothing.
The program
<lang awk> 1</lang>
is the simplest useful program, equivalent to
<lang awk>// {print}</lang>
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. <lang axe>:.PRGMNAME
- </lang>
BASIC
An empty file is a correct program. It won't be near empty as an executable file, though. <lang qbasic></lang>
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>
0 OK, 0:1
Applesoft BASIC
<lang ApplesoftBasic></lang>
Batch File
On Windows XP and older, an empty batch file is syntactically correct and does nothing.
<lang dos></lang>
But on Windows 7, an empty .bat file is not recognized and thus a character must exist in it. Some valid characters are : @ %
<lang dos>:</lang>
BBC BASIC
In BBC BASIC an empty program is syntactically correct. <lang bbcbasic></lang>
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 <lang bracmat>touch empty bracmat 'get$empty'</lang>
In DOS, you can do <lang dos>touch empty bracmat get$empty</lang>
If we drop the requirement that the shortest program is stored in a file, we can do <lang bash>bracmat </lang> (Linux) or <lang dos>bracmat ""</lang> (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: <lang mged>opendb empty.g y</lang>
C
<lang c>main() {
return 0;
}</lang>
As of C99 the return type is required, but the return statement is not.
<lang c>int main() { }</lang>
This is technically undefined behavior but on 8086 compatible processors 195
corresponds to the ret
assembly instruction.
<lang c>const main = 195;</lang>
C#
<lang csharp>class P{static void Main(){}}</lang>
C++
<lang cpp>int main(){}</lang>
Clean
<lang clean>module Empty
Start world = world</lang> Compile the project with No Console or No Return Type to suppress printing of the value of the world.
Clojure
An empty file is the simplest valid Clojure program.
COBOL
<lang cobol></lang>
CoffeeScript
<lang coffeescript></lang>
Common Lisp
<lang lisp>()</lang>
Component Pascal
BlackBox Component Builder; <lang oberon2> MODULE Main; END Main. </lang>
Computer/zero Assembly
The smallest legal program is a single Stop instruction. <lang czasm> STP</lang>
D
<lang d>void main() {}</lang>
Dart
<lang dart>main() { }</lang>
dc
An empty file is a valid program.
DCL
An empty file is a valid program.
Delphi
- See Pascal
Déjà Vu
<lang dejavu></lang>
Shortest module that works with !import
:
<lang dejavu>{}</lang>
E
The shortest possible program:
This is equivalent to: <lang e>null</lang>
eC
or <lang ec>class EmptyApp : Application {
void Main() {
}
}</lang>
EchoLisp
<lang scheme> </lang>
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. <lang edsac>T64K [ set load point ] GK [ set base address ] ZF [ stop ] EZPF [ begin at load point ]</lang>
EGL
General program <lang EGL> package programs;
program Empty_program type BasicProgram {} function main() end end </lang> 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: <lang eiffel>class
ROOT
create
make
feature
make do end
end</lang>
Elena
<lang elena>program = [ ].</lang>
Elixir
<lang elixir></lang>
Elm
<lang elm> --Language prints the text in " " import Html main =
Html.text"empty"
</lang>
Erlang
An empty module: <lang erlang>-module(empty).</lang> An empty Erlang script file (escript): <lang erlang>main(_) -> 1.</lang>
ERRE
<lang> PROGRAM EMPTY BEGIN END PROGRAM </lang>
eSQL
<lang sql>CREATE COMPUTE MODULE ESQL_Compute
CREATE FUNCTION Main() RETURNS BOOLEAN BEGIN RETURN TRUE; END;
END MODULE;</lang>
Euphoria
<lang Euphoria></lang>
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. <lang fsharp></lang> An empty compiled program is: <lang fsharp>[<EntryPoint>] let main args = 0</lang>
Factor
<lang factor></lang> If you want to deploy a stand-alone application, that doesn't suffice though. Here's another version. <lang factor>IN: rosetta.empty
- main ( -- ) ;
MAIN: main</lang>
Falcon
>
Prints an empty line.
>>
Prints nothing.
FALSE
<lang false></lang>
Fantom
<lang fantom>class Main {
public static Void main () {}
}</lang>
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
Fish
Actually the shortest valid program is a space (not empty file!), which is an infinite loop, though. (It keeps looping around)
<lang Fish> </lang>
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:
<lang Fish>;</lang>
Forth
<lang forth></lang> 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>
Fortran
<lang fortran> end</lang>
FreeBASIC
A completely empty program compiles and runs fine: <lang freebasic></lang>
friendly interactive shell
Empty programs are valid, but are useless. <lang fishshell></lang>
Frink
Empty programs are valid. <lang frink></lang>
FunL
An empty text file is a valid FunL program that does nothing. <lang funl></lang>
Futhark
Any Futhark program must have a main
function. Alternatively, a Futhark library can be an empty file.
<lang Futhark> fun main(): int = 0 </lang>
FutureBasic
Why? <lang futurebasic> end </lang>
Gecho
Empty programs are valid. <lang gecho></lang>
Gema
An empty program will copy input stream to output stream unchanged. <lang gema></lang>
Genyris
Go
<lang go>package main func main() { }</lang>
Groovy
<lang groovy></lang>
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: <lang haskell>main = return ()</lang> The simplest possible module other than Main is one which contains no definitions: <lang haskell>module X where {}</lang>
Haxe
<lang haxe>class Program {
static function main() { }
}</lang> 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
<lang hicest>END ! looks better, but is not really needed</lang>
HQ9+
An empty file is a valid HQ9+ program that does nothing.
HolyC
An empty file is the simplest valid HolyC program and returns 0.
Huginn
<lang huginn>main(){}</lang>
I
<lang i>software{}</lang>
Icon and Unicon
<lang Icon>procedure main() # a null file will compile but generate a run-time error for missing main end</lang>
IDL
<lang idl>end</lang>
Inform 7
<lang inform7>X is a room</lang> Inform 7 is a language built for making interactive fiction, so a room needs to be defined for the player to start in.
Intercal
<lang intercal>PLEASE GIVE UP</lang>
Io
J
<lang j></lang> It returns itself: <lang j> -: ". 1</lang>
Java
<lang java>public class EmptyApplet extends java.applet.Applet {
@Override public void init() { }
}</lang>
<lang java>public class EmptyMainClass {
public static void main(String... args) { }
}</lang>
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>
All of the args will be put into an array in the order they were in the call.
<lang java>public class EmptyMainClass {
public static void main(String[] args) { }
}</lang>
<lang java>public class EmptyApplet extends java.applet.Applet {
public void init() { }
}</lang>
@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
<lang joy>.</lang>
Jq
The “empty” filter ignores its input and outputs nothing.
<lang jq>empty</lang>
Julia
Julia accepts an empty file as a program. <lang Julia></lang>
- Output:
$ wc empty_program.jl 0 0 0 empty_program.jl $ julia empty_program.jl $
K
<lang></lang>
KonsolScript
<lang KonsolScript>function main() {
}</lang>
Kotlin
<lang scala>fun main(a: Array<String>) {}</lang>
Lang5
<lang Lang5>exit</lang>
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. <lang Lasso>[]</lang> <lang Lasso><?lasso ?></lang> <lang Lasso><?= ?></lang>
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). <lang lc3asm> .END</lang>
Liberty BASIC
<lang lb>end</lang>
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. <lang lilypond>\version "2.6.12"</lang>
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"
\header {
}
\book {
\score { \new Staff { \new Voice {
} } \layout {
} }
}</lang>
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: <lang lingo></lang>
Lisp
Most Lisp dialects, including Common Lisp, will accept no text (no forms) as a valid program. <lang lisp></lang>
Logo
<lang logo></lang> or end a standalone script with "bye" <lang logo>#! /usr/local/bin/logo
bye</lang>
LSE64
As with Forth, an empty file is the shortest program. To exit the interpreter at the end of a loaded file:
bye
Lua
<lang Lua></lang>
M4
<lang M4></lang>
Maple
<lang Maple></lang>
Mathematica / Wolfram Language
<lang Mathematica></lang>
MATLAB
<lang Matlab> function [varargout] = emptyprogram(varargin) </lang>
Maxima
<lang maxima>block()$</lang>
MAXScript
An empty MAXScript file returns "OK" on execution
Metafont
<lang metafont>end</lang>
МК-61/52
<lang>С/П</lang>
MIPS Assembly
This just exits the program with exit code 0 (exit_success) <lang mips> .text main: li $v0, 10 syscall </lang>
ML/I
<lang ML/I></lang>
MMIX
<lang mmix> LOC #100 Main TRAP 0,Halt,0 // main (argc, argv) {}</lang>
Modula-2
<lang modula2>MODULE Main;
BEGIN END Main.</lang>
Modula-3
<lang modula3>MODULE Main;
BEGIN END Main.</lang>
MUMPS
The empty file is a valid program.
N/t/roff
<lang N/t/roff></lang>
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:
<lang N/t/roff>.mso me.tmac</lang>
Nemerle
Compiles with warnings: <lang Nemerle>null</lang> Compiles without warnings (so, more correct): <lang Nemerle>module Program {
Main() : void { }
}</lang>
NetRexx
The following two samples both generate valid programs.
This minimal example requires that the file be named to match the class: <lang NetRexx>class empty</lang>
This example will generate its class based on the file name: <lang NetRexx>method main(args = String[]) static</lang>
NewLISP
<lang NewLISP>; </lang>
Nim
Nit
Although a Nit module (file) usually include a module declaration, an empty module is a valid Nit program.
Objeck
<lang objeck>bundle Default {
class Empty { function : Main(args : String[]) ~ Nil { }
}</lang>
Objective-C
<lang objc>int main(int argc, const char **argv) {
return 0;
}</lang>
The minimal empty Cocoa/OpenStep application, useful as life-support for many examples given at RosettaCode, is <lang objc>#import <Cocoa/Cocoa.h>
int main( int argc, const char *argv[] ) {
@autoreleasepool { [NSApplication sharedApplication]; } return 0;
}</lang>
OCaml
<lang ocaml>;;</lang>
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.
Oforth
An empty file is a valid oforth file
<lang Oforth>oforth empty.of</lang>
Without file, interpreter can just evaluate bye : <lang Oforth>oforth --P"bye"</lang>
OOC
The Compiler will accept an empty file: <lang ooc></lang>
OpenLisp
We can run OpenLisp in shell mode with an empty program as follows. This is for the Linux version of OpenLisp.
<lang openlisp>
- !/openlisp/uxlisp -shell
() </lang>
OxygenBasic
The smallest possible program is a single space character: <lang oxygenbasic>
</lang>
Oz
Accepted by compiler
The simplest 'program' that can be compiled is a file which contains a single expression. <lang oz>unit</lang> 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.) <lang oz>functor define
skip
end</lang>
PARI/GP
<lang parigp></lang>
Pascal
<lang pascal>program ProgramName;
begin end.</lang> 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>
Perl
The empty program is valid and does nothing but return a successful exit code:
<lang perl></lang>
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:
<lang perl>#!/usr/bin/perl</lang>
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: <lang perl6></lang>
It is also possible to just specify that the program is written in Perl6: <lang perl6>use v6;</lang>
or even: <lang perl6>v6;</lang>
Phix
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.
PicoLisp
<lang PicoLisp>(de foo ())</lang>
Pike
<lang pike>int main(){}</lang>
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. <lang pir>.sub empty_program .end</lang>
PL/I
<lang PL/I>s: proc options (main); end;</lang>
PL/SQL
<lang sql>BEGIN
NULL;
END;</lang>
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. <lang pop11>;;; This is a valid Pop11 program that does absolutely nothing.</lang> 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; define entry_point(); enddefine;
- _TERMIN_IF DEF POPC_COMPILING
entry_point();</lang> 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 <lang postscript>%!PS</lang>
If a particular version of the PS interpreter is needed, this would be included right there: <lang postscript>%!PS-2.0 % ...or... %!PS-3.0 % etc</lang>
PowerShell
An empty script block. A script block is a nameless (lamda) function. <lang PowerShell> &{} </lang>
- Output:
ProDOS
This is an acceptable program: <lang ProDOS>IGNORELINE</lang> But also you could include a delimiter character recognized by the compiler/interpreter: <lang ProDOS>;</lang>
PSQL
<lang sql>EXECUTE BLOCK AS BEGIN END</lang>
PureBasic
An empty file is a correct PureBasic program that does nothing. <lang PureBasic></lang>
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
<lang quackasm>1 QUIT</lang>
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>
- lang racket
</lang>
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: <lang REBOL>REBOL []</lang>
Retro
An empty file is the smallest valid program. <lang Retro></lang>
To save an application doing nothing, you need to do a bit more work though: <lang Retro>&bye is boot</lang>
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, but a null program (or a program with only blanks in it) in those
other scripting languages are also considered an empty program.
version 1
This program can be empty (no characters), or a program with (only) one or more blanks. <lang rexx></lang>
version 2
REXX on MVS/TSO requires REXX to be within a REXX comment that begins on the first line: <lang rexx>/*REXX*/</lang>
Rhope
Main(0,0) |: :|
Ring
<lang ring></lang>
Ruby
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>
Run BASIC
<lang runbasic>end ' actually a blank is ok</lang>
Rust
<lang rust>fn main(){}</lang>
Scala
<lang scala>object emptyProgram extends App {}</lang>
Scheme
<lang scheme></lang>
Scilab
<lang scilab></lang>
Seed7
<lang seed7>$ include "seed7_05.s7i";
const proc: main is noop;</lang>
Set lang
<lang Set_lang></lang>
Sidef
<lang ruby></lang>
Simula
<lang simula>BEGIN END</lang>
Slate
<lang slate></lang>
Smalltalk
<lang smalltalk>[]</lang>
SNOBOL4
A valid program requires an end label. The shortest (virtually empty) program is then: <lang snobol>end</lang>
SNUSP
$#
$ sets the instruction pointer (going right), and # halts the program (empty stack).
Sparkling
<lang Sparkling></lang>
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: <lang ssem>00000000000000000000000000000000 0. 0 to CI jump to store(0) + 1 00000000000000000000000000000000 1. 0 to CI jump to store(0) + 1</lang> 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: <lang ssem>00000000000001110000000000000000 0. Stop</lang>
Standard ML
<lang sml>;</lang>
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.
<lang stata>program define nop
version 15
end</lang>
It's also possible to define an empty function in Mata.
<lang stata>function nop() { }</lang>
Suneido
<lang Suneido>function () { }</lang>
Swift
<lang Swift></lang>
Symsyn
<lang Symsyn></lang>
Tcl
Nothing is mandatory in Tcl, so an empty file named nothing.tcl would be a valid "empty program". <lang tcl></lang>
TI-83 BASIC
<lang TI-BASIC></lang> Displays "Done". If an empty program isn't valid, there are numerous other one-byte solutions:
:
Disp
Return
Stop
TI-83 Hex Assembly
<lang TI-BASIC>PROGRAM:EMPTY
- AsmPrgmC9</lang>
TI-89 BASIC
Prgm EndPrgm
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
<lang trith></lang>
TUSCRIPT
<lang tuscript>$$ MODE TUSCRIPT</lang>
UNIX Shell
<lang bash>#!/bin/sh</lang>
<lang bash>#!/bin/bash</lang>
<lang ksh>#!/bin/ksh</lang>
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. <lang ursa></lang>
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
.)
<lang vb>'</lang>
Verbexx
An empty file is the smallest valid script, but running it does nothing. <lang verbexx></lang>
VHDL
Compiled and simulated by Modelsim: <lang VHDL>entity dummy is end;
architecture empty of dummy is begin end;</lang>
Vim Script
An empty file is a valid program.
Visual Basic
Works with: VB6 <lang vb>Sub Main() End Sub</lang>
Visual Basic .NET
<lang vbnet>Module General
Sub Main() End Sub
End Module</lang>
Wart
X86 Assembly
<lang asm>section .text global _start
_start: mov eax, 1 int 0x80 ret</lang>
<lang asm>.386 .model flat, stdcall option casemap:none
.code start: ret end start</lang>
XPL0
An empty file compiles and builds an EXE file with a single RET instruction, but of course does nothing when executed.
XQuery
<lang xquery>.</lang> The dot selects the current context node and returns it unchanged.
XSLT
<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></lang>
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:
<lang xslt><transform xmlns="http://www.w3.org/1999/XSL/Transform" version="1.0"/></lang>
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">
<template match="/" />
</transform></lang>
xTalk
on startup end startup
XUL
<lang xul> <?xml version="1.0"?> </lang>
Yorick
An empty file is valid and does nothing.
Z80 Assembly
ret
zkl
An empty file/string is valid.
<lang zkl>c:=Compiler.Compiler.compileText(""); c() //--> Class(RootClass#)</lang>
ZX Spectrum Basic
- See BASIC
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: <lang html5><!DOCTYPE html><title></title></lang>
The shortest correct XHTML document is: <lang html5><html xmlns="http://www.w3.org/1999/xhtml"><head><title /></head><body /></html></lang>
LaTeX
<lang latex>\documentclass{article} \begin{document} \end{document}</lang>
Plain TeX
<lang tex>\bye</lang>
- Programming Tasks
- Basic language learning
- Simple
- 360 Assembly
- 8051 Assembly
- 8086 Assembly
- Ada
- Agena
- Aime
- ALGOL 60
- ALGOL 68
- ALGOL W
- AmigaE
- AppleScript
- Argile
- ARM Assembly
- AutoHotkey
- AutoIt
- AWK
- Axe
- BASIC
- Applesoft BASIC
- Batch File
- BBC BASIC
- Bc
- Befunge
- Bracmat
- Brainf***
- Brlcad
- C
- C sharp
- C++
- Clean
- Clojure
- COBOL
- CoffeeScript
- Common Lisp
- Component Pascal
- Computer/zero Assembly
- D
- Dart
- Dc
- DCL
- Delphi
- Déjà Vu
- E
- EC
- EchoLisp
- EDSAC order code
- EGL
- Eiffel
- Elena
- Elixir
- Elm
- Erlang
- ERRE
- ESQL
- Euphoria
- F Sharp
- Factor
- Falcon
- FALSE
- Fantom
- FBSL
- Fish
- Forth
- Fortran
- FreeBASIC
- Friendly interactive shell
- Frink
- FunL
- Futhark
- FutureBasic
- Gecho
- Gema
- Genyris
- Go
- Groovy
- Haskell
- Haxe
- HicEst
- HQ9+
- HolyC
- Huginn
- I
- Icon
- Unicon
- IDL
- Inform 7
- Intercal
- Io
- J
- Java
- JavaScript
- Joy
- Jq
- Julia
- K
- KonsolScript
- Kotlin
- Lang5
- Lasso
- LC3 Assembly
- Liberty BASIC
- Lilypond
- Lingo
- Lisp
- Logo
- LSE64
- Lua
- M4
- Maple
- Mathematica
- Wolfram Language
- MATLAB
- Maxima
- MAXScript
- Metafont
- МК-61/52
- MIPS Assembly
- ML/I
- MMIX
- Modula-2
- Modula-3
- MUMPS
- N/t/roff
- Nemerle
- NetRexx
- NewLISP
- Nim
- Nit
- Objeck
- Objective-C
- OCaml
- Octave
- Oforth
- OOC
- OpenLisp
- OxygenBasic
- Oz
- PARI/GP
- Pascal
- Perl
- Perl 6
- Phix
- PHP
- PicoLisp
- Pike
- PIR
- PL/I
- PL/SQL
- Pop11
- PostScript
- PowerShell
- ProDOS
- PSQL
- PureBasic
- Python
- QUACKASM
- R
- Racket
- Raven
- REBOL
- Retro
- REXX
- Rhope
- Ring
- Ruby
- Run BASIC
- Rust
- Scala
- Scheme
- Scilab
- Seed7
- Set lang
- Sidef
- Simula
- Slate
- Smalltalk
- SNOBOL4
- SNUSP
- Sparkling
- SSEM
- Standard ML
- Stata
- Suneido
- Swift
- Symsyn
- Tcl
- TI-83 BASIC
- TI-83 Hex Assembly
- TI-89 BASIC
- Toka
- Trith
- TUSCRIPT
- UNIX Shell
- Unlambda
- Ursa
- VBScript
- Verbexx
- VHDL
- Vim Script
- Visual Basic
- Visual Basic .NET
- Wart
- X86 Assembly
- XPL0
- XQuery
- XSLT
- XTalk
- XUL
- Yorick
- Z80 Assembly
- Zkl
- ZX Spectrum Basic
- HTML
- LaTeX
- PlainTeX
- Initialization