EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  <19951996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024  Index 1994  <19951996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: A C++ API for the pcas
From: Tony Cox - (415)926-3105 <[email protected]>
To: [email protected]
Cc: [email protected]
Date: Thu, 07 Dec 1995 13:22:13 PST
William writes:-

>Dear all,
>
>Personally I have never used C++ and personally I would like to.
>
>We had a bad brush with it where a programmer created his own little
>world of classes, creators and destructors, no-one ever knew what order
>anything was executing in and the whole thing got scrapped.
>
>Thus there is a certain prejudice against it here on the grounds that
>there's too high a risk that everyone will use it in different ways and
>in complex ways and we won't end up getting the potential gains.
>Probably a lot of us feel that the way that we write code is already
>pretty object-oriented and has been for years.

Object oriented programming does require a far more rigorous approach to
program design, or you end up with just the mess that you describe. Many
programmers with little C++ experience (but plenty of C) tend to see the
additional syntax as more `fun tools' to pepper their code with. The "head down
and charge" approach to programming, which you can get away with in C, doesn't
really fly in C++. 

That said, if you have someone with some experience to do an informal `design
review' so that things don't get out of hand, the result is much better code. 

When I was on the review committee for the (at the time, proposed) B-factory
control system, someone (Steve Lewis?) referenced a paper on the supposed
productivity gains from the use of C++. As I remember, productivity was down in
the first year, level in the second, and up 10% in the third. I'm not sure how
this was measured, but it was sobering reading for me after all the claims
of spectacular improvements in the trade press. But that study was old, and 
perhaps productivity is enhanced now because people are more familiar with the
uses (and abuses) of object oriented design.

It remains true, however, that C++ gives you many more ways of writing totally
obtuse and unmaintainable code.  The "Unix haters handbook" refers to it as
the COBOL of the 90's - not without reason.

>
>On the other hand this can probably successfully be attacked as a
>reactionary view (although you'd be surprised at how many places still
>don't have ANSI C compilers readily available: it's hard to see how
>people will switch to C++ before they have switched to ANSI C). I have
>to admit considerable ignorance on the extent to which C++ is _really_
>used in commercial and scientific tools these days. Perhaps it would be
>good if I (and the rest of the collaboration) were educated. Clearly
>there is a lot of usage of C++ at CEBAF and ANL and it would be good to
>get a dispassionate view of the benefits which have accrued and of the
>costs.

18 months ago, a survey I saw claimed that the ratio between C and C++
programmers (being hired by consultancy firms) was around 10:1. I suspect
this ratio has dropped by now, as C++ gains popularity.

Getting compilers which were fully compliant with the C++ bible (the "Annotated
Reference Manual" or ARM) has been quite a problem until recently. Even now,
I manage to get crashes in a number of compilers when trying to digest some of
my templates. In the number of (smallish) projects I've done in C++, I've ended
up spending rather too much time in programming around these anomalies. And I
havn't tried the C++ exception handling.....

>
>My biggest concern is that the use of C++ in the core of EPICS might
>scare some people off. If this concern is unfounded then I have no
>problem with it.

There is some C++ already in the EPICS distribution. GDCT being one major
'offender'. As for the IOC core code, C++ is pretty much the only game in town
if you want to develop OO code in a real-time environment. Properly designed, I
can see it being of great benefit. Users extending the core code base would
have to buy into the overall design abstraction (by object subclassing), and
so would generally avoid the pitfalls associated with naive programming in C++.

I think many programmers would welcome the chance to become familiar with
the language. It's actually really quite fun to work in, and certainly very
powerful. The `scare' factor is only really relevant for the management, based
upon horror stories like the one you opened with! But before lurching into
a project, I'd recommend reading a good book first.


Tony

--------------------------------------------------------------------------------
Dr Anthony D Cox
Computer Systems Specialist
Stanford Synchrotron Radiation Laboratory
Stanford Linear Accelerator Center
MS 69, Box 4349
Stanford CA 94305
[email protected]
--------------------------------------------------------------------------------


Navigate by Date:
Prev: Re: A C++ API for the pcas Andy Kozubal
Next: Re: A C++ API for the pcas Steve Lewis
Index: 1994  <19951996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Re: A C++ API for the pcas Andy Kozubal
Next: Re: A C++ API for the pcas Steve Lewis
Index: 1994  <19951996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 10 Aug 2010 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·