ambiguous ?

Jim Giles jlg at lanl.gov
Wed Oct 25 10:24:09 AEST 1989


>From article <11398 at smoke.BRL.MIL>, by gwyn at smoke.BRL.MIL (Doug Gwyn):
> It looks to me like Bill Wells was merely stating the facts that are
> apparent to him.  Your inane comments about C's character processing
> being less efficient (than in other programming languages) back him
> up in his assessment.  

I don't see how.  C character strings are null terminated rather
that keeping the length of the string explicitly.  The result of this
is that hardware with specialized instructions for character processing
cannot be used as efficiently in C as with other languages.  The C
strings always have to be prescanned to determine their length before
the operation you are _really_ interested in can be performed.

I have character manipulations routines on the Cray which are
asymptotically faster than one clock per character for such operations
as translating from lower- to upper-case, searching for delimiters,
etc.  To use them with C requires a prescan for the null or the
algorithm must be rewritten to scan for the null simultaneously
with other activities - at least a 50% penalty either way.

> [...]                   For many years one could find systems that
> had both Fortran and C compilers implemented using precisely the
> same code generation and optimization technology, and on those
> systems typical systems programs involving heavy character operations
> (e.g. "grep") ran much faster when coded in C than when coded in
> Fortran.  I actually tried the experiment once.

For many years, C was notorious for not being very well optimized
and the Fortran that accompanied was famous for being _really_ bad.
They had the same code generation and optimization technology because
the Fortran compiler used the C backend - which was not well designed
for the type of optimization Fortran requires.

Furthermore, you are still _assuming_ that I am defensive about
Fortran.  I never claimed that Fortran had _really_fast_ character
handling capabilities - only that some languages other than C could
be expected to outdo C in that regard.  (However, if Fortran's
string handling is slower than C it is for some other reason than
what I discussed above.)

> Please redirect your flames back to alt.flame.

When I decide to flame someone perhaps I will.  In the meantime, the
redirection of articles will only serve you rhetorical purpose of
having the last word on the issue.  I've no objections to your having
the last word - as long as what you say is both true and fair.



More information about the Comp.lang.c mailing list