Re: Simplicity has a future
- From: Marc Boyer <Marc.Boyer@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 31 May 2006 13:23:29 +0000 (UTC)
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
.
- Follow-Ups:
- Re: Simplicity has a future
- From: Richard Heathfield
- Re: Simplicity has a future
- From: Vladimir Oka
- Re: Simplicity has a future
- References:
- Simplicity has a future
- From: jacob navia
- Re: Simplicity has a future
- From: Marc Boyer
- Re: Simplicity has a future
- From: Richard Heathfield
- Simplicity has a future
- Prev by Date: Re: legality of forward declaration
- Next by Date: Re: malloc() implementation
- Previous by thread: Re: Simplicity has a future
- Next by thread: Re: Simplicity has a future
- Index(es):
Relevant Pages
|