Why does TeX have limited capacity?

With today's computers having several gigabytes of memory, why does TeX still have such limited capacity, and why are modern TeX installations not adjusted for higher capacity by default? Why is adjusting TeX capacity only recommended as a last resort?

-
I have not managed to let LuaLaTeX run out of memory. So I do not think your premise holds for modern TeX installations. –  Alexander Jul 18 '13 at 16:34
@DragonLord the input stack is not fixed it is setable in texmf.cnf (stack_size = 5000 by default in texlive 2013) To be honest I have never hit that in a document that was not looping so would hit any limit. –  David Carlisle Jul 18 '13 at 16:41
most instances of running out of space, in practice, are due to code loops. except for a very few elements (e.g. math families) that have (historical) structural reasons for being limited, higher capacity can be defined. but if memory failure is caused by a loop, this only results in longer delays and significant frustration. if you know that you will be reading files with significantly long input lines, or reading several thousand files to compile a particular collection, then it makes sense to increase those sizes. but do it cautiously. –  barbara beeton Jul 18 '13 at 16:45
TeX was developed when dynamically allocated memory was out of the question for many (all?) operating systems. Changing this model would require extensive surgery on the most delicate parts of the program. LuaTeX has basically been rewritten from scratch, so it can take advantage of more modern C libraries. –  egreg Jul 18 '13 at 17:15
–  Yiannis Lazarides Jul 18 '13 at 19:40

The answers to http://tex.stackexchange.com/a/27482/963 show that TeX is able to cope with huge documents. However, memory intensive packages such as `pgfplots` can cause TeX to run out of memory; here by TeX WEB based implementations, that is, Knuth TeX, pdfTeX and XeTeX, are meant. LuaTeX is different on this respect, because it indeed allocates memory dynamically. However, also LuaTeX sets limits for registers (65536 of each kind) and math families (256).