What is the difference between codeine, heroin, and morphine?

Chemically there is no difference.  All of these drugs are derived from opium or the opium chemical structure and are in the Opiate class of drugs.  The only difference between the three is primarily in the manner in which opium is refined or synthetically manufactured and the form and method of delivery.