• Mathimaz (unregistered)

    ...

  • (cs)
  • (cs)
    function DoNothing()
    {
        Nothing();
    }
    
    function Nothing() 
    {
    }
    
  • (cs)
    function DoNothing()
    {
      Nothing();
    }
    
    function Nothing()
    {
      DoNothing();
    }
  • (cs) in reply to blupp
    blupp:
    function DoNothing() { Nothing(); }
    function Nothing() 
    {
    }
    
    Brillant! You've removed the WTF-ness.

    You're quite the party pooper. Now what do we talk about?

  • (cs) in reply to aythun
    aythun:
    function DoNothing()
    {
      Nothing();
    }
    

    function Nothing() { DoNothing(); }

    Brrriiliant!!

  • Bosshog (unregistered)

    The real WTF would be if it did something.

    function Nothing() 
    {
       runGalaxySimulation();
       updateBankBalances();
       archiveTheInternet();
       floodSiliconValley();
    }
    
  • sweavo (unregistered)

    Maybe one of them doesn't return anything, whereas the other has no side effects.

    function LaLaLalalalaa()
    {
      while(!WholeDayThrough)
      {
        DoNothing();
        try
        {
          thing=find_next(!ToDo);
        }
        
        GoNowhere();
        
        if (Time!=NULL)
        {
          BeUnhappy();
        }
      }
    }
    

    'scuse my language, I don't speak java

  • codemonkey (unregistered)

    Maybe they forgot to define what "doing nothing" entails and intended on filling it in at a later time...say, just before production release?

    I would love to see their reasoning behind making nothing functions though.

  • doom (unregistered)

    captcha: doom

  • (cs)

    Doing nothing = waiting to eventually do something

  • (cs)

    I'm not seeing the wtf here. Obviously there's a difference between nothingness and not doing anything.

  • Guran (unregistered)

    This must be som sort of bug-prevention. How many times have you heard the following?

    "The application crashed, you did the last check-in, what did you change?" "Nothing"

    So by assuring a really harmless implementation of Nothing() such things should never occur...

  • GPC (unregistered)

    DoNothing should call Nothing though:

    function DoNothing{ Nothing(); }

  • JS (unregistered) in reply to Mathimaz

    Don't do what Donny don't does. Even if Donny Don't doesn't do anything.

  • Marcel (unregistered)

    Function MakeComment { }

  • (cs)

    The person who wrote Nothing() didn't realize that somebody had already written it. A simple matter of duplicate code (for a dummy callback).

  • rd (unregistered) in reply to RogerC
    RogerC:
    blupp:
    function DoNothing() { Nothing(); }
    function Nothing() 
    {
    }
    
    Brillant! You've removed the WTF-ness.

    You're quite the party pooper. Now what do we talk about?

    How about wooden tables, captcha, fist, and file not found?

  • Brandon (unregistered)

    Entirely not enough recursion, global variables, magic numbers, or infinite loops...

    var i = 0;
    function DoNothing()
    {
      if (i < 42)
      {
        i++;
        DoNothing();
      }
      else
      {
        Nothing();
      }
    }
    
    function Nothing()
    {
      i--;
    }
    
  • zolf (unregistered)

    """python version"""

    def nothing():
      global nothing, do_nothing, really_nothing
      nothing = do_nothing
    def do_nothing():
      global nothing, do_nothing, really_nothing
      do_nothing = really_nothing
    def really_nothing():
      global nothing, do_nothing, really_nothing
      really_nothing = nothing
    
  • Aidan (unregistered)

    doNothing() { }

    dontDoNothing() { doNothing() ; }

  • jbosss (unregistered)

    I have only one thing to add: ""

    Captcha: tesla. man, I miss my old TV

  • (cs) in reply to zolf

    It's really just a clever deployment solution. See, who wants to go through that pesky compile step every time?

    They just add calls this function and then insert code directly into it in memory at run time until it behaves as desired.

  • AdT (unregistered)

    function DoNothing() { // TODO: Inline assembler does not seem to work in JavaScript :-( // TODO: Find a different way to do nothing // asm { NOP }; }

  • Spock (unregistered)

    Very enterprisy.

    Capta: Stinky.... ewww

  • Spock (unregistered)

    Very Enterprisy

  • DAVE_CHANG (unregistered)

    I have days that emulate this function.

  • Joe User (unregistered)

    http://imgs.xkcd.com/comics/exploits_of_a_mom.png

  • (cs) in reply to Aidan

    Of course, this should be:

    Aidan:
    doNothing() { Nothing(); }

    dontDoNothing() { !doNothing(); }

  • Synonymous Coward (unregistered) in reply to Raymond Chen

    Maybe it was written by someone who didn't know about the void operator.

    function Nothing() { }
    alert(Nothing() === void(0));
  • Southern (unregistered)

    Compiles Does what it says Does not have extra lines Does not need comments Does not waste nanoseconds

    Etc

    It's utopical

  • Daz (unregistered)

    Does exactly what it says on the tin!

  • BBT (unregistered)

    the second function should be named doAnything(). When you doNothing, you don't doAnything. Then it would make complete sense that doAnything() does not get called by doNothing().

  • (cs)

    Maybe some crafty API takes two callbacks, say onFail and onFailFail. This way, if the function fails you can do failure handling in onFail. If onFail fails, you call onFailFail to log an error or something.

    And the API is friendly enough to yell at you for using the same function for both. Obviously if onFail fails, you don't want to call it again! Are you trying to create an infinite loop?

    /Man, I'm totally going to put stuff like that n my next application just to give people a headache.

  • Loren Pechtel (unregistered)

    There's nothing wrong with a function called Nothing or something of the sort. I've done it more than once.
    It can make it clearer what a piece of code is doing.

  • DAVE_CHANG (unregistered)

    doAnything() { var h = Math.random(); for (var i=0; i < h; i++) { doNothing(); } }

  • (cs) in reply to sweavo
    sweavo:
    'scuse my language, I don't speak java

    It's javascript, not java. Your only problems are: try with no catch, and null should be lowercase. And none of the variables you're using exist, but they could be defined at any time elsewhere, so it's a runtime error only.

    Synonymous Coward:
    Maybe it was written by someone who didn't know about the void operator.
    function Nothing() { }
    alert(Nothing() === void(0));

    It never occured to me that undefined was a specific entity that could be compared to itself.

  • chris (unregistered)

    Both functions are clearly necessary to keep the code readable:

    if (0 == 1) {
        DoNothing();
    }
    

    but

    do {
        Nothing();
    } while (0 == 1);
    

    Really, who would want to read "do DoNothing()"?

    (Hey, what about "PLEASE DO NOTHING"?)

  • Harrow (unregistered) in reply to BBT
    BBT:
    the second function should be named doAnything(). When you doNothing, you don't doAnything. Then it would make complete sense that doAnything() does not get called by doNothing().
    Yes. Thank you. I could see that the code was wrong, but I couldn't quite see how to fix it.

    -Harrow.

  • (cs)

    function DoNothing() { Do(); Nothing(); }

    function Do() { }

    function Nothing() { }

  • Graham (unregistered)

    Damn- I hope that function was well tested.

  • Scott tiger (unregistered)

    I thought this looked funny. Found it in all the sites that we do.

    function nothing(){ return; }

  • sweavo (unregistered) in reply to Random832
    Random832:
    sweavo:
    'scuse my language, I don't speak java

    It's javascript, not java. Your only problems are: try with no catch, and null should be lowercase. And none of the variables you're using exist, but they could be defined at any time elsewhere, so it's a runtime error only.

    Oh cock it! You mean after all these years of avoiding JS like the plague it is, I've gone and written some for fun?!

    Enter your First Name: 20 Enter your last Name: 15 Your email address is: 35@javascript_sucks.com

  • Artem Ploujnikov (unregistered)

    Empty functions are useful for overriding or specifying default event handlers in certain cases.

    e.g. click

  • Dude (unregistered)

    ...

    I wont tell anyone. My Lips are sealed. Now i have to call a friend. (Evil laughg)

    Capacha: Ewww (When i will think of food that i dont like, i will think about this capacha)

  • O Thieu Choi (unregistered)

    Positively (well, negatively) Heideggerian!

  • Stephen Baker (unregistered)

    Perhaps they think the empty function in prototype is a WTF too? http://www.prototypejs.org/api/prototype

  • TimJ (unregistered)

    The solution is easy: DoNothing is a function. Nothing is a constructor for instances of Nothing. So you invoke it like that:

    DoNothing(); var something = new Nothing();

  • Anon (unregistered) in reply to sweavo
    sweavo:
    'scuse my language, I don't speak java
    Obviously, if this were Java instead of JavaScript, it would be:
    public final class Utils {
        /**
         * Does nothing.
         */
        public static final void doNothing() {
            nothing();
        }
        /**
         * @deprecated replaced with {@link #doNothing()}
         */
        public static final void nothing() {
            // nothing
        }
    }

    And while that is a joke, it's unfortunately fairly normal, as this excerpt from Sun's current implementation java.awt.Component demonstrates:

        /**
         * Prompts the layout manager to lay out this component. This is
         * usually called when the component (more specifically, container)
         * is validated.
         * @see #validate
         * @see LayoutManager
         */
        public void doLayout() {
            layout();
        }
    
        /**
         * @deprecated As of JDK version 1.1,
         * replaced by doLayout().
         */
        @Deprecated
        public void layout() {
        }

    That is real, as anyone with Sun's JDK can verify by peeking in src.zip.

  • iMalc (unregistered)

    Presumably Nothing uses these funtions. I guess the author felt that it was good to know that they could DoNothing if they wanted to, which would be nice to know.

Leave a comment on “Not Doing Nothing”

Log In or post as a guest

Replying to comment #158522:

« Return to Article