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.
Very good human.
Good human.
In C/C++, undefined should be the meme of the little girl smiling while the house burns down behind her.
In C. In C++, the image is zalgoified, corrupted, cropped, lens flared, color-inverted, and for some reason converted to Targa file format.
Now give me a negative number
lmao good one
I see how you censored at “undefined”. Thanks. The actual value could easily kill anyone who sees it.
Rust is neat because it doesn’t have the bottom 2
Lack of support for nulls sounds like a huge pain in the ass.
*Laughs in Option<T>*
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.
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
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.
not sure the distinction between null and undefined is doing anything for me here
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.
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.
In Javascript you can do
let a = undefined
, defining the varialea
asundefined
.A significant difference to defining it as
null
is thattypeof null == "object"
, whiletypeof undefined == "undefined"
.