550
top 30 comments
sorted by: hot top controversial new old
[-] MurdoMaclachlan@lemmy.world 39 points 1 year ago* (last edited 1 year ago)

Image Transcription: Meme


[Four images of toilet roll holders, each with text above them.

The first shows a toilet roll holder holding a partially-used roll of toilet paper. Its text reads, "Non-zero value".

The second shows a holder holding a completely used roll of toilet paper, leaving just the cardboard tube. Its text reads, "0".

The third shows a holder with no toilet roll or cardboard tube on it at all. Its text reads, "null".

The fourth shows no holder; simply plain wall. Its text reads, "undefined".]


I am a human who transcribes posts to improve accessibility on Lemmy. Transcriptions help people who use screen readers or other assistive technology to use the site. For more information, see here.

[-] jeff@programming.dev 15 points 1 year ago

Good human.

[-] MostlyBlindGamer@rblind.com 4 points 1 year ago

Very good human.

[-] Hubi@feddit.de 21 points 1 year ago

Now give me a negative number

[-] Amputret@lemmy.dbzer0.com 5 points 1 year ago

Roll held in under-hanging fashion, with free end against the wall.

[-] sweeny@sh.itjust.works 3 points 1 year ago* (last edited 1 year ago)
[-] RobotToaster@infosec.pub 4 points 1 year ago* (last edited 1 year ago)

while(1){toilet_paper--}

[-] randombit 14 points 1 year ago

In C/C++, undefined should be the meme of the little girl smiling while the house burns down behind her.

[-] nintendiator@feddit.cl 3 points 1 year ago

In C. In C++, the image is zalgoified, corrupted, cropped, lens flared, color-inverted, and for some reason converted to Targa file format.

[-] fart@sh.itjust.works 12 points 1 year ago

not sure the distinction between null and undefined is doing anything for me here

[-] JackbyDev@programming.dev 8 points 1 year ago

Basically JavaScript uses undefined to mean keys that don't exist. You know how sometimes when you're wondering about the semantics of "present but null" and "absent"? It's basically that. Undefined means it isn't there but things are only null if they've been set to null.

There are probably more nuances but that is the gist.

[-] deegeese@sopuli.xyz 7 points 1 year ago

One is missing but has expected values, the other is completely unknown, like an unimplemented function.

[-] ipkpjersi@lemmy.one 3 points 1 year ago

Depends on the programming language. In JavaScript, it literally means that like the key or variable does not actually exist. Whereas like in C/C++, writing random bytes to random memory addresses would result in "undefined behaviour" which means basically anything could happen.

[-] crystal@feddit.de 2 points 1 year ago* (last edited 1 year ago)

In Javascript you can do let a = undefined, defining the variale a as undefined.

A significant difference to defining it as null is that typeof null == "object", while typeof undefined == "undefined".

[-] Speiser0@feddit.de 10 points 1 year ago

I see how you censored at "undefined". Thanks. The actual value could easily kill anyone who sees it.

[-] Gentoo1337@sh.itjust.works 5 points 1 year ago

I knew someone that had the null set tattooed on felt they had made a deeply philosophical statement by doing so.

[-] CanadaPlus 2 points 1 year ago* (last edited 1 year ago)

+INF - a landscape covered in toilet paper out past the horizon. It probably ends, but nowhere you can see.

I have no idea how to represent negatives.

Edit: Subnormals - less than one square is on the roll.

[-] aidan@lemmy.world 2 points 1 year ago

No, at least for JS the picture for undefined should actually be for "not defined" which yes is different. Undefined would be an empty holder without the spool holder.

0 = a 0 value

null = a value that means no value

undefined = the variable doesn't point to a value

not defined = there is no variable or anything

[-] traches@sh.itjust.works 2 points 1 year ago

Rust is neat because it doesn't have the bottom 2

[-] deegeese@sopuli.xyz 2 points 1 year ago

Lack of support for nulls sounds like a huge pain in the ass.

[-] labsin@sh.itjust.works 5 points 1 year ago* (last edited 1 year ago)

It has std:option

So every object that can be None or Some, needs to be checked when used. And only options can be set to None

[-] CanadaPlus 5 points 1 year ago* (last edited 1 year ago)

Yeah it's a bit inaccurate to say it's not supported. It just has edge case handling written explicitly into whatever thing you're building (I assume it's required to do so in order to be well-typed). It took this idea from Haskell, which might have gotten it from Miranda or something.

[-] labsin@sh.itjust.works 2 points 1 year ago

I like the pattern a lot more. It makes you just initialize the value and only keep it 'nullable' for where it's needed and then you need to check. Even .net implemented it (but a bit more awkward)

[-] CanadaPlus 1 points 1 year ago

Yup. Programmers are really stupid, if the compiler forces us to explicitly handle weird situations that's a feature.

[-] lavafroth@programming.dev 3 points 1 year ago

*Laughs in Option*

[-] traches@sh.itjust.works 3 points 1 year ago

It also doesn't have throw/try/catch. If a function can fail, it returns a Result and you have to deal with the failure case explicitly.

[-] csm10495@sh.itjust.works 1 points 1 year ago

Now make one with someone pointing at it for NULL pointer vs tp pointer.

load more comments
view more: next ›
this post was submitted on 06 Jul 2023
550 points (97.6% liked)

Programmer Humor

19623 readers
1 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 1 year ago
MODERATORS