Comparision of C Sharp and C performance

K

Kenny McCormack

spinoza1111 said:
This space is for technical discussion, not personalities.

Well, see, that's where you are wrong. As I've shown many times in the
past, other than langauge lawyering (*), it is impossible to be on-topic
in this newsgroup. Therefore, the clear and simple purpose/raison
d'etre of this group is for trading insults. And we do that well!

(*) Which is on-topic, but has all the appeal to a sensible person as,
well, real life lawyering...
 
M

Moi

Yeah, but you just did.

Didn't you.

I'm sorry.
I won't ever do so again.
(Is it important to you why?)
And...actually helping Nash find a bug is a real qualification, whereas
being related to Dijkstra...isn't.

I get your point. Did you get mine ?

I'd rather not code in C, because it's a poor language.

Thanks: please don't
Thank you,

AvK
 
K

Keith Thompson

Moi said:
Stop calling Turing (or other names). BTW did I mention that I am related
to Dijkstra? *NO I did not.* I only post code here.
[...]

Using the phrase "Turing-complete", which refers to a well known
concept in computer science, is not name-dropping. The fact that the
C preprocessor isn't Turing-complete may well be relevant to whatever
is being discussed.
 
M

Moi

Moi said:
Stop calling Turing (or other names). BTW did I mention that I am
related to Dijkstra? *NO I did not.* I only post code here.
[...]

Using the phrase "Turing-complete", which refers to a well known concept
in computer science, is not name-dropping. The fact that the C
preprocessor isn't Turing-complete may well be relevant to whatever is
being discussed.

And that is -of course- correct.
(but irrelevant in this flame^H^H^H^H^H discussion)

AvK
 
S

Seebs

You can also compile as a native executable. This is useful when you have a
c# executable that needs to work with a 32-bit dll on a 64-but system.
If left as MSIL, the executable is run as a 64-bit process which cannot work
with the 32-bit dll.

This suggests that, were one seriously interested in benchmarking, the three
useful cases would be C# as MSIL, C# as native, and C as native.

Actually, the best thing, if you're seriously interested in benchmarking, is
for someone to give you a lollipop. :p

-s
 
S

Seebs

You appear to be confusing C macros with conditional compilation.

Thank you! Now I think I see what he's getting at.

Evaluation of #if is clearly compile time. Therefore the preprocessor can
do compile-time evaluations. Therefore when the preprocessor expands
macros which perform computations, obviously, the preprocessor should be
doing compile-time arithmetic!

.... Totally wrong, but it would almost sort of make sense if you didn't
understand the preprocessing phase at all. (And yes, I'll happily grant
that the macro language layer is sort of wonky and inconsistent with
the rest of the language. As soon as you've got a time machine, go back
and fix it, 'k?)

-s
 
S

spinoza1111

Thank you!  Now I think I see what he's getting at.

Evaluation of #if is clearly compile time.  Therefore the preprocessor can
do compile-time evaluations.  Therefore when the preprocessor expands
macros which perform computations, obviously, the preprocessor should be
doing compile-time arithmetic!

... Totally wrong, but it would almost sort of make sense if you didn't
understand the preprocessing phase at all.  (And yes, I'll happily grant
that the macro language layer is sort of wonky and inconsistent with
the rest of the language.  As soon as you've got a time machine, go back
and fix it, 'k?)

-s

I already addressed this and (re) determined what the preprocessor
does, which is pure preprocessing. The compiler does constant folding.
I am using this thread to learn and relearn.

This is a dialog, asshole, not an opportunity for you to appear to be
more qualified than you are by putting down other people. In it,
people have the right to make tentative suggestions and be corrected.

Even Richard Heathfield conducts himself better than you here, because
he has actual, if overly narrow, knowledge and is willing to act
professionally most of the time. He does lie: but it's an indication
of how evil people can become here that you act much worse.

You're completely deluded about bytecodes, unqualified to speak on
them and unwilling to learn. You have a psychology degree and are
apparently a sort of script kiddie, tech writer and gofer who is
pretending to be a programmer by destroying other people.
 
S

spinoza1111

Moi said:
On Thu, 31 Dec 2009 09:10:03 -0800,spinoza1111wrote: [...]
use conditional macro instructions, and the C preprocessor (perhaps
fortunately) isn't Turing-complete whereas in BAL you could construct
Stop calling Turing (or other names). BTW did I mention that I am
related to Dijkstra? *NO I did not.* I only post code here. [...]

Using the phrase "Turing-complete", which refers to a well known concept
in computer science, is not name-dropping.  The fact that the C
preprocessor isn't Turing-complete may well be relevant to whatever is
being discussed.

And that is -of course- correct.
(but irrelevant in this flame^H^H^H^H^H discussion)

You made it a bullying session (not a flame war, since that term
implies that I'm engaged in similar behavior to yours, and I am not).

And, the fact is that the preprocessor concept was simultaneously
stolen, downsized and messed up by the original designers of C
including Dennis Ritchie. Much of C is this kind of vandalism. It's
not popular outside of the USA esp. in the EU for that reason.
 
S

spinoza1111

43=3DA0am, (e-mail address removed) (Richard Harter) wrote:
On Wed, 30 Dec 2009 08:39:34 -0800 (PST),spinoza1111
[snip]
Um, the stack of the threads is where you typically put cheap per-
thread data. =3D3DA0Otherwise you allocate it off the heap. =3D3DA0= In the =3D
case of
the *_r() GNU libc functions they store any transient data in the
structure you pass it. =3D3DA0That's how they achieve thread safety= .
It's a clumsy and old-fashioned method, not universally used. It also
has bugola potential.
You see, the called routine is telling the caller to supply him with
"scratch paper". This technique is an old dodge. It was a requirement
in IBM 360 BAL (Basic Assembler Language) that the caller provide the
callee with a place to save the 16 "general purpose registers" of the
machine.
The problem then and now is what happens if the caller is called
recursively by the callee as it might be in exception handling, and
the callee uses the same structure. It's not supposed to but it can
happen.
He's not talking about the technique used in BAL etc. =3DA0The
transient data is contained within a structure that is passed by
the caller to the callee. =3DA0The space for the structure is on the
stack. =3DA0Recursion is permitted.
If control "comes back" to the caller who has stacked the struct and
the caller recalls the routine in question with the same struct, this
will break.
This isn't right; I dare say the fault is mine for being unclear.
C uses call by value; arguments are copied onto the stack. =A0The
upshot is that callee operates on copies of the original
variables. =A0This is true both of elemental values, i.e., ints,
floats, etc, and composite values, i.e., structs.
So, when the calling sequence contains a struct a copy of the
struct is placed on the stack. =A0The callee does not have access
to the caller's struct. =A0To illustrate suppose that foo calls bar
and bar calls foo, and that foo passes a struct to bar which in
turn passes the struct it received to foo. =A0There will be two
copies of the struct on the stack, one created when foo called
bar, and one created when bar called foo.
Correct. And foo sees bar's scratchpad memory, which is a security
exposure. It creates opportunities for fun and games.
I'm foo. I have to pass bar this struct:
struct { int i; char * workarea; }
i is data. workarea is an area which bar needs to do its work. bar
puts customer passwords in workarea. Control returns to foo in an
error handler which is passed the struct. foo can now see the
passwords.
Because you violate encapsulation, you have a security hole, right?
Better to use an OO language in which each invocation of the stateful
foo object gets as much memory as it needs.
Let me know if I am missing anything.

As an initial remark, your example is not the kind of thing that
St. Denis was discussing.  The "per-thread data" is data that is
passed down to routines in a thread.  The top level routines in
the thread get passed a copy of the per-thread data struct; in
turn they pass copies down to the routines they call.  Either the
struct has no pointers at all or, if it does have pointers, they
are opaque pointers.  There is no path for passing data up.

As a second initial remark, your example should be qualified.
Generally speaking, functions that need scratch space provide it
internally.  For the sake of argument, let's suppose that there
is some good reason for supplying scratch space.

You don't "have to pass bar this struct" - there are a number of
alternatives, perhaps too many.  Here are some:

(1) If we know the size of work area we can make it an array.
The struct is:

struct stuff {
    int i;
    char workarea[size];

}

Foo and bar will have separate copies of the workarea.  The
upside is that there is no security hole.  The down side is that
there will be two copies on the stack.

(2) We can malloc the space in the calling sequence.  The
following won't pass muster in a code review but it has the
general idea:

struct stuff {int i; void * workarea;} barbill;

barbill.workarea = malloc(size);

bar(barbill);

In this version, bar frees the workarea.  The upside is that
there is only one copy of the work area.  The downside is that
bar must free the work area space.

(3) Bar can zero out the space when it is done with it.

(4) Foo does not call bar directly; instead it calls an inteface
routine with a handle to bar as an argument; the interface
routine calls bar and takes care of zeroing out the space.

Yes, but now you may not be seeing that you're fixing a fix,
responding to the issue of security exposure (which is a well-known
and unsolvable problem in C starting with sprintf()) with more code
which may or may not be used in practice.
 
S

spinoza1111

spinoza1111wrote:



You appear to be confusing C macros with conditional compilation.

(Sigh) C macros provide an incomplete form of conditional compilation
(#if and #ifdef). But a C preprocessor statement cannot iterate or go
to. But even without iterate and go to it has created a lot of damage.

What the original poster's trick shows: that a combination of constant
folding and the preprocessor in effect negates one useful thing to say
about the preprocessor: that IN EFFECT it makes a pure textual
substitution. This effect is negated by a "standard" which gives the
compiler permission to do constant folding in a visible way up front
(resulting in my example in an unwanted error message when I divide by
zero on purpose in a simple program to test an error handler). To see
the intent original poster's method for determining the size of a
table, you have to forget what you learned when you read elsethread,
that "the C preprocessor does a pure textual replacement".

The *telos* of a system increasingly manned by unqualified corporate
types like Seebach is to destroy the ability to speak plain English
about C. What irritates them isn't "mistakes", since Seebach spoke
mistakenly about .Net and Java bytecode "interpretation" without
bothering to look up JIT compilation.

It's the use of language itself.

The comparision to religious fundamentalism which I've made elsethread
is apropos, because religious fundamentalists hate the metaphors of
speech and destroy religion when (as in Plymouth Bay colony in
Massachusetts in the 17th century) they prefer to forbid women Bible
discussion groups, and persecute their members as witches or (as
today) Islamic and Jewish feminists horrify the self-appointed male
thought leaders.

Seebach dislikes Schildt because he used language to talk about C in a
way Seebach could not: yet Seebach makes even more egregious errors
("the 'heap' is a DOS term" and "bytecodes are interpreted in .Net and
Java").
 
S

spinoza1111

spinoza1111wrote:


You appear to be confusing C macros with conditional compilation.
Neither #if nor #ifdef is a C macro. They are preprocessor directives.

You don't know macros. You see, "macros" were invented long before C.
Their first use was for textual substitution in assembler programs,
but then it was noticed that at the same time and in the same way,
conditional and looping macros could provide more apparent power.

Buy my book to read about this prehistory. Or die.

For this reason, my toolkit of "macros" which generated the tables of
the first cellular mobile OS included conditional and looping
operations to generate Z-80 tables accurately.

Likewise, the code I maintained at Princeton in PL.I that used textual
substitution, conditional compilation and macro-time do while was
"macro" code.

Get more experience before you speak.
 > But a C preprocessor statement cannot iterate or go


If your claim is that you have done a lot of damage using the C
preprocessor, I would not dream of disputing it. Nevertheless, some

I have done very little, since at the time I was (ta da) assisting
Nash with C, I noticed that it was less adequate for real development
than Visual Basic or Rexx.
people seem to manage to use it safely. We call these people "C
programmers".


It's not a trick. It's a technique. It's even demonstrated in the
language spec.

 > that a combination of constant


Look, it's really easy. If you do this:

#define X y

then, while that directive is in effect, every occurrence of X that is
not in a string or comment is replaced with y. That's easy, right?

And if you do this:

#define F(a, b) a foo b bar a baz b

then, while that directive is in effect, every occurrence of this:

F(x, y)

is replaced with this:

x foo y bar x foo y

This is not rocket science.

And if you do this

#define FOO (1/0)

you get a compiler message even though you want to test an error
handler. And so C is powerful in what way?
This effect is negated by a "standard" which gives the
compiler permission to do constant folding in a visible way up front
(resulting in my example in an unwanted error message when I divide by
zero on purpose in a simple program to test an error handler). To see
the intent original poster's  method for determining the size of a
table, you have to forget what you learned when you read elsethread,
that "the C preprocessor does a pure textual replacement".

What are you going on about? The definition was along these lines:

#define COUNTOF(array) sizeof array / sizeof array[0]

modulo the odd parenthesis or so.

Your claim was that the invariant was calculated within the loop
control, right?

Revoked that. Admitted I was wrong, as you need to admit you were
wrong about the much more serious matter of my publications on
comp.risks.
Now, all the preprocessor does is change:

for(i = 0; i < COUNTOF(zog); i++)

to

for(i = 0; i < sizeof zog / sizeof zog[0]; i++)

The calculation of sizeof zog / sizeof zog[0] is NOTHING TO DO WITH the
preprocessor. The preprocessor does in fact do what you call a pure
textual replacement. The compiler sees the division operator and, in any
sensible modern compiler, will replace the constA / constB with the

Wrong. Constant folding is best done behind the scenes in the internal
DAG of the compiler, and must be turnable offable for any program that
desires to see a known calculation being executed at run time. That is
how I implemented it in the compiler I wrote for "Build Your Own
Goddamn .Net Language and Compiler".
result constC. That is nothing to do with the preprocessor whatsoever.

The confusion that results has much to do with the preprocessor
interacting as with the inappropriately visible constant folding bug-
feature.

The result is that the programming language makes intelligent people
look stupid, and small-minded clerks look smart. Plato may have had a
genuine beef against the Sophists and their writing after all,
although I think Plato is full of shit.

Seriously: the intent of high level programming languages was to
empower intelligent grown ups to use computers, not to empower legions
of stunted and nasty little clerks who can't see the forest for the
trees and think it's the height of wisdom to maliciously destroy
people.
 
S

Seebs

There is no professionalism requirement for subscribing to, or
contributing to, comp.lang.c, and therefore the issue of professionalism
is at best a side issue. Having said that, it seems to me that if you're
going to criticise comp.lang.c contributors for a lack of
professionalism, Seebs would not be the obvious target.

It would never have occurred to me to seek professionalism. No one's
paying me to read this newsgroup. My employer can only afford so many
of my opinions. :)
[spinny sez]
You're completely deluded about bytecodes, unqualified to speak on
them and unwilling to learn.

I have no idea on what basis he claims this.

Hey, look! He's stopped mistaking me for Peter Seibel!
lolwut

Yup.

I still think this is the awesomest attempt at a putdown yet. Part of
my job involves taking alleged toolchain bug reports and trying to make an
initial determination as to whether it's likely enough to be a bug to
bother producing or cleaning up a reproducer and forwarding it to the
kind folks at Code Sourcery. That's hardly the whole of my job, but
yeah, I guess in that part I'm mostly just a gofer.

I just don't see why I'm supposed to feel bad about this. I'm acting as
a gobetween to hand stuff to a few of the most prolific contributors
to the GNU toolchains. These people know the compiler far better than
I am ever likely to. It is more efficient to hand the data off to the
experts. Why should I feel bad about this? I get plenty of programming
time; sometimes it's nice to not have to do that.

I don't think I've tried to destroy someone since about 5th grade, and
even then I don't think I had any clue what was going on. I have no
interest in destroying, or even harming, Schildt. I wish to protect
people from deeply flawed material which is demonstrably likely to
cause them serious difficulties in learning to program. If Schildt
wants to take advantage of these criticisms to correct some of his
material (as he did for some in the 4th edition of C:TCR), great! He
can improve his understanding of C, and/or his writing, and be a better
person.
Actually, Seebs is a programmer of no mean repute, and his employers no
doubt count themselves fortunate to have him on the team. In fact, they
are doubly fortunate, since they also have Chris Torek on board.

Ayup. And a fair number of other people who are pretty amazing. I'm
probably our domain expert on C, but only by a pretty narrow margin.
Mostly I'm useful because I can ask useful questions or give likely
guesses on pretty much anything vaguely computer related whether or
not I've ever heard of it before. I am a very effective Second Pair
Of Eyes, and a bit better than the average rubber duck.

-s
p.s.: Happy new year!
 
S

spinoza1111

No, but there's such a thing as respect and decency and speaking
within your area of certified professional competence, especially when
your conduct harms another.
is at best a side issue. Having said that, it seems to me that if you're
going to criticise comp.lang.c contributors for a lack of
professionalism, Seebs would not be the obvious target.

It would never have occurred to me to seek professionalism.  No one's
paying me to read this newsgroup.  My employer can only afford so many
of my opinions.  :)
[spinny sez]
You're completely deluded about bytecodes, unqualified to speak on
them and unwilling to learn.

I have no idea on what basis he claims this.

Your post in which you merely speculated that Java and .Net bytecodes
were "interpreted".
Hey, look!  He's stopped mistaking me for Peter Seibel!


I still think this is the awesomest attempt at a putdown yet.  Part of
my job involves taking alleged toolchain bug reports and trying to make an
initial determination as to whether it's likely enough to be a bug to
bother producing or cleaning up a reproducer and forwarding it to the
kind folks at Code Sourcery.  That's hardly the whole of my job, but
yeah, I guess in that part I'm mostly just a gofer.

Case closed. Herb is a programmer who wrote a complete compiler and
interpreter for C, and you were unqualified to attack him. I need you
to remove "C: The Complete Nonsense" and replace it with an apology
for speaking far beyond your area of competence.
I just don't see why I'm supposed to feel bad about this.  I'm acting as
a gobetween to hand stuff to a few of the most prolific contributors
to the GNU toolchains.  These people know the compiler far better than
I am ever likely to.  It is more efficient to hand the data off to the
experts.  Why should I feel bad about this?  I get plenty of programming
time; sometimes it's nice to not have to do that.


I don't think I've tried to destroy someone since about 5th grade, and
even then I don't think I had any clue what was going on.  I have no
interest in destroying, or even harming, Schildt.  I wish to protect

But you did.
people from deeply flawed material which is demonstrably likely to
cause them serious difficulties in learning to program.  

How would you know? You have said that at this time, you analyze bug
reports. This is a semi-clerical activity, not programming. Therefore
YOU need to learn programming (including how bytecodes are processed
in .Net and Java and the widespread use of the heap outside DOS)
before passing judgement on real programmers.
If Schildt
wants to take advantage of these criticisms to correct some of his
material (as he did for some in the 4th edition of C:TCR), great!  He
can improve his understanding of C, and/or his writing, and be a better
person.


Ayup.  And a fair number of other people who are pretty amazing.  I'm
probably our domain expert on C, but only by a pretty narrow margin.

A strange one indeed, who doesn't use it, only judges other people
based on a pretty virginal understanding of the theory and the
standard.
Mostly I'm useful because I can ask useful questions or give likely
guesses on pretty much anything vaguely computer related whether or
not I've ever heard of it before.  I am a very effective Second Pair
Of Eyes, and a bit better than the average rubber duck.

A false humility coupled with the vicious way in which you have tried
to destroy the reputation of Herb Schildt. Ugly.

But, risk free in the Korporation where the real producers have been
laid off.
 
S

spinoza1111

spinoza1111wrote:


I know C macros. You appear to be confusing C macros with conditional
compilation. Get a C book, and read up on the preprocessor.

I've already addressed this. You want your terminology, which you
learned laboriously and by rote, to be used so that you're write. But
as I have already explained, macros and conditional compilation are
the same entity done at the same time, originating as I have said in
assembler language and PL/1.
As far as I can recall without a copy of the Standard to hand, the
diagnostic message is not required by the Standard, since no constraint
is violated. It's a quality of implementation issue. A good
implementation will warn against dividing by zero. You appear to have an
implementation which, in that respect at least, is good.

If the implementation did not produce the message, you'd complain for
that reason instead.

I would not. C confuses constant folding with macro processing.
Revoked that.

Yes, but you still seem to think that this is *about the C preprocessor*.

 > Admitted I was wrong, as you need to admit you were
wrong about the much more serious matter of my publications on
comp.risks.

(a) It's actually not a very serious matter at all, and (b) I already
dealt with it. Learn to read.

The calculation of sizeof zog / sizeof zog[0] is NOTHING TO DO WITH the
preprocessor. The preprocessor does in fact do what you call a pure
textual replacement. The compiler sees the division operator and, in any
sensible modern compiler, will replace the constA / constB with the

No.

Constant folding is best done behind the scenes in the internal
DAG of the compiler,

The precise details of what is done and when are up to the
implementation. The point is that it's (conceptually speaking) done at
TP7, and not before. So it's nothing to do with the preprocessor.

 > and must be turnable offable for any program that
desires to see a known calculation being executed at run time.

The C Standard does not require this as far as I know. If you know
different, please provide chapter and verse.

Quit changing the subject from the collective crappy behavior of
actual C compilers to the standard.
Is yours.

 > has much to do with the preprocessor


No. It isn't a bug, it's nothing to do with the preprocessor, and
there's nothing inappropriate about it.




The programming language does no such thing. In this thread, you have
made yourself look stupid by making bizarre claims about a subject you

No, I've cleared a matter up by asking questions and being willing to
be wrong. You are making a mess of the clarity that resulted.
don't know very well, but that's your fault, not C's fault. If you
choose to call those who know more than you "small-minded clerks",

I do, because what you know doesn't make you effective programmers. It
makes you into Korporate slaveys.
 
F

Flash Gordon

Richard said:
spinoza1111 wrote:



In practice, in real code, it's hardly used at all, except perhaps in
environments where malloc & co have been banned - i.e. where a so-called
(and mis-named) "safe" subset of C is used.

Banning *alloc and recursion does have advantages. You have a provable
upper bound on memory usage, so you know you won't run out of memory. If
you need to do clever malloc-like things like allocating memory out of a
static array you can tune it so that you won't suffer from memory
fragmentation (having a pool of objects of the correct size) etc.

Of course, not all problems can really be solved without something like
malloc, but the environments where malloc is banned tend to be ones
where the problems to be solved don't actually require it.
 
N

Nick Keighley

Stop calling Turing (or other names). BTW did I mention that I am related
to Dijkstra? *NO I did not.* I only post code here.

I met Babbages great(n)-son once
 
N

Nick Keighley

spinoza1111 wrote:
[C is]
not popular outside of the USA esp. in the EU for that reason.

Actually, C is still very popular in the UK (which, heaven help us, is
in the EU). I wouldn't know about the rest of the EU, but I have no
reason to suspect it's unpopular abroad.

It's used in Italy
 
S

Seebs

If you can find any error of fact on the page, I'm sure Seebs will be
delighted to correct it.

Indeed, even though he's made it clear that he can't, I did actually
pick up the 4th edition, and will eventually be shuffling things around
to replace it with a more recent criticism.

Note that the 4th edition fixes several things, but continues to repeatedly
and totally misunderstand feof().

-s
 
K

Keith Thompson

Seebs said:
Indeed, even though he's made it clear that he can't, I did actually
pick up the 4th edition, and will eventually be shuffling things around
to replace it with a more recent criticism.

Let me encourage you to keep a copy of your original review online,
for comparison purposes if nothing else.
 
S

spinoza1111

spinoza1111 wrote:
[C is]
not popular outside of the USA esp. in the EU for that reason.
Actually, C is still very popular in the UK (which, heaven help us, is
in the EU). I wouldn't know about the rest of the EU, but I have no
reason to suspect it's unpopular abroad.

It's used in Italy

Of course it's "used". But by what people? How competent are they?
And, it would be interesting to know whether their use of C tracks
political (pro-American) views.
 

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

No members online now.

Forum statistics

Threads
473,888
Messages
2,569,964
Members
46,292
Latest member
IngeborgLa

Latest Threads

Top