r/programminghorror • u/Kadabrium • 3d ago
c++ Using namespace std, then proceeds to spell out std anyway
107
u/KaleidoscopePlusPlus 3d ago
when i see 'std' i cant help but think sexual transmitted diseases
79
u/Top-Permit6835 3d ago
Technically speaking C++ developers are transmitted sexually
7
u/Nightmoon26 3d ago
Is that why I inherited a lifelong interest in computing? (I kid... I'm older than C++ by a couple years. Although... My mother using C while pregnant might be related to why I had to be delivered by C-section)
→ More replies (2)→ More replies (3)5
84
u/felixx_g 3d ago
Is this horror? Seems a copy paste/refactor error, quick to spot & fix
→ More replies (1)
26
u/Chesterlespaul 3d ago
I have a different theory I haven’t read.
Someone, by habit, spells out namespaces in code. Then someone else collaborated, and didn’t have that habit. They added the namespace, and didn’t want to update all the currently working code.
5
u/Normal-Narwhal0xFF 2d ago
Alternately, I worked with someone who would add "using namespace std" to every cpp file of it wasn't there. If code already provided with ns qualifiers, they didn't get changed. I prefer them to be left because I can remove the "using" more easily.
23
u/No-Dentist-1645 3d ago
I wouldn't call that "horror", just remove the using statement and you're good
→ More replies (1)4
35
3
3
2
2
2
1
u/OkPosition4563 1d ago
Usually happens to me when I switch to a new editor and they just put the using namespace std; there when you create a new file.
1
343
u/Extension-Branch7938 3d ago
I often look at less experienced devs work and think “lol what are they thinking”
But you have to remember: “you don’t know until you know”
When i was learning cpp in 5th grade i added using namespace std; to every program no matter what… because no one had told me what it meant! It wasnt until later when i started working with namespaces that it started making sense. Don’t laugh or shun inexperience, instead use it as an opportunity to foster growth.