Re: C vs. C++



On Jan 17, 6:04 am, "Malcolm McLean" <regniz...@xxxxxxxxxxxxxx> wrote:
Virtually all data is integers, reals, or strings.
Complex languages blow up the number of types and the number of ways of
arranging the types. Then you need templates to try to control the mess.
So one type of complexity is addressed by adding another layer of
complexity. Sometimes it works, more often the human programmer cannot
easily cope with the extra layers of abstraction, and the program is harder
to debug than it would have been written in a simpler language.


And when you need to create containers of these three types of yours,
templates allow you to define a single set of functions that will
operate correctly on all of them regardless of type (integer, real, or
string, or something else), and regardless of the container (array,
linked list, or something else).

I find it very amusing that the one feature of C++ that people keep
using as an example of it's complexity is templates. Templates are not
that complicated, and they make a lot of thing much simpler. With a
simple template, I can define max/min functions which work correctly
on any type, and do not suffer the problems of a macro. And in only a
few lines of code. Plus, it is very type-safe and will only allow
objects of the same type to be compared.

Granted, templates can be--and have been--abused, but so can any
language features. I don't feel that's a valid comment on the
language, but on the programmer. Look at all power a simple pointer
gives you. It's much maligned, but an extremely useful thing.

REH
.



Relevant Pages

  • Re: why still use C?
    ... > to be at the mercy of the compiler and its designer, ... as a programmer I am no ... > program using templates and expect it to work identically on different ... > in mind that a programming language is a tool to make programs. ...
    (comp.lang.c)
  • Re: Boxing and Unboxing ??
    ... It also increases language complexity, which can increase programmer ... adding one simple parameter qualifier and removing a complex qualifier. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: C vs. C++
    ... codebase that is based on templates, if templates were taken away, and how ... > does that task compare to the complexity of templates? ... In general, the simpler the language, the more debugging you have to do ... rarely have debugging support at all, ...
    (comp.lang.c)
  • Re: C or C++
    ... that the beginner programmer is an adult --- they're like innocent ... it is indeed a simpler language (from a certain ... even though it is an extremely complex language, the complexity ...
    (comp.os.linux.development.apps)
  • Re: C++ in embedded systems
    ... >>As for templates, whether those problems are programmer mistakes or not, ... So, more likely than not, it is a programmer ... He then goes on to develop a example of how to avoid it. ... On top of that the 'issue' is also mentioned again and again in language ...
    (comp.os.linux.embedded)