how relevant is C today?

Scott David Daniels scott.daniels at acm.org
Sun Apr 9 12:20:26 EDT 2006


Sandra-24 wrote:
> C/C++ is used for a lot of things and not going anywhere.
> 
> I recommend you learn it not because you should create applications in
> C or C++, but because it will increase your skills and value as a
> programmer. I recommend you even spend a few weeks with an assembly
> language, for the same reason.

"Back in the day" we wrote _way_ too much in assembly language, often
simply because there was no other language capable of doing, for example
an assembly language.  C has replaced assembly language for most of an
operating system.  In the SIGPLAN conference where C was first publicly
introduced, a later talk began with the speaker, who was talking about
his new portable macro system, said, "Everyone at this conference
should find out about 'C', it makes this work obsolete."

What C has as virtues are simple clear semantics, an obvious map to the
machine code representing each language feature, a language simple
enough to "read through to the machine" in the sense that you can read
a C program and not have a little section in the pure language take
a surprising amount of time ("no surprise delays"), and you can express
most of the bag of tricks assembly language programmers used at the time
to write their operating systems, compilers, ....  One other immense
difference in C was that the language had very few "magic" functions
(setjmp and longjmp are the obvious bits-o-magic).  For the most part,
the entire library could be written in the language "C" itself.
Further, there was a clear mapping between assembly language and C;
you could write a function in assembly that could be called from C,
and there was so little "necessary infrastructure" that you could
also write a function in C that could be called from assembly.

C can express neither exceptions nor coroutines (nor their fancy cousin,
continuations), which could be and were expressed in assembly.  Nor does
C provide memory management.  A few library functions give you some
primitives to roll your own, but garbage collection is out of the
question (despite Hans Boehm), because the language does not carry
enough infrastructure to find type information through introspection.

In exchange for these losses, the C programmer can write code that
executes in response to an external signal and yet does not create a
total hash of the internal memory structures.  That kind of thing is
important in an OS, and something few languages (including C++) can do.
If you intend to study C++, study C first (it is easier to grasp), as
almost everything you learn in C can be used in C++.  C++ is a  "big"
language, while C is a "small" one; it will take much longer to "know"
C++ even though C++ started with the goal of being "C with objects."
If you are interested in languages, reading "the Design and Evolution
of C++" is a great base; it explains how C++ got the way it is from its
initial design goals.

--Scott David Daniels
scott.daniels at acm.org



More information about the Python-list mailing list