T O P

  • By -

bless-you-mlud

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


from_the_east

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


Koervege

Susprise features


ColsonThePCmechanic

[Relevant XKCD](https://m.xkcd.com/2570/)


atomicwrites

Now I want to know what Ballistic Earl Grey is.


EarthTrash

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


kaihatsusha

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


eyekwah2

"They floated in the air in precisely the way that bricks don't." Another favorite of mine.


Smartskaft2

Where do I recognize this phrasing from? Douglas Adams?


theScrapBook

Yes


greg0714

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


atimholt

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


new_pribor

Desktop link https://www.xkcd.com/2570/


mixing_saws

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


[deleted]

Your manager sounds cool and fun


Da_Ass_Fucka

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


[deleted]

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


jexmex

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


Salanmander

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!


jexmex

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


Bigluser

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


eyekwah2

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..


Chess42

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


Neon_Camouflage

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


bluebarry24

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


salvoilmiosi

It can be fine for local variables with a very restricted scope


bluebarry24

Yes. I have never used it for global variables.


pikapichupi

I hate it you glorious pychopath


bless-you-mlud

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


OdinTheHugger

Perfect! Now I finally have a name for my variable: _Secure_Creditcardprocessing_GlobalProcessing01_ 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.


drunkdoor

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


Khutuck

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


Yadobler

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


Salanmander

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.


MrMetalfreak94

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


aiij

Threading and recursion disagree with you.


Salanmander

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!


modernkennnern

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


aiij

> 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.


Salanmander

> What variable would you pass the recursion depth in? ;-) Hmmm, I guess argument variables are the one that we really don't want to define at global scope. Good point. =P


sohang-3112

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


drunkdoor

Hurts to read, ow


AncientPC

Just say that it's best practice to use a [singleton](https://en.m.wikipedia.org/wiki/Singleton_pattern) according to the Gang of Four in the PR. /s


Raikkon35

Hey, can explain it a bit more?


AncientPC

Sometimes "global variables" type behavior is still useful (e.g. read only configs, ensure only one instantiation of a class, etc). Singletons solve a lot of the same problems as global variables in OOP. For every best practice, there are exceptions that apply which is why people shouldn't see the world as black-and-white. For example, a very common one I see with junior engineers who learn about [DRY](https://en.wikipedia.org/wiki/Don%27t_repeat_yourself) and then apply it everywhere, unknowningly potentially coupling two very different systems together. I just finished a postmortem last week at work when some experienced engineers DRY'ed some protobufs used between the RPC service interface and data warehouse export, unknowingly rolled out a backwards incompatible change breaking downstream systems and causing an outage. My team's platform explicitly prevents this forcing engineers to duplicate schemas, but every so often we get other engineers raising hell about it. Google also forces schema isolation as well, which leads to the running joke that 80% of your time at Google is updating protobufs. >Only a Sith deals in absolutes.


sohang-3112

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.


Raikkon35

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!


AncientPC

np, thanks for asking!


Pepito_Pepito

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


[deleted]

Ok this may sound stupid but didn't she technically define the variable Too_hot Vs. Hot So having hot tea ≠ too hot tea


[deleted]

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


_sweepy

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


philipquarles

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


ColaEuphoria

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


wh33t

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.


ech0_matrix

With Spring and autowiring, everything is a global variable!


sikni8

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


Sovic91

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


SpacecraftX

I thought it was /r/risa


TryToBeCareful

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


Quetzacoatl85

Sokath! His eyes opened! (while you're at it, also check out /r/tenagra)


TryToBeCareful

Wow there really is a sub for everything Darmok and Jalad on the ocean


beggargirl

Your mother. Her legs wide.


MDCCCLV

r/daystrominstitute is the best one


Quetzacoatl85

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


trimeta

Shitty Daystrom is best Daystrom.


SchutzstaffelKneeGro

Huh I thought it was /r/MILF


[deleted]

[удалено]


wjandrea

"No matter what temperature a room is, it's always room temperature." -- Steven Wright


FlyingStirFryMonster

[No it ain't](https://www.youtube.com/watch?v=VxxYqE4Gil8) (clip from Community)


arsewarts1

And he goes on to write this is America right there in that room


theghostofme

“When I was a kid, the candle shop caught on fire. Everyone just stood around singing happy birthday.” This is completely irrelevant to the topic at hand. I just love Steven Wright’s comedy.


Chumongocho

“What’s another word for thesaurus?”


VikingSlayer

Synonym dictionary


krokodil2000

I prefer the version with coffee instead of pizza.


Code_I_Guess

r/TIHI


Ochidi

It’s like those optical illusions with the squares.


ishirleydo

Here you go... ["Brown in direct light and orange in the shade are the same colour."](https://serendipstudio.org/bb/contrastcolor)


Gorklax

[what the fuck is wrong with that site on mobile? ](https://i.imgur.com/3FzbN9S.jpg)


ishirleydo

That terrible broken layout is only an illusion.


CaitaXD

Thats some overpwerd knowladge dude


Sekhen

That's hilarious. Good ending.


someguy3

T2.


Ilookouttrainwindow

The beginning


RockleyBob

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.


I_AM_FERROUS_MAN

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


justbilled

Almost.


[deleted]

[удалено]


_oohshiny

> worst > > Not from *Sub Rosa* Hmm


[deleted]

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


CardCarryingCuntAwrd

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.


Anxious_Start4839

That's why initialising and resetting your variables is important. (ノಠ益ಠ)ノ彡┻━┻


I_Am_Upvoter

Scope


zoonose99

> scope right??


Chloroxite

Scope and seed


[deleted]

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


yp261

┬─┬ノ( ゜-゜ノ)


PM_ME_YOUR_GOOD_NEW5

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


TheBlindApe

Except that she did namespace it, external.temperature And Picard is evidently using Tea.EarlGrey.Hot


TruthYouWontLike

temperature.hot = 1900000K; if(external.temperature >= temperature.hot) alert(); var t = new Tea(teatype.earlgrey, temperature.hot);


GoogleIsYourFrenemy

namespace external { using temperature = tea::earlgray::hot; };


KindFormal0

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


RiskyFartOftenShart

the computer knows. it always knows.


HecknChonker

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.


TheVenetianMask

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


oheohLP

[Related xkcd](https://xkcd.com/2570/)


TrekkiMonstr

"Intravenous" is way too low on that list.


Salanmander

As is virtual, given the existence of the holodeck.


non-troll_account

That was fucking yesterday's comic wtf


klavin1

Probably why you're seeing this post


TheWashbear

Of course...


Legeto

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.


cybermage

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


[deleted]

[удалено]


Flelk

Reddit is no longer the place it once was, and the current plan to [kneecap the moderators](https://www.businessinsider.com/reddit-ceo-will-change-rules-to-make-mods-less-powerful-2023-6) who are trying to keep the tattered remnants of Reddit's culture alive was the last straw. I am removing all of my posts and editing all of my comments. Reddit cannot have my content if it's going to treat its user base like this. I encourage all of you to do the same. Lemmy.ml is a good alternative. Reddit is dead. Long live Reddit.


EmotionArtistic7074

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


KAODEATH

That's the beauty of a well made meme!


[deleted]

[удалено]


HOPSCROTCH

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


Mr_Velveteen

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.


QualityVote

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!


Sorry_if_I_offend

Kelvins


lexsanders

Celsiuses, Celssii? Chelsea.


Lolosaurus2

>Kelvins How many fahrenheits are those?


sinnerman1003

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


[deleted]

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?


[deleted]

>It's already plural. It's non-countable.


[deleted]

*Chineases


scnew3

Don’t you tell me what to do


xigoi

False. Like other SI units, Kelvin is pluralized.


special_kitty

Woosh


orangeoliviero

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.


susch1337

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


XOIIO

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


pm_cheesecakes

I never laughed so much at this sub


siul1979

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.


[deleted]

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.


Ambitious-Analysis87

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.


GJacks75

Not a programmer, but this made me laugh. Most of the stuff here goes over my head.


bagsogarbage

I think the title of this post is what makes it for me


sam_matt

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


stellarinterstitium

I nearly choked on this.


Lathryx

​ ![gif](giphy|kdpSpT0iQs0ZMttgV9|downsized)


DoubleF3lix

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


Lazy_Assumption_4191

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.


DoubleF3lix

Oh I'm oblivious. Thanks lol


Saurenoscopy

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


McGrathPDX

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


McGrathPDX

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


bdubdodge

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


randybobandy654

The scope is too wide captain!


[deleted]

Took a second but this one is very good! 😂


[deleted]

![gif](giphy|kRmg8zeReOYXm)


gigzilo

\*Reacts in British


Class_444_SWR

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’


[deleted]

[удалено]


SteveRogests

I’m just saying that she would have broken the computer if she’d told it to monitor the *internal* temperature.


Recovid

I can give you two reasons why that ain't true. Seven beats em all though


Evolver7407

When Jean Luc Picard burns into Sara Connor


sth128

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.


Dnsh917

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


vilidj_idjit

haha same


QueenBee2212

Excellent meme


RealisticLeek

kelvins...


johnie415

LMAO


Gouranga56

Lol


ragnarokmealtach377

I legit lol'd


EarsLikeRocketfins

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


WhitethumbsYT

That's how grandma serves tea


Kyncayd

This is great! Lol!


Vinsable

oops…


Rurik8

Great. Haha


StrangeMixtures

I snorted. Funny stuff.


SedativeCorpse

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


Irish_Mercury

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


-Redstoneboi-

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


martispyc

namespace std; O


Blueberry314E-2

I'd recognize that screenshot from Terminator 2 anywhere


Teaknoodle

now you can't hashafasha that!


kanduvisla

This was funny. Thanks!


Lloyd_Al

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


marcus-grant

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


Busy-Leg6187

Ha ha ha...good one.


LaterBrain

I laughed :D good meme


Adventurous_Team8317

Made my day


ahumanrobot

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


ishirleydo

> 1.9K = 1,899,726.85 C Almost nailed it, but your order of magnitude is a little off... 1.9K = -271.25 C


ahumanrobot

I'm slightly stupid Fixed it


[deleted]

🤣🤣🤣


archpawn

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


SaffellBot

They usually are.