Apr 11

I’ve got your cin and cout *right here*

Over the years I’ve had a few friends begin to learn programming. Occasionally, one of them will find me for help.

I can tell whenever one of them starts out in their first C++ classes, because I start getting asked questions about iostreams, and the questions are almost always about use of esoteric manipulators.

People are intimidated that they’re never going to be able to understand all of the arcane complexities of this built-in system that’s taught to them on day one, which they assume their future livelihood may depend on.

A line and a half of code from one of our servers jumped out at me just now.

They’re reasonably indicative of all of the professionally-created C++ projects I’ve ever worked around.

Here you go:

    // iostreams can suck it
    FILE* fp = fopen( ...

To anyone who asks in the future: You’re safe, guys. Just make it through the class.

4 Comments so far »

  1.  

    Joe Ludwig said

    April 11 2008 @ 1:37 pm

    One of the things I never understood about iostreams was the allergy that C++ purists seem to have to format strings. IMHO, printf kicks the << operator’s pointy overloaded ass.

  2.  

    Ama said

    April 11 2008 @ 2:02 pm

    // Ahahahahahhaa.

  3.  

    OnyxRaven said

    April 11 2008 @ 3:05 pm

    iostreams is one of the worst perversions of operator overloading ever.

    Operator overloading is troublesome to begin with - there are very few times when it makes for easy programming - usually it just leads to endless confusion.

  4.  

    Don Neufeld said

    April 11 2008 @ 8:32 pm

    Yeah, I’m not a big fan of overloading in general. I’ve built some sizable based systems that used overloading and partial template specialization to do their thing. It was a nightmare to debug, hard to explain to other people and generally a pain in the ass.

    Want to really go down the rabbit hole, try this book!
    I do find std::istringstream handy for ad hoc parsing though.

Comment RSS · TrackBack URI

Leave a comment

Name: (Required)

eMail: (Required)

Website:

Comment: