News for hackers. Stuff that matters.
Re:Nix – A One Pager by otabdeveloper4 on Sunday April 07, 2024 @04:44AM (#39959337)
Nix-the-language is isomorphic to JSON, which makes a lot more sense than clinging to some outdated 1970's legacy.
Re:Nix – A One Pager by aidanhs on Sunday April 07, 2024 @05:12AM (#39959467)
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).

Re:Nix – A One Pager by waldrews on Sunday April 07, 2024 @05:21AM (#39959534)
The 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.
Re:Nix – A One Pager by maxcoder4 on Sunday April 07, 2024 @05:20AM (#39959523)
Agreed. 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.
Re:Nix – A One Pager by otabdeveloper4 on Tuesday April 09, 2024 @01:08PM (#39981530)
JSON is not a language, it's a data representation. Nix data is equivalent to JSON, except Nix also has a "path" datatype.
Re:Nix – A One Pager by aidanhs on Sunday April 14, 2024 @02:19PM (#40033153)
First 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

Re:Nix – A One Pager by waldrews on Sunday April 07, 2024 @05:02AM (#39959412)
Lisp originated in 1958. We don't need any of that new-fangled 1970's stuff.
Re:Nix – A One Pager by agumonkey on Sunday April 07, 2024 @06:23AM (#39959785)
Late 50's please.