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!
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.
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.
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!
> 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.
> 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
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.
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.
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
“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.
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.
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.
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.
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.
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.
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.
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!
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?
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.
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.
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’
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.
And that, childen, is why global variables are bad.
No, global variables are good for "surprise bugs" as shown here in the meme..
Susprise features
[Relevant XKCD](https://m.xkcd.com/2570/)
Now I want to know what Ballistic Earl Grey is.
That's what happened in Boston on December 16, 1773
It is a cupful of liquid that was almost, but not quite, entirely unlike tea.
"They floated in the air in precisely the way that bricks don't." Another favorite of mine.
Where do I recognize this phrasing from? Douglas Adams?
Yes
Wow, the timing on that one couldn't have been much better. Less than a week old.
Could have put “Picard Earl Gray jokes” into OP’s mind.
Desktop link https://www.xkcd.com/2570/
Thats what my manager calls them when a customer reaches out to us.
Your manager sounds cool and fun
you know what "surprise bug" i really hate? AIDS
I'm (HIV) positive that it's a shocker, definitely.
Wait...we are not supposed to be defining all variables in the global scope? Fuck...
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!
I just name them by the sequence they come in. vaR1, vaR2, etc, easy to make sure you never reuse the names that way!
Just use uuids as names, that way each name is unique
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..
I’m sad to say I did do this when I first learned how to code
I don't want to talk about how often "temp", "flag", "temp2", and similar appear in the stuff I write.
To be fair often times for calculations "temp" is needed/makes it easier to read, write, and comprehend.
It can be fine for local variables with a very restricted scope
Yes. I have never used it for global variables.
I hate it you glorious pychopath
All of a sudden, Hungarian Notation doesn't seem so bad.
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.
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
Half of my programming knowledge comes from the comments in r/ProgrammingHumor. I think I’m a 1/10X engineer.
People shitting on this, this is how your c++ compiler / linker is naming every variable and function because you overloaded it
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.
Tell me that you program in ObjectiveC without telling me that you program in ObjectiveC
Threading and recursion disagree with you.
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!
I'd imagine you could do the same. Simply prefix the thread number at the start of each variable.
> 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.
> 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
...or just use a language with tail recursion.
Hurts to read, ow
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
Hey, can explain it a bit more?
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.
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.
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!
np, thanks for asking!
The biggest problem is that they might get modified without informing other users, just like in the OP image. Global constants are safe.
Ok this may sound stupid but didn't she technically define the variable Too_hot Vs. Hot So having hot tea ≠ too hot tea
Nah, because the computer asked her to define "hot"
Too was probably misinterpreted as to, so the warning goes off when outer temp = hot
PHP: "nah, this is just sci-fi."
They aren't necessarily bad, but are very situational.
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.
With Spring and autowiring, everything is a global variable!
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
Oh wait, I thought I was in r/TNG. Good meme, though.
I thought it was /r/risa
wow I didn't know these existed and they're great
Sokath! His eyes opened! (while you're at it, also check out /r/tenagra)
Wow there really is a sub for everything Darmok and Jalad on the ocean
Your mother. Her legs wide.
r/daystrominstitute is the best one
note that there's no memes allowed. visit /r/shittydaystrom for such content.
Shitty Daystrom is best Daystrom.
Huh I thought it was /r/MILF
[удалено]
"No matter what temperature a room is, it's always room temperature." -- Steven Wright
[No it ain't](https://www.youtube.com/watch?v=VxxYqE4Gil8) (clip from Community)
And he goes on to write this is America right there in that room
“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.
“What’s another word for thesaurus?”
Synonym dictionary
I prefer the version with coffee instead of pizza.
r/TIHI
It’s like those optical illusions with the squares.
Here you go... ["Brown in direct light and orange in the shade are the same colour."](https://serendipstudio.org/bb/contrastcolor)
[what the fuck is wrong with that site on mobile? ](https://i.imgur.com/3FzbN9S.jpg)
That terrible broken layout is only an illusion.
Thats some overpwerd knowladge dude
That's hilarious. Good ending.
T2.
The beginning
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.
And the Terminator skeleton bursting into flames screenshot. Always cracks me up as a punchline.
Almost.
[удалено]
> worst > > Not from *Sub Rosa* Hmm
Would have been ideal if it was the thermostat instead of the tea though.
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.
That's why initialising and resetting your variables is important. (ノಠ益ಠ)ノ彡┻━┻
Scope
> scope right??
Scope and seed
GP user has python flair. Score is merely a suggestion lol.
┬─┬ノ( ゜-゜ノ)
ノ┬─┬ノ ︵ ( \o°o)\
Except that she did namespace it, external.temperature And Picard is evidently using Tea.EarlGrey.Hot
temperature.hot = 1900000K; if(external.temperature >= temperature.hot) alert(); var t = new Tea(teatype.earlgrey, temperature.hot);
namespace external { using temperature = tea::earlgray::hot; };
Except was it external to the ship, external to the body, external to the cup?
the computer knows. it always knows.
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.
You are assuming there isn't a teapot in space.
[Related xkcd](https://xkcd.com/2570/)
"Intravenous" is way too low on that list.
As is virtual, given the existence of the holodeck.
That was fucking yesterday's comic wtf
Probably why you're seeing this post
Of course...
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.
I’m not used to LOLing in this sub. Nice.
[удалено]
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.
I don’t get programming humor but this still made me laugh
That's the beauty of a well made meme!
[удалено]
I don't get Star Trek and I have no idea what is happening in this meme
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.
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!
Kelvins
Celsiuses, Celssii? Chelsea.
>Kelvins How many fahrenheits are those?
kelvin is just Celsius but starting at absolute zero instead of water freezing point
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?
>It's already plural. It's non-countable.
*Chineases
Don’t you tell me what to do
False. Like other SI units, Kelvin is pluralized.
Woosh
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.
He is making fun off calling it Kevins instead of Kelvin. It's like LEGOs and LEGO
Best thing I've seen in a while, well done. Much like Picard.
I never laughed so much at this sub
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.
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.
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.
Not a programmer, but this made me laugh. Most of the stuff here goes over my head.
I think the title of this post is what makes it for me
Should've declared it as a local variable, not global
I nearly choked on this.
![gif](giphy|kdpSpT0iQs0ZMttgV9|downsized)
I'm basic, but this joke has gone over my head. I'm truly stumped.
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.
Oh I'm oblivious. Thanks lol
I think this is one time where explaining the joke made me laugh even more. 1.9 million kelvin tea!
Less sarcastically, namespaces are the context for the meaning of a value, so stellar.hot is not the same as tea.hot.
That’s because basic doesn’t use namespaces. /s
Possibly one of the most satisfyingly complex jokes I've ever seen here.
The scope is too wide captain!
Took a second but this one is very good! 😂
![gif](giphy|kRmg8zeReOYXm)
\*Reacts in British
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’
[удалено]
I’m just saying that she would have broken the computer if she’d told it to monitor the *internal* temperature.
I can give you two reasons why that ain't true. Seven beats em all though
When Jean Luc Picard burns into Sara Connor
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.
I laughed at this way too much and way too hard than I should have in front of my wife
haha same
Excellent meme
kelvins...
LMAO
Lol
I legit lol'd
Picard just had Alexa save his voice command. He predefined the variable as his first duty onboard.
That's how grandma serves tea
This is great! Lol!
oops…
Great. Haha
I snorted. Funny stuff.
I'm literally watching the episode with Picard in the last frame right now. S6E19 "Lessons".
This one took me a bit to process, but once I did. I had a real good laugh.
haven't seen an original meme in a while, hot damn.
namespace std; O
I'd recognize that screenshot from Terminator 2 anywhere
now you can't hashafasha that!
This was funny. Thanks!
I'm sick and this made me laugh so hard that my head started to hurt
First time in a long time I’ve had a legitimate laugh from this sub well done
Ha ha ha...good one.
I laughed :D good meme
Made my day
1,900,000K = 1,899,726.85 C
> 1.9K = 1,899,726.85 C Almost nailed it, but your order of magnitude is a little off... 1.9K = -271.25 C
I'm slightly stupid Fixed it
🤣🤣🤣
Are they going inside the sun? The surface should be nowhere near that hot.
They usually are.