[comp.lang.c++] Managing C++ Libraries: C++ too complex !!

jim@athsys.uucp (Jim Becker) (11/09/88)

***	Note that this is a combination of the two running topics...
***	and may be considered by some to be a *flame of C++*!!! BEWARE!


	I have been reading these articles with some mirth, after
having dealt with these problems at my current company for the past
year. I find it all very funny.

	C++ is an amazing language, or extension to a popular
language.  So amazing, in fact, that even the instructors teaching the
language from the source don't understand it all. The language has
been designed to "simplify the code development process" and "hide
complexity".  Our experience has been the exact opposite, as there is
so much interdependency in the class definition nesting and the
overloading and the friend functions.... et al.

	We have a fairly large commercial application written in C++,
about 800,000 lines. It is all intertwined. Please tell me the source
files that "trivially" need to be recompiled when I change one of the
include files. I have written a scanner that understands the
interdependencies at the file level, but not at the internal usage
level. We do all the normal things to minimize rereading include
files, yet some of our singular source files depend on over three
hundred (300) include files. Please tell me how this can be
simplified..  :-) :-) As I sit here typing this another person comes
to me to ask this question... "I changed one include file, what do I..."

	I don't know of much of the code that can be extracted from
it's current place and "re-used", as is so widely touted. It all
depends on itself, and is incestual in nature. I'm not saying that
it's the best use of the language, but it is a typical commercial
application as far as the development team. Not all superstars, but
trying to make it.

	If this language is so great, why do we need all these papers
from PHD level intellectuals telling us how to use it?? I believe that
there is a great deal that can be done without buying into the entire
C++ methodology, and I do it in vanilla C. My applications are
compact, easy to understand and read. They can be comprehended fairly
easily and code maintenance isn't too hard, as the program can be
understood in a couple of hours at most.

	I don't want to totally pound on C++, I think that it can be a
great base to use in creating an entirely integrated CASE development
environment (not just a toolkit mind you). There are quite a number of
possible advantages that are possible using it. Unfortunately, noone
has moved the CASE world beyond the Version Control, Configuration
Management, and Editor/Linker/Debugger toolset toward the fully
integrated "software development production world" yet (that I have
witnessed).

	The question that I pose is one of it's impact on the new
programmers out there and the question of continuing code maintenance.
Is this a language that is great for the super human programmers, and
one that becomes "write only" after a master has been at work?? Or is
it a general extension to make the language more flexible and easier
for a novice to intermediate programmer to create cleaner and more
well understood code?? How much will a new programmer have to read to
understand and modify existing code in C++?? Can an average programmer
write better code, or more confusing and obscure code?? Everyone isn't
a star coder out there.

	I've worked in over a dozen languages, and have to laugh at
the big ruckus over C++. It's certainly got it's merits, but in my book
I'll stick with the simplier and make it look better and read easier. I
don't want to hide the logic of what I am coding from the uninitiated
further down the software timeline..

	Burners back on warm!! :-)


-Jim Becker
(C programmer in a land of C++ programmers)

coggins@retina.cs.unc.edu (Dr. James Coggins) (11/11/88)

In article <179@tityus.UUCP> jim@athsys.uucp (Jim Becker) writes:
>	I have been reading these articles with some mirth, after
>having dealt with these problems at my current company for the past
>year. I find it all very funny.

Glad you have a sense of humor. If my job depended on a language I was
forced to use but thought was too complex, I could tend to be rather
irritable. (;-)

The idea behind our articles is that there are people out there who
have NOT been working in C++ for a year and who could use any kind of
practical advice they can get on how to organize a development effort.
I would hope that if you have been working for a year on an 800K line
project you would get little out of our series.  In fact, you should
be able to contribute some options and alternatives that haven't
occurred to me.

[C++ has supposedly]
>been designed to "simplify the code development process" and "hide
>complexity".  Our experience has been the exact opposite, as there is
>so much interdependency in the class definition nesting and the
>overloading and the friend functions.... et al.
>	We have a fairly large commercial application written in C++,
>about 800,000 lines. It is all intertwined. 
>We do all the normal things to minimize rereading include
>files, yet some of our singular source files depend on over three
>hundred (300) include files. Please tell me how this can be
>simplified..  :-) :-) 

Library developers create code with dependencies.  That is part of the
essence of the process.  We won't and can't get away from it.
Dependencies will exist in C or in C++.  C++ depends on header files
more than C, so the problems of header file management are encountered
in smaller projects in C++ than in C.  Our articles presented some
approaches to managing these issues that we have found VERY helpful.
We still need to #include lots of headers, but we manage the headers
and includes better so that they take care of themselves and don't
intrude on our real work. 

Header files are incidental. Techniques such as we described can
minimize the headaches of managing them. 
Dependencies are essential; they can't be eliminated using incidental
methods.  In any language. Sorry. (but see below - better design might
decrease dependencies or their complexity!)

>	I don't know of much of the code that can be extracted from
>it's current place and "re-used", as is so widely touted. It all
>depends on itself, and is incestual in nature.

Here I agree.  I have decided that the conventional wisdom regarding
small-granularity code reuse from object-oriented design is probably
wrong. To reuse a piece of code means that you buy the assumptions
underlying the code at the implementation and realization level.
Classes are not equivalent to abstract data types.

The practical solution is to design multiple class hierarchies to fit
the application; i.e. let the implementation fit the abstraction, not
the other way around.  (this is the '80's version of "design from the
top down")

>	If this language is so great, why do we need all these papers
>from PHD level intellectuals telling us how to use it?? 

(This tirade cuts close to home. You are a bit out of line here.)
(and it's "Ph.D.")

> I'm not saying that
>it's the best use of the language, but it is a typical commercial
>application as far as the development team. Not all superstars, but
>trying to make it.
>I believe that
>there is a great deal that can be done without buying into the entire
>C++ methodology, and I do it in vanilla C. 
>I'll stick with the simplier and make it look better and read easier. I
>don't want to hide the logic of what I am coding from the uninitiated
>further down the software timeline..

These passages and your reference to friend functions indicate that
you are using C++ as a "better C" and not using the object-oriented
design paradigm correctly.  Indeed your 800K line project might be
excessively complex due to flawed design.  If somebody is forcing you
to use encapsulation and inheritance because they are there but
without adopting the object-oriented design paradigm, you have a lot
to complain about but it's not C++ that is the problem.

Maybe you could learn something from some Ph.D.'s that would REALLY
help you.

>Is this a language that is great for the super human programmers, and
>one that becomes "write only" after a master has been at work?? Or is
>it a general extension to make the language more flexible and easier
>for a novice to intermediate programmer to create cleaner and more
>well understood code?? How much will a new programmer have to read to
>understand and modify existing code in C++?? Can an average programmer
>write better code, or more confusing and obscure code?? Everyone isn't
>a star coder out there.

Bad design yields bad code in any language, including C++.  C++ gives
you more than enough rope to hang yourself, but it also provides
abstraction mechanisms that make it easier to write and understand
larger systems of code.  Good management techniques can minimize the
incidental problems of managing headers.  Good design minimizes the
essential problems of complex dependencies.

>-Jim Becker
>(C programmer in a land of C++ programmers)
------------------------------------------------------------------------
James M. Coggins, Ph.D. (and proud of it)
Computer Science                      My season basketball tickets
UNC-Chapel Hill                       came yesterday.
coggins@cs.unc.edu

jima@hplsla.HP.COM (Jim Adcock) (11/11/88)

I have many sympathies with the comments here.

The present implementations of C++ in a world of 
.h .c files, cc's, nmakes, etc. leaves MUCH to
be desired.  The requirements for efficient
code development in C++ seem to overwhelm the 
traditional code development techniques used
in Unix.

I think we should admit C++ is still a little
early in its life as a practical development
tool.  People who choose to use it need to
realize they are jumping on the bandwagon early,
and that this has advantages and disadvantages.

Code reuse comes with code that was designed
for reuse.  Code that was not designed for 
reuse cannot be easily reused.  Whatever language
one uses, one needs to realize that 
reuseability has to be a deliberate design
goal for any code to be reused on future
projects.

I think C++ IS going to require a higher
skill level among its practitioners --
and I have no problem with that.  Although
I doubt all C++ programmers need to be
geniouses at writing code.  I think the
time for "amatuer" code pounders is rapidly
passing.  

...Maybe its possible to assign the better 
programmers to write the code that it is hoped 
will be reused in the future -- and have
the less experienced programmers write
the "application specific" portion of the
code -- that part of the code which is
going to go into this project, and never
used again.

I believe organizations are going to have
to head in a direction where a great portion
of the code on each project is reused.
Software is getting more and more competitive,
-- and with windowing systems is getting more 
and more complicated.  We are rapidly approaching
a point where one simple cannot afford to 
start from scratch on each new project!

I do believe that object oriented programming
has much to offer in the way of offering
reuseable software.  If one's software is
going to be used in a number of different
applications, one will need to be able
to offer a variety of different amounts
of resources to different programs.  Also
if ones software is at all sophisticated
it is going to be working on structures.
So when one has to deal with a varying
amount of structures, one is already dealing
with much of what we call "object oriented
programming."  The other goodies of C++
go towards supporting this goal.

I think people have got to realize the
switch over to object oriented programming
really is a major change from the function
oriented programming that has done in the
past, and is going to require major changes
in how a project does business.  For example,
probably management is going to have to 
support the idea of spending extra time and
money up front to fund the creation of some
really world-class, clean, reuseable libraries
oriented towards whatever task your organization
specializes in.  IE Quality doesn't come free
initially -- it requires some up front
investment -- which if done correctly rapidly
pays itself back.

If people in your organization don't realize
or support the idea that object oriented
programming really is a major change from how
software was made in the past, then you're
probably going to have problems.  Mixing
function oriented design techniques, and object
oriented design techniques tends to lead to
the problems of both.

jim@athsys.uucp (Jim Becker) (11/12/88)

>In article <5217@thorin.cs.unc.edu> coggins@retina.cs.unc.edu (Dr. James Coggins) writes:
>> In article <179@tityus.UUCP> jim@athsys.uucp (Jim Becker) writes:
>>	If this language is so great, why do we need all these papers
>>from PHD level intellectuals telling us how to use it?? 
> 
> (This tirade cuts close to home. You are a bit out of line here.)
> (and it's "Ph.D.")

	My comment about Ph.D.'s (sp -- stand corrected) was NOT
intended to be derogatory in any way, shape or form. What it was
questioning is the intelligence level that is required for a person to
utlize the task at hand.  Although it would be fantastic for more
people to have higher intelligence this is not always the case. Hence
an increase in the base level of intelligence for a person to
comprehend and use any given tool reduces the set of people that can
use the tool.

	A better example of this is newspapers. The biggest paper
local is the New York Daily News, which has the average level of
literacy to comprehend at the sixth grade level. One the other hand,
the Wall Street Journal requires a much higher level of understanding
to read and comprehend.  Therefore, although it has more content, the
Journal has a much lower percentage readership in NYC than the Daily
News.  (Although this may not be the case worldwide, I don't know).

	This is also the case with the Mac vs. the IBM PC. There may
be lots more firepower and wonderful software available with the PC,
but normal people can easily make use of the Mac. The IBM PC learning
curve is a lot steaper, and most users have to gain more computer
literacy than average. Secretaries can take years to get really good
on a PC, but I have taught several the Mac in an hour or less.

	The point that I was trying to make is that some people may be
able to pickup and understand the C++ language easily, but most
average programmers will not. I think that there are many things that
could be done to make an integrated C++ environment better, but
raising the "membership dues" of intelligence does not help to broaden
the usage of the language.


> 
> These passages and your reference to friend functions indicate that
> you are using C++ as a "better C" and not using the object-oriented
> design paradigm correctly.  Indeed your 800K line project might be
> excessively complex due to flawed design.  

	Most everything that we are doing is object-oriented, possibly
somewhat excessively. In all probability a rewrite of the code would
result in a better design/implementation, as is true of most software 
projects. :-)


> Maybe you could learn something from some Ph.D.'s that would REALLY
> help you.

	I would love to learn as much as possible in my life,
especially from Ph.D.'s. There are many _theoretical_ things that I
have learned from those with Ph.D.'s, but I operate in the business
world. I translate from theoretical to _business_. There is a
difference in approach that one develops when out of the academic
world and in the business world. This is the path I have taken.

	If I had the time and money I would pursuit a Ph.D., as I
believe that there is much I could learn and many contributions that I
could make toward improving the academic process through my work and
interest in multi-media information systems. Unfortunately, I
currently have to work commercially for a living.

> 
>>Is this a language that is great for the super human programmers, and
>>one that becomes "write only" after a master has been at work?? Or is
>>it a general extension to make the language more flexible and easier
>>for a novice to intermediate programmer to create cleaner and more
>>well understood code?? How much will a new programmer have to read to
>>understand and modify existing code in C++?? Can an average programmer
>>write better code, or more confusing and obscure code?? Everyone isn't
>>a star coder out there.
> 
> Bad design yields bad code in any language, including C++.  C++ gives
> you more than enough rope to hang yourself, but it also provides
> abstraction mechanisms that make it easier to write and understand
> larger systems of code.  Good management techniques can minimize the
> incidental problems of managing headers.  Good design minimizes the
> essential problems of complex dependencies.
> 

	I find it difficult to read code that uses calls where the
parameters may or may not be changed in the calling procedure. Also,
if functions can come from any base class, and the resulting code
executed can differ depending on the specific type of parameters
passed, it results in a more "multi-dimensional" understanding of what
a call is going to do. Basicially, there is a lot more, in terms of
underlying behavior, that can be happening in a C++ program. You may
not always be aware of it.

	I believe that if a few programmers write a project using good
design it is very possible to get the advantages of these features.
For me, to take an existing set of code that is intertwined and
figuring out what exactly happens is more difficult with C++. This may
be just my problem, as I also have problems picking up chess games in
the middle, but I don't feel that this is an unusual.

> ------------------------------------------------------------------------
> James M. Coggins, Ph.D. (and proud of it)
> Computer Science                      My season basketball tickets
> UNC-Chapel Hill                       came yesterday.
> coggins@cs.unc.edu


-Jim Becker
((the only) C programmer in a land of C++ programmers)

coggins@piglet.cs.unc.edu (Dr. James Coggins) (11/12/88)

	> (This tirade cuts close to home. You are a bit out of line here.)
	> (and it's "Ph.D.")
	
		My comment about Ph.D.'s (sp -- stand corrected) was NOT
	intended to be derogatory in any way, shape or form.

I regretted turning up the burners on this soon after I posted the reply.
I shouldn't have let it tick me off the way it did.

        What it was
	questioning is the intelligence level that is required for a person to
	utlize the task [tool?] at hand.  Although it would be fantastic for more
	people to have higher intelligence this is not always the case. Hence
	an increase in the base level of intelligence for a person to
	comprehend and use any given tool reduces the set of people that can
	use the tool.

        [some examples deleted]

Aha! now I see where we differ.
I think you are associating "intelligence of the user" with
"ability to use a crummy user interface", which is a serious
error.  The Mac has a unified interface based on a simple
and pervasive metaphor.  This beautiful design is what makes it so
easy to learn, not the intelligence or lack thereof in the user
community. Even Ph.D.s (especially Ph.D.'s?) find the Mac easier to
use than the PC. Being able to use a PC does not indicate superior
intelligence, but it might indicate motivation, hard work, time on
your hands, ... .

The problem is not in ourselves, but in our software user interfaces.

		The point that I was trying to make is that some people may be
	able to pickup and understand the C++ language easily, but most
	average programmers will not. I think that there are many things that
	could be done to make an integrated C++ environment better, but
	raising the "membership dues" of intelligence does not help to broaden
	the usage of the language.

I can agree that learning to use C++ effectively is challenging right
now, but this is not the fault of the language and not an indication of
a C++ Programmer Master Race. The problem is that we lack educational
materials right now.  Just like when structured programming came out.
The Ph.D.s had to figure out what SP really meant and what it could
do, then the educational material appeared, and now we don't preach SP
any more because it is accepted from the beginning.  Object-Oriented
design is proceeding the same way.  C++ has found explosive acceptance
even though the language is still evolving because OOP clearly is an
improvement in technique.  We Ph.D.s are working out what OOP really
is and how to use it. The educational material has not yet appeared.
You business types have jumped on the right bandwagon (and you
are to be congratulated on your forward-looking management decisions), 
but being in the forefront has certain tradeoffs.  Getting there
before the educational material has been developed is one of them.
In sum, when we get some reasonable teaching material out there, Joe
Average Programmer will have no trouble learning OOD or C++.

		I find it difficult to read code that uses calls where the
	parameters may or may not be changed in the calling procedure. Also,
	if functions can come from any base class, and the resulting code
	executed can differ depending on the specific type of parameters
	passed, it results in a more "multi-dimensional" understanding of what
	a call is going to do. Basicially, there is a lot more, in terms of
	underlying behavior, that can be happening in a C++ program. You may
	not always be aware of it.

Part of the necessary tool set for a C++ programming environment is a
"class browser" that would ease or eliminate these problems that I
agree can be annoying.  The research community is fully aware of them
and there are people working on such tools now. (those of you working on
such tools are encouraged to edit the subject line and jump right in)
	
---------------------------------------------------------------------
Dr. James M. Coggins          coggins@cs.unc.edu
Computer Science Department   
UNC-Chapel Hill               Not a member of the putative 
Chapel Hill, NC 27514-3175    C++ Master Race.
---------------------------------------------------------------------

jim@athsys.uucp (Jim Becker) (11/15/88)

From article <5278@thorin.cs.unc.edu>, by coggins@piglet.cs.unc.edu (Dr. James Coggins):
> 
> Aha! now I see where we differ.
> I think you are associating "intelligence of the user" with
> "ability to use a crummy user interface", which is a serious
> error.  The Mac has a unified interface based on a simple
> and pervasive metaphor.  This beautiful design is what makes it so
> easy to learn, not the intelligence or lack thereof in the user
> community. Even Ph.D.s (especially Ph.D.'s?) find the Mac easier to
> use than the PC. Being able to use a PC does not indicate superior
> intelligence, but it might indicate motivation, hard work, time on
> your hands, ... .
> 
> The problem is not in ourselves, but in our software user interfaces.
> 

	This is true. It is also part of the evolution that is
occurring with the "Information Age". There is an increasing amount of
material that needs to be digested if one is going to "keep up" with
the world. This needs to be presented to the user in as familiar and
understandable a format as possible.  This is where the Mac has taken
the big leap, everything that one uses is familiar in the nature of
the interface. After getting used to the Mac, it becomes much more
difficult for the busy user to take the time and effort required with
products that are "A Maze of Twisty Different Passages, All Different".

	Since I have become accustomed to the nature of Mac programs,
I have raised my standards as far as the nature of programs that I am
willing to learn. If they consume too much of my time getting started
they are demoted in usage against easier to use products. These
demoted products may actually be much better as far as functionality,
but "time" is becoming one of my most precious resources.

	The easy of use has come to the end user in the form of Mac type
interfaces, the question is the ease of programming for that ease of use.
I believe that products like HyperCard and Fourth (4th) Dimension are the
first steps toward this next generation of computer usage. C++ could move
this way, but there are steps outlined that need to be taken before it 
happens.

> 		The point that I was trying to make is that some people may be
> 	able to pickup and understand the C++ language easily, but most
> 	average programmers will not.
> 
> I can agree that learning to use C++ effectively is challenging right
> now, but this is not the fault of the language and not an indication of
> a C++ Programmer Master Race. The problem is that we lack educational
> materials right now.  [clipped]

	Again we are in agreement. The wrench that I would like to
throw into the works is the changes that are taking place around us.
There are less students that are going into technical and degreed
work. Technology changes so fast that even those coming out of school
become out of date quickly. Job functions and titles are continuing to
evolve and shift at an increasingly faster rate of speed.

	Businesses are finding that they have problems even fitting
people to positions that are fairly typical in the job market,
basically because there is a lessening of skills and literacy in the
marketplace. This is due to immigration and shifts in schooling (no
flames, read anything about this). Businesses have to train workers in
basic algebra and language skills, so what about more complex things
-- like computers!

	The direction that has been taken in much of the business
community is to "de-skill" the jobs that they have. Using non-language
pictures and visuals rather than words and sentences. About a year ago
I went to a presentation of an interactive videodisc setup that was
used to train welders how to weld. Going into the project, the creator
had one basic credo that the customer needed -- that there were no
written words. This is because there would be lots of people of
differing language and literacy background that would not be able to
understand words. Hence it was all pictures.

	Extracting this situation to the discussion at hand. It would
be wonderful if we had the educational materials and the effort and
money and energy to do this. We just elected an "education president",
eh?? I would like to see this happen more than you can believe, as I
think that it is the best road back to making America what it was when
I was growing up. But, after trying to do educational efforts in
software with my own company, I don't hold my breath waiting for the
government or politicians or anyone else to do something about
education. Here in California we are spending more money than ever on
education, but the average kid sure isn't the Einstein you would
expect. Therefore, until the time when we create new kids that are
really bright, part of the solution may be to make the tools that are
used in all forms of development more easily understandable to
"average" level users. Hence my argument toward making higher level
toolkits for users.

> 	
> ---------------------------------------------------------------------
> Dr. James M. Coggins          coggins@cs.unc.edu
> Computer Science Department   
> UNC-Chapel Hill               Not a member of the putative 
> Chapel Hill, NC 27514-3175    C++ Master Race.
> ---------------------------------------------------------------------


-Jim Becker
[attach your own name..]

henry@utzoo.uucp (Henry Spencer) (11/18/88)

In article <179@tityus.UUCP> jim@athsys.uucp (Jim Becker) writes:
>Is this a language that is great for the super human programmers, and
>one that becomes "write only" after a master has been at work?? ...

The same questions have been asked (in the form of assertions, actually)
about C.  Actually, a global s/C++/C/ on your article yields something
that mostly still makes sense.  I think the answers are the same for C++
as for C:  it is not a language for novices; it provides more than
enough rope to hang yourself if you are careless; producing good, clean,
readable programs requires judgement, care, and a professional attitude,
attributes that are not nearly as common as one would like.  C++ strengthens
these statements but does not change them much, except insofar as C++ is
young -- the time and experience needed to develop good judgement are in
short supply as yet.
-- 
Sendmail is a bug,             |     Henry Spencer at U of Toronto Zoology
not a feature.                 | uunet!attcan!utzoo!henry henry@zoo.toronto.edu

shurr@cbnews.ATT.COM (Larry A. Shurr) (11/19/88)

In article <1988Nov17.211353.13358@utzoo.uucp> henry@utzoo.uucp (Henry Spencer) writes:

>The same questions have been asked (in the form of assertions, actually)
>about C.  Actually, a global s/C++/C/ on your article yields something
>that mostly still makes sense.  I think the answers are the same for C++
>as for C:  it is not a language for novices; it provides more than
>enough rope to hang yourself if you are careless; producing good, clean,
>readable programs requires judgement, care, and a professional attitude,
>attributes that are not nearly as common as one would like.

Indeed, I agree.  I wonder if it can be truthfully said that any program-
ming language does not provide enough rope to hang yourself, careless or
not.  And is there any language which does not require "... [good] judge-
ment, care, and a professional attitude?"

regards, Larry
-- 
Signed: Larry A. Shurr (att!cbnews!shurr or osu-cis!apr!las)
Clever signature, Wonderful wit, Outdo the others, Be a big hit! - Burma Shave
(With apologies to the real thing.  Above represents my views only.)