Re: Simplicity has a future



Marc Boyer said:

OK, try this simple test: write a code that read a text line,
without any assumption on its maximal size. Is the C solution
really simplier that the C++ one ?

No, not really. My C solution is very simple and very short: just 23 lines,
divided as follows:

Function declarator lines: 1 \
Blank lines: 1 |
Declaration lines: 5 \ sub-total: 16 lines, in what you might
Opening brace lines: 4 / call "furniture" code - stuff that you
Closing brace lines: 4 | don't really need to worry about.
Return statement: 1 /

That leaves seven more lines. Two of those lines comprise calls to an
existing function (of my own devising, which was not written with your task
in mind, but which was very handy anyway). Another is a loop control
statement (no surprise there). The other four lines are a couple of ifs and
a couple of simple assignments.

Anyone C programmer having trouble understanding the code would probably
have trouble understanding "Winnie the Pooh".

My C++ solution, however, is even simpler!

extern "C" {
#include "my_c_solution's_header.h"
};

and linking in <insert library name here>.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
.