this post was submitted on 08 Jun 2025
304 points (97.2% liked)

Programmer Humor

24709 readers
314 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
 
all 15 comments
sorted by: hot top controversial new old
[–] TootSweet@lemmy.world 26 points 3 weeks ago (1 children)
[–] mindbleach@sh.itjust.works 21 points 3 weeks ago (1 children)

"We wanted it to work like Perl," said someone who should have been killed on the spot.

[–] palordrolap@fedia.io 9 points 3 weeks ago (1 children)

At the time JS was created, Perl didn't have a this. A lot of the docs and books suggested using $self but a reference to the object would be passed as the first parameter to all class methods and you assign that to any name you wanted.

It's only very recently (as in the last year or so) with a new class system that Perl has hard-coded $self for that purpose.

[–] mindbleach@sh.itjust.works 4 points 3 weeks ago (1 children)
[–] palordrolap@fedia.io 2 points 3 weeks ago

Ah. The usually implicit topical "this" didn't even occur to me because I thought, er, this, was about objects. $_ isn't used for those in Perl.

I suppose there might be some parallels with the implicit nature of $_ in non-OO contexts in Perl versus this in OO contexts in Javascript, but, at least to me, that feels pretty tenuous.

[–] nnullzz@lemmy.world 12 points 3 weeks ago

Yeah, this is that.

[–] sourhill@lemmy.sdf.org 12 points 3 weeks ago
const that = this;
[–] fnrir@lemmy.blahaj.zone 8 points 3 weeks ago (1 children)

Rust: do you mean Self or self?

[–] d_k_bo@feddit.org 6 points 3 weeks ago* (last edited 3 weeks ago)

this is commonly used with a similar meaning to self in cases where self can't be used because it is a reserved keyword.

Example:

    fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<St1::Item>> {
        let this = self.project();
        this.inner.poll_next(cx)
    }

https://github.com/rust-lang/futures-rs/blob/master/futures-util/src/stream/select.rs#L113-L116

[–] verstra@programming.dev 6 points 3 weeks ago

Any language feature with such a long definition is a bad language feature.

The less such features, the better the language.

Thus, javascript is not a "good" language for expressing your programs.

[–] Justas@sh.itjust.works 5 points 3 weeks ago

let self = this;

[–] Strawberry@lemmy.blahaj.zone 2 points 3 weeks ago

I did not know that about event handlers, that is actually super convenient

[–] AnotherPenguin@programming.dev 1 points 3 weeks ago (1 children)

In python self is just a convention, you can call it whatever you want :)

[–] aubeynarf@lemmynsfw.com 1 points 4 days ago

and don’t ever pull the mask off by reading the descriptor and meta object protocol.