Theoretically, is it possible to write programs without using variables? What will the most complex program look like? Does the answer vary depending on the language?
Would you be able to use functions? Control flow?
3
A language doesn’t need variables to be Turing-complete; therefore, every program that can be written at all, can also be written without variables.
Some notable languages which don’t have variables, yet are Turing-complete, are:
- Universal Turing Machines
- SK(I) Combinator Calculus
- brainfuck
- Unlambda
- Forth
- Iota, Jot, Zot
Also related is the concept of Tacit Programming and writing code in point-free style.
In general, by thinking about how data flows through a system and is transformed and reduced in the process instead of mutating state, you can get rid of variables, and express computation as a series of combinations of functions. Think of a Unix shell pipeline, for example.
But the really obvious example is: your computer. It doesn’t have variables, yet it executes all your programs.
9