开发者

C / C++ equivalents to the Python Standard Library

I depend heavily on Python's standard library, both for useful data structures and manipulators (e.g., collections and itertools) and for utilities (e.g., optparse, json, and logging), to skip the boilerplate and just Get Things Done. Looking through documentation on the C++ standard library, it seems entirely about data structures, with little in the way of the "batteries included" in Python's standard library.

The Boost library is the only open-source C++ library collection I know of that resembles the Python standard library, however while it does have utility libraries such as Regular Expression support, most of it is also dedicated to data structures. I'm just really surprised that even something as simple as assured parsing and writing a CSV file, made delightfully simple with the Python csv module, looks to require rolling-your-own in C++ (even if you leverage some parsing library by Boost).

Are there other open-source libraries out there for C++ that provide "batteries"? If not, what do you do as a C++ programmer: hunt for individual utility libraries (and 开发者_如何学Pythonif so, how), or just roll your own (which seems annoying and wasteful)?


The Poco library is more like other languages' standard libraries.

Actually the Poco web site's logo says "C++ now comes with batteries included!", which seems to be precisely what you're asking for.

I didn't like it when I tried because I found it too C-like and with too many dependencies between parts (difficult to single out just the functionality you want).

But there are many people & firms using it, so it seems I'm in minority and you will perhaps find it very useful.

In addition, as others have mentioned, for data structures, parsers, and indeed an interface to Python!, and such stuff, check out Boost.

Cheers & hth.,


While C++ does offer many of the comforts extended by OO it keeps a very simple standard library. C++ has STL and Boost. These are very good, and have more then just datastructures.

If your needs are these sorts of higher order functions for prototyping or making application without intense (relative term) speed requirements then C/C++ is probably not the right choice for you. I believe you will find that for most projects that high level languages will be fast enough for your needs. If you are working on an application that requires C/C++ speed (and accompanying standard deviations) then you should probably invest your time carefully picking each individual library you will be using.


http://beta.boost.org/community/sandbox.html

http://www.boostpro.com/vault/

also you can google for "boost+bar", eg

  • boost log -> http://boost-log.sourceforge.net/libs/log/doc/html/index.html
  • boost threadpool -> http://threadpool.sourceforge.net/


http://www.boost.org/doc/libs/1_45_0/?view=categorized

Boost isn't just about data structures - it has lots of the batteries you want - parsing, threads, collections, logging, etc.


With C and C++ you typically won't find a "do it all" library, instead you'll use individual libraries that do different things. You can use one library that does JSON parsing, one that does crypto, one that does logging, etc.

Boost and Qt are the only ones that would be more of a "do it all" type library.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜