T
Tony
How much bloat does the STL produce? Is it a good design
wrt code bloat? Do implementations vary much?
Tony
wrt code bloat? Do implementations vary much?
Tony
Tony said:How much bloat does the STL produce?
Is it a good design
wrt code bloat?
Do implementations vary much?
Tony said:How much bloat does the STL produce? Is it a good design
wrt code bloat? Do implementations vary much?
Noah Roberts said:In general STL containers and algorithms are made to introduce little
bloat and overhead. They are usually very well optimized for the
compiler they are built for. They also increase programmer
productivity by a great margin. Unless you see a problem with a
particular use of an STL container or algorithm it is just plain silly
to concern yourself with such. It is very difficult to beat the usual
STL implementation in size, speed, quality, or dependency.
As far as design goes...the STL is a work of art.
Its readability sucks rocks though. Where would one go to read about
STL memory management design/architecture if anywhere?
peter said:Now If you want to learn something about your standard library, I would
recommend that you simply study the code - preferably while debugging
it. You could also try to write your own collection classes.
And don't forget reading the documentation. Why is it that people think
they can use tools without doing this?
Tony said:Perhaps if you don't try to read it or or try to understand it from the
implementation!
I think what makes it that way is the extremism of
type safety. I'm would use a void* or a cast, judiciously placed
in order to considerably make code more readable. But I guess the
standard has to be pure/extreme in that area.
You're not supposed to read the implementation.
What's important is the interface and the behaviour.
Roland said:Regarding templates there is no difference between interface and
implementation.
Maybe he just wants to understand the template error
messages which is not an outrageous request, IMO.
Tony said:Perhaps if you don't try to read it or or try to understand it from the
implementation! I think what makes it that way is the extremism of
type safety. I'm would use a void* or a cast, judiciously placed
in order to considerably make code more readable. But I guess the
standard has to be pure/extreme in that area.
Roland said:Regarding templates there is no difference between interface and
implementation.
Tony said:How much bloat does the STL produce? Is it a good design
wrt code bloat? Do implementations vary much?
Tony
peter koch said:Pete Becker skrev:
Certainly! Actually, I read Tonys question not as a way to get
documentation but rather to learn how to create the code in the first
place. Rereading, I realize I was influenced by the "difficult to read"
statement.
Sure there is. The interface to std::tr1::result_of is quite simple:
template <class FTY> struct result_of
{
typedef /* return type */ type;
}
The implementation is deep magic.
Mathias Gaunard said:You're not supposed to read the implementation.
What's important is the interface and the behaviour.
There are lots of books for learning how to use the C++ standard library
and especially the containers. Get one.
If you were to use void* instead of T you would not only lose on
readability, usage, and safety (the biggest issue actually) but also in
performance.
Genericity through void* is unmaintenable and dangerous.
YMMV.
You must not know much about C++ if you say that collections of void* are
better.
To have implemented, played with, and benchmarked both, I can tell you I
would never want to drop templates.
Roland Pibinger said:Regarding templates there is no difference between interface and
implementation. Maybe he just wants to understand the template error
messages which is not an outrageous request, IMO.
Noah Roberts said:It isn't about how easy it is to read. In most cases that is very
important but with the standard library there are other considerations
because it needs to be quick, small, etc...all the things you seem to
want. Most of the time one would only sacrifice readability when
necissary based on some known need but the std library maintainers must
get the best performance in many conflicting areas for unknown needs.
The beuty of the STL is the design,
The way these tools can be used to do things that the library
designers could not have possibly forseen is amazing.
One great
measure of design is how easy is it to create new behavior out of the
components, or how easy is it to extend objects in the design to do
things they where not designed for. In that regard the STL is
constantly teaching me new things about good design.
Tony said:Sounds like obfuscation.
Been there. Done that. I wanted architecture/design documentation on the
memory management.
Performance is overrated, these days. Readability improves, usage improves
safety need not be compromised. But I don't want to get into the details:
just go find another well-implemented library and look at it.
Kai-Uwe Bux said:Not at all. It's just acknowledging that header and implementation files
are
meant to be digested by the compiler, whereas published documentation is
meant to be digested by client programmers. The maintenance programmer for
the STL code hopefully and probably has access to design documentation
that
is not shipped with the code.
You will have to ask the vendor for that. The STL is defined by the
standard
only in terms of its behavior. All implementation details are unspecified
and up to the implementor.
As far as memory management in general goes, the only thing guaranteed by
the standard is that you can customize the STL containers by providing
your
own allocators.
Nope. I regularly write programs that run for days to search for examples
or
counter examples to certain conjectures. Speed does matter since it
translates directly into the amount of information I can get out of those
computational experiments.
Performance is especially important when it comes to standard libraries. I
don't want the compiler vendor to decide that _my_ programs may just run a
little slower just so that the code looks nicer. The code is none of my
concerns, readability is what I need for _my_ code. As far as I am
concerned, the code in the STL header files could be computer generated
from other highlevel descriptions. If that made it faster, I'd be all for
it. The maintenance of that code is a problem that I cheerfully leave to
other people.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.