logoalt Hacker News

jedbrooke • today at 5:19 PM • 2 replies • view on HN

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


Replies

__MatrixMan__ • today at 6:04 PM

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.

PinkSheep • today at 5:50 PM

...unless you marry it to a CoW fs that can let it travel back in time :)