In school, I worked primarily with Java, C, and Python. Now that I’m working, I am working with .Net all of the time. Occasionally I have to work on Visual Basic projects which has been an enjoyable learning experience but I seem to get hung up on a few things from time to time. One of my main problems comes from the fact that Visual Basic uses Nothing instead of null as in C# and F#.
Nothing and null, to me, seem to be basically the same with the exception that a non-nullable value type can be set to Nothing in Visual Basic and the value will be set to its default value (i.e. 0 for an Integer). In C#, if a non-nullable value type is set to null there will be a compile-time error. Having the default value of data types be but making created types Nullable and setting values to DBNull.Value for working with databases throws me off. It’s not intuitive switching to Nothing from null. I looked at the IL code of setting a string to null/Nothing in both C# and VB and each time it set the string to ldnull. So is there any underlying reason as to why Visual Basic uses Nothing instead of null as other .Net languages do?
tl;dr Why does Visual Basic use Nothing instead of null?
Remember that VB is based on the original Basic, which is intende to be truly BASIC, easily understood by someone who is not a programmer.
If you try to explain to a non-programmer that what a value is, which makes more sense.
“The value of X is Nothing”
or
“The value of X is null” –> Leads to “Huh”? What the heck is NULL??