Live data from Hacker News

Preserves: An Expressive Data Language

preserves.dev

31–40 of 46 posts

Re: Preserves: An Expressive Data Language

#31
post #25

gotta have some examples on the landing before the fold, otherwise i have no reason to explore

Tutorial link too hard to click? Seriously: these comments inevitably come up for most language related pages, and I don’t see how they don’t fall under the site guidelines of “Please don't post shallow dismissals”.

I made a similar comment. I think they come up because people are genuinely interested in a project and trying to offer the creator a fresh perspective. When creating a project where your the domain expert it's so easy to get stuck in your own head, and then you start explaining the project to a newcomer diving into deep details when they don't understand the starting point.

Until a project has a lot of traction (think docker, react, django not uv or jq) it's very safe to assume that every visitor to your page doesn't understand the background.

Re: Preserves: An Expressive Data Language

#32
post #27
post #20

Earlier quoted context omitted.

I was going to ask the exact same question. The title makes it sound like something I might be interested in, then I visited the page and I have no idea what it does. After some brief reading of docs, I'm trying to write one sentence explanations. Maybe this will be helpful to you What Preserves is a specification and set of libraries in popular languages that lets you reliably exchange data between XML, JSON and EDN…

Thank you! That makes more sense now

I have know idea if the project author would agree with those sentences, I was just proposing them.

Re: Preserves: An Expressive Data Language

#33

Might be an ignorant question but why not just use XML? It seems like XML could do all this, from my limited reading?

XML would require a schema to express the concepts in Preserves, or JSON for that matter.

The reason JSON is lower friction than XML for data representation is that you get basic data representations (numbers, strings, arrays, maps) for free in a natural native syntax that happens to parallel multiple programming languages.

XML, in contrast, is a meta-language that allows schema to express different data representations. You've got to use attributes and elements to represent data and data types. XSD is a common datatype schema, but it's quite verbose, and data serialization looks very different from what it looks like in a programming language representation.

Preserves looks like a superset of JSON. It includes additional data representation concepts through syntax extensions, but the idea is the same.

What I don't see is a standard way to map record types (like "irl" in the tutorial) to a unique identifier like an URI/IRI, or something like a CURIE. That kind of feature would allow Preserves to better describe standardized record types.

Re: Preserves: An Expressive Data Language

#34
post #28

Does Preserves have a page with a comparison to other common serialization languages? As someone familiar with Protobuf, comparing Preserves vs Protobuf text format, here's my quick comparison between the two after reading through the tutorial: - Preserves' Symbol is very close to Protobuf enums. But Symbol can contain characters like dash - There doesn't seem to be an equivalent of Preserves' Record in Protobuf, but…

Protobufs are designed to support schema evolution without explicit versioning. (All fields are optional so they can be added or dropped, provided field numbers aren’t reused.)

It looks like Preserves just uses version numbers in its schemas. On the other hand, you can read the data without a schema, similar to JSON.

Re: Preserves: An Expressive Data Language

#35
post #28

Does Preserves have a page with a comparison to other common serialization languages? As someone familiar with Protobuf, comparing Preserves vs Protobuf text format, here's my quick comparison between the two after reading through the tutorial: - Preserves' Symbol is very close to Protobuf enums. But Symbol can contain characters like dash - There doesn't seem to be an equivalent of Preserves' Record in Protobuf, but…

Protobufs are designed to support schema evolution without explicit versioning. (All fields are optional so they can be added or dropped, provided field numbers aren’t reused.) It looks like Preserves just uses version numbers in its schemas. On the other hand, you can read the data without a schema, similar to JSON.

The version number is the schema language version, not the version of the collection of types described in the file.

The schema language is extensible/evolvable in that pattern matching ignores extra entries in a sequence and extra key/value pairs in a dictionary. So you could have a "version 1" of a schema with

  Person =  .
and a "version 2" with

  Person = @v2 
         / @v1  .
Then, Person.v2 from "version 2" would be parseable by Person from "version 1", and Person from "version 1" would parse using "version 2" as a Person.v1.

The schema language is in production but the design is still a work in progress and I expect more changes before a 1.0 release of the schema language.

(The schema language is completely separate from the preserves data model, by the way -- one could imagine other schema languages being used instead/as well)

Re: Preserves: An Expressive Data Language

#36
post #14

Earlier quoted context omitted.

No, a record is a tagged (sequence of) value(s). If you put a single dictionary-valued "field" in a record, you get a variation with named fields Records have positional "fields" because of the Scheme heritage of the design. -- Re bytestring -- yes there are some concessions to real machines/languages in there that aren't absolutely required. Other examples include booleans and strings, which could have been and and…

Looks like a lot of excellent work! Are there any good examples of nontrivial schemas etc?

Thanks. Yes there are: see sections 15, 16 and 17 of https://synit.org/book/, where Preserves, Preserves Schemas, and the Syndicated Actor Model make a reactive replacement system layer for linux (essentially an alternative to systemd)

Re: Preserves: An Expressive Data Language

#37

Might be an ignorant question but why not just use XML? It seems like XML could do all this, from my limited reading?

XML would make a fine choice. It lacks atomic data types other than text, and compound data types other than sequences, unless you count element attributes, which are in a kind of awkward position because of the historical development of the language. Preserves has a richer suite of primitive data types and decomposes XML's elements into separate notions of map, sequence, and tagged value.

Re: Preserves: An Expressive Data Language

#39
post #22

It seems like it doesn't natively support decimals (needed for financial data) or any sort of date or datetime?

Date and datetime are left to convention: https://preserves.dev/conventions.html#dates-and-times

Decimals I'm on the fence about. Some discussion here: https://gitlab.com/preserves/preserves/-/issues/10

Re: Preserves: An Expressive Data Language

#40
post #8
post #6

> This is a good time to mention that even though from a semantic perspective sets and dictionaries do not carry information about the ordering of their elements. Except they do in Python. It is extremely useful, surprisingly often.

Python remembers order, and exposes it in its iterations, but doesn't use it in its equivalence over dictionaries (== semantics). (ETA: What are you quoting there? I don't think that text appears on the Preserves site) (ETA2: Ah, it's the tutorial. Cool)

Yea. Just pointing out that the order can be significant, so throwing it away isn't generally a good idea.
Post reply on HN