The trouble with I/O in C++
A common measure of a programming language's ease of use is what's called TTHW--"time to hello world." Many popular programming languages have a very low TTHW: in many scripting languages, such as Python and Perl, the "hello world" program is literally the single line: print "hello world"
.
C++ and its ancestor C are systems programming languages, which is to say that their primary concerns are with "power": control over the machine, speed, and (in C++'s case) the ability to leverage the type system with generic algorithms. This is a mixture of concerns not suited to small "hello world" programs.
The canonical "hello world" program in C is as follows:
#include <stdio.h> int main() { puts("hello world"); }
In C++, it is as follows:
#include <iostream> int main() { std::cout << "hello world" << std::endl; }
The canonical C++ source code is not much longer than the canonical C source code, but it has...