this post was submitted on 09 Sep 2023
1053 points (97.2% liked)

Programmer Humor

32561 readers
390 users here now

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

Rules:

founded 5 years ago
MODERATORS
 
top 50 comments
sorted by: hot top controversial new old
[–] [email protected] 339 points 1 year ago* (last edited 1 year ago) (6 children)

Many years ago I had to try to debug a memory manager written by a really talented software engineer, with an interesting take on naming things…

  • He referred to blocks of memory as “cookies”.

  • He had a temporary variable named “handy” because it was handy to have around.

  • He had a second temporary variable that referenced the first one that he called “son_of_handy”.

  • If corruption was detected in a block of memory then it would set the flag “shit_cookie_corrupt”.

  • If too many cookies were corrupt then the system would halt by calling the function “oh_shit_oh_shit_oh_shit”.

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

To be honest I'd like to see his resume, kinda wanna hire him

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

That was close to 30 years ago - a DOS memory manager written prior to Windows 3.0. He’s likely retired now…

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

proposal to rename exit() to oh_shit_oh_shit_oh_shit()

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

screw_you_guys_im_going_home()

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

fuck_this_shit_im_outta_here()

load more comments (3 replies)
[–] [email protected] 45 points 1 year ago

I will keep this legacy alive within my code

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

Okay yeah but I know what all those variables do

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

Sounds like my type of guy.

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

Naming things is one of the two hardest problems in computer science. The other one is cache coherency and off by one errors.

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

That's three... Ohhhh....😅

load more comments (1 replies)
[–] [email protected] 83 points 1 year ago (4 children)

U nd to rembr tht mny snr devs grw up prgrmng on old hrdwr tht ddn't hv mch mmry & oftn th lang ony allwd shrt var nms anywy. Also thy wr th gen of txtspk fr smlr rsns.

Yngr snr devs pckd up bd hbts frm tht gen.

And here's a sentence that's not squashed to cleanse your palettes / give a sigh of relief because I figure if I need a break from typing like that, you need a break from reading it.

Nmng thngs s hrd.

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

I’ve been at this for 25 years and a restriction on variable name length hasn’t been a problem since then.

A good senior dev shouldn’t just be older, they should have continued to learn and evolve.

I do remember texting abbreviations because we texted on a number pad with no autocomplete.

Everyone I know was happy to switch to better keyboards and autocomplete as soon as they were available.

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

Speak for yourself. My company only stopped using Fortran this decade.

load more comments (1 replies)
load more comments (2 replies)
[–] [email protected] 9 points 1 year ago (1 children)

oftn th lang ony allwd shrt var nms

I started coding with TurboBasic which allowed variable names of any length but the compiler only looked at the first two letters (and case-insensitive at that), so DOUGHNUT_COUNT and DoobieCounter were actually the same variable. Good times debugging that kind of shit.

load more comments (1 replies)
load more comments (2 replies)
[–] [email protected] 66 points 1 year ago (1 children)

Hey, sometimes we put a little effort into our acronyms. I published a component named UTI and it was too late to change it by the time management caught on.

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

That can’t be true, because it’s never to late for management to edict changes to a project, even just on a whim.

[–] [email protected] 9 points 1 year ago* (last edited 1 year ago)

"Actually we decided we're going to take this project in a completely different direction. Go ahead and rework 90% of what you just created over the last six months."

load more comments (1 replies)
[–] [email protected] 47 points 1 year ago (4 children)

Fuck character limits for names. Looking at you, ABAP.

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

Character limits and a stupid badly used Hungarian notation to waste limited characters to tell use what the ide already knows.

If you have a table, (that’s an array for sane programmers) name the variable as a plural and we will know it’s a table.

Don’t name two variables the same stupid abbreviation with different Hungarian notation characters stuck to the front

load more comments (2 replies)
[–] [email protected] 12 points 1 year ago (1 children)

Are you not blind after staring at ABAP?

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

Can you bleach my eyes with some really bad ABAP code? I've never seen ABAP and I want to feel scared

load more comments (7 replies)
load more comments (2 replies)
[–] [email protected] 45 points 1 year ago (1 children)

Hah, I (a Sr developer at the time) once built an entire mapping layer in our ETL system to deal with the fact that our product had long and expressive names for every data point but our scientists used statistical tools that had no autocomplete and choked on variable names longer than 32 chars so they named everything in like 8 chars of disemvoweled nonsense.

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

May those who build such unergonomic tools choke on a hair ball

[–] [email protected] 39 points 1 year ago* (last edited 1 year ago) (5 children)

Also, can somebody explain this to sysadmins when it comes to naming computers?

I mean programmers can have some weird naming conventions, but I've never met an adult professional programmer who named all his variables after planets or Harry Potter characters or just called everything stuff like ADMUTIL6 or PBLAB03T1 or PBPCD1602.

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

Windows backwards compatibility can't handle more than 15 characters in a name.

[–] [email protected] 11 points 1 year ago* (last edited 1 year ago)

Harry1

Harry2

Harry3

![meme](i_can_do_this_all_day)

load more comments (1 replies)
[–] [email protected] 19 points 1 year ago (3 children)

Harry Potter characters is a perfectly reasonable server naming scheme. Server names should be easily recognisable but not tied to any particular service/project/function on that machine (as the server may be used for other things later etc)

See RFC 1178: https://www.rfc-editor.org/rfc/rfc1178

load more comments (3 replies)
[–] [email protected] 16 points 1 year ago* (last edited 1 year ago) (9 children)

Pros use computer names like

Server
newerserver
newnewerserver
latestserver
Newlatestserver

load more comments (9 replies)
[–] [email protected] 16 points 1 year ago

There was a thread about that on c/selfhosted a few weeks ago. Created by a particular wild-cat-inspired sysadmin, I might add.

But on a more serious note, the interactions between a sysadmin and their servers (that they have enough responsibility for to be able to name) are much more intimate than the interactions between a dev and their variables. The server names also exist in a much larger namespace, so they need to be more unique.

load more comments (1 replies)
[–] [email protected] 28 points 1 year ago (4 children)

Documentation is like sex: Even when it's bad, it's still pretty good.

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

You've obviously never used Google Cloud documentation.

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

Does that mean self-documenting code is actually masturbation?

load more comments (2 replies)
[–] [email protected] 21 points 1 year ago (2 children)

What kind of shit senior devs are you working with?

load more comments (2 replies)
[–] [email protected] 16 points 1 year ago (1 children)

Nah, always use as lewd names as possible, like really over the top, preferably r34 compliant. And the comments need to be there to explain the fictional stories behind all the names and all the lewdness - and not really to explain what the code does, that's just a common misconception.

If someones dares to look into my code they need to be ready to suffer.

(And no, I'm not a dev, no one in my team can code anything, boss won't give me a an actual dev - and when I write something for other ppl as a favor I make an effort to make the code clean and comments only mildly amusing)

[–] [email protected] 11 points 1 year ago* (last edited 1 year ago) (3 children)

Reminds me when back in the day I was working on a system where one of major component's acronym was BOOTY. It was hard picking right terms and names for the new parts, but I managed to fit a variable named BOOTY_SLAP in there such that none of the reviewers even questioned it.

load more comments (3 replies)
[–] [email protected] 15 points 1 year ago* (last edited 1 year ago) (9 children)

Does anyone have any good advice on variable naming? Here's some of my rules I try to live by:

  • camelCase
  • use prefixes
  • prefixes should be one word followed by an underscore.
  • 10 character limit or 3 word limit, not counting the prefix
  • functions should be prefixed with the file in which they're defined, ie utils_FooBar
  • file names should be one word
  • Start Bools with is
  • Don't use not in bool names.
    • This has farther-reaching implications that will keep you from making confusing code most of the time (I'm sure this will be controversial, but it works no matter what they say)
  • start output with _
  • Globals should be g_VARIABLENAME
  • use the least amount of words possible
  • but being too verbose can draw attention - use this to aide in readability
    • calc_ImportantValueThatWillDecideTheUsersView is better than calc_SumYears if the variable is more important than the others.
  • Even the greatest variable names are not replacements for documentation
  • Even the most readable code is not replacement for documentation.
    • Force yourself to love documentation.

Edit: I realize I was speaking about function-naming with the prefix stuff.

For variables, I still use prefixes, but for variable type. Even if you define the variables as types, it's still incredibly useful. For instance,

a string is s_MyName,

enumerable is e_MyType,

A number is int or double or whatever i_MyAge or d_MyWeight

This might be obvious for custom objects, but I'd still do it like this p_Person or per_Person.

Seriously it does make a huge difference

[–] [email protected] 11 points 1 year ago (1 children)
  • Don't code in a language/style that requires you to write code that makes prefixing necessary - divide and conquer instead
  • Readable code and well written unit/BDD tests is much better than separate documentation that will go out of sync the minute another Dev does some surgical incision into the code
  • Be verbose if you need to in order to convey the relevant semantics, the characters are virtually free
  • Use the casing that is mainstream/recommended by its' developers for the language at hand
load more comments (1 replies)
load more comments (8 replies)
[–] [email protected] 12 points 1 year ago

I have never had any patience with variable names when I realize I have to do a 3-way swap: c=a, a=b, b=c. I'm sure there's 40 years of goddamit=a and fml=a in the wake I've left behind me.

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

Programmers really like their AJTI (acronyms just to impress)

load more comments (2 replies)
load more comments
view more: next ›