Expressions
Expressions are tiny scripts that can be attached to an object attribute or to an event, and that will execute each and every time the value of this attribute is modified or this event occurs. Thus, expressions allow you to specify the behavior of an object while you can still manipulate this or other objects through the Maya interface or through a script.
For example, you can link an attribute to another attribute, such that the value of the first attribute is defined by the value of the second attribute. Unlike connections made through the Connection Editor, the values of both attributes don't need to be exactly the same, but can be related through an expression.
Given two objects named pCube1 and nurbsSphere1, you can relate their respective translateX attributes as follows:
nurbsSphere1.translateX = frame / 10;
frame and time are special keywords in MEL that allow you to retrieve the current frame and time of an animation.
A wave
You may alter more than one attribute in a single expression, though the expression is always linked to a specific object and attribute.
nurbsSphere1.tx = time * 2;
nurbsSphere1.ty = sin(time) * 2;
An irregular wave
The function noise provides a random continuous distribution of values between -1 and 1
nurbsSphere1.tx = time * 2;
nurbsSphere1.ty = noise(time) * 2;
Expression scripts
Since an expression is a tiny script you can use anything you can use in scripts (including variables and control structures). The only difference is that you do not need to use getAttr and setAttr when reading and modifying attributes.