← Back to context

Comment by __MatrixMan__

9 hours ago

I dream of applications that expose sufficient metadata about their outputs such that the OS can know if rerunning is necessary without me needing to specify.

Nixos does this for builds, but I've not seen it generalized to arbitrary processes.

this is kind of the idea behind functional programming. A pure function is one whose output depends only on its input, and no other hidden state, so that let’s you just cache a lut of input -> output for anything you’ve computed before. The tricky thing is anything that reads/writes to memory/disk/network etc. is no longer a pure function and can’t be cached easily

  • Seems like your filesystem could keep track of whether the depended-on bits have changed and invalidate a cache if they did.

    And your network stack could handle things like: "hey last time you gave me 59MB with hash, 0xabcdef123455, can I give my caller a cached copy or has that changed?" ...so that while you're iterating on a bash pipeline that pulls data and transforms it, the data only gets pulled once.

    Even attached peripherals like a scanner are in a position to know whether the old thing is still in there or whether a new thing has been loaded such that they only re-scan when there's a new thingy present to scan.

    I love FP but having it at the OS level would be something new.

You can, in many cases, mangle other use cases into the Nix build system, to varying degrees of success, though there are plenty of complexities with that.