    <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  :: Francis' Scribbles</title>
        <link>https://members.accu.org/index.php/journals/709</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>


        <h2>Journal Articles</h2>


<div class="xar-mod-head"><span class="xar-mod-title">CVu Journal Vol 16, #6 - Dec 2004 + Francis' Scribbles from CVu journal</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/journals/">All</a>

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

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

                     &gt;                         <a href="https://members.accu.org/index.php/journals/c99/">166</a>
                    (12)
<br />

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

                     &gt;                         <a href="https://members.accu.org/index.php/journals/c184/">Journal Columns</a>

                     &gt;                         <a href="https://members.accu.org/index.php/journals/c181/">Francis' Scribbles</a>
                    (29)
<br />

                                            <a href="https://members.accu.org/index.php/journals/c99-181/">Any of these categories</a>

                    -                        <a href="https://members.accu.org/index.php/journals/c99+181/">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;Francis' Scribbles</h1>
<p><strong>Author:</strong>&nbsp;</p>
<p>
<strong>Date:</strong> 08 December 2004 13:16:09 +00:00 or Wed, 08 December 2004 13:16:09 +00:00</p>
<p><strong>Summary:</strong>&nbsp;</p>
<p><strong>Body:</strong>&nbsp;<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e20" id="d0e20"></a>Redmond
Meetings</h2>
</div>
<p>I spent the last two weeks of October in Redmond attending three
Standards meetings; WG21 (C++), ECMA's TC3/TG5 (C++/CLI) and then
WG14 (C).</p>
<p>WG21 is working very hard on developing the next release of the
C++ Standard (scheduled for some time about 2008/9). There are a
great many good ideas for improving or developing C++. Quite a
number of these are originating in the UK.</p>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e27" id="d0e27"></a>The Most
Important Paper</h2>
</div>
<p>However, to my mind, the most important paper N1680 (available
at <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/"
target="_top">www.open-std.org/jtc1/sc22/wg21/docs/papers/</a>) was
not a direct proposal but a discussion document. It is co-authored
by A. Alexandrescu, H. Boehm, K. Henney, D. Lea, B. Pugh, and
entitled '<i class="citetitle">Memory Model for Multithreaded
C++</i>'. The paper makes it clear that providing proper support
for efficient multi-threading is more than just adding a few
libraries. It is not necessary to change the syntax of the language
to provide correct underpinnings for multi-threading but some
changes to the semantics are essential.</p>
<p>Trying to implement multi-threading on top of a single thread
abstract machine simply cripples modern multi CPU, multi-core
hardware. In fact even such primitive developments as Intel's
hyper-threading has to be turned off for many programs to avoid
complete chaos. It isn't just the assumptions that programmers
make, but those that are made by the compilers.</p>
<p>If we had to design a suitable abstract machine from scratch we
would have a task that we would almost certainly get wrong the
first time (Java did, and its designers were neither na&iuml;ve nor
ignorant). However we can capitalise on the experience of others
and we have suitable expertise within the C++ community. What I
have some doubts about is whether we actually have the will. Many
people seem to think that the solutions that are already available
through such libraries as the Boost one are good enough. I do not
think they are and I think that once you spend time understanding
the above paper you will agree. However the argument that what we
have is 'good enough' is a very seductive one because, if accepted,
it allows us to go away and do those other simpler things that we
understand and want in C++.</p>
<p>How urgent is it to provide a suitable memory model for
multi-threaded C++? Well C++ will have many fruitful years left
even if we do not change the abstract machine. But those years will
be numbered. Already AMD has sampled a dual-core CPU (i.e. two
independent processors on a single chip). Intel have announced that
future versions of their Pentium line will be multi-core and Sun
Microsystems are soon to release an 8-core processor. The upshot is
that we are only a very few years away (perhaps as small as two)
from entry-level machines having, effectively, multiple
processors.</p>
<p>Note that this development has been clearly coming for several
years though the present competition between AMD and Intel has
probably brought it forward a couple of years. Every attempt at
increasing performance by increasing CPU speed involves increased
heat production. The current speeds are now pushing the limit of
what can be handled by air-cooling. When chip designers start
muttering about having to go to water-cooling you know we will have
problems, particularly with low-end hardware.</p>
<p>The only viable option is to increase computing power by having
more processors doing the work. From the hardware designer's
perspective this is not a big problem. The problem comes from the
software end. The big number-crunchers have been using multiple
processors and big array processors for years. But getting
effective use from such hardware has meant developing specific
development tools for the hardware in an area where software tools
are expected to cost orders of magnitude more than those we
customarily use for desk-top software development.</p>
<p>Now simple mathematics comes into play. Place C++ head-to-head
with a language such as Java on a single CPU machine and all the
traditional arguments of compiled versus interpreted code, manually
managed memory resources versus garbage collection come into play.
In its own specialist areas each language will be able to
capitalise on its strengths and make a case for continued use.</p>
<p>Move to a multi-processor environment and any language, which
can be used to make efficient use of all the computational
resources available, will outperform one that is tied to a more
primitive model. A lock that stops all other threads is a potential
disaster on a multi-processor machine. Suddenly half your power is
lost on a primitive dual core machine, much more on the more
advanced hardware that is on the horizon.</p>
<p>The upshot is that either C++ evolves to make good use of the
coming hardware or it will lose out to newer languages. Such issues
as support for garbage collection are of minor importance.</p>
<p>Now the interesting thing is that if we get the fundamental
memory model right library designers will be able to provide
efficient components for the application level programmer. The
latter will have to learn a bit about multi-threading (actually.
probably less than what you have to learn today) but will get good
use of the available hardware. If we do not get the underlying
model correct, no amount of excellent library design will
compensate.</p>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e56" id="d0e56"></a>C++
Evolution</h2>
</div>
<p>WG21 deliberately make all the development papers available for
general reading because they hope that others will review them and
add their insights and knowledge in order to improve them.</p>
<p>Just because a paper makes a proposal does not mean that it will
be in the next version of C++. Indeed a great many good ideas will
fall by the wayside. One certain way for an idea to fail is if it
is not actively pursued. WG21 have more than enough to do without
taking on work from others. If you see a proposal that you would
like to see followed through, at the very least provide the authors
with moral support and encouragement. They need to know that others
think the effort worthwhile.</p>
<p>If you are in a position to do more such as contributing your
knowledge and experience of prior art, or volunteering to try the
idea out by modifying a compiler whose source code you have access
to then please come forward.</p>
<p>One of the hidden costs in pursuing any proposal is the fact
that other good proposals will die. We just do not have the
resources to follow every good idea. And even if we did, doing so
would not be good for C++. I know some people think that there
should be a nice coherent development plan for C++. Great idea but
it just does not happen that way. What gets done is what people are
willing to do.</p>
<p>If you want to add a major feature to C++ like full support for
functional programming (just to choose an area where there is some
interest but no existing proposals so I will not be hurting
anyone's feelings) you will have a much better chance for success
by getting together a group of people who will do the work (and
that includes coming to meetings). Sorry if you do not like that
message but it is the practicality of the situation.</p>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e69" id="d0e69"></a>If You Want,
You Must Do</h2>
</div>
<p>An example of how that works is the 'Embedded C' TR that was
produced by WG14. Those that wanted support for such things as DSPs
got together, came to WG14 meetings and did the work.</p>
<p>Others have sat on the sidelines and criticised their doing the
work for a whole range of reasons. Such criticism is unfair,
inappropriate and, in my opinion, unprofessional. The group
believed they needed support at least to the level of an ISO
Technical Report, they put up the resources and no little cost to
themselves and did the work. With more support and more expert eyes
the result might have been better and more comprehensive, however I
do not know that. What I do know is that those who simply tried to
vote the work away on the basis that it should never have been done
demean themselves and those they represent.</p>
<p>Shamefully, for reasons that I cannot explain here, the UK has
been the worst offender over the last few years. Steps are being
taken to correct the position but it would never have happened had
the broad UK C community participated rather than sitting on the
sidelines expecting others to represent them and their needs.</p>
<p>By contrast the UK C++ community has been one of the most active
contributors to the future development of C++. We may not be able
to send many people to WG21 meetings but our BSI Panel meetings are
well attended and bubble with ideas and enthusiasm. Panel members
have been putting in time and personal resources to help make C++
better. We do our best to ensure that C++ becomes better, and
better meets the needs of its users. Most participants have a broad
programming base and actively program in several languages.</p>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e80" id="d0e80"></a>ECMA v ISO</h2>
</div>
<p>You will have noticed that one of the three meetings that I
attended in Redmond was an ECMA meeting concerned with the
development of what is called C++/CLI. In other words a 'dialect'
(Herb Sutter likes to call it a set of bindings, but most of us
think that is too simple a view) of C++ to be used with the ISO
Standard to which .NET conforms.</p>
<p>I hear a good deal of criticism of the ECMA process. I agree
with much of it but there is one thing of which I recently became
conscious and that is that the radical difference in the natures of
ECMA and ISO do legitimately lead to a different process.</p>
<p>ISO Committees are composed of National Body delegations. Those
delegations are supposed to represent their national interests.
Indirectly those will include a substantial element of their
nation's commercial interests. However note that this is indirect.
ECMA Committees are composed of direct commercial
representation.</p>
<p>It is perfectly natural that a decision made in TG5 should be
dominated by the commercial interests of the participating
companies. Such things as currently planned shipping dates are
important. The process will be designed to take much more direct
consideration and input from the participating companies.</p>
<p>ISO committees naturally have a wider community to serve. Where
it becomes interesting is when we have a situation such as that of
WG21 that is colocated with a strong, technically competent NB
Committee (J16). Like ECMA, J16 is largely based on corporate
membership. Like ECMA, J16 members are focused on the needs of the
companies they represent rather than a broader community. Often the
tension between WG21 and J16 goes unnoticed but sometimes it pokes
above the surface.</p>
<p>I am greatly in favour of technical work being done together
without too much commercial influence but it would be a mistake to
ignore that the latter exists and that in the case of both WG14 and
WG21 the (overwhelming) majority of attending experts are actually
from J11 and J16.</p>
<p>Sometimes areas (such as what new work should be done) are
definitely the domain of the ISO Committee and not a National Body.
Yet sometimes the way that proposals get discussed means that the
dominant position of experts from a single country can distort the
outcome.</p>
<p>A case in point is a proposal from a UK expert that WG21 should
produce a TR on a Statistics Library. The UK had only two people at
the Redmond meeting. I had my hands full with the work of the
Evolution Group. Most attending NBs had only one or two
representatives. The result was that when the WG21 Library
workgroup considered the UK proposal for work on a Statistics
Library the discussion was dominated (overwhelmingly) by the J16
experts. A number of strong voices had good commercial reasons for
not wanting to add a Statistics Library even as a TR. Note that I
am not criticising those J16 experts, they were doing their job;
the job that their employers expect and pay them to do. It just is
not the same job as that which should be done by a National
delegation to WG21. Indeed the official US Delegation often has a
markedly different as a national delegation to that of the members
of J16 as members of J16.</p>
<p>I think we need to address the issues that this raises. But
before we do, we need to be willing to provide (or acquire from
other NBs) the resources to do the work. When it comes to the
crunch, it is those who do the work who will determine what
happens.</p>
<p>It is no use sitting on the sidelines and whingeing about things
we do not like, we have to get in there and get involved.</p>
<p>While much of the above is from a UK perspective, much of it
would be valid from the perspective of other National Bodies.</p>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e105" id="d0e105"></a>Problem
18</h2>
</div>
<p>Some programmers seem to hate to use more names in their
programs than they absolutely have to. Your challenge is to write a
program in C++ that outputs the first n members of the Fibonacci
series where the value of n is provided by user input at
runtime.</p>
<p>That is easy for most readers. But there is a limitation, any
variable, function, type or namespace that you declare must be
called <tt class="varname">i</tt>. You are allowed to use anything
you like from the Standard (such as <tt class="function">main</tt>,
<tt class="classname">std::cin</tt> and <tt class=
"classname">std::cout</tt>).</p>
<p>The requirement that it be written in C++ is because I do not
think it can be done in C, and there maybe some other languages in
which the problem is trivial.</p>
<p>In case you think it is impossible, I have a solution (which
took me about ten minutes to develop - but I have the advantage of
knowing the key to coding the problem) that is fifteen lines of
code with not more than one statement per line.</p>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e128" id="d0e128"></a>Commentary on
Problem 17</h2>
</div>
<p>Here is a minimalist version of <tt class=
"function">main()</tt>:</p>
<pre class="programlisting">
int main(){
  a * b;
}
</pre>
<p>Given suitable precursors it will compile and execute. Can you
provide suitable precursors so that the resulting program executes
and outputs:</p>
<pre class="programlisting">
int main(){
  a * b;
}
</pre>
<p>This is a version of an old problem, which is to write a program
that outputs itself. In considering answers I am interested in more
than just a program, I want to see the mental process by which the
author arrived at it.</p>
<p>The first problem with the above code is ensuring that
<tt class="literal">(a * b)</tt> compiles. There are two
possibilities, either <tt class="literal">a</tt> is a type and
<tt class="literal">b</tt> is a pointer to that type or <tt class=
"literal">a</tt> and <tt class="literal">b</tt> are both global
objects with an <tt class="methodname">operator *</tt> that can be
called.</p>
<p>If <tt class="literal">a</tt> is a type then the output must be
generated by some other code that will be run by executing the
program. That basically requires that there is a global object with
has a constructor or a destructor that somehow causes the
output.</p>
<p>If <tt class="literal">a</tt> is not a type then both <tt class=
"literal">a</tt> and <tt class="literal">b</tt> must be global
objects (because they must be declared somewhere.) There must also
be a suitable <tt class="methodname">operator *</tt>.</p>
<p>Once you recognise that the output must be generated by some
code that runs outside <tt class="function">main()</tt> you are
left with a number of options. Here is one that I wrote
earlier:</p>
<pre class="programlisting">
#include &lt;iostream&gt;
struct work {
  work() {
    std::cout &lt;&lt; &quot;int main(){\n&quot;
              &lt;&lt; &quot;  a * b;\n&quot;
              &lt;&lt; &quot;}\n&quot;;
  }
} x;
int a, b;
int main() {
  a * b;
}
</pre>
<p>The submissions I have had so far have gone for more complicated
solutions. That does not make them bad but as a general rule good
programs achieve their objective with a minimum of complexity.</p>
<p>I forgot to give a closing date so I am not going to select a
winner until the end of November (which will be too late for
inclusion in this issue of C Vu.) For obvious reasons, it will be
too late to enter by the time you read this.</p>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e194" id="d0e194"></a>Cryptic Clues
For Numbers</h2>
</div>
<p>Last issue's clue seems to have provided rather a different
problem to readers. Several of you wrote to me with the number
itself but were struggling to produce an alternative clue. Here is
the clue again:</p>
<p><span class="emphasis"><em>Oh for love in the sea! It only
values the fifth bit.</em></span></p>
<p>The first three words give 040 (love is conventionally used in
cryptic clues as 'o' (as a letter) or '0' (as a number) because of
its use in such things as tennis scores. Now, in C that means 32
(octal 40). The second sentences provide confirmation because that
is the value of the fifth bit in a byte (hey, we are C or C++
programmers and so count from zero).</p>
<p>Here is another clue to keep your brain cells working over the
holiday season:</p>
<p><span class="emphasis"><em>Deuce, it sounds like they came for
tea twice. (4 digits)</em></span></p>
<p>There is plenty of potential for alternative clues. Something
that happened on November 15, 1971 might be of use as clue
material.</p>
</div>
</p>
<p><strong>Notes:</strong>&nbsp;</p>
<p><em>More fields may be available via dynamicdata ..</em></p>
</div>
</channel>
</rss>
