My thought was that lower would be more difficult, but the application's speed would be better. Higher, easier to program, but slower run speed.
True?? Or does that all depend on the programmer?
Printable View
In general lower == faster, but programmer skill can generalyl have a big impact on that, a great GW-BASIC programmer can write code that beats crappy assembly. but a good assembly writer can produce the fastest code possible. Ultimatelyassembly has teh potential to be as fast or faster than any other language, but ti takes programmign skil to unlock that potential.
So what you are saying is that a programs speed depend not on just the language its written, but also in the skill of the programmer.
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.
Yes, and that holds true regardless of programming language.Quote:
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.Quote:
Originally Posted by knightjp
Yes. Search the Web to find out.Quote:
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.
From a language perspective code in C++ is neither faster nor slower than code written in C, given good quality compilers for both languages. As both languages have a common base, and the resulting code for the same source code should have the same performance and give the same result.
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.
--
Mats
No. C++ was designed to be a fast, native language which lends tools and features from other paradigms to get the job done.
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.
This is a forum for C and C++ programming.
For AI, I am willing to bet C++ has an advantage over C.
Especially due to OO programming.
C does not have OO capabilities.
You can emulate it, sure, but it will a lot of pains and headaches and probably hurt performance, as well.
What does manage RAM usage mean?
You use what resources you need and free them when you don't need them. Otherwise you get a memory leak.
Do you have to do memory management manually in C++? No, you can use smart pointers to handle that for you.