Does ‘ null ‘ in programming languages actually mean zero/blank or does it have a default value instead of zero?

‘ Null ‘.

The inventor, Tony Hoare, does not call his Billion Dollar Mistake.

Before we can dive in, first a bit of background.

Disclaimer: My background is C# so my explanation is based on this.

You have two types of variables.ValueTypes and Reference types.

For example, Value types are numbers.The Int32 type in C# cannot be the value “NULL” because it is a valuetype.

An object is a Reference type, and it can have a value of NULL.

How about this? If you pick up a valuetype from memory you get the real value.If you retrieve a reference type from memory you will not get the value but a reference where in memory the reference type is.

Long story short: a Reference type does not refer to a valuetype.

Here is a piece of code

Person person; \nint age = 40; \n

The variable person refers to a piece of memory.The variable Age contains the value 40.

‘ Person ‘ now refers to ‘ null ‘, there is nothing left.

person = new person (); \n

Now an instance of the class ‘ person ‘ is put on the spot in memory and the variable ‘ person ‘ then refers.

ADDENDUM: The misery of ‘ null ‘

This has nothing to do with your question, but most people don’t stop what a horror is an implicit ‘ null ‘ value.

‘ Null ‘ helps your typing system to soap.Take this code:

public void Zetage (person person) \n{\n\tperson. Age = 40; \n}\n

How do you know if ‘ person ‘ refers to ‘ null ‘ or to an instance of ‘ person ‘?

Not, you have to check if you have to set up your code so that it does not ‘ can ‘ occur.Actually, you need to write your code so:

public void Zetage (person person) \n{\n\tif (person! = null) \n\t{\n\t\tperson. Age = 40; \n\t}\n}\n

This way you can be sure you don’t get a null reference exception on your ears at runtime.However, this is an extra check and therefore work for the CPU. So your code is less efficient. So, do you program defensively and check each reference type that enters a method?

I like the rule: at public do not, at private .

private void Zetage (person person) \n{\n\tperson. Age = 40; \n}\n

After all, with a private method you know exactly where the call is coming today and so you can limit your checks to the public API.

But yeah… So can also:

public void Zetage (person person) \n{\n\tperson. Age = 40; \n}\n

Someone wants the method to happen somewhere else, turn it on public, forget the null check and BOOM!Null-Reference exception in an edge case.

This makes ‘ null ‘ so dangerous.The compiler cannot fish for you.

In a programming language, “NULL” is referred to as an absence of value.So ‘ empty ‘ is a good indication. Often an implementation is so that it points to the ‘ zero ‘ memory address.

Not all data types in a programming language do not have a value of “nonexistent”. Take a programming language like C and suppose you have a number with value ‘ 0 ‘ there, then this is the concrete number zero.In C You can also have a reference to such a number, a pointer. It then refers to the memory address of the number, where the reference to this memory address can have a value of ‘ 0 ‘ for the concrete number zero. However, the reference is not ‘ 0 ‘.If the reference itself Is ‘ 0 ‘, it indicates that the number has no value.

Based on this, you could apply the semantics of your application for specifically the case with and without value, other than that the number does have a value, but this is, for example, ‘ 0 ‘.

Maybe somewhat vague, but I hope it becomes a bit clearer.

In some programming languages, it is an empty list, which has a fixed memory address, so that only one empty list can exist.

In logical programming, it can be ‘ not ‘ or ‘ false ‘ in some languages.

Also, the number 0 can be indicated in English with the word “null”.

This is how you see various applications.There are more.

I have ten frogs in a wheelbarrow.
During my ride one jumps out, then here, then there.10, 9, 8,…
I don’t stop them back, too much hassle.At a given moment the last frog jumps out. Then there are no more frogs the wheelbarrow.

If we see the frogs as an arithmetic series, then we see 10, 9, 8,… 2, 1, 0.
The value 0 here is the representation of “no frogs”.

But suppose I had a different purpose.Namely making a dish with frog legs. Then I can make one dish less with every frog that jumps out, but if the last frog jumps out, making the dish is no longer possible. Where 0 “No frogs” means I notice here “the operation I want to carry out is no longer possible”.
If you are going to calculate the turnover, however, you can still do 0 frogs x 9.99 = 0, I have not sold any frog legs.

In A programming language it is therefore important to ask yourself what you want to do with that “operation is no longer possible” situation.Do you want to serve chicken, or do you close your restaurant today?
If you do not handle this properly, and you would be going to edit “0” frogs, there might also be some.However, all the other ingredients were present. But the dish does not contain frog legs.
This is potentially hugely dangerous, and therefore you want this situation as “operation is no longer possible”, either “null” is denoted and not as 0.

null or in other languages None indicates that there is no value, and not that the value is 0.

Example, in Python is “” Not equal to None.

There is not as something as a ‘ standard NULL ‘ in programming languages, because each programming language implements ‘ null ‘ differently and this also often differs from data type to data type.

But NULL is not 0. It is a ‘ not value ‘.

I think it’s best to compare with a sheet of paper.I get the assignment (and this time I’m not stubborn, and about this out) to fill in a figure here.

At the moment I have not completed anything, there is nothing.In a programming language that would be NULL. I have yet to meet my condition -completing a digit -met.

At the moment I import 0 here, there is something.So I did nicely, what I had to do.

Therefore, NULL and 0 are two different values.How different languages implement “NULL” is specific to that language and less important for understanding the NULL value.

Null means: No value (none)

Anything other than NULL means: has a value.

There is a difference between null and 0.

0 represents a value, not null.

Therefore, when a programmer chooses to use variables that may be empty (have no value), they may be null.

If there is a choice that requires variables to have a value, they cannot be null, and can only be given a default value, such as e.g.0 for a number, or ‘ ‘ for a text/string, or 1 -1 -1980 for Eem date for example.

In the world of computers, ‘ null ‘ can surprisingly mean a lot of things quite different.

One byte can display a number between 0 and 255.A byte with a value of 0 is sometimes called null. This happens when the 0 also really means 0, so if the byte is part of a numeric number. But bytes are also used to display letters and symbols, usually according to the so-called ASCII table, in which eg. 65 The letter A is, 32 a space, 50 is the symbol 3, etc. And the number 0 is in the ASCII table for the character “Zero” (this is English so it has nothing to do with the Dutch word zero). This is a sign that does not really exist and that can therefore be used to indicate the end of a text.

Another meaning of NULL (now with double L) is when using pointers, something that occurs in particular in third-generation languages such as C++.The term pointer is used when data is stored through an additional intermediate step. So instead of storing the value of something in the normal location, you save the address from a different location in the normal location and then the value is saved. This seems awkward, but has been very useful since. For example, if you do not know how long data can be, you can put a pointer (which always has a fixed length) in the normal location. Or if you have a series of data, you can refer the first one via a pointer to the second, which is again to the third, etc (a so-called pointer chain, also called a linked list). In all cases where pointers are used, there must be a way to indicate that the pointer does not refer to a value, e.g. because a variable has not been set to a value, or because the end of a linked list has been calibrated. This method is called the null pointer (also referred to as NIL).

Yet another meaning is if you work with lists of data.Suppose you have a system with information about your staff. From each employee you save all sorts of data such as name, address, salary, but also which programming languages the employee knows. One knows many programming languages, the other knows only one, so you save it as a list or collection. But Henk van de accounting knows no programming language so for him that list is empty. This is sometimes called null. (Although empty set, English for empty collection, is more common).

In object-oriented languages (e.g. C#) you can store a whole object in a variable.Suppose you program a game, so you don’t have to use all sorts of separate variables for the spot of your doll on the screen, his speed, active weapon, health and all that kind of thing more; You use one variable that contains an object where all the data of your Puppet is collected. And if a second player wants to participate, you can use a second variable with all that data of a second doll. For the programmer this is much easier because der computer does a lot of work itself. In this context, NULL is for an object that is already a variable, but where the computer does not yet have the extra work done it needs to use the object safely. The object has not yet been initialized (uninitialized), or null.

And then there is still the NULL of relational databases.Again another. And because application software often uses relational databases, this NULL is also included in the application and a programmer should understand it. The NULL of the relational database is very precisely defined in the ANSI standard for the SQL language, but unfortunately there is a lot of confusion and misinformation in circulation. NULL means nothing more and nothing less than “This is not information”. If you have a table for your customers and one column is for birth date then you can’t have it for some rows and for others. So he’s in every row and NULL means you don’t actually have him for that row anyway. The result is that you do not know the date of birth of that customer. This often suffers from the statement that NULL means the same as unknown but that is not true. You could have a business as a customer and then the date of birth does not apply to that customer. Or maybe the date Of birth is well known but you do not have access to that information and are therefore not passed on to you. NULL in a relational database means nothing more and nothing less than “no value”.

In the programming, the number is called 0 zero or maybe nought, but not NULL or VOID.Not to be confused with ‘ ZERO ‘, which denozes the ASCII symbol with number 0, not to be confused with ‘ 0 ‘, which denozes the ASCII symbol with number 48. ‘ ZERO ‘ and ‘ DEL ‘ are usually ignored except in C strings.

In different languages, NULL or NIL or NONE is used to indicate a pointer to nothing, which, for example, can indicate the end of a linked list, such as ZERO indicating the end of a string.

In Other languages, for example, SQL, is denoted NULL to indicate that a variable or attribute has no value, for example if you don’t know a person’s gender and “M” or “V” are the only allowed values.

Compare this with the code NaN, which means ‘ not a number ‘, which you can get, for example, by pulling the root out of a negative number.

Furthermore, you might think of an empty set or a data type with 0 valid values (such as the ‘ Boolean ‘ type 2 values: ‘ True ‘ and ‘ false ‘).


Leave a Reply