A switch learns which port is connected to which device, and sends the traffic to the desired devices.
A hub is a repeater, sending all traffic to all devices. Each device has to listen to all the extra traffic.
In a smaller network, the difference between the two is negligible. In a big network, with many cascaded hubs, the collisions can become an issue.