|
jochance wrote: Do you ever really have 0 apples from a weird sort of ship of Theseus-like perspective?Prehistoric man? Pretty sure they know the concept of
"no apples".
jochance wrote: More recently, quantum physics is saying there is no "nothing" and that there is always "quantum foam" that has always been. Physical BS.
Quantum physics a bunch nonsense. Your mom always been fat, because quantum mech says so.
Bastard Programmer from Hell
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
I guess my point was more that while I get the usefulness of bad models, they're still maybe bad in some specifics of practice.
Which is still fine and all. It's not a full and total indictment of concepts. Tons of that self-referential integrity stuff going on in math, yeah?
But most probably do not look at 0/null the same way as they look at other deeper mathematical concepts. It just sits there all happy exactly 1 unit from both -1 and 1. The reality seems to be that you can really never have 0 if you go splitting hairs. That said, it maybe makes it an even more perfect "init" value.
Null though? Null was maybe never destined to be anything but a logical error.
"But I really want to store that something is specifically not known/unknowable!"
"What about all the other stuff you don't even know you don't know?"
"Look, you could've brought this up before we were a decade into RDBMS development. We're keeping it."
"But I didn't know."
"Exactly! And now we can record it!"
|
|
|
|
|
jochance wrote: But most probably do not look at 0/null the same way as they look at other deeper mathematical concepts. Like ALL programmers, I had to deal with floats nearing zero, which is not NULL.
jochance wrote: Null though? Null was maybe never destined to be anything but a logical error. [Coffee] Nope. Let me explain, little padawan;
0 is having no apples.
null is having no concept of apples.
Bastard Programmer from Hell
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
And here I might've supposed you'd want people talking less about things they have no concept of.
What's really important is the ability to dictate to the apple that it is inferior, and they mostly left that out altogether.
lol
|
|
|
|
|
jochance wrote: What's really important is the ability to dictate to the apple that it is inferior, and they mostly left that out altogether. That makes no sense at all.
Pears are superior tough
Bastard Programmer from Hell
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Zero and null are not remotely the same thing. Zero is a value like any other. Null is the absence of any value, "undefined" if you like.
|
|
|
|
|
In C zero and NULL are very much the same thing.
|
|
|
|
|
And so is the color black (assuming an RGB color space).
Or anything else represented as binary zeroes in your favorite computer architecture. That two values of completely different semantics have identical same internal representations doesn't imply that the two values are "very much the same thing" - if you just overlook the type/class information.
In an OO world, any object instance, regardless of class, having a single member which is set to some value represented as all bits reset is also very much the same thing as a numeric zero. Or a null pointer. If you ignore its semantics, the way you do to claim that zero and null are very much the same thing.
|
|
|
|
|
What I actually said was
Quote: In C zero and NULL are very much the same thing. Not that zero and null are the same everywhere.
|
|
|
|
|
We're both right. You're referring to an implementation, I was referring to the concept, the abstraction if you like, where null represents "value unknown" (or "not yet defined").
|
|
|
|
|
Exactly why I prefaced my remark "In C", to make it clear that I was talking about a specific situation.
|
|
|
|
|
In JavaScript, undefined and null are two distinct values. The former meaning not defined and the latter meaning no value. Different concepts completely.
Jeremy Falcon
|
|
|
|
|
Education.
And yes, lack of is a common problem.
Bastard Programmer from Hell
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Addresses of other addresses boggles the mind; until you get the hang of it.
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|
Give freedom back to 'NULL' to exist.
If not: Dear c# designers, please then remove the possibility to define nullable types
|
|
|
|
|
The problems are not about nullable types. Thay are about ordinary references being null.
|
|
|
|
|
There is a bridge joining the two buildings in our location. Any "developer" whose code crashes in production because of a bad pointer gets hanged from the bridge pour encourager les autres.
So no, this is not a common problem.
Seriously, all the developers I work with (even the young 'uns) know what a null reference is, and know to avoid it
Freedom is the freedom to say that two plus two make four. If that is granted, all else follows.
-- 6079 Smith W.
modified 5-Mar-23 12:05pm.
|
|
|
|
|
Quote: Seriously, all the developers I work with (even the young 'uns) know what a null reference is, and know to avoid it
Same here. All the young serious developers I'm working with, know how to handle it.
|
|
|
|
|
0x01AA wrote: Same here.
Here too.
"If we don't change direction, we'll end up where we're going"
|
|
|
|
|
Richard MacCutchan wrote: Do those of you who still work in teams find this is a common problem with younger team members?
Yes, all the time. I almost think it is something you have to learn the hard way, because in my experience, most are not aware of this as they code.
Now, new IntelliSense with VS 2022 and ReSharper will point this out/alert you right away when it happens, but still, everyone should grok this concept.
|
|
|
|
|
A guy on the team I just joined was somewhat miffed about the whole nullable feature in C#. He had learned in university that object oriented languages had nullable references. And C# is an object oriented language... so obviously we could not force references to have values.
|
|
|
|
|
Richard, this is a problem of perception, you seem to think anyone who posts in Q&A is a "developer". Most are probably just learning (and you are their teaching resource) and a lot of them are code monkeys at best.
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
trønderen has also said it well.
Even the C language has confusion on this topic.
Yes, I too believe that they have distinct meanings.
Remember my posing the question of why is this a valid statement in C
zero = 0;
value = malloc( zero );
value is not null nor zero.
Why would I want to allocate zero memory?
Here is what ChatAI says
In the C programming language, calling malloc(0) is allowed and returns a pointer to a memory block of size 0. This is specified in the C standard, which states that malloc(0) is equivalent to malloc(1).
The reason for this behavior is that malloc is intended to allocate memory dynamically, and a request for 0 bytes of memory is considered a valid request. Allocating a block of memory with a size of 0 can be useful in certain situations, such as when you want to create a zero-length array or when you want to allocate memory that you will later reallocate to a different size using realloc.
However, it is important to note that malloc does not guarantee that it will return a pointer to a block of memory that is truly 0 bytes in size. The implementation of malloc may choose to return a block of memory that is larger than the requested size, in which case the additional memory will not be accessible to your program.
Clear as mud.
"A little time, a little trouble, your better day"
Badfinger
|
|
|
|
|
Forgive my ignorance, but what is the point or purpose of a zero length array?
Or at the lower level, reserving zero memory space?
|
|
|
|
|
To declare that it is known, but has a zero length value.
E.g. if my middle name is a zero length string, null, it is known that I have no middle name. If it is null, I may have a middle name not yet entered into the database.
|
|
|
|