Re: Standard Template Library or C?
Johnson wrote:
I am writing a cross-platform program that deals with huge data set. The
program requires high efficiency, high data safety, and good portability
(for both PC and ARM hardware platform, Windows and Linux OS). Now I
have two options to do the job, either using pure C (with pointers and
dynamic allocated memory) or STL.
With pure C, I believe the efficiency is better, and the portability
might be better too, while the data safety will be worse, since I need
to take care of the memory management and wild pointers.
With STL, life becomes much easier for me, but I worried about its
efficiency. I actually don't need most of the algorithms and iterators
provided by the STL. I am not sure if the performance of STL is close to
that of C. I will be happy if it is only 10 or 20 percents slower. I
don't dream it will be faster than C. I also care about the portability.
I am not sure how well the concurrent ARM processor and free compilers
like gcc will support STL.
Could anybody please be kind to give some advice and insight?
C++ was developed to overcome certain drawbacks of C and to introduce
new concepts that make large-scale software development easy while
keeping the portability and efficiency. What you should do is trust the
tool you know to do the job for/with you. That trust seems to be
missing judging from your post.
Efficiency of languages cannot be adequately compared by comparing the
resulting executables. You have to factor in such elements like length
of development, debugging, quality of the resulting product from the
maintainability point of view. Also, in every language it is possible
to write inefficient programs, so you have to use the most efficient
algorithms.
The usual advice given here is, use what you know. If it's C that
you're most comfortable with, use C and leave STL (or whatever) alone
for the time when you get more time to learn it. If it's C++, go with
it and don't look back (at C), you're getting more out of it than you think.
Performance is important, especially when there are lots of data to
process. However, it doesn't matter how fast you do it if you don't do
it right. Make it work first, then measure and see whether you can make
your program run faster. There are tools for that. They are called
"profilers". Learn them and use them. After you got your program
working, that is.
Good luck!
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask