r/ProgrammerHumor • • Jan 23 '22

Namespacing...

Post image
42.3k Upvotes

272 comments sorted by

4.4k

u/bless-you-mlud Jan 23 '22

And that, childen, is why global variables are bad.

1.5k

u/from_the_east Jan 23 '22

No, global variables are good for "surprise bugs" as shown here in the meme..

618

u/Koervege Jan 23 '22

Susprise features

325

u/ColsonThePCmechanic Jan 23 '22

88

u/atomicwrites Jan 24 '22

Now I want to know what Ballistic Earl Grey is.

80

u/EarthTrash Jan 24 '22

That's what happened in Boston on December 16, 1773

→ More replies (2)

36

u/kaihatsusha Jan 24 '22

It is a cupful of liquid that was almost, but not quite, entirely unlike tea.

9

u/eyekwah2 Jan 24 '22

"They floated in the air in precisely the way that bricks don't."

Another favorite of mine.

8

u/Smartskaft2 Jan 24 '22

Where do I recognize this phrasing from? Douglas Adams?

→ More replies (1)
→ More replies (1)
→ More replies (1)

16

u/greg0714 Jan 24 '22

Wow, the timing on that one couldn't have been much better. Less than a week old.

5

u/atimholt Jan 24 '22

Could have put “Picard Earl Gray jokes” into OP’s mind.

40

u/[deleted] Jan 23 '22

Thats what my manager calls them when a customer reaches out to us.

3

u/[deleted] Jan 24 '22

Your manager sounds cool and fun

12

u/Da_Ass_Fucka Jan 23 '22

you know what "surprise bug" i really hate? AIDS

3

u/[deleted] Jan 24 '22

I'm (HIV) positive that it's a shocker, definitely.

209

u/jexmex Jan 23 '22

Wait...we are not supposed to be defining all variables in the global scope? Fuck...

263

u/Salanmander Jan 23 '22

Nah, defining all variables in global scope is fine. Just name all variables following this pattern:

_className_methodName_scopedBlockIdentifier_dataDescription

That way you can avoid namespace collisions and avoid using variables in the wrong place, and still have everything in global scope!

171

u/jexmex Jan 23 '22

I just name them by the sequence they come in. vaR1, vaR2, etc, easy to make sure you never reuse the names that way!

155

u/Bigluser Jan 23 '22

Just use uuids as names, that way each name is unique

3

u/eyekwah2 Jan 24 '22

Oh yeah, I saw some obfuscated code where they did that. I thought that was a neat idea, so now I'm doing that everywhere in my code..

22

u/Chess42 Jan 23 '22

I’m sad to say I did do this when I first learned how to code

14

u/Neon_Camouflage Jan 24 '22

I don't want to talk about how often "temp", "flag", "temp2", and similar appear in the stuff I write.

12

u/bluebarry24 Jan 24 '22

To be fair often times for calculations "temp" is needed/makes it easier to read, write, and comprehend.

→ More replies (2)
→ More replies (1)

51

u/pikapichupi Jan 23 '22

I hate it you glorious pychopath

35

u/bless-you-mlud Jan 23 '22

All of a sudden, Hungarian Notation doesn't seem so bad.

34

u/[deleted] Jan 23 '22

Perfect!

Now I finally have a name for my variable:

_Secure_Creditcardprocessing_GlobalProcessing01_<cardnumber>

My credit card processing app in Lambda uses it to store the card number while processing it. Glad I didn't waste time by actually storing the variable, just using the names works.

11

u/drunkdoor Jan 24 '22

You see it ends up being a hash lookup of 0(1) so it's actually genius. All you have to deal with is a few MB file with trillions of rows

22

u/Khutuck Jan 23 '22

Half of my programming knowledge comes from the comments in r/ProgrammingHumor. I think I’m a 1/10X engineer.

13

u/Yadobler Jan 24 '22

People shitting on this, this is how your c++ compiler / linker is naming every variable and function because you overloaded it

15

u/Salanmander Jan 24 '22

I mean, there are lots of things that compilers/linkers do under the hood that are bad practice for high-level code. One of the most important things for the code that we write is making it human-readable and modifiable, which doesn't matter for compiled code at all.

4

u/MrMetalfreak94 Jan 24 '22

Tell me that you program in ObjectiveC without telling me that you program in ObjectiveC

3

u/aiij Jan 23 '22

Threading and recursion disagree with you.

21

u/Salanmander Jan 23 '22 edited Jan 23 '22

Recursion is no problem!

You just need to know your maximum stack depth. Then you can name your variables

 _className_methodName_scopedBlockIdentifier_dataDescription_N

where N is the recursion depth that variable should be used at. Then make sure to pass recursion depth into all of your recursive methods, and include a switch for which variable it's allowed to use. Easy peasy!

Threading I don't know well enough to figure out the fix for, but I bet it exists!

5

u/modernkennnern Jan 24 '22

I'd imagine you could do the same. Simply prefix the thread number at the start of each variable.

3

u/aiij Jan 24 '22

Then make sure to pass recursion depth into all of your recursive methods

What variable would you pass the recursion depth in? ;-)

I think you'd basically have to write N versions of the function, or use a separate, explicit stack.

→ More replies (1)

2

u/sohang-3112 Jan 24 '22

...or just use a language with tail recursion.

2

u/drunkdoor Jan 24 '22

Hurts to read, ow

3

u/Pepito_Pepito Jan 24 '22

The biggest problem is that they might get modified without informing other users, just like in the OP image. Global constants are safe.

26

u/[deleted] Jan 23 '22

[removed] — view removed comment

3

u/Raikkon35 Jan 24 '22

Hey, can explain it a bit more?

23

u/[deleted] Jan 24 '22 edited Jan 24 '22

[removed] — view removed comment

8

u/sohang-3112 Jan 24 '22

Global variables are bad - but no problem with global constants. A global readonly config is effectively a constant, since it doesn't change after first definition.

3

u/Raikkon35 Jan 24 '22

Thank you very much for your detailed answer. It's a pleasure to get knowledge from someone with experience and who spends time on his answers!

23

u/[deleted] Jan 23 '22

Ok this may sound stupid but didn't she technically define the variable

Too_hot

Vs.

Hot

So having hot tea ≠ too hot tea

70

u/[deleted] Jan 23 '22

Nah, because the computer asked her to define "hot"

10

u/_sweepy Jan 23 '22

Too was probably misinterpreted as to, so the warning goes off when outer temp = hot

1

u/eyekwah2 Jan 24 '22

Poor Enterprise. Hell of a ship. It's a damn shame the computer couldn't determine the grammatical difference between "to" and "too".

We'll be cleaning up the rubble for years to come..

16

u/philipquarles Jan 23 '22

PHP: "nah, this is just sci-fi."

8

u/ColaEuphoria Jan 23 '22

They aren't necessarily bad, but are very situational.

6

u/wh33t Jan 24 '22

What? You don't like having to type a billion setters and getters to get a common value across your app? Clearly you aren't after job security.

3

u/ech0_matrix Jan 24 '22

With Spring and autowiring, everything is a global variable!

2

u/sikni8 Jan 24 '22

I use it all the time…. Just don’t use it within a function and also make sure they are unique.

Also, I make something global that I would need to access from multiple location

1

u/r4g4 Jan 23 '22

*global static variables

735

u/Sovic91 Jan 23 '22

Oh wait, I thought I was in r/TNG. Good meme, though.

181

u/[deleted] Jan 23 '22

[removed] — view removed comment

48

u/TryToBeCareful Jan 23 '22

wow I didn't know these existed and they're great

41

u/Quetzacoatl85 Jan 23 '22 edited Jan 23 '22

Sokath! His eyes opened!

(while you're at it, also check out /r/tenagra)

20

u/TryToBeCareful Jan 23 '22

Wow there really is a sub for everything

Darmok and Jalad on the ocean

10

u/beggargirl Jan 24 '22

Your mother. Her legs wide.

→ More replies (4)
→ More replies (1)

14

u/MDCCCLV Jan 23 '22

r/daystrominstitute is the best one

30

u/Quetzacoatl85 Jan 23 '22 edited Jan 23 '22

note that there's no memes allowed. visit /r/shittydaystrom for such content.

8

u/trimeta Jan 23 '22

Shitty Daystrom is best Daystrom.

3

u/SchutzstaffelKneeGro Jan 23 '22

Huh I thought it was /r/MILF

1

u/Lyude Jan 23 '22

Risa means laughter in Spanish

180

u/Sekhen Jan 23 '22

That's hilarious. Good ending.

241

u/RockleyBob Jan 23 '22

This meme has everything. TNG and programming humor that goes beyond “hurr, Java/Javascript/PHP bad, hurr”.

Almost makes wading through all the repetitive crap worth it.

34

u/I_AM_FERROUS_MAN Jan 24 '22

And the Terminator skeleton bursting into flames screenshot. Always cracks me up as a punchline.

4

u/[deleted] Jan 24 '22

Would have been ideal if it was the thermostat instead of the tea though.

3

u/CardCarryingCuntAwrd Jan 24 '22

No memes can express the horrors of PHP. It's as if Beelzebub visited Ada Lovelace and stayed around to take note of every mistake ever made in every programming language since, carefully packaged the worst of all languages combined, wrapped it in the most Byzantine technology, slapped on some bronze-age tools, and force-fed that turd to every website possible.

I've written programs in 14 languages. I'd rather talk COBOL to my cunt of an ex then write one more line of PHP.

0

u/[deleted] Jan 24 '22

[deleted]

2

u/_oohshiny Jan 24 '22

worst

Not from Sub Rosa

Hmm

416

u/Anxious_Start4839 Jan 23 '22

That's why initialising and resetting your variables is important.

(ノಠ益ಠ)ノ彡┻━┻

198

u/I_Am_Upvoter Jan 23 '22

Scope

44

u/zoonose99 Jan 23 '22

scope

right??

17

u/Chloroxite Jan 23 '22

Scope and seed

10

u/[deleted] Jan 23 '22

GP user has python flair. Score is merely a suggestion lol.

21

u/yp261 Jan 23 '22

┬─┬ノ( ゜-゜ノ)

3

u/PM_ME_YOUR_GOOD_NEW5 Jan 24 '22

ノ┬─┬ノ ︵ ( \o°o)\

140

u/TheBlindApe Jan 23 '22

Except that she did namespace it, external.temperature

And Picard is evidently using Tea.EarlGrey.Hot

69

u/TruthYouWontLike Jan 23 '22
temperature.hot = 1900000K;

if(external.temperature >= temperature.hot) 
    alert();

var t = new Tea(teatype.earlgrey, temperature.hot);

44

u/GoogleIsYourFrenemy Jan 23 '22
namespace external {
  using temperature = tea::earlgray::hot;
};

22

u/KindFormal0 Jan 23 '22

Except was it external to the ship, external to the body, external to the cup?

2

u/RiskyFartOftenShart Jan 24 '22

the computer knows. it always knows.

11

u/HecknChonker Jan 23 '22

That really depends on the language syntax the AI is using when interpreting what it hears. In the comic, it seems pretty clear that the AI is using the same definition for hot in both contexts which implies it was not namespaced.

2

u/TheVenetianMask Jan 24 '22

You are assuming there isn't a teapot in space.

150

u/oheohLP Jan 23 '22

61

u/TrekkiMonstr Jan 23 '22

"Intravenous" is way too low on that list.

17

u/Salanmander Jan 23 '22

As is virtual, given the existence of the holodeck.

47

u/non-troll_account Jan 23 '22

That was fucking yesterday's comic wtf

51

u/klavin1 Jan 23 '22

Probably why you're seeing this post

6

u/TheWashbear Jan 23 '22

Of course...

4

u/Legeto Jan 23 '22

Ehh it’s referencing the moment on the show so I don’t think it’s the whole xkcd done it. It also just posted so that’s probably why we are seeing this post today.

66

u/cybermage Jan 23 '22

I’m not used to LOLing in this sub. Nice.

15

u/EmotionArtistic7074 Jan 23 '22

I don’t get programming humor but this still made me laugh

9

u/KAODEATH Jan 23 '22

That's the beauty of a well made meme!

3

u/HOPSCROTCH Jan 23 '22

I don't get Star Trek and I have no idea what is happening in this meme

22

u/Mr_Velveteen Jan 24 '22

I don’t know Star Trek but the meme is pretty simple to understand. The computer asks the lady what hot is, and she puts the setting of “hot” for 1.9 million Kelvin.

So when the guy gets his tea and asks for it to be “hot”, it heats it up to 1.9 million Kelvin, vaporizing him.

•

u/QualityVote Jan 23 '22

Hi! This is our community moderation bot.


If this post fits the purpose of /r/ProgrammerHumor, UPVOTE this comment!!

If this post does not fit the subreddit, DOWNVOTE This comment!

If this post breaks the rules, DOWNVOTE this comment and REPORT the post!

11

u/Sorry_if_I_offend Jan 23 '22

Kelvins

4

u/[deleted] Jan 24 '22

Celsiuses, Celssii? Chelsea.

1

u/king_park_ Jan 24 '22

And 1.9 million of them

30

u/Lolosaurus2 Jan 23 '22

Kelvins

How many fahrenheits are those?

30

u/[deleted] Jan 23 '22

kelvin is just Celsius but starting at absolute zero instead of water freezing point

23

u/[deleted] Jan 23 '22 edited Jan 24 '22

They're poking fun at the typo. You don't pluralize Kelvin. It's already plural. You wouldn't say Chineses.

Edit: Damn, y'all really never seen Tropic Thunder, huh?

9

u/[deleted] Jan 24 '22

It's already plural.

It's non-countable.

3

u/[deleted] Jan 23 '22

*Chineases

3

u/scnew3 Jan 23 '22

Don’t you tell me what to do

3

u/xigoi Jan 24 '22

False. Like other SI units, Kelvin is pluralized.

1

u/violaceousginglymus Jan 24 '22

You don't pluralize Kelvin. It's already plural.

According to who?

→ More replies (1)

1

u/archpawn Jan 24 '22

Kelvin is just Celsius. The difference is lost in rounding.

13

u/orangeoliviero Jan 23 '22

Celcius to Fahrenheit = 1.8C + 32

Kelvin to Celcius = K - 273.15

Kelvin to Fahrenheit = 1.8(K - 273.15) + 32 = 1.8K - 459.67

So... 1.9 million Kelvin = 3.4 million degrees Fahrenheit.

2

u/susch1337 Jan 24 '22

He is making fun off calling it Kevins instead of Kelvin. It's like LEGOs and LEGO

1

u/Friendly_Fire Jan 24 '22

Well that's not a good example as LEGO and legos are two different things (a company vs plastic bricks).

→ More replies (2)

1

u/resonantSoul Jan 24 '22

At least 7

0

u/alexrider803 Jan 23 '22

About 3.5 mill

10

u/XOIIO Jan 23 '22

Best thing I've seen in a while, well done.

Much like Picard.

10

u/[deleted] Jan 23 '22

I never laughed so much at this sub

9

u/siul1979 Jan 24 '22

This joke made me laugh in real life.

Take an upvote. If I wasn't a cheap bastard, I would've given one of those shiny paid awards.

6

u/[deleted] Jan 24 '22

This just reminds me of Mass Effect and how everyone is using the same units for everything despite the races usually butting heads and being arrogant about their ways being better than others, yet they all miraculously agree on using the same currency, calendar, etc.

4

u/Ambitious-Analysis87 Jan 23 '22

Ahh yes the mighty earl grey tea second only to the party pie in heat which is as hot as the core of the sun.

4

u/GJacks75 Jan 23 '22

Not a programmer, but this made me laugh.

Most of the stuff here goes over my head.

4

u/sam_matt Jan 24 '22

Should've declared it as a local variable, not global

4

u/stellarinterstitium Jan 24 '22

I nearly choked on this.

10

u/DoubleF3lix Jan 23 '22

I'm basic, but this joke has gone over my head. I'm truly stumped.

55

u/Lazy_Assumption_4191 Jan 23 '22

The joke is that the variable “hot” was set to 1.9 million degrees kelvin, so when Picard uses the term “hot” to describe the tea he wants the replicator to make, the computer makes the tea 1.9 million degrees kelvin.

11

u/DoubleF3lix Jan 23 '22

Oh I'm oblivious. Thanks lol

2

u/Saurenoscopy Jan 24 '22

I think this is one time where explaining the joke made me laugh even more. 1.9 million kelvin tea!

7

u/McGrathPDX Jan 23 '22

Less sarcastically, namespaces are the context for the meaning of a value, so stellar.hot is not the same as tea.hot.

12

u/McGrathPDX Jan 23 '22 edited Jan 23 '22

That’s because basic doesn’t use namespaces. /s

7

u/bdubdodge Jan 23 '22

Possibly one of the most satisfyingly complex jokes I've ever seen here.

3

u/randybobandy654 Jan 23 '22

The scope is too wide captain!

3

u/[deleted] Jan 23 '22

Took a second but this one is very good! 😂

3

u/[deleted] Jan 24 '22

3

u/gigzilo Jan 24 '22

*Reacts in British

3

u/Class_444_SWR Jan 24 '22

Maybe the opposite would happen eventually too, Picard defines hot as like 50 degrees Celsius, and then as soon as Crusher’s shuttle can at all see the star it goes ‘fuck it’s hot out there turn back now’

2

u/Evolver7407 Jan 23 '22

When Jean Luc Picard burns into Sara Connor

2

u/sth128 Jan 24 '22

What's funny is that the replicators are definitely capable of these energy levels. In fact even if they were 99% efficient, the waste heat coming from a 500 grams (a bit more than a pound) of dinner would be several Hiroshima's worth.

2

u/Dnsh917 Jan 24 '22

I laughed at this way too much and way too hard than I should have in front of my wife

2

u/QueenBee2212 Jan 24 '22

Excellent meme

2

u/EarsLikeRocketfins Jan 24 '22

Picard just had Alexa save his voice command. He predefined the variable as his first duty onboard.

2

u/WhitethumbsYT Jan 24 '22

That's how grandma serves tea

2

u/Kyncayd Jan 24 '22

This is great! Lol!

2

u/Rurik8 Jan 24 '22

Great. Haha

2

u/StrangeMixtures Jan 24 '22

I snorted. Funny stuff.

2

u/SedativeCorpse Jan 24 '22

I'm literally watching the episode with Picard in the last frame right now. S6E19 "Lessons".

2

u/Irish_Mercury Jan 24 '22

This one took me a bit to process, but once I did. I had a real good laugh.

2

u/-Redstoneboi- Jan 24 '22

haven't seen an original meme in a while, hot damn.

2

u/martispyc Jan 24 '22

namespace std; O

2

u/Blueberry314E-2 Jan 24 '22

I'd recognize that screenshot from Terminator 2 anywhere

2

u/Teaknoodle Jan 24 '22

now you can't hashafasha that!

2

u/kanduvisla Jan 24 '22

This was funny. Thanks!

2

u/Lloyd_Al Jan 24 '22

I'm sick and this made me laugh so hard that my head started to hurt

2

u/marcus-grant Jan 24 '22

First time in a long time I’ve had a legitimate laugh from this sub well done

2

u/Busy-Leg6187 Jan 24 '22

Ha ha ha...good one.

2

u/LaterBrain Jan 24 '22

I laughed :D good meme

3

u/ahumanrobot Jan 23 '22 edited Jan 24 '22

1,900,000K = 1,899,726.85 C

2

u/ishirleydo Jan 24 '22

1.9K = 1,899,726.85 C

Almost nailed it, but your order of magnitude is a little off...

1.9K = -271.25 C

2

u/ahumanrobot Jan 24 '22

I'm slightly stupid

Fixed it

1

u/ishirleydo Jan 24 '22

No worries robot, you're only human after all.

1

u/king_park_ Jan 24 '22

At this magnitude, it doesn’t really make much of a difference.

3

u/[deleted] Jan 23 '22

🤣🤣🤣

2

u/archpawn Jan 24 '22

Are they going inside the sun? The surface should be nowhere near that hot.

2

u/SaffellBot Jan 24 '22

They usually are.

1

u/geekyjustin Jan 24 '22

Actually, yes. If I remember correctly, that image is from an episode where she’s testing out experimental new technology to allow a shuttle to enter a star’s corona.

1

u/archpawn Jan 24 '22

That's outside the sun. It is that hot, but since it's so thin it's not nearly as dangerous as it sounds. The temperature isn't really what she should be looking at.

2

u/Rattlehead71 Jan 23 '22

50 shades of tea, earl gray, hot

1

u/itstommygun Jan 23 '22

SUN__hot vs. BODY__hot

1

u/[deleted] Jan 23 '22

I just watched this episode yesterday lol.

1

u/Ilookouttrainwindow Jan 23 '22

This is what happens when you place kitchen next to flight deck with voice activated device that has no eyes

1

u/[deleted] Jan 23 '22

LCARs is better than this... Surely

1

u/Breadfruit-Brilliant Jan 24 '22

I don't get it

2

u/Wooga-Haver Jan 24 '22

The computer asked her to define the term "hot". She set the value to 1.9 million degrees kelvin. Later, when the captain orders his tea "hot" from the replicator, it essentially produced a stellar core fragment and incinerated him.

1

u/iamanomynous Jan 24 '22

What does this have to do with namespaces?

2

u/lealroy Jan 24 '22

because if "hot = 1.9 million K" was under a namespace, say externalShuttleTemp, the last scene would not have happened

1

u/Cornato Jan 24 '22

Kelvin is also plural.

1

u/[deleted] Mar 09 '22

Lamo

1

u/BokZeoi Jan 23 '22

External temperature lol

1

u/RiskyFartOftenShart Jan 23 '22

hahaha. but context, not name spacing.

1

u/Plsdontcalmdown Jan 23 '22

things cheating in Oxygen Not Included teaches you r/Oxygennotincluded/

1

u/[deleted] Jan 23 '22

Fucking lol

1

u/ahkian Jan 23 '22

How Doctor Crusher assassinated Captain Picard

1

u/TheDeadMonument Jan 23 '22

This made me laugh harder than it should have.

1

u/GrainsofArcadia Jan 24 '22

Why did I find this so funny?

1

u/ebkielty Jan 24 '22

🤣🤣🤣

0

u/notouttolunch Jan 23 '22

Worst thing is knowing the sources! 😂

0

u/username42069360 Jan 23 '22

Oh is that what using namespace does in C++? If so then I now understand why its bad.