If c++ is a lot better?
If c++ is a lot better?
Interestingly, I asked this same question to an uncle of mine, who's a prof in a univ. in california. This was a few years ago, so impressions may have changed now. Anyway, he was talking about this experimental satellite that some of his students were working on and it used an 80186 chip IIRC. He told me that the software was being written in C, because the consensus at a certain propulsion lab was that C++ was not quite a mature language as C.
C provides a better oppurtunity to play with pointers
Most people stick with C because that's what they know. For them, C++ may be overkill and involve too great a learning curve. C++ is a much larger language than C, and therefore more difficult to learn well (although I'd argue both C and C++ are large languages that are difficult to learn well).
it's just quite a base / core language used all over the place. a great starting point i think. c++ is one direction out of many you could go in, from c. personally i'm going in an objective-c direction from c: i don't plan on touching c++ at all.
'better' depends on the problem you are trying to solve - some problems lend themselves to an object oriented design that C++ can solve, some lend themselves to more 'traditional' designs, that standard C can solve. Large applications can be written in C (take a look at the Linux kernel, that's a pretty hefty lump of C code).
Some people also prefer to code in C over C++ because they view C++ as an ugly hack on top of the simple language that is C - I don't know C++ so I won't take that point any further :)
When you're going retro C is for you. What I mean is this. Visual Basic was the first language I learned, but I was very dissatisfied once I knew better with its inefficiency. I started to try to learn Visual C++ but the GUI itself disgusted me. I grew fed up with the entire thing, and wanted to scratch out my programs in notepad. I went for C cause it does not pamper you. I wanted to learn the low-level of things. I wanted to "play" with pointers and memory chunks as they really are. When you get that kind of understanding of the architecture, you become more familiar with what is the fastest way to execute a task. And what takes the least amount of code.
People who code in higher level languages are mostly concerned with getting a project done, in the shortest amount of time, with the smallest amount of effort. People who STILL and do code in C are frequently primarily concerned with HOW a project is done.
This is also why most linux programs are written in C. Cause the same type of person values linux, as those who value C.
It does not matter if you can code C in a C++ program. Cause those type of people don't WANT any of the functionality C++ provides.
And when you get as efficiency fanatic as I am, you desire to pump out things in ASM as well.
Don't forget, there's a lot of existing C code out there, and a lot of very experienced C programmers. And C as a language continues to develop.
hasnt c++ been around for a while
Yes it has, and similarly, lots of people still use C++ ;-)
Yes, the same as with COBOL. Which leads us to legacy code as a reason for still using C.
A lot of a programmer's work lies in maintaining existing software. Such legacy code is almost invariably written in older languages and using older techniques. When you are given the task of fixing a bug or adding a feature to legacy code, you almost never are afforded the luxury of rewriting the entire thing using the latest language nor the latest tools. And if the Y2k panic taught us nothing else, it taught us that the amount of really old legacy code being used out there is much greater than we realize -- such as all that decades-old COBOL code that had us scared.
Similarly, when you are given a new program to write or a new embedded project to design, you are often told by management (or you even suggest it yourself) to base it on an existing program or device that appears to do something similar. Which yet again leads you into using older technologies and older languages.
Plus, some older wisdom continues to exist even though it may no longer be true. For example, C was always chosen over C++ in embedded projects mainly because C++ placed extra demands on the hardware (especially in the amount of RAM required) that were just plain more expensive. But now that larger amounts of RAM are much cheaper and much more powerful processors are available for embedded projects, the old wisdom is not necessary true anymore. Yet it persists.
Then there's the "old programmer" effect, in that there are programmers with decades of C experience but who have not learned C++. So in a brand-new project, their choice for the language will naturally be C, not C++. In the same way that many "revolutions" are won in many fields -- the young generation with the "revolutionary" ideas win when the older generation dies off --, the newer generation of programmers who are taught C++ instead of C (though they must learn C OJT) must wait for the old programmers to die off or retire before they can choose the new projects' language -- and then they'll have to contend with the new generation of young upstarts pushing yet another new language.
And finally, there are some jobs for which C is the better choice. OOP is great for organizing a large project, but for some small projects it would be over-kill. Plus the project may require smaller faster code, which C is better at delivering than C++ is.
Just my two cents worth, offered more because I couldn't sleep.
A tagline I encountered on a newsgroup or forum:
so your saying c is faster than c++?
I think it would be difficult to make a general case one way or the other.
Depending on what the program is going to be doing, then C can be faster than C++. Both languages have thier uses and where they have an advantage in. Typically projects that can really take advantage of OOP are done in C++. Just for example look at a spreadsheet. Each cell on a spreadsheet would be an object. Doing this in C++ would be a lot easier than doing this in C.
I find myself using C more than C++ though, mainly because of what I use C for. Which is building applications that run on barcode scanners. These apps must be fast and have a small footprint. This, to me, is easiest done in C than C++. Although I do agree with what dwise_aol posted in that there are multiple reasons why one language is used over the other. To me, it mainly boils down to C was not made extinct by C++ (or any derivitave of C for that matter) because it still usefull and will remain to be so for years to come.