• Gandor (unregistered)

    I prefer languages, which will let you shoot yourself in the foot if you want to.

    The problem is, that PHP is too easy to use. Maintaining such a mess after someone, that have "somehow" written the app is mind blowing...

  • the beholder (unregistered)

    And I always thought curiosity killed the $cat, when it actually was just pointing to another variable.

  • GWO (unregistered)

    Well, you see, PHP utilises the latest Quantum Computing technologies, so the $cat variable can exist in a superposition of the scalar and array states.

  • (cs)

    I suppose

    svn blame <file>
    

    would do nothing but removed plausible deniability as to why the previous programmer's body parts has been stapled to bulletin board in the coffee room.

  • (cs)

    It's like http://forums.thedailywtf.com/forums/t/26141.aspx optimised to compress the WTF into (almost) the smallest possible code.

  • Kasper (unregistered) in reply to the beholder
    the beholder:
    I always thought curiosity killed the $cat
    Curiosity was framed, ignorance killed the cat.
  • PleegWat (unregistered) in reply to Code Slave
    Code Slave:
    I suppose
    svn blame <file>
    

    would do nothing but removed plausible deniability as to why the previous programmer's body parts has been stapled to bulletin board in the coffee room.

    svn: command not found

  • Kaine (unregistered) in reply to Kasper

    But satisfaction brought 'em back!

  • MightyM (unregistered) in reply to the beholder
    the beholder:
    And I always thought curiosity killed the $cat, when it actually was just pointing to another variable.

    So it's Schrödinger's $cat?

  • MightyM (unregistered) in reply to GWO
    GWO:
    Well, you see, PHP utilises the latest Quantum Computing technologies, so the $cat variable can exist in a superposition of the scalar and array states.

    So it's Schrödinger's $cat?

    (Quoted the wrong post before)

  • (cs)

    The less strongly-typed the language, the more important good unit testing is. This is a cornerstone of Agile development.

  • Anon (unregistered) in reply to MightyM
    MightyM:
    GWO:
    Well, you see, PHP utilises the latest Quantum Computing technologies, so the $cat variable can exist in a superposition of the scalar and array states.

    So it's Schrödinger's $cat?

    (Quoted the wrong post before)

    [image]
  • $$ERR:get_name_fail (unregistered) in reply to MightyM
    MightyM:
    So it's Schrödinger's $cat?
    You mean $schroedinger->cat?
  • Charles (unregistered) in reply to Gandor
    Gandor:
    I prefer languages, which will let you shoot yourself in the foot if you want to.

    Having the power to shoot yourself in the foot by choice is one thing. A well-designed language, though, will make sure it's by choice -- in Clojure, for instance, if I want to mutate a variable (unsafe) rather than temporarily rebinding it (safe), I have to use a function with a with a ! on the end of its name, which marks it as "do this only if you're paying attention" -- and the scoping rules are very, very clear and explicit.

    PHP, on the other hand... well, have you read the "fractal of bad design" essay?

  • Recursive Reclusive (unregistered) in reply to Scrummy
    Scrummy:
    The less strongly-typed the language, the more important good unit testing is. This is a cornerstone of Agile development.
    Does that have any relevance to the story?
  • Doug (unregistered)

    What I want to know is if the reduction of $cat to a single entry is a necessary and intended effect or an unintended consequence. After a couple of years working there will you automatically recognize and use this pattern? I have at least one pattern I use repeatedly that has provoked amazement and revulsion in the uninitiated, but is too useful to give up.

  • (cs) in reply to Doug
    Doug:
    [...] I have at least one pattern I use repeatedly that has provoked amazement and revulsion in the uninitiated, but is too useful to give up.
    I might regret this, but I have to know; what is it?
  • TheSHEEEP (unregistered) in reply to ntroutman
    ntroutman:
    Doug:
    [...] I have at least one pattern I use repeatedly that has provoked amazement and revulsion in the uninitiated, but is too useful to give up.
    I might regret this, but I have to know; what is it?

    Code documentation.

  • Geoff (unregistered) in reply to Doug

    Right, I was wondering if this was 'clever programing' or a pure bug as well.

  • Tobias Rohde (unregistered)

    I expected that it loops only once and $cat is the first element of the array $cat.

    Maybe the code is prehistoric (PHP 3 and older). The function array_pop was implemented in PHP 4.

  • dogmatic (unregistered)

    File this WTF under '$catalogical'

  • barf 4eva (unregistered) in reply to GWO

    hahah! awesome answer!

  • myName (unregistered)

    "And to make matters worse: it actually works"

    in that case the real WTF is complaining about it.

  • (cs) in reply to Kaine
    Kaine:
    But satisfaction brought 'em back!

    What if you can't get no satisfaction?

  • Jazz (unregistered)

    In before everyone insists, without any rational reason or documentation, that PHP is a horrible mutant shitpile that deserves to be ridiculed, belittled, and exterminated.

    (Maybe I've been reading TDWTF too long, but I'm kind of jaded on how PHP is the designated punching bag for languages around here.)

  • (cs) in reply to Jazz
    Jazz:
    In before everyone insists, without any rational reason or documentation, that PHP is a horrible mutant shitpile that deserves to be ridiculed, belittled, and exterminated.

    (Maybe I've been reading TDWTF too long, but I'm kind of jaded on how PHP is the designated punching bag for languages around here.)

    Nope, you haven't been here long enough because the designated punching bag is VB (either 6 or .net it doesn't seem to matter, though if somethignh is still in VB6 I would agree with them anyway)

  • (cs)

    It's quite simple to understand, m'kay? $cat is in scope outside the loop, and $cat is a local variable in scope only within the loop.

    Got that?

  • (cs)

    I prefer comments, that don't use superfluous commas, to ones that do, because the latter, are difficult to read.

  • Leo (unregistered) in reply to Jazz
    Jazz:
    In before everyone insists, without any rational reason or documentation, that PHP is a horrible mutant shitpile that deserves to be ridiculed, belittled, and exterminated.

    ...but it is. Anyone who likes PHP is by definition a terrible developer.

  • BR (unregistered) in reply to Leo
    Leo:
    ...but it is. Anyone who likes PHP is by definition a terrible developer.

    So half of the front-end developers at Facebook then?

  • sfs (unregistered) in reply to GWO
    GWO:
    Well, you see, PHP utilises the latest Quantum Computing technologies, so the $cat variable can exist in a superposition of the scalar and array states.

    Ah, but when you measure the state of the wave-variable, you end up with either the scalar or the array state.

    Thus leading to the Heisenbug uncertainty principle. Loosely stated, this means "you're screwed."

  • M (unregistered) in reply to BR
    BR:
    Leo:
    ...but it is. Anyone who likes PHP is by definition a terrible developer.

    So half of the front-end developers at Facebook then?

    Only half?

  • sfs (unregistered) in reply to Gandor
    Gandor:
    I prefer languages, which will let you shoot yourself in the foot if you want to.

    The problem is, that PHP is too easy to use. Maintaining such a mess after someone, that have "somehow" written the app is mind blowing...

    ...right, because we all know that C++ programs have far fewer bugs than PHP programs...

  • (cs) in reply to sfs
    sfs:
    Gandor:
    I prefer languages, which will let you shoot yourself in the foot if you want to.

    The problem is, that PHP is too easy to use. Maintaining such a mess after someone, that have "somehow" written the app is mind blowing...

    ...right, because we all know that C++ programs have far fewer bugs than PHP programs...

    Because, of course, there's no language other than C++ that he could have possibly meant. No other languages allow you to shoot yourself in the foot, No sir.
  • (cs)

    Shit code is shit.

  • sfs (unregistered) in reply to myName
    myName:
    "And to make matters worse: it actually works"

    in that case the real WTF is complaining about it.

    Until you have a feature request where you have to modify it, and this breaks a lot of stuff, causing hours or days of debugging.

    Brittle code tends to shatter when touched.

  • sfs (unregistered) in reply to DescentJS
    DescentJS:
    sfs:
    Gandor:
    I prefer languages, which will let you shoot yourself in the foot if you want to.

    The problem is, that PHP is too easy to use. Maintaining such a mess after someone, that have "somehow" written the app is mind blowing...

    ...right, because we all know that C++ programs have far fewer bugs than PHP programs...

    Because, of course, there's no language other than C++ that he could have possibly meant. No other languages allow you to shoot yourself in the foot, No sir.
    The OP selected a class of languages: not easy, let you shoot yourself in the foot. I drew a language (C++) from that class to illustrate that the OP's point did not make a ton of sense.

    Feel free to select your own language from that class and see if compares more favorably. I bet it won't. Incidentally, there aren't a lot of commonly-used, modern languages that fit in this class anymore. C++ is one of the better known ones.

  • dogmatic (unregistered) in reply to BR
    BR:
    Leo:
    ...but it is. Anyone who likes PHP is by definition a terrible developer.

    So half of the front-end developers at Facebook then?

    Having worked quite a bit with the FB API and php I would say yes, most if not all the devs at Facebook are pretty terrible.

    The one thing I can say for php, at least it isn't javascript. Now with html5 web devs are expected to make full scale web apps using js, a language that doesn't support file includes and object orientation only through a whole lot of syntactic sugar. And it has to run on many platforms with different implementations of js. Now QA and debugging time has multiplied by an order of 10. Makes me long for the days of Flash and Actionscript... say what you want about Flash, but at least AS3 is a real language and runs relatively the same across platforms. And furthermore, say what you want about the tenets of national socialism, dude, at least it's an ethos!

  • flyboyfred (unregistered) in reply to operagost
    operagost:
    I prefer comments, that don't use superfluous commas, to ones that do, because the latter, are difficult to read.

    Indeed. Commas, which are misplaced, can actually change the meaning of the sentence.

  • Jack (unregistered) in reply to operagost
    operagost:
    I prefer comments, that don't use superfluous commas, to ones that do, because the latter, are difficult to read.
    I prefer comments that have something to do with the story. Oops...
  • Mike (unregistered)

    Maybe the $cat has nine lives?

  • uns (unregistered)

    Had to test this. It really works as advertised.

    $ cat a.php 
    <?php
    
    $a[] = "abc";
    $a[] = "def";
    
    var_dump($a);
    
    foreach ($a as $a) {
      echo "Element of a: $a\n";
    }
    
    var_dump($a);
    
    ?>
    $ php a.php 
    array(2) {
      [0]=>
      string(3) "abc"
      [1]=>
      string(3) "def"
    }
    Element of a: abc
    Element of a: def
    string(3) "def"
    $ 
    
  • Vlad Patryshev (unregistered)

    Creative, but not as bad as the author thinks. Changing the projection, so to say.

  • Jay (unregistered)

    The problem is that there are languages that give you the flexibility to make programs that are efficient and that do a wide variety of tasks, and there are languages that make it hard for you to shoot yourself in the foot. But the overlap between the two is very small.

    Like: C: If it's possible to do it on the computer, you can probably do it with C. But you can hurt easily hurt yourself with a moment of carelessness. It's a high-speed powertool language.

    COBOL: If it involves reading a file with fixed-length fields and printing a report, you may be able to do it with COBOL. But it's very difficult to hurt yourself. It's a child's plastic hammer language.

  • Jay (unregistered)

    The policeman pulls Heisenberg over. "Do you know how fast you were going?" he demands.

    "Honestly officer, I don't," Heisenberg answers. "But I know exactly where I am!"

  • (cs)

    Foreach isn't quite as simple one would think in php, try explaining this one: http://pastebin.com/m4fmWCPD

  • Nagesh (unregistered) in reply to Jay
    Jay:
    If it's possible to do it on the computer, you can probably do it with C.

    This ain't being entirely corect. Yes, true for major OS and some embeded system, but RTOS with most often be runing diferent, special system. it is great massage to be able to have compiler for almost all hardwares using C.

  • I don't get it. (unregistered)

    Is the submitter saying the loop works internally, but after that $cat is just the last element in the array? Seems like a twofer then.

  • Peppitoz (unregistered)

    You want buy cat?

    Cat Very Fresh, Picked this morning. 1 Cat 50 MSK, Cat 75 MSK.

    CAT NOT FOR SALE, good day sir.

  • foo (unregistered) in reply to Jazz
    Jazz:
    In before everyone insists, without any rational reason or documentation, that PHP is a horrible mutant shitpile that deserves to be ridiculed, belittled, and exterminated.
    s/before/after/;s/without/with/ (see 382952 and read the essay it mentions)

Leave a comment on “Loose Cat Handling”

Log In or post as a guest

Replying to comment #:

« Return to Article