Frequently Asked Questions

Table of Contents

1. How Piq compares to JSON?

The Piq language is optimized for human interaction, whereas JSON is a standard, portable and reasonably efficient way of representing structured data.

Unlike JSON, Piq has comments and verbatim text literals. Also, there’s no comma-separators and quotes around field names. These and some other features make Piq a better choice for viewing structured data or editing it in a text editor.

Piq is a strongly typed language and JSON is dynamically typed.

Piq can’t be used without Piqi data definitions. With data definitions, though, it is much more powerful than JSON. For example, in Piq, default field values and even field names can be omitted.

And it is possible to embed untyped JSON in Piq!

Piq has a more powerful data model.

In addition to all data types supported by JSON, Piq/Piqi supports binaries, enums and variants (i.e. tagged unions). There are some other goodies, such as support for floating point NaN, negative and positive infinities.

Piq is evolving, whereas JSON is set in stone.

For example, Piq will eventually get support for semi-structured data.

Note that despite all the differences, data represented in Piq can be reliably converted to and from JSON, XML and Protocol Buffers binary formats. This way one can use Piq for manual data editing and convert it to other formats for other purposes.

Piq documentation

Piq, Piqi and JSON examples

2. How Piqi compares to Protocol Buffers?

As a data serialization system, Piqi is very similar and compatible with Protocol Buffers. In fact, Piqi was largely inspired by it. However, there are some fundamental design differences.

Piqi is designed around a more powerful data model.

In addition to record and enum user-defined types supported by Protocol Buffer, Piqi has lists, type aliases and variants (aka tagged unions).

Rich type support really makes a difference for high-level programming languages such as OCaml and Erlang. For example, without lists and variants, one can’t use utilize full potential of these languages when working with data.

In contrast, Protocol Buffers was designed for object-oriented Java, Python and C++ languages.

Piqi is a high-level data definition language.

Combination of lists, variants, records and aliases can be used to define any complex data structure in a very expressive way. Protocol Buffers data definition language is too low-level in this respect.

Some Protocol Buffers DDL’s features, like nested definitions, can negatively affect expressiveness of data definitions. Piqi avoids such features.

Piqi documentation

Piqi-to-Protobuf mapping

Piqi and Proto examples