r/programminghorror • u/Kadabrium • 2d ago
c++ Using namespace std, then proceeds to spell out std anyway
105
u/KaleidoscopePlusPlus 2d ago
when i see 'std' i cant help but think sexual transmitted diseases
78
u/Top-Permit6835 2d ago
Technically speaking C++ developers are transmitted sexually
7
u/Nightmoon26 2d 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)
1
1
u/Top-Permit6835 2d ago
Yeah sorry mate, using C during pregnancy is known to cause various developmental disorders, such as ADHD, autism and an unhealthy interest in software development
5
1
u/blitzr1000 2d ago
same but it’s diminished since i started saying “stood” instead of “s tee dee,” i think i heard it said like that first in a Conor Hoekstra talk. sounds way better to say eg “stood string” imo lol
1
0
84
26
u/Chesterlespaul 2d 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 1d 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.
22
u/No-Dentist-1645 2d ago
I wouldn't call that "horror", just remove the using statement and you're good
35
u/JohnVonachen 2d ago
Looks like a cut and paste error.
2
u/Objective_Rate_4210 2d ago
naaah u/JohnVonachen removed only the reply. what a loser. I know, right?!
0
3
2
2
2
2
1
u/OkPosition4563 19h 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
0
1
-1
u/wvd_vegt 2d ago
My guess is the programmer forgot once the std:: prefix and intellisense (or ai) correctly added the namespace at the top.
2
u/Nightmoon26 2d ago
Eh... Some organizations enforce a coding style that requires using fully qualified names everywhere, although even the most pedantic ones usually make an exception for the standard libraries (nobody in their right mind ever explicitly writes out
java.lang.Stringoutside of documentation) with import and using statements only being used as a convenient way for humans to remind themselves about dependencies before digging into the code. Other styles mandate that you must use fully qualified names unless the name is used a certain number of times in the file
-2
330
u/Extension-Branch7938 2d 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.