473,725 Members | 1,942 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

STL design "good" wrt producing code bloat?

How much bloat does the STL produce? Is it a good design
wrt code bloat? Do implementations vary much?

Tony
Dec 7 '06 #1
48 2633
"Tony" <rd************ **@sbcglobal.ne twrote in message
news:pn******** *******@newssvr 21.news.prodigy .net...
How much bloat does the STL produce?
None. Some. Much. It depends upon your
notion of 'bloat' and the particular implementation.
Is it a good design
wrt code bloat?
Imo its design is good (using my own notion
of 'good'). See above about 'bloat'.
Do implementations vary much?
Yes.

-Mike
Dec 8 '06 #2

Tony wrote:
How much bloat does the STL produce? Is it a good design
wrt code bloat? Do implementations vary much?
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.

Dec 8 '06 #3

"Noah Roberts" <ro**********@g mail.comwrote in message
news:11******** *************@7 3g2000cwn.googl egroups.com...
>
Tony wrote:
>How much bloat does the STL produce? Is it a good design
wrt code bloat? Do implementations vary much?

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.
Its readability sucks rocks though. Where would one go to read about
STL memory management design/architecture if anywhere?
As far as design goes...the STL is a work of art.
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.

Tony
Dec 8 '06 #4

Tony skrev:
"Noah Roberts" <ro**********@g mail.comwrote in message
news:11******** *************@7 3g2000cwn.googl egroups.com...

Tony wrote:
How much bloat does the STL produce? Is it a good design
wrt code bloat? Do implementations vary much?
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.

Its readability sucks rocks though. Where would one go to read about
STL memory management design/architecture if anywhere?
What do you mean when you say readability sucks? If you read the
standard C++ code from e.g. Dinkumware I agree that the code is not
that easy to read, but you should bear in mind that the code has been
written to be ported to different compilers in several configurations.
Also e.g. variable names look weird, but remember that the code must be
able to work in "hostile" environments where the programmers might e.g.
have definitions such as
#define i 42
.... none of the template code you or I write could handle stuff like
this (nor are we supposed to).

If you think readability of code using the standard library, i believe
that the code in general is quite readable.

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.

/Peter
[snip]

Dec 8 '06 #5
peter koch wrote:
>
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?

--

-- Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com)
Author of "The Standard C++ Library Extensions: a Tutorial and
Reference." (www.petebecker.com/tr1book)
Dec 8 '06 #6

Pete Becker skrev:
peter koch wrote:

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?
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.

/Peter

Dec 8 '06 #7
Tony wrote:
Perhaps if you don't try to read it or or try to understand it from the
implementation!
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.
And when you're familiar enough, a reference should do to learn everything.

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.
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.

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.
Dec 8 '06 #8
On Fri, 08 Dec 2006 16:19:40 +0100, Mathias Gaunard wrote:
>You're not supposed to read the implementation.
What's important is the interface and the behaviour.
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.

Best regards,
Roland Pibinger
Dec 8 '06 #9

Roland Pibinger wrote:
On Fri, 08 Dec 2006 16:19:40 +0100, Mathias Gaunard wrote:
You're not supposed to read the implementation.
What's important is the interface and the behaviour.

Regarding templates there is no difference between interface and
implementation.
You can still write the documentation, which is where clients of your
code should be looking to understand the interface to and behaviour of
your code.
Maybe he just wants to understand the template error
messages which is not an outrageous request, IMO.
If anyone learns how to do that, could you let me know :)

Gavin Deane

Dec 8 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
3509
by: beliavsky | last post by:
Many of my C++ programs have the line using namespace std; but the "Accelerated C++" book of Koenig and Moo has many examples where the library names are included one at a time, for example using std::cin; using std::cout;
1
3130
by: Tyno Gendo | last post by:
Hi everyone I need to move on a step in my PHP... I know what classes are, both in PHP4 and 5 and I'm aware of "patterns" existing, but what I'm looking for are some real world projects eg. Open Source that people consider to use classes and patterns correctly. I lack a senior person to lead me in this so I feel I'm losing out on only using bare PHP class features and not really knowing how to design
0
9401
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9257
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9174
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9111
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6011
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4517
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4782
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3221
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2157
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.