by russellbeattie · 8y ago · 0 comments
cout << "Hello World!" << endl;
It seems like something a bit simpler, readable and predictable would be better for beginners and/or experienced devs alike. I look at that and wonder where did cout come from? Is << a heredoc or some sort of pipe indirection, or am I bit-shifting? And is endl a keyword? Does it always follow cout? Is this like a Pascal endif? Oh, it's basically just a newline. What's wrong with just "\n"? I think C++ devs purposefully make their language as obtuse as possible.Maybe NOT starting with streamio and operator overloading might be a more modern way to start teaching the language?
Not all platforms use “\n” for a new line.
What std::endl really does is flush the internal stream buffer if any.
This is more a problem with folks with experience in other languages, who know bitshift or heredoc syntax. But those can be teached in a more advanced way.
This is the biggest issue with this. STOP TEACHING “using namespace std;”. This is bad, bad, bad, and it sucks.