Re: Static vs. Dynamic typing (big advantage or not)---WAS: c.programming: OOP and memory management

From: Jim Rogers (jimmaureenrogers_at_att.net)
Date: 07/11/04


Date: Sun, 11 Jul 2004 14:05:10 GMT

Gerry Quinn <gerryq@DELETETHISindigo.ie> wrote in
news:MPG.1b5b17cb894cf397989779@news.indigo.ie:

> In article <Xns9520E51638A6Djimmaureenrogers@127.0.0.1>,
> jimmaureenrogers@att.net says...
>> Gerry Quinn <gerryq@DELETETHISindigo.ie> wrote in
>> news:MPG.1b59fe81cfce418c98976b@news.indigo.ie:
>>
>> > C++ is a universal tool. Whatever the project, it's at least
>> > viable to use C++. Which is a big plus, as is the backwards
>> > compatibility with C. After all, if your language is really
>> > unsuitable for a project you've made a much bigger mistake than if
>> > it's simply 'not ideal'.
>>
>> The C compatibility of C++ is also a liability. Most of the
>> weaknesses of C++ syntax come from C. Many other languages are also
>> extremely viable for all projects.
>
> The compatibility as such is not a liability, it is a clear benefit.
> The syntax needed to allow it may be a liability. I find it not so
> bad. Every language has syntax, and none stands out as being
> 'perfect' as far as I can see.
>

Let's look at some of the C compatibility problems.

* CPP - the macro pre-processor. This is 1970's technology.
        It is useful to a degree, but fraught with difficulties.
        Many C++ developers recommend against using macros, replacing
        them with templates. Macros bypass the C++ strong typing rules.

* C-style arrays - These were so nasty that the C++ standard has
        developed an alternative. The Vector class provides fixes
        for most C-style array problems.

* Lack of a boolean value - While C++ does have a boolean value,
        all boolean expressions must evaluate to a 0 or non-0 value
        for C compatibility.

* Switch statement syntax - The C switch statement requires a break
        statement at the end of a choice to prevent fall-through.
        The default behavior is backwards. Switch statements are not
        required to have a "default" option to handle any values not
        explicitly defined in the switch statement. Lack of a default
        option in code leads to many maintenance and debugging problems.

* Structs - No experienced C++ programmer uses structs. They use classes.
        Structs are simply excess baggage left over from C.

Finally, the problem with C compatibility is the long term futility of
the issue. C++ is highly compatible with an obsolete version of the C
language. The C++ and C standards are not maintained together. Each
language standard is developing independently. The most recent C standard
is newer than the current C++ standard. There are some new features in C
syntax not supported by C++.

>> Many people have found C++ to be a useful but nonetheless
>> unremarkable language. The result has been the development of
>> languages such as Java, C#, and D. All three of those languages
>> attempt to "fix" many of the C++ problems while retaining at least
>> a cosmetic similarity with C.
>
> Time will tell whether they replace it or not.

I guess that depends upon what criteria you use. The fact that a
significant number of projects have been, and are being, developed in
Java and C# indicates that those languages have a very real popularity.
What language would have been used for those projects if Java and C#
were not available? It is arguable that at least some of the projects
would have been done in C++. If that argument is true, then those
languages have already replaced C++.

Expecting all people to abandon one language in favor of another as
the only measure of success is just silly. Given that measure C and
C++ are not successful because they have not eliminated the use of
Assembler languages.

>
>> Other languages have dropped the C syntax altogether in an attempt to
>> provide a more readable syntax.
>
> Dropped? Lots of languages such as BASIC never had it and were
> designed for readability from the start.

Languages designs, including syntax, are based upon various decisions.
The C language clearly existed when Ada, Eiffel, Modula 2, and Python
were developed. None of those languages chose the C syntax. The C
syntax was considered and rejected by the authors of those languages.

> In some senses, popularity does impinge on its usefulness, sometimes
> positively and occasionally negatively. And usefulness is surely part
> of some quality metrics.
>

You should hope that I never become your quality manager.
Quality is not measured by the popularity of the tools used to create
a product. Quality is a measure of the intrinsic properties of the
software product itself, related to the requirements used to create the
product.

The popularity of a language has no impact on the quality of the
products produced using that language.

Jim Rogers



Relevant Pages