this post was submitted on 22 Jul 2025
449 points (97.3% liked)

Programmer Humor

25180 readers
1632 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS
 
top 46 comments
sorted by: hot top controversial new old
[–] IAmNorRealTakeYourMeds@lemmy.world 10 points 13 hours ago

Break convention

` class foo: def init(cunt, bar): cunt.bar=True

`

[–] eager_eagle@lemmy.world 79 points 1 day ago* (last edited 1 day ago) (4 children)

nah, I'm never complaining about self in Python after having tried the this and that nonsense in JS.

oh, you're using a named function instead of an arrow fn? Guess what, this is not what it used to be anymore.

[–] joyjoy@lemmy.zip 20 points 23 hours ago (1 children)

Oh, you assigned a method to a variable before calling it? Congratulations, this is now undefined.

[–] pinball_wizard@lemmy.zip 3 points 7 hours ago (1 children)

Yes. There's no telling what this is. this could be anything. We tried to keep track of this, but no one knows when this will change.

[–] joyjoy@lemmy.zip 5 points 7 hours ago

I used to be with this, but then they changed what this was.

Now what I'm with isn't this, and what's this seems weird and scary to me.

This'll happen to you!

[–] kayohtie@pawb.social 30 points 1 day ago (2 children)
[–] theit8514@lemmy.world 39 points 1 day ago (1 children)

Only if you define it.

const that = this

[–] mesamunefire@piefed.social 14 points 1 day ago (1 children)

I remember that a long time ago. Oh god

[–] Aurenkin@sh.itjust.works 6 points 1 day ago

I remember this too... what a nightmare.

[–] eager_eagle@lemmy.world 28 points 1 day ago* (last edited 1 day ago) (1 children)

it's common practice as a workaround to save this when changing contexts, since this may change under you, in callbacks and such

[–] Johanno@feddit.org 1 points 12 hours ago

Kotlin:

this@outerFunction.bla
[–] mesamunefire@piefed.social 7 points 1 day ago

Yeah totally agree.

[–] dufkm@lemmy.world 4 points 1 day ago

As a non-programmer who's occasionally dabbled with wxPython, I've entangled myself with self.parent.parent and their childs/siblings more than once. At that stage I know my project is done.

[–] Lightfire228@pawb.social 50 points 1 day ago (3 children)

Sorry, I'm too Rust-pilled for this OOP nonsense


pub fn new() -> Self {
    Self::self().self.unwrap()
}

[–] shape_warrior_t@programming.dev 18 points 1 day ago (1 children)

Even regular Rust code is more "exciting" than Python in this regard, since you have a choice between self, &self, and &mut self. And occasionally mut self, &'a self, and even self: Box<Self>. All of which offer different semantics depending on what exactly you're trying to do.

[–] dejected_warp_core@lemmy.world 5 points 16 hours ago (1 children)

I'll add that 100% of the above is understood by the compiler. Unlike Python or JavaScript where you don't know how bad you have it until the program is already running.

[–] Lightfire228@pawb.social 5 points 8 hours ago

At least python has a decent runtime typing system

JS's type system feels like what you'd get by giving a monkey access to unlimited cocaine and a computer

[–] panda_abyss@lemmy.ca 28 points 1 day ago (2 children)

Reminds me of java

I have Toolkit toolkit = Toolkit.getDefaultToolkit(); seared into my brain. Then there were the bean factories…

[–] frezik@lemmy.blahaj.zone 15 points 1 day ago (1 children)

At least with Rust, there is a specific, defensible goal for why it does that.

Java is just over designed. All of java.io reads like somebody's Object Orientated Programming 101 final project, and they'd get a B- for it. Lots of things where you can see how they're abstracting things, but there's no thought at all in bringing it together in a tidy way.

[–] Fiery@lemmy.dbzer0.com 5 points 1 day ago (3 children)

Not like C# is all that much better. So much garbage in the fundamentals just because it was done that way at the start and "they can't change it now". The best example is the IList interface.

Theoretically this interface exposes both index-based access and collection-like modifications and as such would be perfect in a function if you need those two features on a type. In reality you can't use it as a function parameter because half the official types implementing IList aren't modifiable and throw a runtime error. E.g Arrays

[–] sudo_halt@lemmygrad.ml 1 points 5 hours ago

Embrace the holy light of Dart

[–] ThirdConsul@lemmy.ml 1 points 12 hours ago

Oh god, I didn't knew that. That's funny.

[–] kogasa@programming.dev 1 points 19 hours ago* (last edited 19 hours ago) (1 children)

That's a footgun sure but at least you can avoid it once you're aware of the problem.

I never write function signatures with mutable interfaces. It's always IEnumerable, IReadOnlyCollection, or IReadOnlyList; otherwise, use a concrete type. The latter is typical for private/protected methods that are called with instance members of a concrete type rather than public interfaces. If you want to mutate an object, you should own it. Public methods are invoked with data not owned by the instance.

For example, a lot of extension methods in LINQ have a signature IEnumerable --> IEnumerable, and internally the first thing they do is call .ToList(). The interface makes minimal assumptions about the input data, then puts it into a concrete type you can manipulate efficiently. You can similarly define a method for IReadOnlyList and explicitly make it mutable via .ToList(), rather than use IList and check .IsReadOnly. Both ensure correctness but the former does it at the type level, at design time, instead of relying on runtime checks.

C# is old and full of oldness. But it's also an excellent language that can be written beautifully if you know how. And there's lots of great code to learn from in the open-source dotnet core runtime repo and related projects.

[–] Fiery@lemmy.dbzer0.com 2 points 10 hours ago (1 children)

Functional programming fixes the problem by simply not making it OO anymore, and while I'm personally a big fan of the paradigm there are situations where an OO approach is preferable (or even only to conform to a project's existing way of doing things).

[–] kogasa@programming.dev 1 points 9 hours ago

What I described isn't necessarily functional. This is just a principle for ensuring objects represent clear and well-defined contracts. The idea is that to mutate something, you should own it; that means interfaces / public APIs, which can be called externally, should take immutable arguments. You can still mutate instance members internally because those are owned by the instance. If mutation is really necessary between two objects then it should be coordinated by an object owning them both.

[–] MonkderVierte@lemmy.zip 1 points 16 hours ago

Now my brain wants to relate Java somehow to beancounters.

[–] PlexSheep@infosec.pub 12 points 1 day ago

Having a field called r#self is malicious madness

[–] mesamunefire@piefed.social 27 points 1 day ago (1 children)

Explicit vs implicit. Ive always liked it being explicit like that. It's better than magic keywords in say ruby.

Personally the "spaces are code" gets on my nerves for the same reason. It's implicit to the language so you just have to remember.

[–] lemming741@lemmy.world 13 points 1 day ago (1 children)

Am I not YAMLy enough for your YAML club?

[–] mesamunefire@piefed.social 8 points 1 day ago

Heh yeah yaml is another one.

[–] kubica@fedia.io 9 points 1 day ago
[–] latenightnoir@lemmy.blahaj.zone 4 points 1 day ago (2 children)

Kinda' looks like how a psychotic break feels:-?

[–] albbi@piefed.ca 5 points 1 day ago* (last edited 1 day ago) (1 children)

Write a new method, make sure to reference self first. Write a new method, make sure to reference self first. Call the method, make sure to reference self first.

Yeah, I can see it.

[–] amos@lemmy.zip 5 points 14 hours ago

You don't reference self when calling a method, what on earth are you talking about? You start with the instance when calling the method, like most/all other OOP languages.

Also there are benefits with the explicit self/this to access instance properties. In C++ you need to make sure all class properties/members have a naming scheme that does not conflict with potential parameter names or other names of other variables.