Having used both extensively, I can tell you that it is much more difficult to write slow, bloated, overly complex code in C than in C++. It keeps you honest in that way. Also, most of the good things of C++ such as object-oriented programming and templating can be done at a basic level in C. For example, in C++, a class function is just an ordinary function with a hidden pointer to a (class) structure. Why not just pass in a pointer to a class structure in C? And class member privacy can easily be a m
>For example, in C++, a class function is just an ordinary function with a hidden pointer to a (class) structure. Why not just pass in a pointer to a class structure in C?
GNOME does this. It's great for everything except writing concise, readable C code. They have a language on top of this called Vala, which uses GNOME's type system (and in fact compiles to C) but without having to write complex object and type initialization code. But AFAIK not a lot of people use it.
It's been ages since I read Stroustrup or Kernighan & Ritchie, as I have largely moved on from embedded/Unix programming into Web based systems but I seem to recall one of the arguments for using C++ was that it could always do things as efficiently as C and possibly more so.
Likely true, but the benefit of C that I'm highlighting is that it gives you very little rope to hang yourself with in terms of creating a system composed of layer-upon-layer of classes. In contrast, I once worked with someone who loved to create class-upon-inherited-class for the simplest things in C++. Everyone who looked at his code wondered "where's the beef?", that is, the part that did something useful. The code worked, so the useful part must have been in there somewhere. But it sure wasn't easy
C++ allows makes it very easy for projects to end up in abstraction hell where the main function essentially is a one-liner and the rest is layer upon layer of abstractions that just re-defines the language. Programming C++ requires a LOT of discipline from everyone involved to not end up in unreadable mess. For a very long time C++ was considered to be unsuitable for safety critical application. MISRA C++ haven't been around for more than 5 years or so.
According to all the latest reports, there was no truth in any of the
earlier reports.
Given that (Score:2)
C++ is more or less a superset of C (give or take a few minor issues [wikipedia.org]), why has regular C continued to thrive?
Re: (Score:1)
Having used both extensively, I can tell you that it is much more difficult to write slow, bloated, overly complex code in C than in C++. It keeps you honest in that way. Also, most of the good things of C++ such as object-oriented programming and templating can be done at a basic level in C. For example, in C++, a class function is just an ordinary function with a hidden pointer to a (class) structure. Why not just pass in a pointer to a class structure in C? And class member privacy can easily be a m
Re: (Score:0)
>For example, in C++, a class function is just an ordinary function with a hidden pointer to a (class) structure. Why not just pass in a pointer to a class structure in C?
GNOME does this. It's great for everything except writing concise, readable C code. They have a language on top of this called Vala, which uses GNOME's type system (and in fact compiles to C) but without having to write complex object and type initialization code. But AFAIK not a lot of people use it.
Re: (Score:1)
It's been ages since I read Stroustrup or Kernighan & Ritchie, as I have largely moved on from embedded/Unix programming into Web based systems but I seem to recall one of the arguments for using C++ was that it could always do things as efficiently as C and possibly more so.
Re: (Score:1)
Likely true, but the benefit of C that I'm highlighting is that it gives you very little rope to hang yourself with in terms of creating a system composed of layer-upon-layer of classes. In contrast, I once worked with someone who loved to create class-upon-inherited-class for the simplest things in C++. Everyone who looked at his code wondered "where's the beef?", that is, the part that did something useful. The code worked, so the useful part must have been in there somewhere. But it sure wasn't easy
Re: (Score:0)
Bercause C adopted a lot of what made C++ a superset.
Re: (Score:0)
Less is more.
C++ allows makes it very easy for projects to end up in abstraction hell where the main function essentially is a one-liner and the rest is layer upon layer of abstractions that just re-defines the language.
Programming C++ requires a LOT of discipline from everyone involved to not end up in unreadable mess.
For a very long time C++ was considered to be unsuitable for safety critical application. MISRA C++ haven't been around for more than 5 years or so.