1. 27
  1.  

  2. 11

    Language bindings for Nix? If I already have Nix, why would I …

    This package targets people who wish Nix had a type system.

    Ah. Gotcha.

    https://github.com/dhall-lang/dhall-nix

    1. 10

      While I’m kind of indifferent to the language itself, those detailed error messages and the --explain command-line flag make me salivate. More programming languages should try to strive for that level of detail where possible.

      1. 6

        Interesting. I’m pondering non-turing-complete languages myself. I believe they are under-estimated and should be used more often for anything that looks like configuration.

        Configurations usually start simple, like we only need “x = y” statements. Oh wait, sections would be nice, so use the ini-format. Oh wait, nesting stuff would be nice, so use JSON/XML/Lisp. Oh wait, we want to reduce duplicated stuff, so use a preprocessor. Oh wait, more abstractions would be nice, so use some scripting language already. Stop, we just skipped one level before scripting languages, the non-turing-complete languages!

        Concerning Dhall, I never met the “Oh wait, we want to annotate types” idea. Is that really desireable for configurations?

        1. 6

          should be used more often for anything that looks like configuration

          And perhaps not just that. It’s worth checking out Turner’s “Total Functional Programming” and The Little Prover if you’re curious and unfamiliar with the space/ideas.

          1. 6

            Yes, configuration languages escalate quickly to full-fledged languages.

            1. 4

              Oh wait, more abstractions would be nice, so use some scripting language already. Stop, we just skipped one level before scripting languages, the non-turing-complete languages!

              Jumping to a scripting language is also jumping from a pure language to an impure one. IMHO this may be a bigger problem than going from total to turing complete. When a scripting language is used for config, it’s very tempting to start reading in other files, checking the hostname, overriding behaviour using env vars, checking for something in a database, etc. and before long you’ve got a whole “configurator” application, complete with its own config; and ‘checking what the configuration says’ for your original application may (a) give different results depending on the phase of the moon, and (b) cause arbitrary side-effects. It also becomes tempting to put functionality in the “config script” which should really live in the actual application.

              With a pure config, the only thing that the code can do is to calculate some part of the result; it can’t even alter other parts of the result, due to immutability.

              I’ve been writing a lot of stuff in the Nix expression language recently, and its purity makes it quite nice. It’s only pure by convention though, since ‘derivation’ values can contain arbitrary code (usually Bash) which can be executed using ‘import’, if one were so inclined.

              1. 1

                There’s also the thing that “oh wait, we want to reduce duplicated stuff” can also be seen as “oh wait, we have our configuration model all wrong”

              2. 4
                1. 4

                  I think you clicked the title instead of “N comments.” Here’s the link:

                  https://lobste.rs/s/csbwwu/dhall_non_turing_complete_configuration

                  1. 3

                    Oops, thanks mate!

                2. 3

                  Either make a library for a programming language or a program that read basic configuration data.

                  But inventing a new configuration language for every program looks like a lot of unnecessary efforts adding a lot of complexity, and adds one more half baked language to learn every time.

                  1. 2

                    It’s what most are doing for some reason. There’s a need or a wish there to fulfill. Might as well give them something more robust to use for it.

                  2. 2

                    Anyone know how this differs from jsonnet? http://jsonnet.org/