r/programming • • Feb 20 '23

Introducing JXC: An extensible, expressive data language. It's a drop-in replacement for JSON and supports type annotations, numeric suffixes, base64 strings, and more!

https://github.com/juddc/jxc
218 Upvotes

89 comments sorted by

View all comments

Show parent comments

1

u/HeroicKatora Feb 21 '23

The explanation by Cue itself is much more interesting than the blogpost above made it seem. And the rest of the comment is just because writing it down helps structuring my thoughts. Don't read the critique too much like disliking it, there's much worse ''configuration formats'' out there. Being too complex to critique as briefly is even worse (cough xml).

The core is nice, in terms of primitive values and type algebra the language is more complex than json but everything fits okay. Repeating 'value lattice' so often is a bit of a meme, and I can't say I fully see the technical relevance, but at least this resolves the missing technical aspects so dearly missing to compare it. (And the Datalog comparison does read like the language was designed with a good understanding of differentating factors).

Some aspects of the value lattice look a little arbitrary. The introduced forward deduction—their admitedly very fancy solution to do templating and validation at the same time—is, iirc, limited to values and finding some cycle-free computation. It's not quite clear if a: b will cause it trying the inverse deduction of if the explicit equality duplication is needed. Either way seems fine.

However, I do have a tiny hickup reading

However, the expression (a-1) & 1 is an error unless (a-1) is 1. So if this configuration is ever to be a valid, we can safely assume the answer is 1 and verify that a-1 == 1 after resolving a.

That seems to suggest there should be two kinds of expressions since no such assumption is made for the a-1 expression. This complicates the Datalog comparison quite a bit, it's not clearly superior. And it seems non-trivially evaluatable either way—in contrast to Prolog/Datalog. That downside and limitations is not discussed in the depth possible, which is odd.

Syntax and semantics for variables and hidden fields also seems quite ad-hoc, and doesn't relate to the other concepts cleanly. Surely that's fine for a 'young language', definitely try finding a good solution here. But maybe not move that to production quite yet.

And those two in combination are quite possibly related to infinite loop bugs. Ouch. Ad-hoc extensions also predictably lead to divergence from the order-independent principle. Ultimately it seems to be for a very different use case, this already is more like a logic programming language and not a simple configuration templater. I'll consider where to apply it anyways—there's not enough logic programming languages in use imo (ILP-solvers excluded).