Hi Motiejus,
Thank you! I will try to answer some of your questions inline and I'll
start separate email threads to answer the rest of them.
On Mon, Feb 4, 2013 at 12:02 PM, Motiejus Jakštys <
desir...@gmail.com> wrote:
> On Mon, Feb 04, 2013 at 02:46:19AM -0600, Anton Lavrik wrote:
>>
>> 1. With this release, the Piqi language self-definition [1]
>> became stable. Why is it a big deal? There are several
>> implications.
>>
>> - Any .piqi module (including self-definition itself!) can be
>> automatically and reliably converted to and from any
>> supported portable data formats. It means JSON, XML and
>> Protocol Buffers supported today, but also any other format
>> that Piqi may support in the future.
>>
>> - In practical terms, it means that programs written in any
>> language can consume and manipulate type definitions from
>> .piqi modules. Also, because external representation of
>> Piqi modules is not going to change in a backward
>> incompatible way, applications built around Piqi type
>> definitions won't be forced to change often (if at all).
>>
>> [1]
http://piqi.org/self-definition/#piqi_piqi_source
>
> Please tell me if I understand correctly the consequence: if I make a
> library which understands piqi in <insert language here>, then I can be
> confident that it will be backwards compatible forever?
Yes. At least this is the goal. We are still at version 0.6 but I
really tried to stabilize it as best as I could. In fact, this is
where I spent 90% of effort in this release.
> I still think I don't get the point (my conclusion sounds wrong). Can
> you tell more why it can be useful, maybe with a few examples? Seems
> like a major change/improvement, but I can't understand its importance.
Think language or protocol standards. Like C89 or SQL92 or various
RFCs. One part of standardization is fixing the interface various
parties can rely on.
Another example would be operating system ABIs. I don't believe they
are standardized, but there are well known examples of very stable
ABIs that have been backward compatible for over a decade now.
There is one more example that stands out: JSON. It is a "forever"
spec meaning that the author didn't want it to ever evolve and didn't
put any versioning in place.
Speaking of Piqi, it is likely to evolve over time and build up more
features. It is quite natural, because it is self-defined and,
therefore, easily extensible in a backward compatible way. But I
expect the core spec to remain stable for a long time. This, I guess,
makes Piqi conceptually similar to ABIs and its core spec, hopefully,
to JSON. Depending on how it goes, I may or may not introduce
versioning of the core spec.
What makes Piqi unique is that everybody is free to extend Piqi the
spec and the language in any way he needs without writing a single
line of code and interfering with the core features. I'll show how it
works in practice in the new piqic-erlang.
Keep in mind that Piqi the language is slightly different from Piqi
the portable spec. While the spec is stable and shouldn't change, the
Piqi language that we use in .piqi modules _can_, in fact, change in
backward incompatible ways. But it will never happen overnight. For
example, although there are some syntax changes in this release, the
older syntax is still supported. If you use older syntax with the new
Piqi version, you will notice warnings that prompt you to use the new
syntax. At some later point, I may put together some tooling that will
automatically migrate the specs to the new syntax (this would work
similar to "gofix" tool in the Go language). Overall, this makes the
Piqi language similar to other computer languages that evolve through
versioning.
>> - generalized and improved encodings schemes for top-level
>> JSON and XML values
>
> Please tell more about this or link to the documentation. Does it mean
> that strings now are encoding aware? How is it represented in JSON?
I used "encodings" as a general term that refers to how data is
encoded into (or represented in) various formats. There was no change
in character encodings handling in strings -- it is strictly UTF-8 as
it was before.
There are 2 important backward incompatible changes:
1. Top-level values of primitive types, when serialized to JSON, are
now wrapped in {"value": ...} object instead of {"_": ...}.
2. Top-level values, when serialized to XML, are now wrapped into
<value>...</value> top-level element. In the previous version, the
name of the top-level element was derived from the name of the type,
e.g. <int>1</int> for values of type int.
The old format is still accepted during deserialization, but never
produced during serialization.
Another change related to JSON is that JSON fields like {...
"field_name": []} are omitted from serialized output by default.
Previously, it was the case only for fields like {... "field_name":
null}. The "json-omit-null-fields" setting can explicitly control this
behavior in "piqi convert", Erlang and OCaml serialization.
There were some other minor changes and improvements here and there,
but they shouldn't have any visible effect
> - New experimental .deprecated flag for fields and options
>
> Does the compiler give a warning now? Or at runtime when converting? It
> is definitely useful, but how can we exploit it? Documentation is quite
> scarce on it.
At the moment, this flag is not handled in any way by the
implementation. But it is recognized as a valid property one can
define for fields and options. Later, I'll think of adding an
automatically generated deprecation warning on attempt to use a field
or an option that was marked as .deprecated.
Anton