• (cs) in reply to too_many_usernames
    too_many_usernames:
    Ah, yes, the inevitable stream of "0 is a value, where NULL is the absence of any value" philosophical discussions...


    I do not think there is anything philosophical about it.  The languages,  databases, progrmmers and designers who accept the concept of 'nullness' define it as NO VALUE.  Seems to me zero is a value.

    Codifiers of systems of logic are allowed to coin such definitions.

    Without null, the following dialoge (it should be obvious how to transform this to code) is impossible:
    ----------------------------------
    How many do you want?

    I haven't said.

    OK - I will give you the default.
    ----------------------------------

    Isn't that very different from:
    --------------------------------
    how many do you want?

    Zero.

    OK - I will give you zero (or not give you any).
    --------------------------------
    ?
    I know that this explanation is somewhat pedantic, but logic, programming and system design can, at times, appear to be very subtle to the untrained eye.

    There is, in fact, a real difference tween null and zero and many designs would be handicapped or bullied into defining a magic value if the concept was not implemented already.  In fact, null is a magic value in that it cannot be confused with a real number and it can, if desired, trigger alternate processing.

    I do have a serious matter to bring up - nobody has suggested the obvious, essential and mandatory isNullAndVoid declarations.

  • (cs) in reply to Mr Beeper

    This reminds me so much of

    "He's not completely dead,... "

    "She turned me into a newt!!"

  • (cs) in reply to Bullet
    Bullet:

    "She turned me into a newt!!"



    We. Thought. You. Was. A. Toooooad!
  • (cs) in reply to Stu

    This sounds a lot like "Meet Spinal Tap"...

    Nigel:  ...the numbers all go to eleven.  Look...right across the board.
    Marty: Ahh...oh, I see....
    Nigel: Eleven...eleven...eleven....
    Marty: ...and most of these amps go up to ten....
    Nigel: Exactly.
    Marty: Does that mean it's...louder? Is it any louder?
    Nigel: Well, it's one louder, isn't it? It's not ten. You see,
    most...most blokes, you know, will be playing at ten. You're on ten
    here...all the way up...all the way up....
    Marty: Yeah....
    Nigel: ...all the way up. You're on ten on your guitar...where can you go
    from there? Where?
    Marty: I don't know....
    Nigel: Nowhere. Exactly. What we do is if we need that extra...push over
    the cliff...you know what we do?
    Marty: Put it up to eleven.
    Nigel: Eleven. Exactly. One louder.
    Marty: Why don't you just make ten louder and make ten be the top...
    number...and make that a little louder?
    Nigel: ...these go to eleven.
    How much more NULL can you get?  The answer is none.  None more NULL.


  • (cs)

    This sort of reminds me of something I was going to do as an April fool's prank.  I started working on a next-generation version of "true" and "false" called TrueNG.  The idea was rather than just simple binaries /bin/true and /bin/false, I would instead have a shared library that implemented true as a function, and then have language bindings for perl, tcl, etc., as well as the traditional binaries (that just link against libtrue).

    Version 2.0 was going to have network capability, not unlike distributed.net, where people could calculate the value of truth and submit it.  It never got off the ground because I couldn't work out an implementation that didn't leave it open for a denial-of-truth attack.

  • (cs) in reply to marvin_rabbit

    LMAO!  Brilliant![:D]

  • (cs) in reply to RangerRick
    RangerRick:

    ...because I couldn't work out an implementation that didn't leave it open for a denial-of-truth attack.


    I had to do a double-take there.  Good one.
  • (cs)

     

    Bullet:

    This reminds me so much of

    "He's not completely dead,... "

    "She turned me into a newt!!"

    How do you know she is a witch?

    Alex Papadimoulis:

    static public final boolean isWitch(double _value)
    {
      return (Math.abs(_value)  < 0.0001);
    }

  • Matt (unregistered)

    isNotQuiteNullYet

  • (cs)
    VGR:

    If only universities would start teaching that premature optimization is the root of all evil.


    I'm pretty sure the root of all evil is this too, too, post-ironic and oft-repeated remark about premature optimization.  I vote we place it up there with "Fist," "Brillant," and all the other old saws we have hanging over the workbench.
  • (cs) in reply to Bullet

    "And... what else floats?"

    "Churches!"

    "Very Small Rocks"

    "A Duck!"

    "... so... if she... weighs as much as a Duck..."

    PAULA!

     

  • cp (unregistered) in reply to ammoQ

    The correct names for these functions would be IsNearlyZero, and IsVeryNearlyZero. But I would take the advise given earlier and define some thresholds to compare against.

    jmho.

  • (cs) in reply to Stine

    Anonymous:
    A professor put it like this:

    Lets say you are walking around downtown with 6 cents in your pocket.  A beggar walks up and asks if you have a penny or nickel?  Do you tell him "no"?  If you're a bastard you do.

    If it's an XOR...

  • (cs) in reply to jvancil

    Two wrongs don't make a right, but if you add up enough nulls you'll get a non-null!  Multiply a null by a big enough number, and you've really got something to work with.  Subtract a nullity from a small enough reality, and it disappears.

    If you need a NULL value, and you're in a context that doesn't support it (e.g. you can't create an object wrapper), then I might suggest carrying a neighbouring bool that indicates nullity.  Or find a comparable solution.  "Cute" is for personal tools and home hacks, where you can control the inputs.

    int someNumber_value;
    bool someNumber_nullFlag;

    As bad as the code gets, at least it avoids tripping into (or out of) a black hole accidentally.  I'd hate to be the poor co-op student called in to fix a problem caused by somebody being billed because they ordered a null quantity of an expensive item ... and "fixing" it by ensuring they only ordered a very null quantity, instead!

  • BAReFOOt (unregistered) in reply to John Bigboote
    John Bigboote:
    ammoQ:
    "Null" means "Zero" in German and other languages. I think those methods are badly named, should rather be "isZero" resp. "isVeryZero".


    public static System.Boolean HabenSieEineNull(System.Double derValue)


    Did you mean:

    öffentlich statisch boolesch istNull(doppelt _wert) {
      gibZurück (Math.abs(_wert) < 0.0001);
    }
  • (cs)
    Alex Papadimoulis:
    the most common is using a "magic value" to represent NULL. Generally, this "magic value" is the smallest value possible, such as -1.79769313486232e308.

    And I was just reading about various magic numbers, including the one about

    const bool FALSE_FLAG = (0xCE0 == 0xDEAF);

    ...what, an old joke? Well, give me a break, just heard it today...

  • Jerry Kindall (unregistered)

    This is a good example of full frontal nullity.

  • (cs) in reply to Bus Raker
    Bus Raker:

     

    Bullet:

    This reminds me so much of

    "He's not completely dead,... "

    "She turned me into a newt!!"

    How do you know she is a witch?

    Alex Papadimoulis:

    static public final boolean isWitch(double _value)
    {
      return (Math.abs(_value)  < 0.0001);
    }

    No, no, no, you need to re_use code,

    static public final boolean isWitch(Person accused, <FONT color=#0000ff>Duck</FONT> trialDuck)
    {
      return isNull(accused.Weight - trialDuck.Weight);
    }

  • (cs)

    It's quite simple. All nulls are equal, but some values of null are more null than others.

  • Willie (unregistered) in reply to squirrel

    Doesn't C/C++ just make NULL = (void *)0?

    Seems like a pretty good definition of NULL to me.

  • (cs) in reply to RangerRick

    RangerRick:
    This sort of reminds me of something I was going to do as an April fool's prank.  I started working on a next-generation version of "true" and "false" called TrueNG.  The idea was rather than just simple binaries /bin/true and /bin/false, I would instead have a shared library that implemented true as a function, and then have language bindings for perl, tcl, etc., as well as the traditional binaries (that just link against libtrue).

    Version 2.0 was going to have network capability, not unlike distributed.net, where people could calculate the value of truth and submit it.  It never got off the ground because I couldn't work out an implementation that didn't leave it open for a denial-of-truth attack.

     

    denial-of-truth attack- thats gold!

  • Steven Fisher (unregistered) in reply to reed
    reed:
    Huh. Are we sure that by "Null" they don't mean "insignificantly small", for doing comparisons, for example?

    I'd say it quite clearly DOES mean exactly that. A stupid name for the function, granted, but not stupid enough to be interesting.

    Truly stupid code should show fundamental misunderstandings rather than poor name choices. Something that can be fixed with a search-replace is not that noteworthy.

  • Dave (unregistered)

    Doesn't schools teach the concept of NaN (Not A Number).  I mean, even C and C++ support these!

    Yes, Javascript supports it as well. Try this:

    alert(typeof(NaN));

    Not A Number is a NUMBER! Bbbbbuut, if it's not a number, how can it be a number, unless it's Not A Number but then how can it be a number, AAAAAAAAAAAAUUUUUUUUGGHHHHH!

     

     

  • BAReFOOt (unregistered) in reply to Anonymous
    Anonymous:
    ammoQ:
    "Null" means "Zero" in German and other languages. I think those methods are badly named, should rather be "isZero" resp. "isVeryZero".


    Then the real WTF is German being a very dull null language.


    So do you think "ACHTUNG, ZERHACKSTÜCKUNGSAPPARATUR! JAHAHA, WUNDERBAR! NEIN, VERBOTEN! MEIN LEBEN!" sounds... dull???
    Then go ask your granddad (or some rtcw/et-player) what he thinks about those words. *evil grin*

    P.S.: If you don't understand this humor, then YOU are dull! HARRR! ;)
    Alternate P.S.: * Maybe he'll answer you and if it's raining all day and all night he might sound snobish and dull, while when it's hot like hell he'll probably sound like having a hot potato in his mouth. ;P

    ______
    "Just remember: Here at Sunny Meadows, THERE IS NO I IN INSANITY!"
  • (cs) in reply to Willie
    Anonymous:
    Doesn't C/C++ just make NULL = (void *)0?

    Seems like a pretty good definition of NULL to me.



    in C it is #define NULL ((void*) 0) as you said but in C++ it's #define NULL 0

  • Fred the wondermonkey (unregistered) in reply to marvin_rabbit
    marvin_rabbit:
    > isNull(double _value)

    That was just the start. I'm sure the rest of the library was:

    isTruelyNull(double _value)
    isReallyQuiteSpectacularlyNull(double _value)
    isNullToEndAllNull(double _value)
    isMoreNullThanTheOtherNull(double _value)
    isSoNullThatWhenItSitsAroundTheNullItSitsAROUNDTheNull(double _valu

     

    You forgot

    <FONT face="Courier New">isWithANameLikeMangledBabyDucksYouKnowItsGotToBeExtremelyNull()</FONT>

  • (cs) in reply to WeatherGod

    WeatherGod:
    Doesn't schools teach the concept of NaN (Not A Number).  I mean, even C and C++ support these!

    This code is definitely not NaN-friendly.

     

    No, and they doesn't teach grammar either.

  • (cs)

    [8-)]

     

    class MeasureThisWTF {
    

    public final static long IS_NULL = 0; // NOT A WTF? public final static long IS_MAGIC = 1; public final static long IS_ENTERPRISE = 2; public final static long IS_PAULA = 4; public final static long IS_FILE_NOT_FOUND = 8; public final static long IS_XML = 16; public final static long IS_WEB_TWO_DOT_OH = 32; public final static long IS_REINVENT_WHEEL = 64; public final static long IS_CONSULTANT = 128; public final static long IS_JUST_PLAIN_SILLY = 256;

    public static void main(String args[]) { long returnCode = IS_NULL + IS_MAGIC + IS_JUST_PLAIN_SILLY;

    System.out.println("Hello WTF! [W-T-F-iness: " + returnCode + "]");
    

    } }

  • (cs) in reply to Silex

    double isNuller(double a, double b) {
    return (abs(a) < abs(b)) ? a : b;
    }

    --Rank

  • (cs) in reply to BAReFOOt

    Anonymous:
    John Bigboote:
    ammoQ:
    "Null" means "Zero" in German and other languages. I think those methods are badly named, should rather be "isZero" resp. "isVeryZero".


    public static System.Boolean HabenSieEineNull(System.Double derValue)


    Did you mean:

    öffentlich statisch boolesch istNull(doppelt _wert) {
      gibZurück (Math.abs(_wert) < 0.0001);
    }

    Beavis:  Yeh, Yeh.  Like I know Spanish, too!  Yeh, "Pizza".  Yeh, Yeh.  "El, Nullo". Heh-heh

  • (cs) in reply to Mr Beeper

    Mr Beeper:
    Fools.  Lisp already solved this over 40 years ago (tm) with Is-Null, Is-Pretty-Null, and The-Nullest.  And you other guys are just NOW inventing these functions?

    I owe you one.  The first post (in this thread) to make me laugh out loud!

  • Eggboy (unregistered)

    I do think this design could help in a number of not-simply-a-simple-null-value problems. I defently want to use this......

  • (cs) in reply to TomCo
    TomCo:

    [8-)]

     

    class MeasureThisWTF {
    

    public final static long IS_NULL = 0; // NOT A WTF? public final static long IS_MAGIC = 1; public final static long IS_ENTERPRISE = 2; public final static long IS_PAULA = 4; public final static long IS_FILE_NOT_FOUND = 8; public final static long IS_XML = 16; public final static long IS_WEB_TWO_DOT_OH = 32; public final static long IS_REINVENT_WHEEL = 64; public final static long IS_CONSULTANT = 128; public final static long IS_JUST_PLAIN_SILLY = 256;

    public static void main(String args[]) { long returnCode = IS_NULL + IS_MAGIC + IS_JUST_PLAIN_SILLY;

    System.out.println("Hello WTF! [W-T-F-iness: " + returnCode + "]");
    

    } }

    Now THAT is funny!

     

  • Tilendor (unregistered) in reply to squirrel

    Is that for real?  No null bull?

    After a bit of a-null-ysis I have null-ted that tis a most null-tible and null-farious use of code.  To he person who found this, the null-ble thing to do would be to null-tify your supervisor.  If you knull who wrote it, find someone more knull-igble to teach them better practices.  There is null way this should be left standing as is.  This kind of null-compoop thinking needs nullified.  Either use a better solution (actual null-able values, or a flag.)  or properly name the functions.  To discourge them, you could award him a Null-Bell prize.You have the time it takes me to count from 0 to Null to get started (I'm trying to be generous... I could have said VeryNull).

    ....

    What was that?  Ok, I'll put down the stick.

    ....

    Step away what?

    ...

    Oh, the dead horse.  Right OK.

    Side note:  Now that the value of Null if being replaced by functions, is Null still going to be backwards compatible, or will I need to write like this:

    IF(Pointer == TheValueFormerlyKnownAsNull){ .... }

  • (cs) in reply to RiX0R
    RiX0R:

    So what's wrong with plain old 0?

     

    null and 0 (zero) are two different things, 0 is a value like 3 or 700 but null means no value.
  • niko (unregistered)

        Nullth post!

  • David (unregistered)

    "VERY NULL"! I actually laughed out loud at that. Good one.

  • bah (unregistered)

    Like most WTFs here, the real WTF is the people replying.

    Null also means 'zero', which is obviously the intent of this code. As opposed to 'empty', which is the meaning we commonly consider 'null' to have.

    For the idiots who state that he should have just tested for zero, you can't do that safely with double values, as it is incredibly rare that you will find two variables out of two different mathematical operations to have the EXACT same value. So 'A - B' will almost always have a remainder. Note that if you had ASKED why you couldn't do this, you would not be an idiot; asking would be a sign of wisdom, accepting that there are things which you do not yet know, and implying your desire to learn.

    The WTF here is probably Mihhon, who incorrectly understood what the original author was doing. I would enjoy knowing if those method names are the original names; if so, so what? How many times have you, as a programmer, not been able to bother yourself to pause in a mad programming dash to think of the 'perfect name' for a method? IsNull? IsZero? IsTiny? IsReallyTiny?

    My own function for this, which I used to use all the time, is called 'isZero' and takes two arguments, the value and the limit in sig figs. Still, I wouldn't consider a fellow programmer an idiot based on something like this; if I has only two particular zero cut-offs, I'd use two different methods as well; it is easier to refactor, if needed.

    If this site took the view that 'bad code' should be made an example of, and CORRECTED, I would enjoy it. Instead the forums are full of idiots who think they impart wisdom with snappy comments such as 'HAHAH what an idiot! WTF++'.

    I daresay this could be an interesting site, and it is SOooo close. But it falls flat, simply because it focuses on being insulting, rather than insightful. Hopefully others agree and the site improves. Until then, cheers,

  • (cs) in reply to Silex
    Silex:
    Anonymous:
    Doesn't C/C++ just make NULL = (void *)0?

    Seems like a pretty good definition of NULL to me.



    in C it is #define NULL ((void*) 0) as you said but in C++ it's #define NULL 0


    In C++, I always use some sort of wrapper with a specially designed NULL created for the individual circumstance and avoid #define NULL 0 calls like the plauge.

  • (cs) in reply to campkev
    campkev:

    WeatherGod:
    Doesn't schools teach the concept of NaN (Not A Number).  I mean, even C and C++ support these!

    This code is definitely not NaN-friendly.

     

    No, and they doesn't teach grammar either.



    Sorry.  What I wouldn't give to be able to use that Edit button.  I noticed my error right when I clicked the Post button.

  • (cs)

    The isNull() function in BrainF***.  See how much simpler this makes things?  Sadly, I couldn't figure out the ASCII for "very null".

    >+++++++[<+++++++>>+++++++<-]>->,>[<]<.

  • Jalf (unregistered) in reply to bah

    Too true, unfortunately. It's obviously just for doing floating-point comparison, except he's hardcoded two different epsilon values with the two functions. Ok, so most people would have a more general solution (and probably come up with some better names for the functions), and probably wouldn't have used the word "null", which is a bit misleading, but hardly a wtf.
    If you want to compare two floating point numbers for equiality, that is what you're supposed to do. First, subtract them from each other, then see if the resulting value is sufficiently small (by taking the absolute value and comparing it to some epsilon).

  • Fortress (unregistered)

    I've been following this site daily for a while now, probably six months.  This is the first WTF that made milk come out of my nose.

    Of course, the REAL WTF is that at nearly 5:30 PM it was milk and not a fine Kentucky Burbon.

  • (cs) in reply to IQpierce
    IQpierce:

    This reminds me of a manager I had who would send out status reports of our tasks from time to time. First he would flag them with priorities of "H", "M", and "L", for High, Medium, and Low. But after a couple of months, he introduced the priorities "HH", "HM", "ML", and "LL". It was explained that HH was "Very High", "HM" was "High-to-Medium"... you get the idea. Then he started using special color coding to denote which tasks were "blockers", and bolding which tasks where "critical bug fixes", and he introduced "HHH" tasks which were "EXTREMELY High priority" and.. it got a little confusing.

    But I was just waiting for an "MM" priority to show up. You know - "Very Medium." And perhaps "MMM" for "EXTREMELY Medium."

    Makes about as much sense as "Very Null."

    Good WTF.

    You need HTM (Higher Than Medium), SHTM (Slightly Higher Than Medium), and ASHTM (A Smidgen Higher Than Medium)...

  • (cs) in reply to too_many_usernames

    too_many_usernames:
    ...(I'm sure that in most modern databases and strictly typed languages, NULLs are implemented internally with some sort of magic number or wrapped with a flag somewhere that is transparent to the programmer), and part due to presentation - especially in databases where information is transmitted in sequential, delineated form where there must be a fixed number of spaces; if things could be transmitted instead as entities with characteristics, the concept of NULL would probably not be required....

    Actually...... Microsoft SQL Server doesn't have a placeholder value for NULL.  It has a bitmap for NULLable columns and for every column that is NULL, the value is skipped in the chunk of row data.  Therefore, a row is variable length and NULLs aren't stored as anything other than a NULL flag.

    As for languages, most only support null for reference types.  So, a null is a pointer that points to nowhere.  You might think that's a value, but it takes less space than a non-null value.  A null Date consists of only a two (or four) byte pointer.  A non-null Date consists of a pointer and about 8 bytes of Date data(depending on language and platform).

    NULLs do have a distinct meaning.  Try adding 50 rows to database, set all of them to some value.  Do an AVG() aggregate on the 50 values.  Now set 10 of them to NULL.  Do another AVG().  The NULLs will behave differently than any fixed value.  This is very useful for cases like "How many servings of alcohol did the average party goer drink", where those who didn't go to the party have a NULL in the servings column.  Those who went to the party, but didn't drink have a 0.

  • Rod (unregistered) in reply to GoatCheez

    Clearly this is a fundamental concept which should be supported by the language. Binary logic just doesn't reflect modern cultural norms. We need

    If ...
       Then ...
       Else   ...
       Maybe...

     

  • Looce (unregistered) in reply to Tilendor
    Anonymous:

    Side note:  Now that the value of Null if being replaced by functions, is Null still going to be backwards compatible, or will I need to write like this:

    IF(Pointer == TheValueFormerlyKnownAsNull){ .... }



    You'd have to declare a bitmap to hold the symbol that represents the new name of NULL. And comparing bitmaps is a pain, trust me.

    <font size="2">public static bool areBitmapsTheSame(Bitmap b1, Bitmap b2) {
      if (b1.Width == b2.Width && b1.Height == b2.Height)
        // compare pixel values of the two bitmaps
    }

    public static bool areBitmapsTheVerySame(Bitmap b1, Bitmap b2)
    {
      return FILE_NOT_FOUND;
    }
    </font>

  • (cs) in reply to bah

    Anonymous:
    Like most WTFs here, the real WTF is the people replying. Null also means 'zero', which is obviously the intent of this poster 'Bah'.

    Who else stops reading as soon as someone starts a post like this?  The real WTF is people not understanding sarcasm.

  • (cs) in reply to IQpierce

    LOL!  I wish I had this example for the chapter on designing encoding schemes in my books. 

  • (cs) in reply to Rod

    ... this is obviously an implementation of "Tri-Null"


Leave a comment on “It's Pretty Null”

Log In or post as a guest

Replying to comment #:

« Return to Article