M
Mike Copeland
I have a lot of C-based code that I'm (slowly) converting to C++,
STL, and what I hope to be code that's easier to manage. I'd also like
to gain performance increases and reduced code - but I'm not really
seeing the latter improvements. 8<{{
As I think about it, there appear to be some trade-offs with either
type of coding:
1. C-based strings require fixed (max) size declarations and runtime
code to scan these character strings to determine size - so that
operations can be made on them. There's overhead in both object file
size and execution processing to deal with such data.
2. STL strings, on the other hand, are instantiated as object pointers
that require runtime memory allocation(s), which might be done over and
over as the data values change throughout execution. (That is, checks
must determine if currently allocated data sizes are adequate, and
deallocation/reallocation done if not. This might require substantial
runtime logic to do for each and every string object.)
Thus, program object sizes should probably be smaller for C++
programs, but C-based programs should generally be larger than
corresponding C++ executables. I'm not seeing this phenomenon at all -
in fact, the opposite seems true.
I don't know if C++ programs execute any faster than C programs (I
suspect they don't), and I don't know if any of my applications would
expose this fact, either way.
I do know that my C++ programs are invariably larger than their C-
based versions.
If there's no other factor in what I'm seeing, I guess the only real
benefit to C++ and STL is ease of coding, debugging and maintenance.
<sigh> Any thoughts?
STL, and what I hope to be code that's easier to manage. I'd also like
to gain performance increases and reduced code - but I'm not really
seeing the latter improvements. 8<{{
As I think about it, there appear to be some trade-offs with either
type of coding:
1. C-based strings require fixed (max) size declarations and runtime
code to scan these character strings to determine size - so that
operations can be made on them. There's overhead in both object file
size and execution processing to deal with such data.
2. STL strings, on the other hand, are instantiated as object pointers
that require runtime memory allocation(s), which might be done over and
over as the data values change throughout execution. (That is, checks
must determine if currently allocated data sizes are adequate, and
deallocation/reallocation done if not. This might require substantial
runtime logic to do for each and every string object.)
Thus, program object sizes should probably be smaller for C++
programs, but C-based programs should generally be larger than
corresponding C++ executables. I'm not seeing this phenomenon at all -
in fact, the opposite seems true.
I don't know if C++ programs execute any faster than C programs (I
suspect they don't), and I don't know if any of my applications would
expose this fact, either way.
I do know that my C++ programs are invariably larger than their C-
based versions.
If there's no other factor in what I'm seeing, I guess the only real
benefit to C++ and STL is ease of coding, debugging and maintenance.
<sigh> Any thoughts?