C
#include <stdio.h>
main()
{
for(;;)
{
printf ("Hello World!\n");
}
}
And a 1986 entry from Bruce Holloway:
#include "stdio.h"
#define e 3
#define g (e/e)
#define h ((g+e)/2)
#define f (e-g-h)
#define j (e*e-g)
#define k (j-h)
#define l(x) tab2[x]/h
#define m(n,a) ((n&(a))==(a))
long tab1[]={ 989L,5L,26L,0L,88319L,123L,0L,9367L };
int tab2[]={ 4,6,10,14,22,26,34,38,46,58,62,74,82,86 };
main(m1,s) char *s; {
int a,b,c,d,o[k],n=(int)s;
if(m1==1){ char b[2*j+f-g]; main(l(h+e)+h+e,b); printf(b); }
else switch(m1-=h){
case f:
a=(b=(c=(d=g)<<g)<'<g)<<g;
return(m(n,a|c)|m(n,b)|m(n,a|d)|m(n,c|d));
case h:
for(a=f;a=e)for(b=g<<g;b<n;++b)o[b]=o[b-h]+o[b-g]+c;
return(o[b-g]%n+k-h);
default:
if(m1-=e) main(m1-g+e+h,s+g); else *(s+g)=f;
for(*s=a=f;a<e;) *s=(*s<<e)|main(h+a++,(char *)m1);
}
}
1984 & 1986 versions dredged up and submitted by: tdg@cray.com (Terry Greyzck)
:-)
Was the shortest C Hello World Program
Strangest abuse of the rules: <...!uunet!mcvax!hutcs!jar> Jari Arkko
Jari Arkko
Laboratory of Information Processing Science
Helsinki University of Technology
Otakaari 1
02150 Espoo
Finland
Judges notes:
On many systems the compiler will not allow you to send the
object file to /dev/tty. The author suggested:
cc -c -o /dev/tty jar.1.c
On systems that have symbolic links, we suggest:
ln -s /dev/tty jar.1.o
cc -c jar.1.c
if your system has symbolic links. The shell script run
by the makefile simply cats the .o file to the terminal
which can be used as a last resort.
Abuse of the rules winners usually result in a change of the
rules. Starting in 1990, compiling entries must result an
regular file which can be executed.
Selected notes from the author:
This program is (supposedly) the smallest C program able to
print "Hello world.". The compilation itself produces the
desired printout and the program need not be actually run.
Copyright (c) 1989, Landon Curt Noll & Larry Bassel.
All Rights Reserved. Permission for personal, educational or non-profit use is
granted provided this this copyright and notice are included in its entirety
and remains unaltered. All other uses must receive prior permission in writing
from both Landon Curt Noll and Larry Bassel.
jar.1.c
char*_="Hello world.\n";
submitted by: Jari.Arkko@lmf.eua.ericsson.se (Jari Arkko)
This one is the shortest C Hello World Program
Most Versatile Source: Jyrki Holopainen
Jyrki Holopainen
Oy LM Ericsson Ab
SF-02420 Jorvas
Finland
Judges' comments:
To use:
make lmfjyh
./lmfjyh
See the makefile for details.
There's more than one way to get around disk quotas. :-)
Some people have reported problems compiling this entry
with gcc 2.3.3.
The make command:
make tidy
will remove the "special" file that is created during the
make of lmfjyh.
Selected notes from the author:
"Practical and efficient method of compressing source code"
1. Introduction
I will shortly present a totally new compression method.
It may be used to compress any types of files, but it works
best with C-source code.
As an example, I have taken a simple "Hello world!" program
that should be familiar to all C-programmers.
Listing 1. A simple "Hello World" program:
main()
{
puts("Hello World!");
}
2. Packing method
Normally a file name is used only to identify the file,
but this new revolutionary method introduces a totally new concept:
THE FILE NAME IS THE PROGRAM. There is no need to waste
valuable disk space to store source code. The program is
embedded in the file name, only a minor portion of it
is inside the file.
Listing 2. Compressed "Hello world":
char*_=__FILE__;
Listing 3. Code embedded in the file name:
";main(){puts("Hello World!");}char*C=".c
The sample program in listing 1 is 36 bytes long. By using the new
compression method, the example program may be squeezed to sixteen
bytes. In the example the compression ratio is 2:1. It is evident
that the longer the program is, the better the compression ratio
is. The maximum compression ratio in a UNIX environment is 254:16
which equals approximately to 16:1. By using the method a one
megabyte of source code can be compressed to 64 kilobytes.
One might easily think that the program could be compressed to a
single byte by writing a one character long preprocessor directive
in the source file and defining the actual source code in the
command line, eg. 'cc hello.c -DX=main(){puts...'. With this
method nothing is gained, since the compiling commands must be
stored in a file, and that takes even more space than writing the
code in a source file as presented in listing 1.
3. Packing files in a UNIX environment
In a UNIX environment it is possible to write almost any program by
including the code in file names. Since '/' is used to separate
path components and cannot therefore exist in a file name, all
features of C-language cannot be used.
In C, the '/' is used as a division operator and it may also be a
part of a comment start and end identifier. This is, however, not a
dangerous limitation, since practice has shown that comments are
almost totally unnecessary. A real programmer can more easily
understand pure source code, and misleading comments are
disastrous. The division operation may be replaced with pow(x, -1)
and multiplication when using real numbers or with div() function
when using integers.
Large programs must be separated into small modules. This enforces
people to write better programs, since monolithic programming style
cannot be used. Program development will also be faster, no extra
code need not be recompiled after changes have been made.
4. Usage with currently available tools
I have tested how well this new method works with currently
available programming tools.
Any ANSI conforming C-compiler that runs under a REAL operating
system should be able to compile the code. (there may be problems
with some older UNIX variants)
4.1. Compilers:
These worked:
gcc versions 2.0, 2.1, 2.3.2 (ld failed at AIX with gcc 2.1)
cc (HP-UX)
cc (VAX)
These failed miserably:
cc (SunOs/Solaris) - could not start cpp properly
cc/xlc (AIX) - could not open source
4.2. Other tools:
4.2.1 Debuggers: (tested at SunOs 4.1.2)
dbx - Quit with a very 'informative' error message:
"dbx: fatal error: Is a directory"
gdb - Printed almost the same error message ":Is a directory".
It was, however, possible to step through the code but
not list it.
4.2.2 Lints:
- None of the lints at tested environments were able
to open the file.
5. Conclusions
The method can be used to compress any types of files, actually the
compression ratios are even better when compressing other files
than C-source. For example plain text files may be compressed with
INFINITE compression ratio. It is trivial task to compress a 100
kilobytes long text file in about 400 files whose lengths are zero
bytes. The drawback is that the files must be unpacked before they
can be used, so a large amount of temporary disk space is needed,
while C-source is totally usable in the compressed form.
Evidently, there is a long way to go before this new programming
technique may be widely used, since currently there are only few
tools supporting it. The advantages over the traditional methods
are, however, so great that there is no doubt that this method will
be new standard.
Copyright (c) 1993, Landon Curt Noll & Larry Bassel.
All Rights Reserved. Permission for personal, educational or non-profit use is
granted provided this this copyright and notice are included in its entirety
and remains unaltered. All other uses must receive prior permission in writing
from both Landon Curt Noll and Larry Bassel.
lmfjyh.c
char*_=__FILE__;
submitted by: Jari.Arkko@lmf.eua.ericsson.se (Jari Arkko)