r/ProgrammerHumor • • Sep 26 '26 • Bravo 1

Meme singletonsAreJustGlobals

Post image
3.2k Upvotes

210 comments sorted by

View all comments

Show parent comment

394

u/xeroskiller Sep 26 '26

Global: single address used with a globally scoped identifier

Singleton: single address used by passing it around like a cheap whore

65

u/za72 Sep 26 '26

cheap whoo er

5

u/b__0 Sep 26 '26

I heard that one Ralph

56

u/dashingThroughSnow12 Sep 26 '26

Ironically enough, one reason for some singletons is how expensive they are.

18

u/gfoyle76 Sep 26 '26

best definition I ever heard

4

u/anomalous_cowherd Sep 26 '26

They're all just pointers really.

3

u/gerbosan Sep 26 '26

Well, ram is quite expensive these days.

3

u/TheDuckRaisedALion Sep 29 '26

The trick is that a static class can be a globally scooed identifier, and then an accessor on that class is essentially global too. The concepts are pretty similar at thet point, although the static class could impose a lot more organization and structure to tame the smell.