A friend of mine asked me yesterday which are the differences between a hub and a switch. After giving her a quick explanation, I realized that I'd write something better and leave it here for anyone else interested. However, a detailed explanation could need a lot of background theory, so these are just the basic ideas that differentiate these network devices.
First of all: Ethernet's logical topology is a bus: a single cable carries all data in all directions, which reach all equipments connected to it. Just think about a network using 10Base2 or 10Base5 (coaxial cable) and you'll quickly understand this point.
Now suppose you collapse all the bus (the cable that reaches all computers) in a little box and then connect this little box to each computer using another cable. This box is basically a hub, a level 1 device in the OSI model. Note that the physical topology of the network has become a star (all cables go to a central point), but logically, it's still a bus (this last part is important, because Ethernet is always a bus).
More specifically, a hub processes data bit by bit. Whenever a bit arrives through a port, it's automatically replicated to all others. Aside replication, it also regenerates and amplifies the transmitted signal. But keep in mind that it doesn't process any of the data that travels through it (it's a level 1 device).
On the other hand, a switch is more complex. It's quite similar to a hub in its physical functionality, though a switch isolates connections between hosts: frames sent through a port are only replicated to the port that contains the target computer, not all ports. To do this, the switch stores the received frame into memory, gets its target MAC address, finds a match in its MAC-to-port translation table and transmits the frame to that port. Therefore, this is a level 2 device.
Because the switch handles level 2 frames (not raw bits), it can do much more than just replicate data. For example, it can avoid the replication of collisions and errors: the former is always present, but the later is only found in store and forward switches (not cut-through).
However, a good (and very expensive) switch can do much more than this; it can apply security policies to ports, replicate configurations to other switches, manage virtual LANs, etc.