Morphine and heroin aren't quite the same thing. Morphine is the basic compound which actually produces an effect in the brain. The issue is that morphine doesn't move from the bloodstream into the brain particularly effectively.But yes been on morphine in hospital though, it was shite, doesn't kill the pain at all, you just stop thinking about it, didn't realise that was the same
It's not something I'd like try put it that way
If you take morphine and stick two acetyl groups on it you get diacetylmorphine (hence 'diamorphine' in medical use), better known as heroin, which crosses the blood-brain barrier much faster so you get a quicker and more intense effect. Once the heroin is inside the brain the acetyl groups are removed and the morphine gets to work on the opioid receptors.
Codeine is the opposite - introducing two methyl groups onto morphine reduces the ability to enter the brain so codeine produces a less intense effect. Hence why you can buy codeine over the counter but not morphine or heroin.
There's a whole range of opiate morphine derivatives (oxycodone etc.) which have a minor chemical tweak to the basic morphine structure. There are also synthetic opioids which are structurally unrelated to morphine but work on the same receptors and so produce similar effects. Tramadol and fentanyl are fairly well known examples.
Edit - turns out memory is playing tricks on me. Codeine only has one methyl group and is first metabolised in the liver to morphine which then crosses the blood-brain barrier.