![](/static/253f0d9b/assets/icons/icon-96x96.png)
![](https://programming.dev/pictrs/image/8140dda6-9512-4297-ac17-d303638c90a6.png)
In applied CS, it’s common to talk about pure and impure functions instead of Turing machines.
Pure functions are, broadly speaking, equivalent to Turing machines. A pure function may only depend on its inputs (like a Turing machine) and has no outputs besides the return value (like the end state of a Turing machine’s tape).
Impure functions cover algorithms that aren’t Turing machines. For example, you might have a random number generator rand: ∅ → N
that outputs different natural numbers on every invocation rand()
and is hence impure. Output functions are also impure, e.g., a function write: N → ∅
that writes a number into a file can’t be a Turing machine, because Turing machines have no concept of files.
Computer programs that consist entirely of pure functions aren’t very useful, because they can’t interact with the user or reality. The typical approach to solving this is to put the core program logic inside pure functions that interact with impure parts through a limited interface. That way, you can apply CS concepts to the important parts of the program and neatly separate out the impure parts.
I wonder when Firefox is going to add a configuration menu for keybinds.