What is the relationship, if any, between iostream and the STL

Discussion in 'C++' started by blangela, Jan 16, 2007.

  1. blangela

    blangela Guest

    Someone has asked me what the relationship is, if any, between iostream
    and the STL. My suspicion is that iostream uses some of the
    functionality provided by the STL, but I have no actual kowledge on
    which to base my suspicion. Anyone out there know? Please make you
    answer as verbose as possible.

    Thanks,

    Bob
     
    blangela, Jan 16, 2007
    #1
    1. Advertising

  2. blangela

    Noah Roberts Guest

    blangela wrote:
    > Someone has asked me what the relationship is, if any, between iostream
    > and the STL. My suspicion is that iostream uses some of the
    > functionality provided by the STL, but I have no actual kowledge on
    > which to base my suspicion. Anyone out there know? Please make you
    > answer as verbose as possible.


    The "STL" was a third party library that was brought into the standard
    library. It behaved in certain ways and worked with certain concepts
    not necissarily in compiler libraries at the time (I don't believe
    there was a standard). When the STL became part of the standard
    library parts of the implementation library changed to better work with
    concepts in the STL. This includes string to which were added
    iterators, and iostreams I believe - again, iterators where added.

    Now days when people say "STL" they usually mean the C++ part of the
    standard library (in otherwords not the C compat crap), which iostreams
    are of course part of. IMHO the term should really be depricated but
    whatever.
     
    Noah Roberts, Jan 16, 2007
    #2
    1. Advertising

  3. blangela wrote:
    > Someone


    Who? Your instructor at school or your interviewer?

    > has asked me what the relationship is, if any, between
    > iostream and the STL. My suspicion is that iostream uses some of the
    > functionality provided by the STL, but I have no actual kowledge on
    > which to base my suspicion. Anyone out there know?


    Implementors of the library know the most, of course.

    > Please make you
    > answer as verbose as possible.


    First and foremost, 'iostream' is part of the Standard Library. If
    by "STL" you mean the Standard Library, here is your relationship.
    I am not saying that just to wave you off, it's important in the sense
    that the design intent and philosophy behind streams is in tune with
    the rest of the library.

    The streams fit into the rest of the library in two major ways: they
    define (overload) operators for inputting and outputting types defined
    in the library (std::basic_string, for one), and they also provide
    iterators for use in some library algorithms. Also, there is a certain
    link (so to speak) between streams and locales.

    Whether streams make any use of any other parts of the library
    behind the scenes, is unspecified. They can use stream functionality
    provided by the Standard C library. As to sorting, searching, copying
    and other algorithms, I don't see why not. Allocators and other
    memory management stuff as well.

    V
    --
    Please remove capital 'A's when replying by e-mail
    I do not respond to top-posted replies, please don't ask
     
    Victor Bazarov, Jan 16, 2007
    #3
  4. blangela

    blangela Guest

    Victor Bazarov wrote:
    > blangela wrote:
    > > Someone

    >
    > Who? Your instructor at school or your interviewer?
    >


    A colleage at work asked the question.

    > > has asked me what the relationship is, if any, between
    > > iostream and the STL. My suspicion is that iostream uses some of the
    > > functionality provided by the STL, but I have no actual kowledge on
    > > which to base my suspicion. Anyone out there know?

    >
    > Implementors of the library know the most, of course.
    >
    > > Please make you
    > > answer as verbose as possible.

    >
    > First and foremost, 'iostream' is part of the Standard Library. If
    > by "STL" you mean the Standard Library,


    I meant Standard Template Library by STL

    here is your relationship.
    > I am not saying that just to wave you off, it's important in the sense
    > that the design intent and philosophy behind streams is in tune with
    > the rest of the library.
    >
    > The streams fit into the rest of the library in two major ways: they
    > define (overload) operators for inputting and outputting types defined
    > in the library (std::basic_string, for one), and they also provide
    > iterators for use in some library algorithms. Also, there is a certain
    > link (so to speak) between streams and locales.
    >
    > Whether streams make any use of any other parts of the library
    > behind the scenes, is unspecified. They can use stream functionality
    > provided by the Standard C library. As to sorting, searching, copying
    > and other algorithms, I don't see why not. Allocators and other
    > memory management stuff as well.
    >
    > V
    > --
    > Please remove capital 'A's when replying by e-mail
    > I do not respond to top-posted replies, please don't ask
     
    blangela, Jan 16, 2007
    #4
  5. blangela wrote:
    > Victor Bazarov wrote:

    [..]
    >> First and foremost, 'iostream' is part of the Standard Library. If
    >> by "STL" you mean the Standard Library,

    >
    > I meant Standard Template Library by STL


    Do you mean the library that SGI publishes? Since 1998 there is
    *Standard Library*. Vendorless STL doesn't exists since adoption of
    the International Standard for C++ language. "STL" is an obsolete
    term AFA C++ _language_ is concerned.

    V
    --
    Please remove capital 'A's when replying by e-mail
    I do not respond to top-posted replies, please don't ask
     
    Victor Bazarov, Jan 16, 2007
    #5
  6. On 16 Jan 2007 11:23:59 -0800, "blangela" wrote:
    >Someone has asked me what the relationship is, if any, between iostream
    >and the STL.


    Apart from being later (partially) incorporated into the C++ Standard
    both libraries presented something 'new' and 'cool' at the time they
    were make public. In the early nineties iostreams came out with OO
    design and fancy operator overloadings, in the mid nineties STL used a
    value-oriented, anti-OO, generic 'paradigm' influenced by functional
    programming. If they were not ennobled by the C++ Standard you would
    hardly find those libraries in current C++ code.

    Best regards,
    Roland Pibinger
     
    Roland Pibinger, Jan 17, 2007
    #6
  7. blangela

    Lionel B Guest

    On Wed, 17 Jan 2007 10:25:43 +0000, Roland Pibinger wrote:

    > On 16 Jan 2007 11:23:59 -0800, "blangela" wrote:
    >>Someone has asked me what the relationship is, if any, between iostream
    >>and the STL.

    >
    > Apart from being later (partially) incorporated into the C++ Standard
    > both libraries presented something 'new' and 'cool' at the time they
    > were make public. In the early nineties iostreams came out with OO
    > design and fancy operator overloadings, in the mid nineties STL used a
    > value-oriented, anti-OO, generic 'paradigm' influenced by functional
    > programming. If they were not ennobled by the C++ Standard you would
    > hardly find those libraries in current C++ code.


    Right! Of course I'd much rather use printf instead of std::cout <<, char*
    instead of std::string, double* instead of std::vector<double>, ... but
    hey, they're part of the C++ standard, so I'd better use them.

    Piffle.

    --
    Lionel B
     
    Lionel B, Jan 17, 2007
    #7
  8. blangela

    Dizzy Guest

    Lionel B wrote:
    > On Wed, 17 Jan 2007 10:25:43 +0000, Roland Pibinger wrote:
    >
    >> On 16 Jan 2007 11:23:59 -0800, "blangela" wrote:
    >>>Someone has asked me what the relationship is, if any, between iostream
    >>>and the STL.

    >>
    >> Apart from being later (partially) incorporated into the C++ Standard
    >> both libraries presented something 'new' and 'cool' at the time they
    >> were make public. In the early nineties iostreams came out with OO
    >> design and fancy operator overloadings, in the mid nineties STL used a
    >> value-oriented, anti-OO, generic 'paradigm' influenced by functional
    >> programming. If they were not ennobled by the C++ Standard you would
    >> hardly find those libraries in current C++ code.

    >
    > Right! Of course I'd much rather use printf instead of std::cout <<, char*
    > instead of std::string, double* instead of std::vector<double>, ... but
    > hey, they're part of the C++ standard, so I'd better use them.


    What you would prefer to use is very subjective of course but in the listed
    cases there are clear technical advantages of using:

    1. std::cout << instead of printf: mainly type safety and optimization
    (better runtime speed), ie why not use the compile time lookup matching
    types and argumets when looking for overloaded functions than telling
    printf what types you will list (where you may get it wrong while the
    compiler won't) also the same compiled code made to deal with various
    things is generally worse optimizable than specific code ment to work with
    specific types (ie an overloaded version of << than a general printf())

    2. std::string instead of char*: providing safer method for string
    manipulation (when not explicitely providing lengths for example) plus
    simple things like always knowing the size of the string (and not having to
    repeatedly call strlen() which is a O(n) operation)

    3. std::vector<double> instead of double* (I supose you actually mean
    instead of a C array of double because it's not the same thing with a
    pointer in general thus no comparation is possible in general): not many
    people know that the standard mandates that &v[0] is a contigous array that
    can be manipulated externally (thus most people that wanted a C array
    because they needed to work with legacy APIs can do it with std::vector
    just fine) or that (most) implementations have specializations for using
    std::copy() on std::vector::iterator and that in fact they actually call
    memcpy and such in the cases where that is possible, etc

    --
    Dizzy
    http://dizzy.roedu.net
     
    Dizzy, Jan 17, 2007
    #8
  9. blangela

    Lionel B Guest

    On Wed, 17 Jan 2007 16:36:43 +0200, Dizzy wrote:

    > Lionel B wrote:
    >> On Wed, 17 Jan 2007 10:25:43 +0000, Roland Pibinger wrote:
    >>
    >>> On 16 Jan 2007 11:23:59 -0800, "blangela" wrote:
    >>>>Someone has asked me what the relationship is, if any, between iostream
    >>>>and the STL.
    >>>
    >>> Apart from being later (partially) incorporated into the C++ Standard
    >>> both libraries presented something 'new' and 'cool' at the time they
    >>> were make public. In the early nineties iostreams came out with OO
    >>> design and fancy operator overloadings, in the mid nineties STL used a
    >>> value-oriented, anti-OO, generic 'paradigm' influenced by functional
    >>> programming. If they were not ennobled by the C++ Standard you would
    >>> hardly find those libraries in current C++ code.


    Sorry if it wasn't clear:

    <irony>

    >> Right! Of course I'd much rather use printf instead of std::cout <<, char*
    >> instead of std::string, double* instead of std::vector<double>, ... but
    >> hey, they're part of the C++ standard, so I'd better use them.


    </irony>

    [snip]

    --
    Lionel B
     
    Lionel B, Jan 17, 2007
    #9
  10. blangela

    Dizzy Guest

    Lionel B wrote:

    > On Wed, 17 Jan 2007 16:36:43 +0200, Dizzy wrote:
    >
    >> Lionel B wrote:
    >>> On Wed, 17 Jan 2007 10:25:43 +0000, Roland Pibinger wrote:
    >>>
    >>>> On 16 Jan 2007 11:23:59 -0800, "blangela" wrote:
    >>>>>Someone has asked me what the relationship is, if any, between iostream
    >>>>>and the STL.
    >>>>
    >>>> Apart from being later (partially) incorporated into the C++ Standard
    >>>> both libraries presented something 'new' and 'cool' at the time they
    >>>> were make public. In the early nineties iostreams came out with OO
    >>>> design and fancy operator overloadings, in the mid nineties STL used a
    >>>> value-oriented, anti-OO, generic 'paradigm' influenced by functional
    >>>> programming. If they were not ennobled by the C++ Standard you would
    >>>> hardly find those libraries in current C++ code.

    >
    > Sorry if it wasn't clear:
    >
    > <irony>
    >
    >>> Right! Of course I'd much rather use printf instead of std::cout <<,
    >>> char* instead of std::string, double* instead of std::vector<double>,
    >>> ... but hey, they're part of the C++ standard, so I'd better use them.

    >
    > </irony>


    :) Got me on that, I didn't fully read the quoted statement above (lost me
    arround "new and cool at the time") thus did not realised the irony...

    --
    Dizzy
    http://dizzy.roedu.net
     
    Dizzy, Jan 17, 2007
    #10
  11. blangela

    Noah Roberts Guest

    Lionel B wrote:
    > On Wed, 17 Jan 2007 16:36:43 +0200, Dizzy wrote:
    >
    > > Lionel B wrote:
    > >> On Wed, 17 Jan 2007 10:25:43 +0000, Roland Pibinger wrote:
    > >>
    > >>> On 16 Jan 2007 11:23:59 -0800, "blangela" wrote:
    > >>>>Someone has asked me what the relationship is, if any, between iostream
    > >>>>and the STL.
    > >>>
    > >>> Apart from being later (partially) incorporated into the C++ Standard
    > >>> both libraries presented something 'new' and 'cool' at the time they
    > >>> were make public. In the early nineties iostreams came out with OO
    > >>> design and fancy operator overloadings, in the mid nineties STL used a
    > >>> value-oriented, anti-OO, generic 'paradigm' influenced by functional
    > >>> programming. If they were not ennobled by the C++ Standard you would
    > >>> hardly find those libraries in current C++ code.

    >
    > Sorry if it wasn't clear:
    >
    > <irony>
    >
    > >> Right! Of course I'd much rather use printf instead of std::cout <<, char*
    > >> instead of std::string, double* instead of std::vector<double>, ... but
    > >> hey, they're part of the C++ standard, so I'd better use them.

    >
    > </irony>
    >


    Unfortunately there are those that feel this way and advocate prefering
    such types even given the long list of technical reasons not to.
     
    Noah Roberts, Jan 17, 2007
    #11
  12. On Wed, 17 Jan 2007 14:21:43 +0000 (UTC), "Lionel B" wrote:
    >Right! Of course I'd much rather use printf instead of std::cout <<, char*
    >instead of std::string, double* instead of std::vector<double>, ... but
    >hey, they're part of the C++ standard, so I'd better use them.


    As if C Standard libraries were the only imaginable alternatives to
    STL and iostreams - probably for you.
     
    Roland Pibinger, Jan 17, 2007
    #12
  13. blangela

    Lionel B Guest

    On Wed, 17 Jan 2007 17:06:11 +0000, Roland Pibinger wrote:

    > On Wed, 17 Jan 2007 14:21:43 +0000 (UTC), "Lionel B" wrote:
    >>Right! Of course I'd much rather use printf instead of std::cout <<, char*
    >>instead of std::string, double* instead of std::vector<double>, ... but
    >>hey, they're part of the C++ standard, so I'd better use them.

    >
    > As if C Standard libraries were the only imaginable alternatives to
    > STL and iostreams - probably for you.


    Yes, there are "imaginable alternatives": I could use C-style I/O (but I
    find it clunkier and more error-prone than C++-style I/O). I could use raw
    pointers and do my own memory allocation (but I find it clunkier and more
    error-prone than eg. std::vector). I could write my own I/O wrappers or
    containers (but life is too short to re-invent wheels). I could use
    third-party I/O systems or containers or "semi-standard" libraries like
    Boost (I occasionally do if they offer some advantage/functionality over
    the standard facilities).

    So I use C++-style I/O and standard containers because:

    1) They work very nicely for me.

    2) They are standard! Therefore my code is far more likely to be
    comprehensible to others than non-standard stuff.

    3) I don't want to re-invent wheels.

    4) I have invested a good deal of time and effort to familiarise myself
    with their paradigms and learn their usage.

    --
    Lionel B
     
    Lionel B, Jan 18, 2007
    #13
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ken Cox [Microsoft MVP]

    Re: Relationship between IIS Sessions and ASP.NET Sessions?

    Ken Cox [Microsoft MVP], Aug 8, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    5,421
    Luther Miller
    Aug 8, 2003
  2. John Tiger
    Replies:
    10
    Views:
    5,666
  3. ai@work
    Replies:
    9
    Views:
    569
    Ron Natalie
    Dec 16, 2004
  4. S. Nurbe

    iostream + iostream.h

    S. Nurbe, Jan 14, 2005, in forum: C++
    Replies:
    7
    Views:
    805
    red floyd
    Jan 15, 2005
  5. red floyd
    Replies:
    3
    Views:
    557
    Dietmar Kuehl
    Mar 8, 2005
Loading...

Share This Page