Re: Simplicity has a future



Le 31-05-2006, Richard Heathfield <invalid@xxxxxxxxxxxxxxx> a écrit :
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).

Which one ?

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".

What is your definition of "C programmer" ?
When did you met C beginner last time ?
Or wich version of "Winnie the Pooh" did you have looked ?

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

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

and linking in <insert library name here>.

So C++ is simpler than C: that is what I wanted to illustrate ;-)

Marc Boyer
.



Relevant Pages

  • Re: Simplicity has a future
    ... Anyone C programmer having trouble understanding the code would ... You underestimate the depths of Winnie the Pooh! ... Especially in the original Latin. ...
    (comp.lang.c)
  • Re: Simplicity has a future
    ... Anyone C programmer having trouble understanding the code would ... You underestimate the depths of Winnie the Pooh! ... Especially in the original Latin. ...
    (comp.lang.c)
  • Re: Simplicity has a future
    ... Anyone C programmer having trouble understanding the code would probably ... You underestimate the depths of Winnie the Pooh! ...
    (comp.lang.c)
  • >>> POOH PICTURES <<<
    ... winnie the pooh mothers day pictures ... winnie the pooh halloween coloring pictures ...
    (rec.music.classical)
  • Re: The greatest men ever
    ... He's Winnie the Pooh... ... Willy nilly silly old bear. ... Back to the days of Christopher Robin and Pooh. ...
    (rec.humor)