11 ms·
Does anyone know the rationale for creating Nixlang? Guix's use of Scheme proves there isn't a novel feature unavailable elsewhere, so it seems like a lot of wa
by Harkins 8y ago
Does anyone know the rationale for creating Nixlang? Guix's use of Scheme proves there isn't a novel feature unavailable elsewhere, so it seems like a lot of wasted effort to implement a language that will likely only ever be used for one suite of programs. (And tooling; though almost none exists now, making the choice even more expensive.) I've tried to find one, but "nix" is a difficult thing to google for given the couple decades people have used it as a catchall term for unix and unix-like operating systems.
- clhodapp 8y agoI believe the motivation is that it eschews a lot of convenient crutches that would defeat the purpose of using nix (e.g. impurity) and adds a lot of convenient crutches that don't (e.g. a lot of implicit coercion for derivations).
- rekado 8y agoPurity is a property of the functional methodology, not of the language. You don't need to use an effect-free language when operating in an environment that renders most effects void.
- catern 8y agoThe Nix thesis may give some insight: https://nixos.org/~eelco/pubs/phd-thesis.pdf https://nixos.org/~eelco/pubs/phd-thesis.pdf Guix's use of Guile is fundamentally equivalent to the Nix package manager's use of the Nix language, but the approach Guix takes to organizing packages is very different. IMO, the Nix language approach is cleaner and more elegant when it comes to describing packages, but it's not clear whether that's worth the cost of using a domain-specific language. So, it still remains to be seen what's the best approach.
- rekado 8y agoIn Guix there are first class package objects that have references to other first class packages. Together they form a lazily evaluated graph. At a lower level, package objects can be compiled into one or many derivations, which is where things start to look more similar to Nix again. In Nix the idea of "functional package management" is more visible as there are no packages but functions with arguments that would result in a package once evaluated.
- catern 8y agoYep, Guix package objects with references to other package objects, versus Nix functions with arguments, is what I was referring to.
- cwp 8y agoI think one of the keys features is lazy evaluation. Nixpkgs is one giant expression that evaluates to the complete set of packages that it provides. But since only some the attributes of that set are evaluated in any given invocation, it's still efficient. That can be vertical (eg, a package and it's dependencies) or horizontal (eg, the names of all the packages). Guix shows that this isn't the only way to do it, but it is a good way.
- rekado 8y agoGuix packages are also evaluated lazily. Package objects (values of the `<package>` type) can have an arbitrary number of declared inputs, which are package objects as well. These are not evaluated eagerly, of course. Lazy evaluation does not have to be a language feature. In the case of Guix's `<package>` record, only some of the fields are delayed or thunked.
- zimbatm 8y agoThe difference is that the lazy evaluation needs to be baked in. There are many scenarios in the nixpkgs code-base where lazy evaluation is used on a not-package level. For example the NixOS module system depends heavily on it. I haven't used Guix to be able to compare but it saved my life many times. I suspect the advantage for Guix is that it forces things to be better structured.
- mbrock 8y agoI like Scheme, but I think a lot of people actually wouldn’t want to write their packages and OS configuration files as S-expressions. Nix is an extremely simple language with quite familiar syntax, a kind of JSON with functions and string interpolation. Note also that Guix uses Scheme a lot more deeply than Nix uses the Nix language, in the sense that Nix uses e.g. shell scripts where Guix uses Scheme statements. Actual “coding” in the Nix language is relatively rare.
- akavel 8y agoFor me personally, as a person who's tried Nix, it's helpful that the Nix language is simple, self contained and easy to learn & grok quickly. I never learnt Scheme, and its use in Guix, though extremely interesting and appealing in theory, also feels notably overwhelming to me. That I'd have to learn a whole (presumably huge) R7RS or something, just to be able to use Guix. And then still have to learn the Guix "API" or DSL over that to be able to actually use it. While the Nix language is small and fully described in the Nix manual, in surprisingly few words.
- rekado 8y agoDisclaimer: as a Guix co-maintainer I'm totally biased. We don't use R7RS in Guix. You need to know about the Scheme syntax, obviously (including keyword arguments), and a couple of common procedures like `string-append`, but aside from that you don't really need to know much about Scheme at all. What comes in handy is the Guix DSL, which provides a convenient way to specify packages and download origins. Guix also has a bunch of utility procedures that are useful extensions to their Scheme counterparts, such as `mkdir-p` (which does what you think it does) or the `substitute*` form to substitute expressions in a file or list of files. One important difference between Nix and Guix is that Guix does not glue shell snippets together, but eventually compiles to Guile builder scripts, so it's Scheme all the way down.
- mbrock 8y agoDoes Guix let you write interactive programs in Scheme as part of the system configuration? For example, defining a systemd service that uses Guile libraries and so on, as a subexpression of your OS configuration file? While also referring to shared variables like the system's hostname, etc? I skimmed the paper on "Code Staging in Guix" and I think this should be very doable, but I haven't yet tried Guix for real. This ability seems like it would have huge implications for system development... I've dabbled with such experiments using Nix, but the lack of hygienic code staging makes it a bit icky.
- otabdeveloper2 8y agoNobody wants an arbitrary complex program for describing some trivial build steps. A programming language here is an anti-feature. Ideal would be some DSL that isn't even Turing complete, but that's not practical at the moment. Maybe we'll get there some day.
- k_bx 8y agoDhall and Dhall-nix are definitely a step towards that.
- mbrock 8y agoIt's difficult to not be Turing complete. Makefiles are Turing complete: https://nullprogram.com/blog/2016/04/30/ https://nullprogram.com/blog/2016/04/30/
- X6S1x6Okd1st 8y agoReally what no one wants is a build step that takes forever. I'm more upset about how long nix-env -i takes than what the computational complexity of the programming language is
- Nullabillity 8y agonix-env -i is slow because it has to evaluate every package definition. nix-env -iA is way faster.
- joepie91_ 8y agoThe ability to build abstractions is actually one of the key points of what makes Nix work, conceptually. So yes, a 'programming language' (how are you defining that anyway?) is absolutely a feature here.
- solatic 8y agoDo yourself a favor and watch Gabriel Gonzalez's talk "Nix: Under the Hood" ( https://youtu.be/GMQPzv3Sx58 https://youtu.be/GMQPzv3Sx58 ).
- deleted 8y ago[deleted]
- karmakaze 8y agoThis is the first I've heard of Nix. A quick search reminded me that it has nothing to do with Nim, and turned up NixOS that I have heard of. Here's a good description of why I should care: https://yakking.branchable.com/posts/what-and-why-nix/ https://yakking.branchable.com/posts/what-and-why-nix/