Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. Why do so many "developers" not understand 'null'?

Why do so many "developers" not understand 'null'?

Scheduled Pinned Locked Moved The Lounge
helpsharepointcollaborationbeta-testingtutorial
61 Posts 36 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Lost User

    I have just gone through four QA questions, each of which is an error caused by a null reference. And yet none of the posters seems to have any idea a) how to diagnose and fix it, or b) even what the error means. Do those of you who still work in teams find this is a common problem with younger team members?

    J Offline
    J Offline
    jmaida
    wrote on last edited by
    #22

    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

    H 1 Reply Last reply
    0
    • L Lost User

      I have just gone through four QA questions, each of which is an error caused by a null reference. And yet none of the posters seems to have any idea a) how to diagnose and fix it, or b) even what the error means. Do those of you who still work in teams find this is a common problem with younger team members?

      J Offline
      J Offline
      jmaida
      wrote on last edited by
      #23

      Excellent topic.

      "A little time, a little trouble, your better day" Badfinger

      1 Reply Last reply
      0
      • L Lost User

        I have just gone through four QA questions, each of which is an error caused by a null reference. And yet none of the posters seems to have any idea a) how to diagnose and fix it, or b) even what the error means. Do those of you who still work in teams find this is a common problem with younger team members?

        Sander RosselS Offline
        Sander RosselS Offline
        Sander Rossel
        wrote on last edited by
        #24

        It seems to me not only null is the problem, but programming knowledge in general. Throughout my career I've seen very bad code by very "experienced" people. Not just the young kids, but the old farts too. It's so bad I'm now convinced that about 90% of the people are just plain bad at their job :sigh:

        Best, Sander Azure DevOps Succinctly (free eBook) Azure Serverless Succinctly (free eBook) Migrating Apps to the Cloud with Azure arrgh.js - Bringing LINQ to JavaScript

        1 Reply Last reply
        0
        • L Lost User

          I have just gone through four QA questions, each of which is an error caused by a null reference. And yet none of the posters seems to have any idea a) how to diagnose and fix it, or b) even what the error means. Do those of you who still work in teams find this is a common problem with younger team members?

          C Offline
          C Offline
          CPallini
          wrote on last edited by
          #25

          Because there's null to understand.

          "In testa che avete, Signor di Ceprano?" -- Rigoletto

          1 Reply Last reply
          0
          • L Lost User

            I have just gone through four QA questions, each of which is an error caused by a null reference. And yet none of the posters seems to have any idea a) how to diagnose and fix it, or b) even what the error means. Do those of you who still work in teams find this is a common problem with younger team members?

            D Offline
            D Offline
            den2k88
            wrote on last edited by
            #26

            Nobody teaches to use a debugger, a real one at least. For my first months in the real World I debugged with printf - I did image analysis. Debugging imaging algorithms by printing 1024x1024 tables of numbers? I did that. One of my dreams is to get a teaching position in CS. I will not let anybody out of the room until they learn to place breakpoints and use the watch window.

            GCS/GE d--(d) s-/+ a C+++ U+++ P-- L+@ E-- W+++ N+ o+ K- w+++ O? M-- V? PS+ PE Y+ PGP t+ 5? X R+++ tv-- b+(+++) DI+++ D++ G e++ h--- r+++ y+++*      Weapons extension: ma- k++ F+2 X

            1 Reply Last reply
            0
            • L Lost User

              I have just gone through four QA questions, each of which is an error caused by a null reference. And yet none of the posters seems to have any idea a) how to diagnose and fix it, or b) even what the error means. Do those of you who still work in teams find this is a common problem with younger team members?

              M Offline
              M Offline
              Martijn Smitshoek
              wrote on last edited by
              #27

              Depends on the definition of "young" ;P But, seriously, I see so many powers that be in a high tech company internalize their fears of mistakes by programmers who simply don't get the deeper meaning of a sort-of tri-state logic, so that when when you apply it correctly, you're going to get smacked by individuals who wallow in this fearmongering mindset. Thinking, "if I can't comprehend this to treat the information properly and make a mess, I'm going to force you into that same fear, so that I won't look incompetent and alone". The real issue though, is the hiring policy. Like, who the ***k hired you, and worse, who made you the boss around here? Do you have more skeletons in the closet regarding your pretend-strong, feeble character? Ok I digress. But if you lack the technical grid to understand what your responsibility is towards the state of a variable, you should really be looking for another job. No wonder IT systems have so many vulnerabilities.

              1 Reply Last reply
              0
              • L Lost User

                I read somewhere, years ago, that zero/nothing is one of the most difficult concepts for the human brain to understand. I think it was suggested that that was why there is no zero in Roman numerals.

                H Offline
                H Offline
                haughtonomous
                wrote on last edited by
                #28

                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.

                L J 2 Replies Last reply
                0
                • H haughtonomous

                  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.

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #29

                  In C zero and NULL are very much the same thing.

                  T 1 Reply Last reply
                  0
                  • L Lost User

                    I have just gone through four QA questions, each of which is an error caused by a null reference. And yet none of the posters seems to have any idea a) how to diagnose and fix it, or b) even what the error means. Do those of you who still work in teams find this is a common problem with younger team members?

                    G Offline
                    G Offline
                    giulicard
                    wrote on last edited by
                    #30

                    This happens because young programmers learn (at first) languages like python, C#, or other high-level languages right away. Old farts like me have had to put up with C, if not even assembly language. At least on K&R, it is explained what a null pointer is, although my favorite chapter is the one where complicated declarations (which are not complicated at all) are described. It's fine to learn high-level languages right away, but don't we want to take a look at how things work internally? Maybe with the help of the old, decrepit, and "very dangerous" C? I'm not saying to delve into Assembly ... C is sufficient. I am always amazed when I see young computer science students get stunned when I tell them about the two's complement. Old languages may be old and decrepit (though still widely used), but they would still be very useful for many people. To be picky, even high-level languages run on hardware whose principles are still those of John von Neumann's architecture, evolved or not. Many people would still have a lot to learn from "very very very ugly and dangerous" languages like C. And I don't find anything complicated or difficult to understand in malloc(0) either. It must be because I am an old fart. Cheers

                    L 1 Reply Last reply
                    0
                    • G giulicard

                      This happens because young programmers learn (at first) languages like python, C#, or other high-level languages right away. Old farts like me have had to put up with C, if not even assembly language. At least on K&R, it is explained what a null pointer is, although my favorite chapter is the one where complicated declarations (which are not complicated at all) are described. It's fine to learn high-level languages right away, but don't we want to take a look at how things work internally? Maybe with the help of the old, decrepit, and "very dangerous" C? I'm not saying to delve into Assembly ... C is sufficient. I am always amazed when I see young computer science students get stunned when I tell them about the two's complement. Old languages may be old and decrepit (though still widely used), but they would still be very useful for many people. To be picky, even high-level languages run on hardware whose principles are still those of John von Neumann's architecture, evolved or not. Many people would still have a lot to learn from "very very very ugly and dangerous" languages like C. And I don't find anything complicated or difficult to understand in malloc(0) either. It must be because I am an old fart. Cheers

                      L Offline
                      L Offline
                      Lost User
                      wrote on last edited by
                      #31

                      So true. I started with machine code and progressed to Assembler, and thence to high level languages. I still think C is the most elegant and easy to learn of all.

                      giulicard wrote:

                      It must be because I am an old fart.

                      Ha, ha; you and me both.

                      1 Reply Last reply
                      0
                      • L Lost User

                        It isn't. I have one apple in my hand. How much do you have in yours? Even prehistoric hunters came back with "zero". There's no 0 in Roman Numerals because it would not make sense to count nothing. A farmer that owes no taxes gets ignored, they counted what was owed. "Zero" would have no use there; even if that is the return of your hunting trip, 0 is not recorded. Writing is too precious to record zero's.

                        Bastard Programmer from Hell :suss: "If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.

                        J Offline
                        J Offline
                        jochance
                        wrote on last edited by
                        #32

                        Do you ever really have 0 apples from a weird sort of ship of Theseus-like perspective? Some cultures lack that sort of integer concept from a similar view... all apples are not created equal. No point talking about N of them as the potential distance from reality only increases the further from 1 you get. Forget apples to oranges, they don't even do apples to apples. More recently, quantum physics is saying there is no "nothing" and that there is always "quantum foam" that has always been. Maybe the young ones are so much smarter they look dumb. Nahhh haha. But maybe sending null across a wire as a matter of course is a little bit dumb too.

                        L 1 Reply Last reply
                        0
                        • L Lost User

                          I have just gone through four QA questions, each of which is an error caused by a null reference. And yet none of the posters seems to have any idea a) how to diagnose and fix it, or b) even what the error means. Do those of you who still work in teams find this is a common problem with younger team members?

                          M Offline
                          M Offline
                          MikeCO10
                          wrote on last edited by
                          #33

                          Meh, because often it's a pain in the neck? Look at most languages and the various operators or functions built around 'null'. Then there's things like empty, not set, nothing, and default 'blank' types. Gets into a lot of fun, especially with databases and SQLs. Speaking of fun, and a fun discussion, I had a young programmer use the three values of a boolean. I asked what he was doing. I said go get that switch on the wall to be 'not answered', lol. I'm a firm believer in two boolean values. If you're looking for 3 answers, use a different data type and clearly capture the intent. In my database designs, I leave no null values. Saves that pesky code, lol.

                          1 Reply Last reply
                          0
                          • L Lost User

                            I have just gone through four QA questions, each of which is an error caused by a null reference. And yet none of the posters seems to have any idea a) how to diagnose and fix it, or b) even what the error means. Do those of you who still work in teams find this is a common problem with younger team members?

                            E Offline
                            E Offline
                            englebart
                            wrote on last edited by
                            #34

                            Because so many programmers do not understand pointers… or the fact that a pointer has to point to something/anything before you use it/dereference it. If you understand pointers, then you know how Java/C#/etc deal with objects.

                            1 Reply Last reply
                            0
                            • L Lost User

                              I have just gone through four QA questions, each of which is an error caused by a null reference. And yet none of the posters seems to have any idea a) how to diagnose and fix it, or b) even what the error means. Do those of you who still work in teams find this is a common problem with younger team members?

                              C Offline
                              C Offline
                              Cpichols
                              wrote on last edited by
                              #35

                              I don't understand the problem. People actually don't know what null is? Are you able to educate them on it once you get your jaw off the floor?

                              1 Reply Last reply
                              0
                              • L Lost User

                                I have just gone through four QA questions, each of which is an error caused by a null reference. And yet none of the posters seems to have any idea a) how to diagnose and fix it, or b) even what the error means. Do those of you who still work in teams find this is a common problem with younger team members?

                                A Offline
                                A Offline
                                agolddog
                                wrote on last edited by
                                #36

                                In my case, before retiring, it wasn't youth. It was aggressive ignorance by people who were "professional" developers for decades. Hence my retirement.

                                1 Reply Last reply
                                0
                                • L Lost User

                                  I have just gone through four QA questions, each of which is an error caused by a null reference. And yet none of the posters seems to have any idea a) how to diagnose and fix it, or b) even what the error means. Do those of you who still work in teams find this is a common problem with younger team members?

                                  B Offline
                                  B Offline
                                  BillWoodruff
                                  wrote on last edited by
                                  #37

                                  i tried to explain that to C# students (back when i had a few) by saying that a "null reference" is a named/typed placeholder/slot for a pointer/reference to something which is not defined. you, the programmer, have the "freedom" to create the named/typed slot. and, that the common exception "null reference" was what happened after your running code made demanded/needed/required a defined pointer. you have a favorite metaphor, or explanation ... i am all ears ! of course, now, Visual Studio/C# compiler (and ReSharper) are going to ... suggest a check. and, now, C#/>NET has new Attributes for static Type analysis: [^].

                                  «The mind is not a vessel to be filled but a fire to be kindled» Plutarch

                                  E 1 Reply Last reply
                                  0
                                  • L Lost User

                                    In C zero and NULL are very much the same thing.

                                    T Offline
                                    T Offline
                                    trønderen
                                    wrote on last edited by
                                    #38

                                    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.

                                    L 1 Reply Last reply
                                    0
                                    • T trønderen

                                      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.

                                      L Offline
                                      L Offline
                                      Lost User
                                      wrote on last edited by
                                      #39

                                      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.

                                      H 1 Reply Last reply
                                      0
                                      • L Lost User

                                        I have just gone through four QA questions, each of which is an error caused by a null reference. And yet none of the posters seems to have any idea a) how to diagnose and fix it, or b) even what the error means. Do those of you who still work in teams find this is a common problem with younger team members?

                                        B Offline
                                        B Offline
                                        Bruce Patin
                                        wrote on last edited by
                                        #40

                                        I have to deal with Microsoft employees not understanding null for dates or GUIDs, thereby actually making programming, especially if a database is involved, even more difficult.

                                        1 Reply Last reply
                                        0
                                        • L Lost User

                                          I have just gone through four QA questions, each of which is an error caused by a null reference. And yet none of the posters seems to have any idea a) how to diagnose and fix it, or b) even what the error means. Do those of you who still work in teams find this is a common problem with younger team members?

                                          J Offline
                                          J Offline
                                          jschell
                                          wrote on last edited by
                                          #41

                                          Richard MacCutchan wrote:

                                          Do those of you who still work in teams find this is a common problem with younger team members?

                                          Versus other problems by inexperienced (younger) persons in any craft? I didn't get better with null until I burned myself so many times that I started focusing on it intently. Thus experience.

                                          1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups