WXF is a fully documented binary encoding for Wolfram Language expressions. WRI has already published a Python encoder/decoder for this format. ExternalEvaluate
also uses it.
Has anyone developed a WXF encoder for C++?
Unlike in Python, in C++ there's no standard set of data structures to use to represent a WL expression. Therefore I expect that eventually there will be several C++ WXF libraries, backed by different data structures and intended for different uses.
The specific use case I have in mind here is returning complex results from LibraryFunctions that cannot be simply represented as an MTensor. The typical solution for this is using MathLink. I suspect that encoding those results to WXF, transferring them as a ByteArray, then decoding with BinaryDeserialize
will be faster, in some cases much faster, than using MathLink. This suspicion is based on noticing that sometimes, even encoding to JSON and transferring as a string can be faster than using MathLink.