(E-Mail Removed) wrote:
> > Be very, very careful about comparisons like this! You are right:
> the
> > code isn't doing anything useful. The C++ compiler may be smart enough
> > to detect that only the outermost loop has any lasting effect: it
> > changes np. If the compiler is clever enough to know that
> > pc.GetParticle(ps) has no side-effects, then it may simply eliminate
> > the inner loops altogether.
>
> The problem is actually I am comparing C# with FORTRAN. I have ported
> the code over from FORTRAN and then proceded to tell my colleges how
> much faster the C# would be. Then I ran the code go my ass smacked!!
> The bottleneck was in this code loop. Remember that FORTRAN was used by
> dinosuars, how can it be faster than C#!!!
It wouldn't surprise me at all that FORTRAN / COBOL / C might be
_faster_ than C#. If anyone claimed to me that C# is _faster_ then I
would immediately be suspicious.
C# comes with tremendous advances in the ability to organize code (O-O
/ visual designers, etc), advances in security, interoperability with
databases, etc.... but speed? No, I don't think so.
If we're writing a sophisticated multi-cultural / multi-language
WinForms application that calls Web Services or reads from a database,
and I'm using C# and you're using C, I'm sure that I could _write_ the
code much, much faster than you could, but would my code _run_ faster
in the end? Probably after my two weeks of coding and your ten months
of coding, your code would probably run faster, but that's not the
"why" of using C# in that scenario, is it?