In August 1999, the following challange was posted to the internet
newsgroup: comp.arch.embedded
---------------------------------------------------------------------
WHICH IS BETTER - C or C++ ????

This is a programming challenge in response to those of you who read
the "Nuts to OOP" article in Embedded Systems magazine and didn't
agree with it.

Instead of shouting and arguing which language, C or C++, is better
(for embedded or otherwise), I have decided to make this challenge to
anyone that would dare say anything nice about C++.  It is possible
(albeit remotely) that a C++ programmer will accept this challenge and
win.  This challenge will make it possible for any C++ programmer to
PROVE to the world that C++ is better.  No zingers, no fowl language,
no name calling - just a programming challenge. 

If anyone fails to accept this challenge, then they can't say for sure
that C++ is better than Real C can they?

Attached is a PACMAN-like game programming example in Real C that I
have written specifically for this challenge. The program was written
in about 16 hours and is about 3K in size.  A successful challenger
will be able to clone the program in C++ with OOP in less time and
with fewer bytes.  You are encouraged to copy it and pass it on to
other C++ experts who might want to take on the challenge.
---------------------------------------------------------------------
The attached .ZIP file included C-MAN.COM at 3165 bytes, and the
following CHALENGE.TXT file:
---------------------------------------------------------------------
Take the Real C Challenge and Attempt to PROVE that C++ is Better!!


The enclosed program was written entirely in C.  It is a simple
PACMAN-like game and took me a whopping 16 hours to write and debug.
There was no assembly used with the exception of a few inline I/O
primitives.  The challenge is to write an identical version in C++
that is the same size or smaller than this one and also to write it
in the same or less time.

This is a contest to determine which language is better to write
programs in - C or C++.  It is not a contest about assembler, forth,
pascal, or any other language.

Failure of someone to provide a C++ clone of this program that is
smaller and developed in less time will serve to indicate that real
C is the winner and that C++ is the loser.


C-MAN Game Rules

C-MAN is a PACMAN-like game that is played in a maze on the screen.
The keyboard moves the C-MAN player and the computer moves the
PLUSPLUS-MAN player.  When the program title screen is shown, press
any key to start the game.  The game can be aborted at any time by
pressing the ESCAPE key.

C-MAN is a C programmer who starts out in the game with 4 jobs.  A job
is represented by a green dollar sign.  Whenever C-MAN takes a job, a
new job appears somewhere on the screen to replace the old job.  Also
on the board is PLUSPLUS-MAN who is a C++ progeammer.  PLUSPLUS-MAN is
after C-MAN's jobs and will roam around the screen looking for one of
them to steal.  The object of the game is for C-MAN to eat PLUSPLUS-MAN
before PLUSPLUS-MAN steals all of C-MAN's jobs.  Whenever C-MAN eats
PLUSPLUS-MAN, he gets a new job on the screen, but unfortunately, a
university some where spits out another PLUSPLUS-MAN to contend with.
The game is over when the user presses ESCAPE or PLUSPLUS-MAN steals all
of C-MAN's jobs.


The Basics

This program is a COM file and runs under DOS or a DOS box under
Windows.  It was compiled in TINY model using Turbo C 2.0 with a
custom startup module.  The reason a COM file was chosen was because
it is the most compact of all executable files.  If you choose to
compete with an EXE, then your difficulty level is considerably
higher.  My program contains all of its data internal to itself
and does not utilize any external files.  Also, if you use any
library functions, you must include them as static libraries in
your final program.  Also, the sizes of any external data files
will be added to your file size total.

In order to be valid, a competing C++ program must use Objects.


A Head Start

I will not be releasing the source to my example until someone else
makes a bonafide C++ attempt at this challenge.  It took me 16 hours
to test and debug this thing.  Giving out the source would give others
an unfair advantage.  Nevertheless, I am willing to share some obvious
items that you may or may not be aware of.

1. The program runs under DOS and uses 320x200-256 VGA color graphics.

2. The keyboard functions are system BIOS calls.

3. With a program like this, there are several entities that a C++
   programmer might find OBJECT-able.  Also, this program uses a
   lot of tables that C++ is supposed to work better at than C.

4. The player called PLUSPLUS-MAN is controlled by a single neuron
   artificial intelligence subroutine.  In C, this is trivial.  He
   must be able to wander the screen in an intelligent manner.
   He must also have a certain degree of self preservation and be
   able to recognize danger when he sees it.  Unlike the human
   player, he cannot see through walls or objects.

5. It took me an hour or two just to design the graphics used in this
   program.  They are not very fancy and I am sure that just about
   anybody could do better.  Nevertheless, they are already done and
   in plain view for you to copy.


Conclusion

This game is a programming example and is not intended to be of any
other value.  From a gaming perspective, it is rather dull compared
to just about any other computer game out there.

In case it isn't obvious, the contest winner will be the language
that can write a C-MAN program with the smallest executable file
and in the least amount of time.

If you intend to take me up on this challenge, let me know by email.
My address is: n4mwd@amsat.org

Dennis Hawkins
---------------------------------------------------------------------
To date, no C++ programmer has taken him up on his challenge, however
I had been following the posting for a few days, and noted several
complaints about various aspects of the challenge... I felt it would
be useful to show the results of a C programmer developing to this
specification (which is what a C++ programmer would be doing), so I
wrote this program in Micro-C:

When compiled with the standard Micro-C library, MCMAN.COM weighs in
at 3273 bytes, however since Dennis had removed the TC startup code
(which is over 1K), and rewritten several of the TC library functions,
I felt it was fair to trim the referenced library modules of functions
which were not actually used. This reduced the executable size to: 2873.
The unused functions are:
  LRG.ASM:
   lrg_getpal(), lrg_setpal(), lrg_fill(), lrg_hline(), lrg_vline(),
   lrg_draw(), lrg_erase(), lrg_scale() and lrg_retrace()
  MEMIO.ASM:
   peekw(), poke(), pokew(), in(), inw(), out(), outw()

Noteworthy points of discussion:
  MCMAN is designed to closely mimic C-MAN's "look and feel"
  MCMAN is compiled with the standard Micro-C startup code
    (C-MAN compiled with standard TC startup is over 5k)
  MCMAN.C contains no inline assembly language or BIOS/DOS interrupts calls
    (It does use the BIOS 8x8 character set table)
    (C-MAN calls BIOS to write chars, MCMAN draws them using the table)
  MCMAN has smoother graphics than C-MAN, and is "flicker free"
  MCMAN is compiled for the 8088, C-MAN for the 80286
    (Compiling C-MAN for the 8088 adds about 250 bytes)
  MCMAN's ++MAN is a bit easier to catch (my kids complained)
  Total time to develop/debug MCMAN was about 4 hours.

(The above is not intended to slight Dennis's code, which appears to be
quite well done - I would not have squeezed MCMAN nearly so much without
his program as a goal to beat - The above represents the fact that it is
much easier to improve on a design than to build it from scratch, and I
would expect a C++ programmer accepting the challenge to do the same).
