this post was submitted on 21 Jun 2023
52 points (98.1% liked)

Programmer Humor

32548 readers
487 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS
 
top 10 comments
sorted by: hot top controversial new old
[–] [email protected] 8 points 1 year ago

Perl actually uses my and our to do scope.

my @foo;

our $bar;

[–] [email protected] 2 points 1 year ago

personally I prefer including the file

prog_constants.h

int program_state; // Keeps track of stuff

in all translation units. That way I can easily keep track of what different parts of the program are doing at any time by modifying a single variable.

[–] [email protected] 2 points 1 year ago

I hate how long it took me to get this, but I love it.

[–] [email protected] 2 points 1 year ago (1 children)

This is a great one. I'm definitely using it in class this fall to explain static variables.

[–] DonjonMaister 2 points 1 year ago

Fun fact: I made this meme to explain my classmates static variables.

[–] [email protected] 1 points 1 year ago (2 children)

Young man, could.you explain your shitpost?

[–] [email protected] 3 points 1 year ago (1 children)

int variable => local scope => my int from the perspective of an instance

static int variable => class scope => our int, for all instances of a class

[–] [email protected] 2 points 1 year ago (1 children)

You know what's funny? In PHP it's backwards :D

[–] [email protected] 2 points 1 year ago

well of course it is!

[–] [email protected] 1 points 1 year ago

I said, young man, what the fuck was that post?