Re: To go with Go or C/C++?
On Friday, 3 May 2013 10:05:40 UTC+1, Andy Champ wrote:
I learned C first. I still find that for certain kinds of I/O the
detailed control of printf & scanf is better than streams. Even though
in general the divorcing of format and values is a PITA...
eg:
printf("%4x", i)
std::cout << std::hex << std::setw(4) << i;
If you need something quick, and you've already invested the
time and effort to learn the printf markup language, then the
C style IO is OK. (Provided you only have to output simple
types, of course. In most larger applications, you'll mostly be
outputting user defined types. And usually through various
filters and such, and not directly to a file.)
But for larger applications, embedding the format in the output
string is a real maintenance nightmare. What happens when the
client says that all of the interest rates (but none of the
other values) should be output with one more digit of precision?
In C++, you modify the interest_rates manipulator, and the job
is done. In C, you have to find every fprintf in the code,
figure out which of the format specifiers concerns interest
rates, and modify it. And then get everything translated again
to other languages, since this information is embedded in the
translated strings. (Or if you're doing real local language
output, grammatically correct, etc., you have to rework all of
the language specific DLLs. Whereas in C++, all of the language
specific DLLs will have used your manipulator.)
--
James