This was intended as a meme but is actually a good representation of what "Null" is. In C#, when you declare string s = "My shit"; it means that "s" is a reference to a memory location that holds the data "My shit". string s = null; means that the reference "s" exists but it's not pointing to any object, as in it holds nothing. Answer from abd53 on reddit.com
🌐
freeCodeCamp
freecodecamp.org › news › a-quick-and-thorough-guide-to-null-what-it-is-and-how-you-should-use-it-d170cea62840
A quick and thorough guide to ‘null’: what it is, and how you should use it
June 12, 2018 - Note: Some programming languages (mostly functional programming languages like Haskell) don’t support the concept of null. Instead, they use the Maybe/Optional Pattern to represent the ‘absence of a value’. The compiler ensures that the ‘no value’ case is handled explicitly. Hence, null pointer errors cannot occur. ... If a reference points to null, it always means that there is no value associated with it.
Discussions

Why is there a NULL in the C language? - Stack Overflow
Same as we use definitions instead of "raw" values or expressions or human readable variable names like loopCounter instead of p755_x. ... No, NULL is beneficial for compilers as well. If, for some int *x, a programmer means to write x = null pointer; but types *x = null pointer;, the compiler ... More on stackoverflow.com
🌐 stackoverflow.com
language agnostic - What is the purpose of null? - Stack Overflow
I am in a compilers class and we are tasked with creating our own language, from scratch. Currently our dilemma is whether to include a 'null' type or not. What purpose does null provide? Some of our More on stackoverflow.com
🌐 stackoverflow.com
tsql - How can I explain the difference between NULL and zero? - Software Engineering Stack Exchange
It is like an empty cell on a sheet of graph paper. A cell can have a "0" in it, but it can also be empty. Null is still a value, but you have deemed it special. For example if your cells were now characters, you may use the empty cell as a space and a null cell is no longer possible unless you designate or create a character to be the special case. What null means depends on how the the data is interpreted: Null data may mean "not yet provided", and a program ... More on softwareengineering.stackexchange.com
🌐 softwareengineering.stackexchange.com
February 13, 2012
What is Null?
This was intended as a meme but is actually a good representation of what "Null" is. In C#, when you declare string s = "My shit"; it means that "s" is a reference to a memory location that holds the data "My shit". string s = null; means that the reference "s" exists but it's not pointing to any object, as in it holds nothing. More on reddit.com
🌐 r/learnprogramming
60
34
July 5, 2024
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Glossary › Null
Null - Glossary | MDN
In computer science, a null value represents a reference that points, generally intentionally, to a nonexistent or invalid object or address. The meaning of a null reference varies among language implementations.
🌐
Wikipedia
en.wikipedia.org › wiki › Null_function
Null function - Wikipedia
June 6, 2025 - In computer science, a null function (or null operator) is a subroutine that leaves the program state unchanged. When it is part of the instruction set of a processor, it is called a NOP or NOOP (No OPeration).
🌐
W3Schools
w3schools.com › c › c_null.php
C NULL
NULL is a special value that represents a "null pointer" - a pointer that does not point to anything.
🌐
Khoury College of Computer Sciences
khoury.northeastern.edu › home › kenb › MeaningOfNull.html
The Meaning of Null in Databases and Programming Languages
The main distinction between the relational null and the programming language null is the following: The relational null represents the absence of a value in a field of a record; whereas the programming language null represents one of the possible values of a variable.
Find elsewhere
🌐
Wikipedia
en.wikipedia.org › wiki › Null_(SQL)
Null (SQL) - Wikipedia
January 7, 2026 - In a database table, the column reporting this answer would start with no value (marked by null), and it would not be updated with the value zero until it is ascertained that Adam owns no books. In SQL, null is a marker, not a value. This usage differs from most programming languages, where a null value of a reference means it is not pointing to any object.
🌐
ThoughtCo
thoughtco.com › definition-of-null-958118
What Does Null Mean in Computer Programming?
April 27, 2019 - Null is a constant built into C, C++, and C#. It has a value of zero. Null can also be the value of a pointer that points nowhere.
🌐
Quora
quora.com › What-is-the-reason-for-using-the-term-null-values-instead-of-zero-or-none-in-programming
What is the reason for using the term 'null values' instead of 'zero' or 'none' in programming? - Quora
Answer (1 of 3): You will sometimes hear or see it referenced as none, but vary rarely as zero. Mostly this is convention, but you have different data types and for Numerical values zero is perfectly valid. When discussing a program you often discuss the variables as well as the data they contain...
Top answer
1 of 5
7

Actually, you can use a literal 0 anyplace you would use NULL.

Section 6.3.2.3p3 of the C standard states:

An integer constant expression with the value 0, or such an expression cast to type void *, is called a null pointer constant. If a null pointer constant is converted to a pointer type, the resulting pointer, called a null pointer, is guaranteed to compare unequal to a pointer to any object or function.

And section 7.19p3 states:

The macros are:

NULL

which expands to an implementation-defined null pointer constant

So 0 qualifies as a null pointer constant, as does (void *)0 and NULL. The use of NULL is preferred however as it makes it more evident to the reader that a null pointer is being used and not the integer value 0.

2 of 5
5

NULL is used to make it clear it is a pointer type.

Ideally, the C implementation would define NULL as ((void *) 0) or something equivalent, and programmers would always use NULL when they want a null pointer constant.

If this is done, then, when a programmer has, for example, an int *x and accidentally writes *x = NULL;, then the compiler can recognize that a mistake has been made, because the left side of = has type int, and the right side has type void *, and this is not a proper combination for assignment.

In contrast, if the programmer accidentally writes *x = 0; instead of x = 0;, then the compiler cannot recognize this mistake, because the left side has type int, and the right side has type int, and that is a valid combination.

Thus, when NULL is defined well and is used, mistakes are detected earlier.

In particular answer to your question “Is there a context in which just plain literal 0 would not work exactly the same?”:

  • In correct code, NULL and 0 may be used interchangeably as null pointer constants.
  • 0 will function as an integer (non-pointer) constant, but NULL might not, depending on how the C implementation defines it.
  • For the purpose of detecting errors, NULL and 0 do not work exactly the same; using NULL with a good definition serves to help detect some mistakes that using 0 does not.

The C standard allows 0 to be used for null pointer constants for historic reasons. However, this is not beneficial except for allowing previously written code to compile in compilers using current C standards. New code should avoid using 0 as a null pointer constant.

Top answer
1 of 16
49

Null: The Billion Dollar Mistake. Tony Hoare:

I call it my billion-dollar mistake. It was the invention of the null reference in 1965. At that time, I was designing the first comprehensive type system for references in an object oriented language (ALGOL W). My goal was to ensure that all use of references should be absolutely safe, with checking performed automatically by the compiler. But I couldn't resist the temptation to put in a null reference, simply because it was so easy to implement. This has led to innumerable errors, vulnerabilities, and system crashes, which have probably caused a billion dollars of pain and damage in the last forty years. In recent years, a number of program analysers like PREfix and PREfast in Microsoft have been used to check references, and give warnings if there is a risk they may be non-null. More recent programming languages like Spec# have introduced declarations for non-null references. This is the solution, which I rejected in 1965.

2 of 16
32

null is a sentinel value that is not an integer, not a string, not a boolean - not anything really, except something to hold and be a "not there" value. Don't treat it as or expect it to be a 0, or an empty string or an empty list. Those are all valid values and can be geniunely valid values in many circumstances - the idea of a null instead means there is no value there.

Perhaps it's a little bit like a function throwing an exception instead of returning a value. Except instead of manufacturing and returning an ordinary value with a special meaning, it returns a special value that already has a special meaning. If a language expects you to work with null, then you can't really ignore it.

🌐
Quora
quora.com › What-does-NULL-mean-in-programming-languages
What does NULL mean in programming languages? - Quora
Answer (1 of 6): null is the pointer or reference to address zero. Why would this be needed or used? Let’s say you are searching for a library book that you want to read. Unlike Amazon, your library doesn’t have every book.
🌐
Wikipedia
en.wikipedia.org › wiki › Null_object_pattern
Null object pattern - Wikipedia
October 20, 2025 - In object-oriented computer programming, a null object is an object with no referenced value or with defined neutral (null) behavior. The null object design pattern, which describes the uses of such objects and their behavior (or lack thereof), was first published as "Void Value" and later ...
Top answer
1 of 16
104

To explain to a boss the difference between "zero" and "null":

"Zero" is a value. It is the unique, known quantity of zero, which is meaningful in arithmetic and other math.

"Null" is a non-value. It is a "placeholder" for a data value that is not known or not specified. It is only meaningful in this context; mathematical operations cannot be performed on null (the result of any such operation is undefined, and therefore also generally represented as null).

For example, as in the comments: "What is your yearly income?" is a question requiring a numeric answer. "0" is a perfectly valid answer for someone who does not work and has no investment income. If the user does not enter a value at all, they don't necessarily make no money; they just didn't want to tell your software how much (or little) they make. It's an unknown, not specified; therefore, to allow the software to continue, you specify the "null" placeholder for that data field within the software. That's technically valid from a data perspective; whether it's valid at the business level depends on whether an actual numeric value (even zero) is required in order to perform a mathematical operation (such as calculation of taxes, or comparison with thresholds determining benefits).

In computers, virtually any operation on a variable containing null will result either in null or in an error condition, because since one of the variable's values is not known, the result of the expression cannot be known. The equivalent of performing math on null would be if I asked you "What's five plus the number I'm thinking of right now?". It's impossible for you to give a definite answer because you don't know the number I'm thinking of. An operation on zero, except for dividing by it, is usually valid and will return another known, unique value.

2 of 16
174

Boss-speak is always tough...

Zero is a number so you can do things with it.

Null is a unicorn. It doesn't exist so you can't do anything at all with it.

🌐
Wordpress
basicsofwebdevelopment.wordpress.com › 2014 › 07 › 03 › what-is-a-null-error-in-code-execution
What is a null error in code Execution | Learn the basics of the Web and App Development
June 7, 2015 - Null means that the object doesn’t exist. If you read this MSDN post, you will get the understanding of the concept of null, how they’re created in programming, how they’re a cause of an error in programming.
🌐
GeeksforGeeks
geeksforgeeks.org › c language › null-pointer-in-c
NULL Pointer in C - GeeksforGeeks
The Null Pointer is the pointer that does not point to any location but NULL.
Published   January 10, 2025
🌐
Quora
quora.com › What-is-the-definition-of-null-in-computer-science-Why-is-it-considered-as-a-special-value-or-state-for-variables-and-arrays
What is the definition of 'null' in computer science? Why is it considered as a special value or state for variables and arrays? - Quora
NULL generally is the value given to something that is “missing”. For example, in databases a value could be a boolean (TRUE or FALSE) but if the value was missing or unknown, we might also allow NULL.
🌐
Upwork
upwork.com › resources › articles › {name}
Null in Java: Understanding the Basics - Upwork
August 5, 2024 - In Java, null is a literal used to denote the absence of an object. It is strictly typed, meaning it can only be assigned to reference types. Null checks are a common practice to prevent NullPointerExceptions, which can crash the program if ...