High performance object serialization library supporting sum types

江枫思渺然 提交于 2019-12-05 05:38:26

If by "like Google protocol buffers" you mean ability to generate code for multiple languages then probably such thing doesn't exist. Emulating sum types in languages which don't support them is awkward at best (try to pattern match on boost:variant for example). So it makes sense to leave them out if main target is mainstream languages.

If you are content with using only haskell/ocaml/whatever there is plenty of choices. For haskell there are cereal, binary, safecopy and probably others. There is piqi project for ocaml.

I'm not aware of any practical systems that support sum types other than Piqi (I'm the author). Piqi is compatible with Protocol Buffers and natively supports OCaml and Erlang. Absence of sum types in Protocol buffers was one of the reasons why I created it.

My plan is to expand Piqi to support other languages such as Haskell, Clojure, etc.

Is there need for a "high-performance" format? Many general-purpose formats should be able to simply use existing constructs -- specifically, Maps/hashtables, to support unions (just include entry with key that indicates type of actual value). So maybe you could just use simple convention to use, say, JSON, to transfer such content.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!