this post was submitted on 28 Mar 2024
613 points (98.1% liked)

Programmer Humor

32048 readers
1520 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] 9 points 5 months ago

Self-explanatory code doesn't need comments!

[–] [email protected] 2 points 5 months ago

Aah.... Like reading a novel. But with a lot of weird punctuation.... Or maybe just like a novel then.

[–] [email protected] 3 points 5 months ago* (last edited 5 months ago)

I don't (brain processes the photons bouncing off the object and colliding with the cones and rods in the retina) a problem with this.

(See what I did there?)

(I think I met my dad joke quota for the month.)

[–] [email protected] 21 points 5 months ago (1 children)

I'll take this over the more "classic" styles, when people seed to believe they were paying the compiler by the character.

[–] [email protected] 7 points 5 months ago (1 children)

I respect code golfers the same way I respect a cobra, from a distance. Don't bring that single character naming to the codebase please.

[–] [email protected] 4 points 5 months ago

Exactly, use emojis or gtfo

[–] [email protected] 7 points 5 months ago

Like... there's such a thing as comments my dude.

[–] [email protected] 2 points 5 months ago

this is a crime against humanity

[–] [email protected] 11 points 5 months ago (1 children)

Bruh didn't know how to use comments to describe a function or variable...

[–] [email protected] 16 points 5 months ago

Clearly this is what we call "self documenting code".

[–] [email protected] 1 points 5 months ago

I use C++ and in certain projects, I am already halfway there.

[–] [email protected] 14 points 5 months ago* (last edited 5 months ago) (4 children)

The real naming fail is calling the class "GameManager", still my number one pet peeve. With a class name as vague as that you would have to add tons of information into the variable name. (Also the class name begs for unorganized code. I mean name one function or variable that you could not justify putting into the "GameManager" class. After all if it's managing the game it could justifiably perform any process in the game and access any state in it.)

Once you put the first bool into a class with a name like AccessibilitySettings, calling it something like HighContrast is completely sufficient.

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

"Manager" classes often end up like "God classes", just like how "Utils" classes end up with a bunch of random stuff in them.

[–] [email protected] 1 points 5 months ago

At my first job I was working on an MMO and we had a DatabaseManager class with 10k+ lines of code. Less than the first 200 lines actually used any of the members of that class.

[–] [email protected] 4 points 5 months ago (1 children)

Unity actually gives any class with the name GameManager a special gear icon. You cant just forgo the cool gear icon!

(Its not too terrible from an organizational standpoint because most of the scripts are attached to game objects. MonoBehavior is a component of GameObject. For instance, you’d never have player movement in the GameManager class, you would put it in the component class attached to the player character GameObject.)

[–] [email protected] 2 points 5 months ago* (last edited 5 months ago)

you’d never have player movement in the GameManager class

You want to bet? (Source: I teach game programming on a college level.)

But yeah, your comment about the gear icon is sadly more true than people may realize. Game developers do questionable things. => Engine developers cater to people. => Students argue that if something is supported it can't be that bad. Sometimes it feels like fighting windmills.

[–] [email protected] 4 points 5 months ago

With a class name as vague as that you would have to add tons of information into the variable name.

Technically they did exactly that.

[–] [email protected] 6 points 5 months ago

We've all been guilty of these mistakes, naming stuff is hard, structuring your project is hard, learning the grains of a language takes time. But comments like these are golden nugets, some might read this and think "oh yeah, this makes sense" and rethink their whole methodology of naming and structure. You might have pushed someone reading your comment, to think more about these things.

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

I’m already annoyed by the end of public static final string that the variable name doesn’t even bother me in these sorts of langauages. All things should be public, static, & final, by default so they aren’t necessary to write. You should only have to write what unsafeties you are opting into.

[–] [email protected] 4 points 5 months ago (1 children)

You may enjoy having a look at F#. It says that it's "functional first", but I think a better description would be "an opinionated version of C#".

For example it doesn't have a "const"-keyword. Instead it has a "mutable"-keyword, because everything is const by default.

[–] [email protected] 1 points 5 months ago

Being attached to the CLR isn’t my cup of tea, but I have been learning its older cousin OCaml off & on the last 1½ years

[–] [email protected] 6 points 5 months ago (2 children)

String if_you_must_please_at_least_separate_the_words

[–] [email protected] 5 points 5 months ago

PascalCase is standard in C#

[–] [email protected] 7 points 5 months ago

That's just camel case vs snake case (though in this case, it also has the first character capitalised)

[–] [email protected] 9 points 5 months ago

You forgot to declare custom primitive types. You cannot create a bool you gotta declare a DoubleYouDoubleYouDoubleYouDotLemmyGradDotML_Bool

[–] [email protected] 1 points 5 months ago (1 children)

When the variable name is the description that should be in the comments.

Idea: Comments that automattically populate the end of any line a given variable is invoked on, including spelling out formulas from that line. ie: float y=mx+b // (cartesian y value)=(slope)(cartesian x value)+(cartisian y-intercept)

"Duplicated" coments not actually in the file, but specified witt the creation of such variables and spread around by the code editor /IDE.

[–] [email protected] 4 points 5 months ago

Then, you could take those comments, and have the compiler use them to ensure you're using the right variable in the right place. Oh wait, we just invented a type system.

[–] [email protected] 6 points 5 months ago* (last edited 5 months ago) (2 children)

Hot take, but the main problem with this is that you have to type variables or use them in larger expressions. Otherwise I like it.

These would make a great mouseover text. I don't know if there's any standard way to support that. Actually, how come coding in non-plaintext formats never took off?

[–] [email protected] 5 points 5 months ago (1 children)

In pretty much any language I've used there is some standard for doc comments that would show up as mouseover text in the IDE.

[–] [email protected] 1 points 5 months ago* (last edited 5 months ago)

I need like a tutorial on IDEs, because clearly I'm using them wrong. Or I tend to work on things that are poorly documented and just haven't been able to take advantage, I guess that's possible.

[–] [email protected] 2 points 5 months ago

snake_case_might_be_better_for_that

[–] [email protected] 10 points 5 months ago

"Commenting is for n00bs"

[–] [email protected] 4 points 5 months ago

Wtf. It's not even center aligned.

[–] [email protected] 0 points 5 months ago
load more comments
view more: next ›