r/ProgrammerHumor • • 23d ago

Meme encapsulationByIntimidation

Post image
605 Upvotes

24 comments sorted by

View all comments

Show parent comment

48

u/AlwaysHopelesslyLost 23d ago

Follow up question. Why?

90

u/lllorrr 23d ago • Heartwarming

Because Javascript lacks proper private object fields. And sometimes programmers have a bright idea to use library internals from outside.

9

u/Megolas 23d ago

I mean, there are private fields in JS for years now. Probably these are used to sync with the devtools or to support ancient browsers 🤷‍♂️

11

u/Silly_Guidance_8871 23d ago • Regret

And yet, I still field issues where someone's using a browser that doesn't support the feature, and I'm being tasked to make it work.

2

u/Draconis_Firesworn 20d ago

yk i was seeing discussion on python __/name mangling and saw people complaing about problems that only happen when you try to access a private variable outside its class causing weird stuff in a way that only happens when you do the thing you are explicitly told not to, and wondering why this is such a common complaint. Ig this isn't unique to python

1

u/asato977424 16d ago

Python's double-underscore mangling avoids subclass name clashes; it isn't access control, so deliberate access still works.

1

u/Draconis_Firesworn 16d ago

you can, doesnt mean you should

34

u/artofthenunchaku 23d ago

It's just a tongue-in-cheek way to indicate that you really, probably shouldn't be touching that variable without a really good reason. There's a lot of variable naming like that in Meta codebases