Simplicity has a future

M

Marc Boyer

Le 31-05-2006 said:
Marc Boyer said:
Le 31-05-2006 said:
Le 31-05-2006, Richard Heathfield <[email protected]> a écrit :
[Any] C programmer having trouble understanding the code would probably
have trouble understanding "Winnie the Pooh".

What is your definition of "C programmer" ?

Someone who understands C.

All the C99 standard ?

C90 is still C. Anyone who understands C90 sufficiently well is not likely
to struggle with C99.

I agree.
...and type too quicky too.

because I gives you contradiction or because I ask you questions ?
Good, because the answer to the question depends on what one means by
"better".

An is also highly dependent of the context. I guess the same man
is able to find one tool better in a situation and another tool in
another situation.
Good, because it depends on what you mean by "simpler".

"simpler" <=> "more simple" ?
You wrote you have a "simple" C solution.
And the OP also use word like "simple" and "complex". I was assuming
there was a 'well known' meaning.

Marc Boyer
 
R

Richard Heathfield

Marc Boyer said:
because I gives you contradiction or because I ask you questions ?
Neither.


"simpler" <=> "more simple" ?

Yes, but what do you mean by "more simple"?
You wrote you have a "simple" C solution.

I do - but what do /I/ mean by "simple"?
And the OP also use word like "simple" and "complex". I was assuming
there was a 'well known' meaning.

There is a well-established dictionary meaning, but programming has a habit
of placing words under considerable strain. "Simple" is a good example.

We have already seen that we can code a simple task ("read a line") in 90+
lines of C (as someone posted recently elsetopic here in clc), or in 23
lines of C of which only about four actually do very much (as I explained
upthread).

Clearly, C is simpler than C.

We can code the task even more simply in C++, by calling the C solution from
C++.

Clearly, C++ is simpler than C.

We can code the task even more simply in C, because we don't need the extern
nonsense.

Clearly, C is simpler than C++.

Clearly, the meaning of "simple" is not simple.
 
M

Marc Boyer

Richard Heathfield said:
Marc Boyer said:

Neither.

So why ?

[SNIP long discussion on 'simple']
Clearly, the meaning of "simple" is not simple.

OK. In french we say "tout ça pour ça" but I do not know the
correct translation in english. Perhaps could I say "Much Ado About
Nothing".

Marc Boyer
 
S

SuperKoko

jacob said:
A recent article on CNN described the problem that phone makers
are facing.

(http://www.cnn.com/2006/TECH/biztech/05/29/cellphone.usability.ap/index.html)

Most people are rejecting the new "supercharged"
cell phones because they just do not want to learn the
incredible complex menus and stuff that you need to use them.

The new phones are just too complicated to use.

The same thing is happening with programming languages too.

Perhaps for guys who program as a hobby.
But a *professional* has to know things deeply, and use the best tools.
For instance, I deem that any professional programmer (independently of
his job), must know several programming languages (for instance, one or
two assembly languages, C, C++, python, perl and php).

Similarly, if I would not want that physic engineers chose to not learn
physics because it is "too complex".

Yeah, I think that it is necessary to learn several languages... Even
assembly, even if you'll never ever write a single line of assembly...
For the same reason a doctor (even a general practicionner) has to
learn biology and biochemestry, even if he will never really "use"
biochemestry.
Learning assembly is at least useful for debugging (and learning
biochemestry can be useful for understanding diseases).

A professional programmer must be a specialist.

And, for becoming a specialist, several years are required... Learning
C++ features (even deeply, reading the C++03 standard) can be done in a
few weeks.
Of course, once you have finished to read the C++ standard, if you want
to be a professional, you'll have to program things during several
years, in order to really learn programming paradigms.

I deem that a professional C programmer which programs large
applications, should learn C++ paradigms (and paradigms from other
languages too), perhaps by first learning other languages, and then,
come back to C, and write code in C using these paradigms (because C
allows them, even if it is error-prone and painful for the fingers
typing on the keyboard).

Unfortunately, there are not many *professionals* in developers team
nowadays, which explains that most desktop applications s**ks nowadays
(for instance, they use 100 times more memory and CPU than they
should).
Extremey complicated languages like C++ are loosing ground to more
simpler languages. People get tired of trying to learn a
monster language where learning the language gets in the way
of the basic needs of the user. You use a language to do something,
and when you have to learn too much stuff or the learning curve
is too steep, a simpler language wins.


This means for C, that C (contrary to what many people think)
has a good opportunity to attract new users. Being a much
simpler language it is the language of choice when you want something
that works without a lot of effort.
First having a simplier refence manual, doesn't mean that the code will
be simplier : If you really want to program correctly with C:
You'll have to dynamically allocate a lot (all) of resources, and check
*all* allocation failures, and handle them properly without *any*
memory leak...
For doing that C++ is much easier to use (thanks to RAII and
exceptions).
Furthermore RAII and exceptions are far easier to handle without bugs
in C++.

If simplier was always better, BCPL or B would be a better language
than C.

Note also that : "Simpler on the paper" doesn't mean "simpler for the
programmer".
For instance, smalltalk has no operator precedences... It is far
simpiler for the implementation, and seems to be simplier in the
reference manual...
But, the reality is that it is a pain for programmers... And that it is
really error prone.

In what sense, malloc/realloc/free is simplier than std::string for
string handling?
 
J

jacob navia

SuperKoko a écrit :
First having a simplier refence manual, doesn't mean that the code will
be simplier : If you really want to program correctly with C:
You'll have to dynamically allocate a lot (all) of resources, and check
*all* allocation failures, and handle them properly without *any*
memory leak...
For doing that C++ is much easier to use (thanks to RAII and
exceptions).
Furthermore RAII and exceptions are far easier to handle without bugs
in C++.


Mmmm... that is easy to do in C if you use Boehms Weiser garbage
collector.

Many C compilers offer it, for instance gcc, lcc-win32 and others.

Even C++ people can benefit from it, no kidding! :)
 
M

Mike S

jacob navia wrote:
[...]
C++, because of the very high learning curve, stays in the way of people
doing the JOB they want to do with the language.

<OT style="all my responses are OT, not just this part">
IMHO the "learning curve" associated with C++ has more to do with
learning the precepts of Object-Oriented Programming than the language
itself. If you have a solid understanding of OOP, then a lot of the
"complexity" of C++ disappears.
C has less surprises, less to learn, and uses FAR LESS MEMORY.

C uses far less memory? If you mean a program written in C will compile
to a smaller executable than a comparable program written in C++, then
I can't believe that claim at all. Whether or not you can consistently
get your C compiler to spit out smaller executables than your C++
compiler for a similar piece of source code is more likely because the
C compiler generated better object code than the C++ compiler. Hell, if
I compile a C++ program to run in legacy 16-bit mode on my x86, I'll
bet it'll be smaller than the corresponding C program written to run on
32-bit Windows, by virtue of the fact that sizeof int will likely be 2
bytes smaller in the 16-bit version, *and* the fact that I can compile
the 16-bit version to a flat binary file, whereas the Windows version
will have to be packaged into the Portable Executable (EXE) file
format, which will invariably bloat the resulting program with EXE
headers, relocation tables, etc. My point is that the size of compiled
programs in either C or C++ (or any language) is more dependent upon

a) how well the compiler can generate object code for the given
language, including how well it can optimize the code
b) which machine you're compiling on and/or the target OS. E.g. if a
particular CPU has a single machine instruction equivalent to
printf("hello world\n") (let's assume stdout goes to a terminal on this
platform), then a "hello world" program you compile on that system will
probably be much smaller than it would be processors that don't support
the PRINT HELLO WORLD instruction.

As for "C has less surprises", I have two words: undefined behavior ;-)
Not only RAM, that nobody cares too much, but HUMAN MEMORY, a far more
precious resource than RAM!

The memory footprint of a language is the amount of data your brain
must load into your neural network to be able to use that language
efficiently.

Well, I don't usually sit down at my computer, ready to program, and
then wait 15 minutes while I "load" a page-for-page copy of the latest
C Standard into my brain. You learn a language by using it, not by
memorizing it.
People that reject a language where they can't possibly know what
are they calling, aren't stupid. The contrary is true. They just
follow the KISS principle!

KEEP IT SIMPLE!

Again, I don't think C++ is overly complex. I think it *can* be. That
is, the programmer is the one who controls how complex his code is - it
is fairly easy to obfuscate C++ code, but there are ways to
de-obfuscate it as well (such as the "using [namespace];" directive to
prevent code from being polluted with namespace qualifiers). The core
language isn't really that hard to grasp, especially if you already
have a knowledge of C and, as I mentioned, you understand the basics of
OOP.

Mike S
 
I

Ian Collins

Richard said:
That approach is likely to bite you one day, if it hasn't silently done so
already.
No, don't forget this is embedded code, so it gets built for the target
with a C compiler, I just use C++ on the host for development and testing.

I just looked back through the code I first used this approach on (back
in '95) and there were three reasons for doing it:

1) lots of smelly code and resultant bugs caused by abuse of enums.

2) lots of smelly code and bugs caused by inappropriate casts. C++
static_cast is a powerful tool for both highlighting (easy to grep for)
and checking casts.

3) I wanted to use mock objects for the hardware the device drivers were
controlling. This is probably why I still do this for new code, it
enables simple tricks that are hard (if not down right impossible) to do
in C like:

#include <inttypes.h>

#if defined __cplusplus
struct SomeRegister
{
SomeRegister& operator=( uint32_t ) {
//do stuff on setting register
}

operator uint32_t() {
//do stuff on reading register
}
};
#else
typedef uint32_t SomeRegister;
#endif

typedef struct
{
SomeRegister reg;
} Registers;

int main(void)
{
Registers registers;

registers.reg = 42;

uint32_t n = registers.reg;
}
 
J

Juuso Hukkanen


Good catch Old Wolf,
Considering that Tomás says Jkop is a different person, You may have
find his long lost twin brother Alternatively you may have provided
important clues for his true identity, in case he has suffers from
severe amnesia. In either case this is a pretty fantastic discovery!

Check:
Both are cracy about using "monkeys":
http://groups.google.com/groups/sea...&enc_author=pCSVAA4AAACGVHDaAE9iLvmctw04UvwT&

and both favor 'k' as variable:
http://groups.google.com/groups/sea...&enc_author=pCSVAA4AAACGVHDaAE9iLvmctw04UvwT&

and Blah classes:
http://groups.google.com/groups/sea...d&enc_author=pCSVAA4AAACGVHDaAE9iLvmctw04UvwT

Amazingly both Jkop and Tomás sign their messages by putting a dash
before their name ( -Jkop / -Tomás )
http://groups.google.com/groups/search?q=Jkop&qt_s=Haku&enc_author=pCSVAA4AAACGVHDaAE9iLvmctw04UvwT
http://groups.google.com/groups/search?q=Tomás&qt_s=Haku&enc_author=pCSVAA4AAACGVHDaAE9iLvmctw04UvwT

Ok, the last one could be purely a culture thing since Reverse DNS
puts them both to to Ireland [City: Dublin]

that according to IP (83.70.62.165 ) taken from the first message by
Tomás written:
http://groups.google.com/group/comp.lang.c++/msg/712f48c4bb80c42b?dmode=source

and also according to Jkops last message IP (83.70.59.143) and his
own admission
http://groups.google.com/group/comp.lang.c++/msg/bca50ec7d164900c?dmode=source
http://groups.google.com/group/comp.lang.c++/msg/8b01d92538b1dcf3

Juuso
 
T

Tomás

Juuso Hukkanen posted:

Good catch Old Wolf,


What is this... a witch hunt?!

This is absolutely ridiculous! There are people who post to newsgroups
under a pseudonym (Old Wolf for example), and there are people who post
using their full name.

You're trying to weed out someone who has changed psuedonym... that's quite
admirable -- I've a jig-saw puzzle in my cupboard if you'd like to play
with that later.

Both are cracy about using "monkeys":


"monkey" is a well-known choice for an arbitrary word. (It's also the prime
example of a word which ends in "y" but yet doesn't change to "ies" to form
the plural).

and both favor 'k' as variable:


"k" is used throughout the science community significantly to signify a
constant. It's been plastered throughout every Physics book I've ever read.

and Blah classes:


If "Blah" isn't an arbitrary name, I don't know what is.

Amazingly both Jkop and Tomás sign their messages by putting a dash
before their name ( -Jkop / -Tomás )


Oh by Jesus then it simply MUST be me.

Ok, the last one could be purely a culture thing since Reverse DNS
puts them both to to Ireland [City: Dublin]


Last time I checked there were about 1.5 million people in Dublin.

Lift my DNA off one of his posts and then I'll admit it was me. Also, you
get the secret, mystery, sparkly prize!

If that will be all, can we get back to discussing the C programming
language?

-Tomás
 
C

CBFalconer

jacob said:
A recent article on CNN described the problem that phone makers
are facing.

(http://www.cnn.com/2006/TECH/biztech/05/29/cellphone.usability.ap/index.html)

Most people are rejecting the new "supercharged"
cell phones because they just do not want to learn the
incredible complex menus and stuff that you need to use them.

The new phones are just too complicated to use.

The same thing is happening with programming languages too.

Extremey complicated languages like C++ are loosing ground to more
simpler languages. People get tired of trying to learn a
monster language where learning the language gets in the way
of the basic needs of the user. You use a language to do something,
and when you have to learn too much stuff or the learning curve
is too steep, a simpler language wins.

This means for C, that C (contrary to what many people think)
has a good opportunity to attract new users. Being a much
simpler language it is the language of choice when you want something
that works without a lot of effort.

Then why are you trying to complicate the language with foolishness
such as operator overloading, garbage collection, references, etc.?

--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
More details at: <http://cfaj.freeshell.org/google/>
Also see <http://www.safalra.com/special/googlegroupsreply/>
 
O

Old Wolf

Juuso said:
Good catch Old Wolf,
Considering that Tomás says Jkop is a different person, You may have
find his long lost twin brother Alternatively you may have provided
important clues for his true identity, in case he has suffers from
severe amnesia. In either case this is a pretty fantastic discovery!

Check:
Both are cracy about using "monkeys":
and both favor 'k' as variable:
and Blah classes:
Amazingly both Jkop and Tomás sign their messages by putting a dash
before their name ( -Jkop / -Tomás )
Ok, the last one could be purely a culture thing since Reverse DNS
puts them both to to Ireland [City: Dublin]
that according to IP (83.70.62.165 ) taken from the first message by
Tomás written:
and also according to Jkops last message IP (83.70.59.143)

Also:

The only guy ever to use (e-mail address removed) as an address here
(as far as I can tell). He changed it a couple of weeks ago --
coincidence again?

A propensity to write "signed main()" (actually this was how I
first noticed).

Variables called "cheddar" and "chocolate".

Replying to any request for code with something that uses
reinterpret_cast to a reference type, or " *new ", or a ten-page
bizarre_cast<> template that doesn't actually do anything
useful.

And of course his manner of insulting anybody who disagrees
with the last thought that popped into his head:
http://groups.google.com/group/comp.lang.c++/msg/4ab1585e1a5aed4d

The only anomaly is that Tomás hasn't called any variables
"poo" yet (maybe he grew up a bit).

I wonder how long he will continue to deny it (or if anybody
else on this NG cares, which is less likely).
 
R

Richard Heathfield

Ian Collins said:
No, don't forget this is embedded code, so it gets built for the target
with a C compiler, I just use C++ on the host for development and testing.

Very, very, very bad idea. You test under C++ rules, but execute under C
rules, and the two sets of rules are different. Wouldn't it make more sense
to test under the same rules you will use for execution?
 
R

Richard Heathfield

Old Wolf said:
I wonder how long he will continue to deny it (or if anybody
else on this NG cares, which is less likely).

We don't care one iota. We don't know what you're talking about. We're not
interested. We'll work out for ourselves whether Tomas is someone we get on
with, and we'll do it individually, not as a group.

For my part, Tomas comes across as a reasonably knowledgeable but somewhat
abrasive poster. When he lightens up a bit, he'll be fine. And I don't give
two hoots whether he has, or has not, reinvented himself, if the end
product is someone who can write C code well. A little less intensity would
be a welcome change, though.
 
I

Ian Collins

Richard said:
Ian Collins said:




Very, very, very bad idea. You test under C++ rules, but execute under C
rules, and the two sets of rules are different. Wouldn't it make more sense
to test under the same rules you will use for execution?
No. Don't forget development testing isn't on the same hardware as the
production environment (which has its own comprehensive acceptance tests).

With all the test cases I have tried, the Sun C and C++ compilers
generate the same code given the same source.

If there was a way to do the mock objects I described in C, I might
consider building the C parts of the test harness with the C compiler,
but then I'd loose the extra type checking.
 
R

Richard Heathfield

Ian Collins said:
No. Don't forget development testing isn't on the same hardware as the
production environment (which has its own comprehensive acceptance tests).

Okay, so you test it again using the live code. Fair enough.
 
J

Juuso Hukkanen

Lift my DNA off one of his posts and then I'll admit it was me.

No need to go into needle-type of pointers, you are probably right.
Sorry and have a great day -Tomás.

Juuso
 
M

Malcolm

Keith Thompson said:
Malcolm.

And if I'm storing arbitrary data, perhaps even a stream of random
numbers, there's no way any kind of AI can "guess" that the byte with
a value of 138 is really supposed to be 137. For that matter, eggs
commonly come in packages of 18; how is this AI of yours supposed to
know whether I meant 12 or 18?
It is an analogue device. So instead of having eight on/off transistors to
represent an 8-bit byte, it has a single charge, which it can resolve to 256
levels with acceptable accuracy. There is always the slight danger, however,
of a shift by one place.
The memory is worse that a conventional one, because it is less reliable, so
why use it? Because it is cheaper to produce.
So you see that a shift from 12 to 18 is impossible. However a shift from 12
to 11 is possible, if we use ASCII. However if we don't use ASCII, but some
encoding where digits are contiguous with non-digits, AI or an intelligent
human reader can make the correction. "Buy 1* eggs" is nonsense, but since *
is contigous with 2, and '#' is contiguous with eight, the correct meaning
can be retrieved. Similarly English text with one lettfr wrong is perfectly
readable.

Where the memory falls down is where the computer insists on an exact
representation, for instance a list of random numbers. Obviously you
wouldn't use it for a life support system.
I'm sure there are hypothetical architectures that are (a) useful, and
(b) impractical for a conforming C implementation. I don't think
you've come up with such an example. (Trinary arithmetic springs to
mind.)
Of course I have. It is a perfectly sensible, but hypothetical, example of a
technological change forcing abandonment of one of the provisions of the
standard.
 
W

Walter Roberson

However if we don't use ASCII, but some
encoding where digits are contiguous with non-digits, AI or an intelligent
human reader can make the correction. "Buy 1* eggs" is nonsense, but since *
is contigous with 2, and '#' is contiguous with eight, the correct meaning
can be retrieved.

This is comp.lang.c and the C standards require that the digits
be numerically contiguous. 2 cannot be numerically contiguous with *
because 2 must be numerically contiguous with 1 and 3.
It is an analogue device. So instead of having eight on/off transistors to
represent an 8-bit byte, it has a single charge, which it can resolve to 256
levels with acceptable accuracy. There is always the slight danger, however,
of a shift by one place.
The memory is worse that a conventional one, because it is less reliable, so
why use it? Because it is cheaper to produce.

If it is that much cheaper, use more of it and use ECC or
constellation codes. Hardware corrections for marginal memory is
a developed field: you don't want to risk losing a multimillion dollar
space-probe to the first cosmic ray that comes along.

Besides, "Buy 1* eggs" is not nonsense: * is used to indicate
footnotes, and old-time programmers use * in ways that pun upon
regular expressions. If a programmer sent me "Buy 1* eggs", I would
interpret it as "buy one or more eggs", and "buy exactly 12 eggs"
would not be anywhere near foremost in my mind.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,141
Latest member
BlissKeto
Top