So a skilled C programmer can write a program that runs faster than a program written in C++?
I apologise for being an ignorant fool in asking so many questions, but I would just like to be sure before I spend time learning a language and getting started on my project.
Last edited by knightjp; 11-26-2008 at 10:13 PM.
Yes, and that holds true regardless of programming language.Originally Posted by knightjp
Not likely, since with a few tweaks of that C program (or none at all) it probably could become a C++ program.Originally Posted by knightjp
Yes. Search the Web to find out.Originally Posted by knightjp
There are plenty of resources on the web for learnign assembly. Intel has some very in depth pdf manuals on their processors that are free to download. I think AMD offers stuff too.
A question asked in search of understanding, is never a sign of a dull wit.
Last edited by abachler; 11-26-2008 at 10:18 PM.
C++, however, supports a higher level language, which can be used to make the code simpler. If the "make the code simpler" is used incorrectly, it may offer higher productivity for the programmer but at the cost of performance. However, that is not a necessity. There are good ways and bad ways to write code in all languages.
Writing good code in any language requires a good understanding of the language and the algorithms for the problem. The choice of algorithm is often the most critical aspect of any part of the optimization/performance of any application - if we pick the wrong sorting algorithm to sort 1 million elements, it will take 1 million times 1 million iterations to sort it. With the right algorithm, it is 1000 times faster. That is just one example of many such things.
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
It was to be an evolution of C, and maintain backwards compatibility, and so it does.
All in all, C++ is a very fast, blazingly fast language, like C, with very little overhead.
It's true that using some tools, it may be a little slower than C, say 10% or so (taken from a recent vector of vector vs dynamic array test).
But you can do all that in C within C++, as well, giving additional flexibility, when the necessity arises.
Anyhow, C++ also features things that C could only dream of, and it becomes at very little performance cost. Being able to automatically clean up resources. Great facilities for code reuse. Lots of finished, tested and flexible code for things such as dynamic arrays.
It also has the ability to perform a lot of work at compile time, saving execution time where C would have to do it all in runtime.
So it all evens out.
A skilled C programmer can write a program that's faster than a poorly written C++ program.
A skilled Basic programmer could probably do the same...
All languages have their strengths and weaknesses, but most often those are less of a factor in runtime performance of the generated executables than are outside factors like the skill of the people writing the code, the compiler and how it was used, the hardware on which it runs, network and disk latency, etc. etc.
And most often those differences are not a problem in real world use of the programs.
For example a program that spends 90% of its time waiting for user input isn't going to benefit from some clever bit of coding that makes the other 10% of the code 1% faster.
A program that's going to be running for hours or days at a time isn't going to benefit from having its startup time reduced from seconds to milliseconds.
Looks like 'C' has the vote and considering that this is a forum for C programming, I'm not surprised. C is the choice here and I'm pretty sure that's good enough for me.