Re: Is C99 the final C?

From: David M. Wilson (dw-google.com_at_botanicus.net)
Date: 12/01/03


Date: 30 Nov 2003 16:21:54 -0800

Hi Michael!

"Michael B." <usemike@spamblocked.com> wrote in message...

> Of course, I speak only of features in the spirit of C; something like
> object-orientation, though a nice feature, does not belong in C.
> Something like being able to #define a #define would be very handy,
> though, e.g:
>
> #define DECLARE_FOO(bar) #define FOO_bar_SOMETHING \
> #define FOO_bar_SOMETHING_ELSE

Although this is my opinion, I think a lot of people would agree:
preprocessor magic should be kept simple and to a minimum. Although
some wonderful tricks can be accomplished using the current
preprocessor syntax (and indeed, your proposed extension), it quickly
becomes a maintenance and readability nightmare - for the coder who
originally wrote it, or for someone else who is picking up the code.

For large #if #else #endifs around platform-specific code, usually
there is a nicer solution found in abstracting said code, and writing
per-platform translation units which are then linked in by your build
system.

> I'm not sure whether the features of cpp are even included in the C
> standard

They are.

> I would also like to see something along the lines of C++ templating,
> except without the really kludgy implementation that the C++ folks decided
> to go to ( and without the OOP ).

I'd imagine that adding a new fundamental concept such as this to the
C standard stands as good a chance at getting approval as a snowball's
chance of not melting in hell. :)

C is a very simple and uniform language - possibly a major reason for
the roaring success it has had over the years. It is also very
explicit - usually a statement does exactly what it says it does
(unless it includes a cpp macro ;). Concepts such as templates,
although useful, detract from the overall simplicity of the language.

> Templates save a lot of time when it comes to commonly-used data
> structures, and as they are entirely implemented at compile-time and don't
> include, by their definition, OOP (although they can be well suited to
> it), I think they would be a nice addition and in the spirit of C.

I would almost say that C already supports 'templates' for structures
at least. For example, imagine:

   struct list_head {
      struct list_head *next, *prev;
   };

   struct my_list_type {
      struct list_head list_head;
      void *my_data;
   };

   struct my_list_type ml;

As far as I can tell, accessing ml.list_head.next is just as quick
(after compilation) as accessing ml.next, assuming that 'ml.next' is
part of a structure that was generated using a template facility.

This example actually comes from a real project - namely the Linux
kernel. Lots of other people use it too. You could consider it a
'cultural standard idiom'. :)

Yes, coining a stupid phrase like that was completely unneccesary. :D

> Your thoughts? I'm sure there's some vitriol coming my way but I'm
> prepared 8)

C is simple. It has stood the test of time, and thus "if it ain't
broke, don't fix it".

I believe that C is on it's way out as a general use tool. Sure, it
probably has 20 years left, but programming ideologies are evolving,
and computing is moving to new heights.

C has found it's niche market in lower level and high performing
applications, it is relatively expressive, and it generates small,
tight code. That market isn't about to change, and neither (I believe)
is C. Let's leave it be until the dog has its day, and finally goes to
sleep.

C is dead! Long live QuantumC! ;)

David.



Relevant Pages

  • Re: Starting Out
    ... coding styles and how they can be applied when using each language. ... Templates can be used to perform arbitrary ... the availability of sophisticated data structures in the STL ... compile-time, eliminating an important class of run-time errors and making ...
    (comp.programming)
  • Re: Enabled languages
    ... certain document templates...making a minor tweak to a standard custom style ... 2003 Language Settings, ... I've tried checking all of my language settings (everything is English ... standard document templates. ...
    (microsoft.public.word.docmanagement)
  • Re: How to prevent changes to normal.dotm
    ... I totaly agree with you that the job for support is to support people. ... in the templates a made macro's and so on. ... computers verry much and ask to please setup there computers so they ... log-in script to copy the standard templateto the user template folder. ...
    (microsoft.public.word.docmanagement)
  • Re: export
    ... > The standard mandated lots of things not demanded by the market, ... Only when you think of templates as functions. ... You don't compile them to object code, ... cannot make libraries of metafunctions and meta-object files with any ...
    (comp.lang.cpp)
  • Re: Error meaning in STL
    ... you get a diagnostic mode (compile-time switch) ... string yields undefined behaviour according to the standard (in order not ... servers, all runngin Windows Server 2003 and SQL Server 2005. ...
    (microsoft.public.vc.stl)