News for hackers. Stuff that matters.
Re:We want to make Nix better by ghoward on Friday September 02, 2022 @02:51PM (#32694462)
Disclaimer: I'm working on a build system that will eventually do what Nix does but make it much easier to use.

If they do manage to create a system where Nix is hidden, and end users never have to directly touch it, I think this could work and make my work never see the light of day.

But I have my doubts that they will be able to do that, and it boils down to one simple reason: declarative is not powerful enough.

Don't get me wrong, for 90%, possibly more, of use cases, it's enough. And it is preferable to keep things declarative as long as possible, so much so that my build system will have a way of restricting itself to purely declarative code when possible (and will error otherwise).

However, when more power is necessary, it is required; it is not possible, by the definition of Turing-completeness and declarative, to do the same thing with a declarative language that can be done with a Turing-complete language. So when that power is missing, the only option is to work around it.

This is why Nix is really just a front for bash. For all of its faults, at least bash is Turing-complete.

But this fact means that there will be things that Nix will fail to do on its own. I suspect this means that the abstraction around Nix will always be leaky. Maybe it won't be unacceptably leaky, but I'm not very hopeful.

I think Nix would be better served by doing the following:

1. Rewriting the language. This would require an auto-transformer to the new language in order to not throw away the entirety of nixpkgs, but transforming a declarative language to a Turing-complete one is easy.

2. Spend gobs of time on user experience. Make the usual commands short, easy to remember, and easy to use with few options. Make usual things easy and powerful things safe. For example, to make a powerful thing safe, make sure that screwing it up will not screw up their system.

3. But not only should they be safe, they should feel safe, giving users every opportunity to back out without consequences. This is where git goes wrong: it does not feel safe, so users are scared of it. [0] I believe Nix is the same way, even though it is safer than git.

4. Spend gobs of time on documentation. Use Fred Rogers' list of rules for talking with children [1] in each piece of documentation. This will make it easier to avoid the trap of not explaining something the user needs because the writer forgot that they didn't know it. In essence, the documentation should treat new users as Fred Rogers treated children: ignorant, but capable.

5. The documentation also needs to have a different focus. Instead of focusing on how great Nix is, it should focus on helping users get stuff done. Nix enthusiasts should be able to say, "Oh, you want to set up a development environment for your project? Great, go to such-and-such tutorial. It will tell you exactly how to do that even if you don't have Nix installed." This should be done for as many use cases as people have, including less common ones. Some examples: using Nix as a build system, using Nix to install multiple versions of glibc and how to switch between them, using Nix to set up systemd, using Nix to replace a Docker container in production, using Nix to distribute builds, etc.

[0]: https://xkcd.com/1597/

[1]: https://www.mentalfloss.com/article/547536/mr-rogers-rules-f...

Re:We want to make Nix better by ParetoOptimal on Friday September 02, 2022 @02:56PM (#32694512)
> However, when more power is necessary, it is required; it is not possible, by the definition of Turing-completeness and declarative, to do the same thing with a declarative language that can be done with a Turing-complete language. So when that power is missing, the only option is to work around it.

I fall heavily into the use less powerful languages and "liberties constrain, constraints liberate" camps.

I'd be very interested in a real world example of this, though I know that class of examples is hard to come by.

Re:We want to make Nix better by ghoward on Friday September 02, 2022 @03:09PM (#32694649)
> I fall heavily into the use less powerful languages "liberties constrain, constraints liberate" camp.

For what it's worth, so do I. That's why my build system will allow users to set those constraints. It's a great idea.

> I'd be very interested in a real world example of this, though I know that class of examples is hard to come by.

There are many, but I'll say one: anything that requires iteration until a fixed point is reached. A concrete example of this is building documentation in LaTeX.

Or it may even be simpler than that. Maybe your build requires some sort of special code should two arguments have specific values. In other words, edge cases often require Turing-compete power to resolve.

Re:We want to make Nix better by theCodeStig on Friday September 02, 2022 @07:00PM (#32696697)
Ok then, would you consider markup languages declarative, XML... XSLT?
Re:We want to make Nix better by ghoward on Friday September 02, 2022 @11:17PM (#32698310)
Yes. They are declarative.
Re:We want to make Nix better by HowTheStoryEnds on Friday September 02, 2022 @05:13PM (#32695774)
Would you consider lisp to be (possibly) declarative?
Re:We want to make Nix better by theCodeStig on Friday September 02, 2022 @07:02PM (#32696712)
Not all lisps are declarative, but a lisp certainly can be declarative.
Re:We want to make Nix better by ghoward on Friday September 02, 2022 @05:16PM (#32695801)
No, it is Turing-complete.

I was going off of the article and Nix documentation that says Nix is declarative. But if it actually is not, then there shouldn't be a problem with power.

However, Nix proponents shouldn't claim it is declarative either.

Re:We want to make Nix better by theCodeStig on Friday September 02, 2022 @07:03PM (#32696721)
Laziness, and purely functional go a long way toward declarative.
Re:We want to make Nix better by ghoward on Friday September 02, 2022 @11:23PM (#32698341)
Declarative has a few definitions with respect to computer languages, and the Nix community seems to be using one and ignoring others.

When I think of declarative, I think of a language that has less power than a Turing-complete language. Think Make without bash or any shell. Or HTML without CSS.

In other words, the Nix community seems to use "declarative" as meaning "without side effects" where some programmers, like myself, hear "declarative" and think of something like HTML without CSS or JSON.

Re:We want to make Nix better by vdijkbas on Friday September 02, 2022 @04:41PM (#32695488)
> This is why Nix is really just a front for bash. For all of its faults, at least bash is Turing-complete.

Nix is Turing-complete. This was even sometimes considered a problem because it makes the language too powerful:

https://nixos.org/~eelco/talks/guix-feb-2018.pdf

Re:We want to make Nix better by ghoward on Friday September 02, 2022 @05:14PM (#32695789)
This is news to me, I admit. But if this is true, then people shouldn't say Nix is declarative.
Re:We want to make Nix better by grumbel on Saturday September 03, 2022 @05:12AM (#32700109)
This shouldn't really come as a surprise, any reasonably powerful language will end up Turing complete sooner or later, it's pretty difficult to avoid. Nix specifically doesn't even hide it, it has plain old function and recursion as primitives.

What makes it declarative is the lack of side effects and laziness.

Re:We want to make Nix better by ghoward on Saturday September 03, 2022 @08:48AM (#32701359)
What I'm trying to explain is that using the term "declarative" is confusing to a lot of developers who who not think of functional programming as declarative, but rather think of something like JSON.
Re:We want to make Nix better by grumbel on Saturday September 03, 2022 @01:25PM (#32704041)
I don't see it as confusing, it's a pretty accurate description. The Nix language is for most part a JSON-look-alike with a couple of additional features. You don't really program in it, you declare/return a data structure. The only programming you do in Nix is to make it a little easier to build that data structure. It's kind of like the old days when people would parse JSON with eval(), which would also grand you features that plain JSON wouldn't have.

Even NixOS itself doesn't do all that much actual programming in Nix, most of the code that does stuff is written in C++. The Nix language itself doesn't let you escape out of its sandbox.

Re:We want to make Nix better by throwamon on Friday September 02, 2022 @06:44PM (#32696544)
Although it's debatable, it's very common for functional languages to be categorized as declarative.
Re:We want to make Nix better by ghoward on Friday September 02, 2022 @11:41PM (#32698446)
Perhaps, but that categorization is going to confuse a lot of developers. It sure confused me until I said something wrong, and all of you Nix proponents descended on me.

This confusion is not good for Nix.

Re:We want to make Nix better by nonsequitur on Friday September 02, 2022 @04:20PM (#32695314)
Nix is turing complete (it can implement the Lambda Calculus), even conveniently so.
Re:We want to make Nix better by ghoward on Friday September 02, 2022 @05:13PM (#32695777)
Then people shouldn't say it is, such as in the article under discussion.
Re:We want to make Nix better by theCodeStig on Friday September 02, 2022 @07:05PM (#32696738)
What aspect of lambda calculus is not declarative?