# Basic Internal Architecture

numbers | sequences of binary digits |

strings | sequences of character code bytes or byte pairs |

symbols | pointers to the central table of symbols |

general expressions | sequences of pointers to the head and elements |

Internal representations used by the Wolfram Language.

When you type input into the Wolfram Language, a data structure is created in the memory of your computer to represent the expression you have entered.

In general, different pieces of your expression will be stored at different places in memory. Thus, for example, for a list such as {2,x,y+z} the "backbone" of the list will be stored at one place, while each of the actual elements will be stored at a different place.

The backbone of the list then consists just of three "pointers" that specify the addresses in computer memory at which the actual expressions that form the elements of the list are to be found. These expressions then in turn contain pointers to their subexpressions. The chain of pointers ends when one reaches an object, such as a number or a string, which is stored directly as a pattern of bits in computer memory.

Crucial to the operation of the Wolfram Language is the notion of symbols such as x. Whenever x appears in an expression, the Wolfram Language represents it by a pointer. But the pointer is always to the same place in computer memory—an entry in a central table of all symbols defined in your Wolfram Language session.

This table is a repository of all information about each symbol. It contains a pointer to a string giving the symbol's name, as well as pointers to expressions that give rules for evaluating the symbol.

The basic principle of Wolfram System memory management.

Every piece of memory used by the Wolfram System maintains a count of how many pointers currently point to it. When this count drops to zero, the Wolfram System knows that the piece of memory is no longer being referenced, and immediately makes the piece of memory available for something new.

This strategy essentially ensures that no memory is ever wasted, and that any piece of memory that the Wolfram System uses is actually storing data that you need to access in your Wolfram System session.

■ Create an expression corresponding to the input you have given. |

■ Process the expression using all rules known for the objects in it. |

■ Generate output corresponding to the resulting expression. |

The basic actions of the Wolfram Language.

At the heart of the Wolfram Language is a conceptually simple procedure known as the *evaluator,* which takes every function that appears in an expression and evaluates that function.

When the function is one of the thousand or so that are built into the Wolfram Language, what the evaluator does is to execute directly internal code in the Wolfram Language. This code is set up to perform the operations corresponding to the function, and then to build a new expression representing the result.

The basic feature that makes the Wolfram Language a self‐contained system.

A crucial feature of the built‐in functions in the Wolfram Language is that they support *universal computation*. What this means is that out of these functions you can construct programs that perform absolutely any kinds of operations that are possible for a computer.

As it turns out, small subsets of the Wolfram Language*'*s built‐in functions would be quite sufficient to support universal computation. But having the whole collection of functions makes it in practice easier to construct the programs one needs.

The underlying point, however, is that because the Wolfram Language supports universal computation you never have to modify its built‐in functions: all you have to do to perform a particular task is to combine these functions in an appropriate way.

Universal computation is the basis for all standard computer languages. But many of these languages rely on the idea of *compilation*. If you use C or Fortran, for example, you first write your program, then you compile it to generate machine code that can actually be executed on your computer.

The Wolfram Language does not require you to go through the compilation step: once you have input an expression, the functions in the expression can immediately be executed.

Often the Wolfram Language will preprocess expressions that you enter, arranging things so that subsequent execution will be as efficient as possible. But such preprocessing never affects the results that are generated, and can rarely be seen explicitly.