    <rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:admin="http://webns.net/mvcb/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:content="http://purl.org/rss/1.0/modules/content/">
     <channel>
        <title>ACCU  :: C minus</title>
        <link>https://members.accu.org/index.php/articles/724</link>
        <description>Professionalism in Programming</description>
        <dc:language>en-us</dc:language> 
        <dc:creator>Administrator</dc:creator> 
        <admin:generatorAgent rdf:resource="http://www.xaraya.org" /> 
        <admin:errorReportsTo rdf:resource="mailto:webeditor@accu.org" />
       <sy:updatePeriod>hourly</sy:updatePeriod>
       <sy:updateFrequency>1</sy:updateFrequency>
       <docs>http://backend.userland.com/rss</docs>




<div class="xar-mod-head"><span class="xar-mod-title">Project Management + CVu Journal Vol 8, #2 - Apr 1996</span></div>

<table border="0" cellpadding="1" cellspacing="0">
    <tbody>
    <tr>
        <td valign="top">
            Browse in :
       </td>
       <td valign="top">

                                            <a href="https://members.accu.org/index.php/articles/">All</a>

                     &gt;                         <a href="https://members.accu.org/index.php/articles/c13/">Topics</a>

                     &gt;                         <a href="https://members.accu.org/index.php/articles/c66/">Management</a>
<br />

                                            <a href="https://members.accu.org/index.php/articles/">All</a>

                     &gt;                         <a href="https://members.accu.org/index.php/articles/c76/">Journals</a>

                     &gt;                         <a href="https://members.accu.org/index.php/articles/c77/">CVu</a>

                     &gt;                         <a href="https://members.accu.org/index.php/articles/c136/">082</a>
<br />

                                            <a href="https://members.accu.org/index.php/articles/c66-136/">Any of these categories</a>

                    -                        <a href="https://members.accu.org/index.php/articles/c66+136/">All of these categories</a>
<br />
</td>
   </tr>
   </tbody>
</table>




<div class="xar-error">
   <p>
 <strong>Note:</strong> when you create a new publication type,
the articles module will automatically use the templates
<em>user-display-[publicationtype].xt</em>
and <em>user-summary-[publicationtype].xt</em>.
If those templates do not exist when you try to preview or display a new article,
you'll get this warning :-)  Please place your own templates in themes/<em>yourtheme</em>/modules/articles . The templates will get the extension .xt there. </p>
</div>
<div class="xar-norm xar-standard-box-padding">
   <h1><strong>Title:</strong>&nbsp;C minus</h1>
<p><strong>Author:</strong>&nbsp;</p>
<p>
<strong>Date:</strong> 03 April 1996 13:15:26 +01:00 or Wed, 03 April 1996 13:15:26 +01:00</p>
<p><strong>Summary:</strong>&nbsp;</p>
<p><strong>Body:</strong>&nbsp;<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e16" id="d0e16"></a></h2>
</div>
<p>I have recently read Safer C by Les Hatton. One of the points he
makes is that programming languages tend to gain more and more
features and very rarely get simplified. From page 175 of Safer
C:</p>
<div class="sidebar">
<p>For the reader's information, the phrase usually used to defend
existing bad practice is that removing it 'will break existing
code'. In the author's opinion, this is the best thing that could
happen to it.</p>
</div>
<p>He also points out that the simplicity of C means that high
quality compilers and supporting tools are available on most
platforms. It would be a great shame if C becomes much more
complex. With this in mind, here are some ways in which I would
like to see C simplified and restricted. I note that Stephen Baynes
(March CVu) started off his article with similar intentions but
ended up by wanting all sorts of additions. I have been very strict
with myself here and avoided any additions. There are obviously
plenty of people who know how C should be extended.</p>
<p>These are informal ideas - I am no expert on the C standard. And
no, I don't expect many of them to be implemented.</p>
<div class="orderedlist">
<ol type="1">
<li>
<p>Remove keyword <tt class="literal">auto</tt>. It doesn't do
anything, unless you know better of course.</p>
</li>
<li>
<p>Remove keyword <tt class="literal">register</tt>. Leave
optimisation to your compilers. Compilers are getting very good at
this these days. Keep the language simple and they'll go on getting
better.</p>
</li>
<li>
<p>Remove keyword <tt class="literal">goto</tt>. Well, of
course.</p>
</li>
<li>
<p>Remove keyword <tt class="literal">continue</tt>.</p>
</li>
<li>
<p>Forbid keyword <tt class="literal">break</tt> outside a switch
statement.</p>
<p>I'll leave Messrs Henney and Corfield to justify 4 and 5. I'm
too busy adjusting my own code. More seriously, I do have some
sympathy with the Harpist's attitude in CVu 8.1. I would not forbid
&quot;returning early&quot; for this reason. But in the above cases, I think
the benefits of simplifying the language, and of making code
written by different programmers more similar, outweigh the
readability argument.</p>
</li>
<li>
<p>Remove bitfields.</p>
</li>
<li>
<p>Remove octals.</p>
</li>
<li>
<p>Make it illegal for two variables with the same name to be in
scope simultaneously. I can't imagine why anyone would want to do
this delibrately, so why allow it accidentally?</p>
</li>
<li>
<p>Remove the increment and decrement operators (++ and --). I know
they're convenient: so are flick-knives. I also know that you would
never mis-use them, and nor would I. But consider the following
example which was found by Les Hatton in a major new financial
system (perhaps looking after your money). One of the design goals
was portability. (See page 72 of &quot;Safer C&quot;.)</p>
<pre class="programlisting">
for ( i = 0; i &lt; 100; a[i++] = b[i])
{
...
}
</pre>
<p>By the way, my compiler displays this when compiling the
above:</p>
<p><tt class="literal">Warning: undefined behaviour: 'i' written
and read without intervening sequence point.</tt></p>
<p>&quot;undefined behaviour&quot; is a warning?? Undefined behaviour should
be uncompilable. Yes, evidently, compilers can detect some abuses
of -- and ++, but removing them altogether is simpler and
safer.</p>
</li>
<li>
<p>Remove <tt class="literal">int</tt>s. I have a feeling I may be
losing what sympathy I had at the beginning of this article...But
think how much time would have been saved in porting between 16-bit
and 32-bit systems if programmers had been forced to use only
<tt class="literal">short</tt>s or <tt class="literal">long</tt>s.
Since shorts are guaranteed to be at least 16 bits, and longs at
least 32, it is a lot easier to write portable code if you restrict
yourself in this way. You can even <tt class=
"literal">printf()</tt> them portably, unlike the various typedefs
(U32, S16bits, etc) that those concerned about portability usually
use.</p>
</li>
<li>
<p>Remove plain <tt class="literal">char</tt>s. The argument is
similar to that for <tt class="literal">int</tt>s. Force
programmers to specify <tt class="literal">signed</tt> or
<tt class="literal">unsigned</tt> and another lot of portability
problems vanish.</p>
<p>Both (10) and (11) have consequences for the standard
library.</p>
<p>The main changes would be:</p>
<p>Replace <tt class="literal">int</tt> with <tt class=
"literal">long</tt> or <tt class="literal">short</tt> as
appropriate.</p>
<p>Replace <tt class="literal">char</tt> with <tt class=
"literal">unsigned char</tt>.</p>
<p>Replace <tt class="literal">size_t</tt> with <tt class=
"literal">unsigned long.</tt></p>
<p>Replace <tt class="literal">ptrdiff_t</tt> with <tt class=
"literal">signed long</tt>.</p>
<p>I'll now deal with simplifications to the standard library.</p>
</li>
<li>
<p>Remove <tt class="literal">gets()</tt>.</p>
</li>
<li>
<p>Remove <tt class="literal">varargs</tt>. Hopefully it's on its
way out anyway.</p>
</li>
<li>
<p>Remove <tt class="literal">stdarg</tt> and <tt class=
"literal">vsprintf()</tt>. A curious point: Stephen Baynes thinks
that <tt class="literal">vsprintf()</tt> isn't in the standard
library and wants to add it. I think it is and want to remove it. I
do not accept his argument about displaying messages in a GUI. I
have been programming for a GUI for over five years on Acorn
machines. My first approach was indeed to write extensions of
<tt class="literal">printf()</tt> to display messages in windows.
But more recently the issue of internationalisation has caused a
rethink. Complex <tt class="literal">printf()</tt> style format
strings are not translatable, and simple ones don't need variable
arguments.</p>
<p>If this is too drastic, there is a compromise.</p>
</li>
<li>
<p>Remove the <tt class="literal">va_arg</tt> definition from
<tt class="literal">stdarg</tt>. The aim is to ensure that the only
functions with variable arguments are <tt class=
"literal">scanf()</tt>, <tt class="literal">fscanf()</tt>,
<tt class="literal">sscanf()</tt>, the <tt class=
"literal">printf()</tt> family, and user extensions to the
<tt class="literal">printf()</tt> family which work in a similar
way, ie the last named argument is a <tt class=
"literal">printf()</tt> style format string. This would at least
enable a compiler to check arguments to functions with variable
arguments if the format string is a literal (and warn if it
isn't).</p>
</li>
</ol>
</div>
<div class="sidebar">
<p>I hope that those that disagree with Graham aren't going to sit
on their hands. I am only going to say to things at this stage.</p>
<p>C has to cope with the needs of a wide variety of different
programming tasks and portability isn't always the issue.</p>
<p>My mother relates the following episode:</p>
<p>When I was just over two I got hold of a valuable ornament,
dropped and broke it. My defence was that 'I could reach it so it
must have been OK to play with it.' That caused my mother to
realise that you do not teach responsible behaviour by making
irresponsible behaviour impossible.</p>
</div>
</div>
</p>
<p><strong>Notes:</strong>&nbsp;</p>
<p><em>More fields may be available via dynamicdata ..</em></p>
</div>
</channel>
</rss>
