Do you use C++'s libraries?

  • (2 Pages)
  • +
  • 1
  • 2

29 Replies - 4053 Views - Last Post: 16 January 2012 - 11:42 AM

Poll: Do you use C++'s libaries (45 member(s) have cast votes)

Please Select C++ libraries you use regularly

  1. iostreams (43 votes [14.53%] - View)

    Percentage of vote: 14.53%

  2. string (45 votes [15.20%] - View)

    Percentage of vote: 15.20%

  3. sstream (25 votes [8.45%] - View)

    Percentage of vote: 8.45%

  4. algorithm (18 votes [6.08%] - View)

    Percentage of vote: 6.08%

  5. iterators (14 votes [4.73%] - View)

    Percentage of vote: 4.73%

  6. functional (11 votes [3.72%] - View)

    Percentage of vote: 3.72%

  7. numeric (6 votes [2.03%] - View)

    Percentage of vote: 2.03%

  8. stdexcept (8 votes [2.70%] - View)

    Percentage of vote: 2.70%

  9. exception (10 votes [3.38%] - View)

    Percentage of vote: 3.38%

  10. memory (12 votes [4.05%] - View)

    Percentage of vote: 4.05%

  11. vector (33 votes [11.15%] - View)

    Percentage of vote: 11.15%

  12. map (21 votes [7.09%] - View)

    Percentage of vote: 7.09%

  13. set (12 votes [4.05%] - View)

    Percentage of vote: 4.05%

  14. deque (9 votes [3.04%] - View)

    Percentage of vote: 3.04%

  15. bitset (7 votes [2.36%] - View)

    Percentage of vote: 2.36%

  16. list (10 votes [3.38%] - View)

    Percentage of vote: 3.38%

  17. stack (12 votes [4.05%] - View)

    Percentage of vote: 4.05%

Which do you use more often?

  1. C libraries (5 votes [11.11%] - View)

    Percentage of vote: 11.11%

  2. C++ libraries (36 votes [80.00%] - View)

    Percentage of vote: 80.00%

  3. Third party frameworks (4 votes [8.89%] - View)

    Percentage of vote: 8.89%

Would you rather:

  1. Use a library function already available (28 votes [62.22%] - View)

    Percentage of vote: 62.22%

  2. Write the code myself (17 votes [37.78%] - View)

    Percentage of vote: 37.78%

Vote Guests cannot vote

#1 NickDMax  Icon User is offline

  • Can grep dead trees!
  • member icon

Reputation: 2247
  • View blog
  • Posts: 9,237
  • Joined: 18-February 07

Do you use C++'s libraries?

Posted 30 August 2011 - 01:33 PM

I suspect that most C++ programmers do not actually use the standard library very often. Opting instead to use the C function and write their own implementations.

Indeed I can't honestly say that I embrace the standard library as I am time and time again amazed to find out how many time I have "reinvented the wheel" on something that was right there in the library. I hardly ever think in terms of the standard library. I can probably write out a list of 80-90% of the functions available in the C standard library (at least the function names if not the exact usage syntax) but I don't think I can even get 10% of the C++ standard libraries... I am constantly referring back to std::vector and std::string's documentation and "discovering" new methods that I had never really noticed (or at least they had not stuck with me).

Is This A Good Question/Topic? 3
  • +

Replies To: Do you use C++'s libraries?

#2 jimblumberg  Icon User is offline

  • member icon


Reputation: 3846
  • View blog
  • Posts: 11,771
  • Joined: 25-December 09

Re: Do you use C++'s libraries?

Posted 30 August 2011 - 02:07 PM

I also find myself researching the function prior to using them, however I usually have look up both C and C++ functions. I found several of the C++ fairly complicated but once I learned them I wondered how I could ever have been able to write a program without them.


Jim
Was This Post Helpful? 0
  • +
  • -

#3 Aphex19  Icon User is offline

  • Born again Pastafarian.
  • member icon

Reputation: 614
  • View blog
  • Posts: 1,873
  • Joined: 02-August 09

Re: Do you use C++'s libraries?

Posted 30 August 2011 - 02:13 PM

I do use C++ standard libraries, but only when I am not too concerned with any overhead which may be caused (all be it trivial more often than not). For example, STL vectors are often very useful, but when overused they can and will slow down an application, sometimes unnecessarily. Don't get me wrong though, I agree that the C++ standard library is probably more useful than I even know and is likely highly optimised, but I am careful when using any library in speed critical applications, which most of my applications are.
Was This Post Helpful? 0
  • +
  • -

#4 NickDMax  Icon User is offline

  • Can grep dead trees!
  • member icon

Reputation: 2247
  • View blog
  • Posts: 9,237
  • Joined: 18-February 07

Re: Do you use C++'s libraries?

Posted 30 August 2011 - 03:01 PM

I think a lot of people don't realize that the algorithms and numeric library can be used with non-standard-library objects. I hope that the addition of lambas will actually encourage the use of some of the standard library more (since you don't have to write irritating functors for predicates etc.)
Was This Post Helpful? 0
  • +
  • -

#5 RetardedGenius  Icon User is offline

  • >>──(Knee)──►
  • member icon

Reputation: 125
  • View blog
  • Posts: 555
  • Joined: 30-October 10

Re: Do you use C++'s libraries?

Posted 30 August 2011 - 03:20 PM

I'm quite embarrassed to admit that I've yet to use a third party library for my C++, I wouldn't even know how to install it to be honest. I should really look into Boost! :)
Was This Post Helpful? 0
  • +
  • -

#6 NickDMax  Icon User is offline

  • Can grep dead trees!
  • member icon

Reputation: 2247
  • View blog
  • Posts: 9,237
  • Joined: 18-February 07

Re: Do you use C++'s libraries?

Posted 30 August 2011 - 03:59 PM

RetardedGenius a good guide to get started with is Boost book. The printed version even seems to cover the newest version 1.47 which I am very excited about.

The build is a bit time consuming but surprisingly easy. I had to do it a couple of times to get the settings right but many of the libraries are "header only" so you don't have to build anything to use them, just add the boost directory to your includes.
Was This Post Helpful? 4
  • +
  • -

#7 ishkabible  Icon User is offline

  • spelling expret
  • member icon





Reputation: 1618
  • View blog
  • Posts: 5,707
  • Joined: 03-August 09

Re: Do you use C++'s libraries?

Posted 30 August 2011 - 04:06 PM

i can't belie people don't use deques. did you know there faster than vectors at pushing and popping? that is something i do A LOT and often do it from both ends. deques are VERY nice.

as for numeric, i have never even touched it :/ ill have to check it out.
Was This Post Helpful? 0
  • +
  • -

#8 BetaWar  Icon User is offline

  • #include "soul.h"
  • member icon

Reputation: 1106
  • View blog
  • Posts: 6,922
  • Joined: 07-September 06

Re: Do you use C++'s libraries?

Posted 30 August 2011 - 05:52 PM

I generally prefer to write my own code, but there are times when it is just easier and faster to use something that exists already.

The major problem that I have with the STD library is that most of its memory is dynamically allocated, and most of my projects don't want everything to be dynamically allocated (for instance I may be saving some objects to a file as binary - really fast to load back to the original objects, but if they dynamic memory is outside a specific range it is lost upon program close). That just isn't acceptable... at least not to me.
Was This Post Helpful? 1
  • +
  • -

#9 NickDMax  Icon User is offline

  • Can grep dead trees!
  • member icon

Reputation: 2247
  • View blog
  • Posts: 9,237
  • Joined: 18-February 07

Re: Do you use C++'s libraries?

Posted 30 August 2011 - 08:35 PM

View PostBetaWar, on 30 August 2011 - 08:52 PM, said:

(for instance I may be saving some objects to a file as binary - really fast to load back to the original objects, but if they dynamic memory is outside a specific range it is lost upon program close). That just isn't acceptable... at least not to me.


These seem like a design concern and have nothing specifically to do with the standard library itself. There is no reason why dynamic objects can't persist upon program closing any more than local objects. You just make them do it -- just like you had to make the local ones.
Was This Post Helpful? 0
  • +
  • -

#10 baavgai  Icon User is offline

  • Dreaming Coder
  • member icon

Reputation: 5643
  • View blog
  • Posts: 12,359
  • Joined: 16-October 07

Re: Do you use C++'s libraries?

Posted 31 August 2011 - 04:37 AM

When doing anything with STL collections or object in general, my first thought is, "there's probably a canned function to do this." I then search about and usually find it.

At the same time, there are some C++ism's I find myself reluctant to embrace. The whole static_cast syntax of doom makes me cringe every time I see it and I admit I rarely use it unless I have to.
Was This Post Helpful? 0
  • +
  • -

#11 Serapth  Icon User is offline

  • D.I.C Head

Reputation: 53
  • View blog
  • Posts: 153
  • Joined: 17-August 11

Re: Do you use C++'s libraries?

Posted 31 August 2011 - 10:19 AM

I have always found C++ streams off putting. I only just recently started doing a bit of C++ coding after after a half dozen years or so of using C# and Java extensively and now that I am back I find myself still not liking the stream libraries.

I just find them horrifically unintuitive and cludgey. Compared to the world of C#, they are almost the definition of pain.

Now the good part, the standard libraries and BOOST have come a long ways since I last worked in C++, BOOST especially, so I find myself having to roll a lot less custom code, which is a good thing.

This post has been edited by Serapth: 31 August 2011 - 10:19 AM

Was This Post Helpful? 0
  • +
  • -

#12 NickDMax  Icon User is offline

  • Can grep dead trees!
  • member icon

Reputation: 2247
  • View blog
  • Posts: 9,237
  • Joined: 18-February 07

Re: Do you use C++'s libraries?

Posted 31 August 2011 - 11:38 AM

As a polyglot programmer I understand the irritation that can come from not being able to do what is most natural to you. But I have never really understood why people find streams such a pain. I love the operator approach and I love that it is simple to write a custom operator<< or operator>> and custom manipulators. I really don't quite get what is so uncomfortable about the operator model.

I would rather send arguments via an operator then function call. Probably with the same level of aggravation you feel for streams I hate writing System.out.println() and Console.WriteLine()...

C++11's variadic templates of course will allow for typesafe calls to printf like functions. But... I am a little curious about how that will work with relation to code size. Am I creating custom blocks of code for every different format I choose?
Was This Post Helpful? 0
  • +
  • -

#13 Serapth  Icon User is offline

  • D.I.C Head

Reputation: 53
  • View blog
  • Posts: 153
  • Joined: 17-August 11

Re: Do you use C++'s libraries?

Posted 31 August 2011 - 11:56 AM

I think part of it is definitely C++'s overuse of the > and < characters. And yeah, I prefer methods to overloaded operators, so we definitely have a varience in opinion there.

I also came to C++ from C initially, and at least at first streams were substantially more confusing than standard C io functions. Worse, there was no direct parallel to the *printf() formating functions, at least not initially. So streams were not only more confusing, they were less functional. Since then, things have improved and yeah, those printf/scanf formating functions had some serious downsides, but once you set an initial impression it is hard to shake it.

This post has been edited by Serapth: 31 August 2011 - 11:58 AM

Was This Post Helpful? 0
  • +
  • -

#14 NickDMax  Icon User is offline

  • Can grep dead trees!
  • member icon

Reputation: 2247
  • View blog
  • Posts: 9,237
  • Joined: 18-February 07

Re: Do you use C++'s libraries?

Posted 31 August 2011 - 12:21 PM

Yes C++ is deeply pledged by its C-roots. Many programmers don't even really take the time to "learn C++" rather they "pick it up" from C and Java/C# knowledge and run. i.e. they know C and they know OOP concepts and they mash this in to C-with-classes. (this is how I learned C++ btw).

Meanwhile the richness of the underlying language and its library go largely unnoticed as we quickly turn to third party object libraries to get anything done (i.e. graphics) many of which are actually C based anyway (i.e. OpenGL, SDL etc.)

Meanwhile understanding that should have come from learning the core language becomes the preview of gurus when in principal these things should have been understood long ago.

for example as I write this only 1 user has checked the <memory> header. This header contains smart pointers which are dead useful and really should be used far more than they are. In C++11 and moving forward with parallel programming this library is even more important. Yet at the moment is not getting much love in the wild (or at least here on DIC).
Was This Post Helpful? 0
  • +
  • -

#15 Serapth  Icon User is offline

  • D.I.C Head

Reputation: 53
  • View blog
  • Posts: 153
  • Joined: 17-August 11

Re: Do you use C++'s libraries?

Posted 31 August 2011 - 12:40 PM

View PostNickDMax, on 31 August 2011 - 12:21 PM, said:

Yes C++ is deeply pledged by its C-roots. Many programmers don't even really take the time to "learn C++" rather they "pick it up" from C and Java/C# knowledge and run. i.e. they know C and they know OOP concepts and they mash this in to C-with-classes. (this is how I learned C++ btw).

Meanwhile the richness of the underlying language and its library go largely unnoticed as we quickly turn to third party object libraries to get anything done (i.e. graphics) many of which are actually C based anyway (i.e. OpenGL, SDL etc.)

Meanwhile understanding that should have come from learning the core language becomes the preview of gurus when in principal these things should have been understood long ago.

for example as I write this only 1 user has checked the <memory> header. This header contains smart pointers which are dead useful and really should be used far more than they are. In C++11 and moving forward with parallel programming this library is even more important. Yet at the moment is not getting much love in the wild (or at least here on DIC).


There are a couple key probems:

First, most books and tutorials are actually pretty terrible. Many of them do in fact teach C++ as a better C, while others, including Stroustrup's are so dry as to be almost impossible to read at times as anything other than a reference. When putting together a resource with recommendations for new developers I had a horrible time coming up with good recommendations for new C++ developers. C++ without fear is the only real stand out title, while Effective C++ is the only real must own C++ book. Given how long the language has been around, that is almost shameful.This is an area Java absolutely trounces C++.

Second, many of those features or abilities are fairly esoteric. Worse, C++ often makes "simple" tasks anything but. For example, I am writing a tutorial in C++ right now and I generally am a C# developer, and the staggering difference in something so simple and common as using a map<> is simply staggering. It's a powerful language, but it imposes a great deal of unnecisarry difficulty on i's users. Difficulty that makes the learning curve even steeper.In some ways assesable libraries like SFML or even OGRE are nice in that they can hide some of the initial complexity from the reader, while at the same time demonstrating good C++ technique. However, the many popular C libraries really are rather harmful, as they reinforce the C++ as a better C mindset.

Finally, the standard libraries and Boost are written by language experts and it shows. Trying to grok the code is probably beyond 80% of c++ coders.
Was This Post Helpful? 2
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2