I have ADHD. I used to be the same as you. Now that it's treated I can write code in a busy cafe. I too didn't understand how people could be productive in a cafe. But apparently all our minds work differently (that's totally non-sarcastic, I'm always amazed at how hard empathy is)!