I've done this for years, even working on homework in my college cafeteria or other public space. It's actually an interesting social phenomenon: if I'm sitting at a table surrounded by textbooks, notes, and my laptop, people have absolutely no problem coming up and starting a conversation; if I'm sitting at an empty table with nothing but a plate of food in front of me, but with headphones in, not a soul will disturb me.
I've done this for years and it's kind of shocking how many people feel free to ignore the "hey, trying to work here" signal sent by headphones.
But I also have to admit that I've typically worked at companies where I was part of a smaller technology team in a larger company. As opposed to working at tech-oriented companies where the majority of my coworkers were fellow engineers who would (theoretically) be a little more understanding.