4 ms·
Can you elaborate on what you're getting at? Syntax-wise it's about as similar to JSON as Erlang expressions are (i.e. superficially similar in some cases). S
by aidanhs 2y ago
Can you elaborate on what you're getting at?
Syntax-wise it's about as similar to JSON as Erlang expressions are (i.e. superficially similar in some cases).
Semantics-wise I've personally found any superficial similarity to JSON to be actively unhelpful in understanding because of some important processing differences (e.g. paths, laziness).
- maxcoder4 2y agoAgreed. I've tried to write a json-nix converter (because I wanted to try configuring my system in jsonnet) and it's absolutely not easy, or obvious how to do this.
- waldrews 2y agoThe FunctionalScript language is supposed to be a superset of JSON and a subset of Javascript that's pure and functional. Not sure that's suited to the use case Nix is going for, but that sounds like what we'd get if we took the extended-JSON path.
- otabdeveloper4 2y agoJSON is not a language, it's a data representation. Nix data is equivalent to JSON, except Nix also has a "path" datatype.
- aidanhs 2y agoFirst a minor quibble: if you're talking about 'Nix data', then starting the conversation by talking about 'Nix-the-language' is rather misleading. That aside, Nix allows you to create infinite datastructures, e.g. $ nix eval --expr 'rec { z = { a = z; i = 5; }; }.z.a.a.a.i' 5 which you can't do with JSON. But even if JSON did have some way of handling datastructure 'loops', it's still not helpful because of laziness. You almost never want to eagerly evaluate a Nix expression to produce what you seem to term 'Nix data', because you'll invoke the `derivation` built in function to create paths you never actually reference - this is why laziness is such an important property of Nix. So I'm still not clear what user-facing part of Nix is isomorphic to JSON. If it's just "Nix types [0] are similar to JSON types" then...sure. [0] https://nixos.org/manual/nix/stable/language/values https://nixos.org/manual/nix/stable/language/values