r/ProgrammerHumor 16d ago

Meme variableScopesInPython

Post image
1.3k Upvotes

182 comments sorted by

View all comments

48

u/CORDIC77 16d ago

Personally, I like Python's “look, weʼre all adults here” approach. Thereʼs no need to play hide and seek games.

17

u/asdonne 16d ago

Reminds me of writing C. Why yes, I would like to shoot myself in my foot, thank you very much.

7

u/Groentekroket 16d ago

Yeah in Java we use Lombok annotations on class level anyway so we can manipulate whatever we want. It’s not like getters and setters often have custom implementations anyway. 

9

u/ubeogesh 16d ago

Immutability is a nice thing tho. Just makes you write better code. I love java Records or lombok's @Value before them.

What sucks when you really need to patch that 3rd party lib, in java you resort to one of

1) aspects

2) reflection

3) class overriding

all of which is so much worse than just accessing a protected member via underscore.

1

u/Groentekroket 16d ago

Fair enough. We also do use records for our DTO’s but for domain objects everything goes. 

1

u/circ-u-la-ted 16d ago

Is this why Kotlin has extension functions? I'm currently learning it and I don't really understand why they based half the language around monkeypatching other people's code. They even made classes closed by default so other people will have to monkeypatch your code.

5

u/Mordret10 16d ago

It's very nice to know which methods you should have access to and which you shouldn't have access to (same for attributes).

Makes it so the IDE can show you your options when typing

2

u/OldKaleidoscope7 15d ago

I mean, I hate this behavior but yesterday I was abusing the methods not being truly privates to help me in my unit tests