J
jacob navia
Recently in another thread, we discussed a bit about C vs C++
maintenance. As usual in those discussions, many of the arguments and
ideas behind the views expressed weren't even said, and even less dicussed.
I would like to make the motives behind my viewpoint explicit.
Object oriented programming (OO for short) took off in the middle of the
80s. It promised increased modularity through components and reduced
numebr of lines of code through reuse.
The reality is quite different however.
OO legacy code is very difficult to deal with due to acute lack of
modularity and the additional dependencies introduced by the frameworks
that OO code needs to get going. Since the frameworks lack in many cases
a formal API, the code using them becomes completely dependent of the
framework through inheritance...
This can be impossible to get rid of later, when either the framework is
abandoned or (the other extreme) it changes regularly each year and each
year you have to spend a lot of work just to keep up with it.
Another big problem is the lack of modularity of OO, because modularity
relies on explicit and well defined INTERFACES and APIs, that are seldom
used in OO programming. Everything is tied with everything else, and the
code becomes a horrible tangle of code, appropiately known as a "tar
ball"
`
C++ adds to the problems of code maintenance with its implicit
overloading of identifiers that makes impossible for the maintenance
programmer to figure out easily what function is being called when he
sees a function call or even a simple statement like "a+b". In most
cases the only sure way to know is to put a breakpoint and try to bring
the program to that point in the debugger. This doesn't always help
unless the debugger is available and the work to be done to bring the
program to that point is not beyond a certain threshold.
Add to this lethal mix the template problem. Templates give genericity
to C++ at an enormous cost in maintenance problems. In general, it is
impossible to debug problems in templates when they are extensively used
unless the one debugging the application is the original author of the
whole mess. Any modification even an apparently harmless one can produce
a cascade of completely incomprehensible error messages in a completely
unrelated part of the code. If many modifications were done before
recompiling the whole application this can be incredibly difficult to
solve. Templates introduce a new sub-language in C++ that is run during
compile time. It is completely impossible in a complex application to
test templates with all possible types that they could receive as input.
Concepts were designed to allow some specifications to be given to
templates in an explicit form, but they failed (more on this later). We
are stuck with no specifications for template parameters at all. Testing
is therefore much more difficult.
One of the most telling facts about the complexity of C++ was the
"Concepts" catastrophe. After years of effort, the creator of the
language realized that he was unable to introduce a new feature and the
feature was taken out of the new C++ standard to be published shortly.
This proves that C++ has grown so complex that there isn't any human
mind capable of understanding it, not even the mind that started the
language several years ago.
Now, since C++ is uncomprehgensible in its totality, C++ programmers
master *some* part of it well and use a subset of it that fits their
needs and the needs of the company. Problem is, obviously there isn't a
SINGLE subset that is approved by everyone
Each programmer will use then, the constructs he/she is used to. The
only looser is the maintenance programmer that needs to understand them ALL.
Much of my time is spent debugging a C++ mountain of code. Maybe that
is why my repugnance against C++ and complexity holes is so great, I am
surely biased. But people here can't deny that maintenance is a BIG part
of any software activity, and that languages are seldom designed from
that point of view.
Many speak about easy of use, meaning the easy to WRITE code. I prefer C
because easy of use means for me more the ability of READING and
UNDERSTANDING code in that language.
Obviously these are my views and engage only myself. I hope we can avoid
polemic in discussions here. This is not an "all out" attack on C++
either. It is just a dissenting view about it, and an explanation why I
prefer C.
jacob
maintenance. As usual in those discussions, many of the arguments and
ideas behind the views expressed weren't even said, and even less dicussed.
I would like to make the motives behind my viewpoint explicit.
Object oriented programming (OO for short) took off in the middle of the
80s. It promised increased modularity through components and reduced
numebr of lines of code through reuse.
The reality is quite different however.
OO legacy code is very difficult to deal with due to acute lack of
modularity and the additional dependencies introduced by the frameworks
that OO code needs to get going. Since the frameworks lack in many cases
a formal API, the code using them becomes completely dependent of the
framework through inheritance...
This can be impossible to get rid of later, when either the framework is
abandoned or (the other extreme) it changes regularly each year and each
year you have to spend a lot of work just to keep up with it.
Another big problem is the lack of modularity of OO, because modularity
relies on explicit and well defined INTERFACES and APIs, that are seldom
used in OO programming. Everything is tied with everything else, and the
code becomes a horrible tangle of code, appropiately known as a "tar
ball"
`
C++ adds to the problems of code maintenance with its implicit
overloading of identifiers that makes impossible for the maintenance
programmer to figure out easily what function is being called when he
sees a function call or even a simple statement like "a+b". In most
cases the only sure way to know is to put a breakpoint and try to bring
the program to that point in the debugger. This doesn't always help
unless the debugger is available and the work to be done to bring the
program to that point is not beyond a certain threshold.
Add to this lethal mix the template problem. Templates give genericity
to C++ at an enormous cost in maintenance problems. In general, it is
impossible to debug problems in templates when they are extensively used
unless the one debugging the application is the original author of the
whole mess. Any modification even an apparently harmless one can produce
a cascade of completely incomprehensible error messages in a completely
unrelated part of the code. If many modifications were done before
recompiling the whole application this can be incredibly difficult to
solve. Templates introduce a new sub-language in C++ that is run during
compile time. It is completely impossible in a complex application to
test templates with all possible types that they could receive as input.
Concepts were designed to allow some specifications to be given to
templates in an explicit form, but they failed (more on this later). We
are stuck with no specifications for template parameters at all. Testing
is therefore much more difficult.
One of the most telling facts about the complexity of C++ was the
"Concepts" catastrophe. After years of effort, the creator of the
language realized that he was unable to introduce a new feature and the
feature was taken out of the new C++ standard to be published shortly.
This proves that C++ has grown so complex that there isn't any human
mind capable of understanding it, not even the mind that started the
language several years ago.
Now, since C++ is uncomprehgensible in its totality, C++ programmers
master *some* part of it well and use a subset of it that fits their
needs and the needs of the company. Problem is, obviously there isn't a
SINGLE subset that is approved by everyone
Each programmer will use then, the constructs he/she is used to. The
only looser is the maintenance programmer that needs to understand them ALL.
Much of my time is spent debugging a C++ mountain of code. Maybe that
is why my repugnance against C++ and complexity holes is so great, I am
surely biased. But people here can't deny that maintenance is a BIG part
of any software activity, and that languages are seldom designed from
that point of view.
Many speak about easy of use, meaning the easy to WRITE code. I prefer C
because easy of use means for me more the ability of READING and
UNDERSTANDING code in that language.
Obviously these are my views and engage only myself. I hope we can avoid
polemic in discussions here. This is not an "all out" attack on C++
either. It is just a dissenting view about it, and an explanation why I
prefer C.
jacob