Empty program: Difference between revisions

From Rosetta Code
Content added Content deleted
(→‎[[C plus plus|C++]]: Corrected: main *may not* return anything but int, but for main the return statement is optional (no matter what the MS compiler tells you))
m (Categorizing programming examples)
Line 5: Line 5:
=Programming Languages=
=Programming Languages=
==[[Ada]]==
==[[Ada]]==
[[Category:Ada]]
'''Compiler:''' [[GCC]] 4.1.2
'''Compiler:''' [[GCC]] 4.1.2


Line 10: Line 11:


==[[BASIC]]==
==[[BASIC]]==
[[Category:BASIC]]
'''Compiler:''' [[QBASIC]]
'''Compiler:''' [[QBASIC]]


Line 15: Line 17:


==[[C]]==
==[[C]]==
[[Category:C]]
'''Compiler:''' [[GCC]] 4.0.3
'''Compiler:''' [[GCC]] 4.0.3


Line 22: Line 25:
}
}


==[[C Sharp|C#]]==
==[[C sharp|C#]]==
[[Category:C sharp]]
'''Compiler:''' Microsoft (R) Visual C# 2005 Compiler version 8.00
'''Compiler:''' Microsoft (R) Visual C# 2005 Compiler version 8.00


Line 33: Line 37:


==[[C plus plus|C++]]==
==[[C plus plus|C++]]==
[[Category:C plus plus]]
'''Compiler:''' [[GCC]] 4.0.3
'''Compiler:''' [[GCC]] 4.0.3


Line 48: Line 53:


==[[Haskell]]==
==[[Haskell]]==
[[Category:Haskell]]
'''Standard:''' [[Haskell98]]
'''Standard:''' [[Haskell98]]


Line 56: Line 62:


==[[Java]]==
==[[Java]]==
[[Category:Java]]
'''Compiler:''' Sun [[javac]], [[JDK]] 1.5.0 and up
'''Compiler:''' Sun [[javac]], [[JDK]] 1.5.0 and up


Line 85: Line 92:


==[[Pascal]]==
==[[Pascal]]==
[[Category:Pascal]]
'''Compiler:''' [[Borland Pascal]]
'''Compiler:''' [[Borland Pascal]]


Line 93: Line 101:


==[[Perl]]==
==[[Perl]]==
[[Category:Perl]]
'''Interpreter:''' [[Perl]] 5.8.8
'''Interpreter:''' [[Perl]] 5.8.8


Line 105: Line 114:


==[[PHP]]==
==[[PHP]]==
[[Category:PHP]]

<?php ?>
<?php ?>


Line 114: Line 123:


==[[Ruby]]==
==[[Ruby]]==
[[Category:Ruby]]
'''Interpreter:''' [[Ruby]] 1.8.5
'''Interpreter:''' [[Ruby]] 1.8.5


Line 123: Line 133:


==[[UNIX Shell]]==
==[[UNIX Shell]]==
[[Category:UNIX Shell]]
'''Interpreter:''' [[Debian Almquist SHell]]
'''Interpreter:''' [[Debian Almquist SHell]]


Line 132: Line 143:


==[[Visual Basic .NET|VB.NET]]==
==[[Visual Basic .NET|VB.NET]]==
[[Category:Visual Basic]]
'''Compiler:''' Microsoft (R) Visual Basic Compiler version 8.0
'''Compiler:''' Microsoft (R) Visual Basic Compiler version 8.0


Line 140: Line 152:


==[[xTalk]]==
==[[xTalk]]==
[[Category:xTalk]]
'''Interpreter:''' [[HyperCard]]
'''Interpreter:''' [[HyperCard]]


Line 147: Line 160:
=Markup Languages=
=Markup Languages=
==[[LaTeX]]==
==[[LaTeX]]==
[[Category:LaTeX]]
'''Compiler:''' [[pdfeTeXk]], Version 3.141592-1.30.4-2.2 (Web2C 7.5.5), [[LaTeX2e]] (2003/12/01)
'''Compiler:''' [[pdfeTeXk]], Version 3.141592-1.30.4-2.2 (Web2C 7.5.5), [[LaTeX2e]] (2003/12/01)



Revision as of 02:43, 24 January 2007

Task
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

Ada

Compiler: GCC 4.1.2

  procedure Empty is begin null; end;

BASIC

Compiler: QBASIC

  END

C

Compiler: GCC 4.0.3

int main (int argc, char *argv[])
{
  return 0;
}

C#

Compiler: Microsoft (R) Visual C# 2005 Compiler version 8.00

static class Program
{
    static void Main(string[] args)
    {
    }
}

C++

Compiler: GCC 4.0.3

int main ( int /*argc*/, char * * /*argv*/ ) 
{
 // Unused arguments should not be named
 // There are variations:
 // 1: main may explicitly return a value
 //    (other non-void-returning C++ functions must do so,
 //    but there's a special exception for main that falling off it
 //    without an explicit return is equivalent to a "return 0;" at
 //    the end of the main function)
 // 2: The arguments may be omitted entirely
}

Haskell

Standard: Haskell98

module Main where
main :: IO ()
main = return ()

Java

Compiler: Sun javac, JDK 1.5.0 and up

public class EmptyMainClass {
    public static void main(String[] args) {
    }
}
public class EmptyApplet extends java.applet.Applet {
    @Override public void init() {
    }
}

Compiler: Sun javac, JDK 1.0 and Up

public class EmptyMainClass {
    public static void main(String[] args) {
    }
}
public class EmptyApplet extends java.applet.Applet {
    public void init() {
    }
}

@Override will be telling the compiler need to override this function. It's presents 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.

Pascal

Compiler: Borland Pascal

program ProgramName;

begin
end.

Perl

Interpreter: Perl 5.8.8

#!/usr/bin/perl


Is this correct? As far as I am aware, that is a shell statement, not perl code. It instructs the shell as to where to find the interpreter to use.

#!/usr/bin/ksh

Would use the korn shell. etc..?

PHP

<?php ?>

Python

Interpreter: Python 2.4.3

#!/usr/bin/env python

Ruby

Interpreter: Ruby 1.8.5

#!/usr/bin/env ruby

Starting an Interactive RuBy shell

 irb

UNIX Shell

Interpreter: Debian Almquist SHell

#!/bin/sh

Interpreter: Bourne Again SHell

#!/bin/bash

VB.NET

Compiler: Microsoft (R) Visual Basic Compiler version 8.0

Module General
    Sub Main()
    End Sub
End Module

xTalk

Interpreter: HyperCard

on startup
  
end startup

Markup Languages

LaTeX

Compiler: pdfeTeXk, Version 3.141592-1.30.4-2.2 (Web2C 7.5.5), LaTeX2e (2003/12/01)

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