Live data from Hacker News

Cue – A language for defining, generating, and validating data

cuelang.org

131–140 of 167 posts

Re: Cue – A language for defining, generating, and validating data

#131

Earlier quoted context omitted.

What if you're using multiple programming languages?

Then just pick one of them. This may be simpler than introducing another language to the project.

What if you are interfacing between multiple projects? It’s not about introducing another language, it’s about integrating pre-existing systems.

Re: Cue – A language for defining, generating, and validating data

#132
Okay, so I've spent some time trying to understand this, and I think it's actually really cool, but I found the "About" and "Concepts" documents tumid and murky.

Here is my understanding of the basic concepts:

- It allows a schema-like set of constraints to be declared for JSON (and therefore for YAML & TOML) in a syntax that is an extension of JSON.

- Cue deals with types (sets of values) where JSON deals with single values. Ordinary JSON syntax for a primitive value denotes a set containing that one value. For example, `a: 1` means that the set of possible values for `a` is {1}. Cue calls this a concrete definition.

- Cue provides operators for union (`|`) and intersection (`&`) of sets, and inequalities for ranges of numbers, and so on. `1 | 2` denotes `{1, 2}`.

- Built-in names provide the types `int`, `float`, `string`, etc.

- Cue "struct" types look like JSON objects, associating names with sets. Each name/value pair is a constraint, and all constraints must be met. For example, `{a: int}` denotes "the set of objects that have a property `a` with the value in `int`".

- Properties can be referenced by name; this allows a property defined in one place to be used a type (set) definition in multiple places.

- When a name is bound more than once, the sets associated with each binding are intersected. This means that enforcing a schema reduces to simply combining the schema definition with the "concrete" bindings and throwing an error when an empty set is encountered.

BTW, if I do have it all wrong and what I've described above is not an accurate description of Cue, then I think I'll have to go build what I've described.

Some reasons I'm afraid I'm off-base:

- What's with the lengthy discussion of lattices, and related terminology? Sure, we can construct a lattice from the set of possible types and a "subset of" operator, but that's another level of abstraction away from the necessary concepts, so I don't see what value it adds.

- The `|` operator is described as constructing a sum type, when it seems to me it must actually be a (non-discriminated) union. Elsewhere the `|` operator is described as "computing the join", which to me would mean finding an element in a lattice, but for this to make sense to me I have to think of it as adding an element to the lattice (again all the lattice or poset terminology serves only to obfuscate things).

Re: Cue – A language for defining, generating, and validating data

#133
post #88

Earlier quoted context omitted.

I am pretty sure you placed the hate on the wrong target, you probable are hating borgcfg, instead of the GCL/BCL language. Disclaimer: was borgcfg owner 2016-2019.

you are probably right. Felt like the documentation for borgcfg was extremely hard to just find. Maybe I'm wrong about this. This is also not the place to discuss this probably. But GCL made it so whatever variable was actually being used by borgcfg was obscured by layers upon layers of imports.

well, if people testing their BCL, like what they do with c++, things will be better. But you know what, if they do that google officially will be a company built on BCL...

Re: Cue – A language for defining, generating, and validating data

#134
post #41

Earlier quoted context omitted.

A safer yaml: https://hitchdev.com/strictyaml/

I am really curious why people are downvoting this. I've always thought that a more restrictive and simpler version of yaml would be a good alternative.

Guessing there were a couple of cue devs that didn’t appreciate a competitor mentioned.

Re: Cue – A language for defining, generating, and validating data

#135
post #47

A new configuration language. Yes. That's exactly what we need.

We do indeed. XML is awful, YAML is a clusterfuck, JSON is often insufficient, and so is INI. TOML looks promising, but might not make it out of its niche. If Cue is basically a better YAML with built-in schemas, that sounds pretty good.

can you back what you are saying? i personally think we don't. most continuous integration pipelines need static configuration files, not languages. to be honest, i have no idea where this language fits in a software development process...

Re: Cue – A language for defining, generating, and validating data

#136
post #132

Okay, so I've spent some time trying to understand this, and I think it's actually really cool, but I found the "About" and "Concepts" documents tumid and murky. Here is my understanding of the basic concepts: - It allows a schema-like set of constraints to be declared for JSON (and therefore for YAML & TOML) in a syntax that is an extension of JSON. - Cue deals with types (sets of values) where JSON deals with singl…

> What's with the lengthy discussion of lattices, and related terminology?

It's how the author thinks about the values. All the operations move a value up (|) or down (&) the lattice and those operations are associative, commutative, etc. Moving down past the concrete values gets you bottom, the error value, so 1 & 2 is _|_. It fits into things like default values where (using # for * because HN formatting doesn't do escape sequences) a: int | #1 and a: int | #1 unify to 1 because #1 & #1 = #1 but a: int | #2 added would result in a: int because #1 & #2 = _|_ so there is no default anymore.

I don't think the extended discussion on lattices is particularly useful. A much better intro is the tutorial [1] plus the concepts page [2]

[1] https://github.com/cuelang/cue/tree/master/doc/tutorial [2] https://cuelang.org/docs/concepts/logic/

The motivation is clearly to build a tool for configuring kubernetes but I see the combination of data, validation, and order independence as being valuable outside that use. I've definitely had projects where it'd fit. The main reason I'd think twice is because it does add a LOT of concepts for something that can be pretty simple on most projects.

Re: Cue – A language for defining, generating, and validating data

#137
post #89

Earlier quoted context omitted.

Or make me go blacklist this project and everything to do with it (largeCapital pop >5M)

I found this comment: "In V3 the hobby field is explicitly disallowed. This is not backwards compatibly as it breaks previous field that did contain a hobby field" in https://cuelang.org/docs/usecases/datadef/ So if you add a field, you break existing code that doesn't know about the field.

No. That's not what it says.

However, if you had code that expected to receive a `hobby` field in V1, that tries to parse it and you removed it in V3, then yes, obviously, it breaks existing code. That is basic API design

Re: Cue – A language for defining, generating, and validating data

#139
post #89

Earlier quoted context omitted.

Or make me go blacklist this project and everything to do with it (largeCapital pop >5M)

I found this comment: "In V3 the hobby field is explicitly disallowed. This is not backwards compatibly as it breaks previous field that did contain a hobby field" in https://cuelang.org/docs/usecases/datadef/ So if you add a field, you break existing code that doesn't know about the field.

This is wrong. CUE has optional closed schemas marked by a double colon. The V3 entity you’re talking about is explicitly declared to be a closed definition and therefore disallows unknown fields in entities that claim to accord to the V3 type. Not all definitions are closed.

Even for those that you choose to close, it’s a matter of having different code for different definitions. The claim that it just automatically breaks isn’t true even when closed definitions are used.

BTW, this feature speaks to CUE’s intended purpose as a configuration language. It is (or at least can be) nice to ignore unknown fields in transmitted payloads for forwards and backwards compatibility. But if I’m trying to configure some software and misspell a field, I probably want the configuration file to fail validation, not have the software run with an unintended configuration.

Re: Cue – A language for defining, generating, and validating data

#140
post #132

Okay, so I've spent some time trying to understand this, and I think it's actually really cool, but I found the "About" and "Concepts" documents tumid and murky. Here is my understanding of the basic concepts: - It allows a schema-like set of constraints to be declared for JSON (and therefore for YAML & TOML) in a syntax that is an extension of JSON. - Cue deals with types (sets of values) where JSON deals with singl…

tumid and murky

This should have its own word. Murid is too close to 'lurid'. Tumky, perhaps, though it lacks a certain heft and judginess.

Post reply on HN