C / C++相当于 Python 标准库

发布于 2024-10-08 15:57:13 字数 1099 浏览 0 评论 0原文

我严重依赖 Python 的标准库,无论是有用的数据结构还是操纵器(例如,集合itertools)和实用程序(例如,optparse, json日志记录),跳过样板文件并直接完成任务。浏览 C++ 标准库的文档,它似乎完全是关于数据结构的,几乎没有涉及 Python 标准库中的“电池”。

Boost 库是我所知道的唯一一个类似于 Python 标准库的开源 C++ 库集合,然而,虽然它确实具有正则表达式支持等实用程序库,但其中大部分也专用于数据结构。我真的很惊讶,即使是像保证解析和编写 CSV 文件这样简单的事情,也可以通过 Python csv 模块,看起来需要在 C++ 中自行实现(即使您利用 Boost 的某些解析库)。

是否还有其他提供“电池”的 C++ 开源库?如果没有,作为 C++ 程序员,你会做什么:寻找单独的实用程序库(如果是,如何),或者只是推出自己的实用程序库(这看起来很烦人和浪费)?

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 if so, how), or just roll your own (which seems annoying and wasteful)?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

肩上的翅膀 2024-10-15 15:57:13

Poco 库 更像其他语言的标准库。

实际上,Poco 网站的徽标上写着“C++ 现在附带电池!”,这似乎正是您所要求的。

当我尝试时我不喜欢它,因为我发现它太像 C,并且各部分之间有太多依赖关系(很难选出您想要的功能)。

但有很多人&公司使用它,所以看来我是少数,你也许会发现它非常有用。

此外,正如其他人提到的,对于数据结构、解析器,甚至是 Python 接口!以及此类内容,请查看

干杯&呵呵,

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

别把无礼当个性 2024-10-15 15:57:13

虽然 C++ 确实提供了 OO 扩展的许多优点,但它保留了一个非常简单的标准库。 C++有STL和Boost。这些都非常好,并且不仅仅是数据结构。

如果您需要的是用于原型设计或制作应用程序的此类高阶函数,而没有强烈的(相对术语)速度要求,那么 C/C++ 可能不是您的正确选择。我相信您会发现对于大多数项目来说,高级语言的速度足以满足您的需求。如果您正在开发需要 C/C++ 速度(以及伴随的标准偏差)的应用程序,那么您可能应该投入时间仔细挑选您将使用的每个单独的库。

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.

最后的乘客 2024-10-15 15:57:13

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

Boost 不仅仅是关于数据结构 - 它有很多你想要的电池 - 解析、线程、集合、日志记录等。

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.

瞄了个咪的 2024-10-15 15:57:13

对于 C 和 C++,您通常不会找到“全能”库,而是使用执行不同操作的单独库。您可以使用一个进行 JSON 解析的库、一个进行加密的库、一个进行日志记录的库等。Boost

和 Qt 是唯一更像“全能”类型库的库。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文