Minix: Hello world!
Minix is about computing and computing is done with programs. Programs are made with compilers, nowadays. Assemblers are still around, but the current clock speeds do not really necessitate them anymore. Therefore I will mainly concentrate on compiler generated 'Hello world' style programs in this section.
The first source is written in Modula-2 of course.
Modula-2
Below is the source that I fed into the Minix Modula-2 compiler. It ran out of the box, of course. This program s so simple that it is hard to make errors. Still, the source shows that:
MODULE hello;
IMPORT InOut;
BEGIN
InOut.WriteString ("Hello world, this is Minix 3 calling.");
InOut.WriteLn;
InOut.WriteString ("Written with the m2 Modula-2 compiler.");
InOut.WriteLn;
END hello.
Compiling is easy:
bash-3.00$ m2 hello.mod -o hello
bash-3.00$ ls -lh
total 21
-rwxr-xr-x 1 jan other 20k Feb 15 11:55 hello
-rw-r--r-- 1 jan other 214 Feb 15 11:02 hello.mod
bash-3.00$ strip hello
bash-3.00$ ls -lh
total 17
-rwxr-xr-x 1 jan other 16k Feb 15 11:56 hello
-rw-r--r-- 1 jan other 214 Feb 15 11:02 hello.mod
I think this is quite clear. Minix is very Unixy. Most of the commands and functions will run out of the box.
The executables work and can be stripped.
C
Of course, Minix comes with a good C compiler. My knowledge of C is limited, still I needed only 6 compiler/editor runs to get all the errors out. Here is the source:
#include <stdio.h>
void main (void)
{
printf ("Hello World!\n");
printf ("This is written with the C compiler of Minix.\n");
}
Only in the 'void main (void)' line, I had no errors... I'm just a simple Modula-2 guy. Compiling was easy:
bash-3.00$ cc hello.c -o helloc
bash-3.00$ ls -lh
-rwxr-xr-x 1 jan other 16k Feb 15 11:56 hello
-rw-r--r-- 1 jan other 131 Feb 15 12:18 hello.c
-rw-r--r-- 1 jan other 214 Feb 15 11:02 hello.mod
-rwxr-xr-x 1 jan other 8k Feb 15 12:18 helloc
bash-3.00$ strip helloc
bash-3.00$ ls -lh
-rwxr-xr-x 1 jan other 16k Feb 15 11:56 hello
-rw-r--r-- 1 jan other 131 Feb 15 12:18 hello.c
-rw-r--r-- 1 jan other 214 Feb 15 11:02 hello.mod
-rwxr-xr-x 1 jan other 6k Feb 15 12:19 helloc
I hate to admit it, but the C compiler makes a lot smaller executables than the Modula-2 compiler does...
Still, Modula-2 is easier to write and maintain and fits in better with my line of thinking. Everyone use his
favorite compiler please! Otherwise these guys made the ACK (Amsterdam Compiler Kit) for nothing.
Pascal
In the 'ack' package are three compilers: Modula-2, C and Pascal. So it's only fair to test the Pascal compiler as well. It took some time to get it going, since my last attempt at a Pascal-like language was in 1978. Here it comes:
program hello (output);
begin
writeln ('Hello world');
end.
The difficult parts for me were the 'output' parameter in the first line and the single quotes in the string.
For the rest there is some resemblance with Modula-2. The statistics:
bash-3.00$ pc hello.p -o hellop
bash-3.00$ ls -l hellop
-rwxr-xr-x 1 jan other 5136 Feb 16 10:58 hellop
bash-3.00$ strip hellop
bash-3.00$ ls -lh hellop
-rwxr-xr-x 1 jan other 3680 Feb 16 10:59 hellop
For some reason, the Pascal executable is even smaller than the C program which is odd since I have reason to
believe the other compilers in fact just have another frontend... Let's do another test with the text strings
identical. Here are the results:
bash-3.00$ pc hello.p -o hellop
bash-3.00$ cc hello.c -o helloc
bash-3.00$ m2 hello.mod -o hellom
bash-3.00$ ls -l hello?
-rwxr-xr-x 1 jan other 7432 Feb 16 11:14 helloc
-rwxr-xr-x 1 jan other 20160 Feb 16 11:15 hellom
-rwxr-xr-x 1 jan other 5232 Feb 16 11:14 hellop
bash-3.00$ strip helloc
bash-3.00$ strip hellom
bash-3.00$ strip hellop
bash-3.00$ ls -lh hello?
-rwxr-xr-x 1 jan other 5864 Feb 16 11:15 helloc
-rwxr-xr-x 1 jan other 16320 Feb 16 11:15 hellom
-rwxr-xr-x 1 jan other 3776 Feb 16 11:15 hellop
Stripping helps, that's clear. And the Pascal compiler produces the tightest code! More investigation is
needed. So return to these pages now and then, or just do it yourself and let me know!
Page created on 16 Februray 2007 and
Page equipped with FroogleBuster technology