windows 节俭与协议缓冲区
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4293385/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Thrift vs Protocol buffers
提问by please delete me
I've been using PB for quite a while now, but, Thrift has constantly been at the back of my mind.
我已经使用 PB 有一段时间了,但是,Thrift 一直在我的脑海中。
The primary advantages of thrift, as I see it are:
在我看来,节俭的主要优点是:
- Native collections (i.e, vector, set etc) vs PBs repeated providing functionality similar to, but not quite like (no iterators unless you dig into RepeatedField which the documentation states "shouldn't be required in most cases").
- A decent RPC implementation provided, instead of just hooks to plug your own in.
- More officially supported languages (PB offers "official" support for Java, C++, Python)
- 本机集合(即向量、集合等)与 PB 重复提供类似于但不完全相似的功能(没有迭代器,除非您深入研究 RepeatedField,文档指出“在大多数情况下不需要”)。
- 提供了一个不错的 RPC 实现,而不仅仅是插入您自己的钩子。
- 更多官方支持的语言(PB 为 Java、C++、Python 提供“官方”支持)
The cons of Thrift:
节俭的缺点:
- The RPC implementation means I can't plug in my own (for example) encryption/authentication layer on top.
- Windows support doesn't seem to be great.
- PB definitely seems to have, if not better, more accessible documentation.
- RPC 实现意味着我无法在顶部插入我自己的(例如)加密/身份验证层。
- Windows 支持似乎不是很好。
- PB 似乎确实有(如果不是更好的话)更易于访问的文档。
Neutral:
中性的:
- Unknown size of .lib/.dll on Windows (Thrift).
- Large size of .lib on Windows (PB, but it does offer a -lite which is significantly smaller).
- Speed wise, they both seem to be similar.
- Windows 上 .lib/.dll 的大小未知(Thrift)。
- Windows 上的大尺寸 .lib(PB,但它确实提供了一个明显更小的 -lite)。
- 速度方面,它们似乎很相似。
I'm not quite ready to take the plunge and switch to Thrift yet, can anyone offer me more pros/cons, or reasons to go one way or the other?
我还没有准备好冒险转向 Thrift,有人可以为我提供更多的优点/缺点,或者以一种或另一种方式走的理由吗?
Thanks!
谢谢!
回答by Grzegorz Wierzowiecki
As I've said as "Biggest differences of Thrift vs Protocol Buffers?"topic :
正如我所说的“Thrift 与 Protocol Buffers 的最大区别?” 话题 :
Referring to Thrift vs Protobuf vs JSON comparison:
参考Thrift vs Protobuf vs JSON 比较:
- C++, Python, Java - in-box support in Protobuf and Thrift.
- Protobuf support for other languages (including Lua, Matlab, Ruby, Perl, R, Php, OCaml, Mercury, Erlang, Go, D, Lisp) is available as Third Party Addons(btw. Here is SWI-Prolog support).
- Protobuf has much better documentation and plenty of examples.
- Protobuf objects are smaller
- Protobuf is faster when unsing "optimize_for = SPEED"
- Thrift has integrated RPC implementation, while for Protobuf RPC solutions are separated, but available(like Zeroc ICE).
- Protobuf is released under BSD-style license
- Thrift is released under Apache license
- C++、Python、Java - Protobuf 和 Thrift 中的内置支持。
- Protobuf 对其他语言(包括 Lua、Matlab、Ruby、Perl、R、Php、OCaml、Mercury、Erlang、Go、D、Lisp)的支持可作为第三方插件使用(顺便说一句。这里是 SWI-Prolog 支持)。
- Protobuf 有更好的文档和大量示例。
- Protobuf 对象更小
- 取消“optimize_for = SPEED”时,Protobuf 更快
- Thrift 集成了 RPC 实现,而Protobuf RPC 解决方案是分离的,但可用(如Zeroc ICE)。
- Protobuf 是在 BSD 风格的许可下发布的
- Thrift 是在 Apache 许可下发布的
Additionally, there are plenty of interesting additional tools available for those solutions, which might decide. Here are examples for Protobuf: Protobuf-wireshark, protobufeditor.
此外,还有许多有趣的附加工具可用于这些解决方案,这可能会有所决定。以下是 Protobuf 的示例:Protobuf-wireshark,protobufeditor。
回答by awdz9nld
You might want to analyse your need first:
您可能想先分析您的需求:
Do you need a protocol-agnostic format? For example, do you want to implement a custom protocol or need 100% portability? In such a case use PB.
您需要与协议无关的格式吗?例如,您是要实现自定义协议还是需要 100% 的可移植性?在这种情况下使用 PB。
If you are fine with the default protocol of Thrift, and you needa protocol to begin with, by all means, go with Thrift.
如果您对 Thrift 的默认协议没问题,并且您需要一个协议作为开始,请务必使用 Thrift。
Hope this helps.
希望这可以帮助。
回答by alexras
Our project's main reason to stick with Thrift over protocol buffers was that protocol buffers don't auto-generate a complete RPC server, and existing solutions for PB seemed to all be fairly unstable. Just my $0.02.
我们的项目坚持使用 Thrift over protocol buffers 的主要原因是 protocol buffers 不会自动生成完整的 RPC 服务器,而且现有的 PB 解决方案似乎都相当不稳定。只是我的 0.02 美元。
回答by John Zwinck
You need to specify your use case(s) in detail. Else this is a "Which is better, a car or a truck?" question.
您需要详细指定您的用例。否则,这是“汽车或卡车哪个更好?” 题。