- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
This same thing works in Python.
Does exactly the same as the above PHP code.
Admin
Admin
If you seal a $cat in $address, with a vial of $liquid, how do you observe to see if $cat is still allocated?
CAPTCHA: nisl - a slightly nicer needle. No, that is not the answer to Schrodinger's $cat.
Admin
Also in Indian $cow is sacred $cat aint
Admin
Apparently you skipped over the story, and headed right to the comments section.
Admin
A particular use of the macro processor in C and C++. It often happens that adding a new feature requires a predictable sequence of changes over a number of files. It is tedious to visit each file to make the changes, and hard to remember all the changes needed. I make an include file that has one feature per line, with all the feature's parameters wrapped in a macro call. I always name the macro MC (probably short for MaCro). Then throughout the code when I'm defining some aspect of these features, I redefine the macro MC and #include the file. This means I only have to add one line to one file to implement the feature (or the predictable parts of it anyway), I have all the other features in front of me, so it's easy to spot discrepancies, and I can be sure I updated all the proper spots. Looks like a crock, though, and IDE's don't always like it.
For example, here are some lines from OpsMC.h
OpTypes.h includes it to make an enum of ADD_OP, SUB_OP, etc and NUM_OPS
In a .C file three arrays are set up, which can be indexed by the enum above and will stay in synch when someone adds another operator.
The payoff is greater in more complex situations. Sorry for the slow response, it took time to boil this down.
Admin
The WTF wasn't "this is PHP." The WTF was "look what heinous thing someone did in PHP."
Admin
So a professional programmer, claiming proficiency in a specific language, is hired to completely overhaul a code base written in that language.
Said professional, when confronted with a simple control structure, is then mystified by that language's basic behavior.
I think I spotted the WTF.
Admin
And just as I predicted, you have no rational reason for that statement, or any documentation which suggests that it's true, even a little.
It's like you're trying to prove me right.
Admin
Charles is not "everyone." Four words in quote marks are not "documentation," or even a decent citation. And the essay, which I went and googled at your request, is a poorly-supported opinion piece written by a developer who either can't or won't take the time to understand a language before criticizing it.
His metaphor of PHP as a toolbox is a good one, but when he grabs a tool and it's not what he needs, he immediately jumps to "OMG PHP's tool X doesn't do Y!" when only two more seconds of searching would reveal that if he pulled the Y tool out of the box, it would do exactly what he needs.
Sure, plenty of crap developers make pentagonal houses which fall apart when you knock on them using PHP. Plenty of good developers make flexible, secure websites with PHP, too, but you don't hear about them, because you like having PHP as the designated scapegoat to rag on.
Either show me some documentation that isn't one person's closed-minded uneducated opinion rant, or shut the fuck up.
Admin
The real WTF is computer fucking programmers. Fuck off and die the lot of you cunts.
Admin
Admin
He doesn't complain about PHP not being able to do X or Y, he complains about the inconsistencies with the language and it's irrational, unpredictable naming convention for things.
I also find it funny you call him close minded when you're the one screaming how good PHP is without being able to even acknowledge its obvious flaws.
Stay pist, PHP guy.
Admin
Of course that was way back then. Back before simply knowing COBOL meant I too, am an oldtimer! :(
Admin
Here's Perl:
And the results:
Arguably more "correct"?
Admin
Not enough possible variable names.
Must use same name for many variables.
Admin
You are giving too much credit to the authors of the code. The correct response is:
'svn' is not recognized as an internal or external command, operable program or batch file.
Admin
Am I reading it wrong, or did the story imply that the for loops are hidden in include files?
Admin
Admin
Certainly sounded like it implied that to me.
Admin
Cracks me up every time.
Admin
$ cat 'door: no hands' cat: cannot open door: no hands
Admin
I want to hug every $cat, but I can't, because they've been overwritten.
Admin
The point that you are apparently not capable of comprehending is that a language like PHP is notoriously vulnerable to mysterious errors, because there is nothing to prevent scenarios like we see IN THIS STORY in advance of encountering it during runtime. With good unit testing this would be caught before it turned into a search akin to finding a needle in a haystack. For this reason, I would also go as far as to contend that PHP is a poor choice for Agile development.
Do you see the relevance now? Or are you such a hyper-defensive PHP developer that you can't handle a civil discussion about the pros and cons of your beloved platform?
Admin
I hope I'm not the first to question your assumption that they have SVN that goes back that far...
Admin
This isn't a big deal and that's just scripting languages for you. It should be obvious that it works that way. You should know that a lot of things in scripting languages work when you wouldn't expect coming from the background of a stricter language. Never expect things, read the documentation and experiment to find out how your language works. Turn on strict error reporting as well.
I have seen far worse abominations in PHP, for example someone grossly misusing $$ and ${} (yes, that potentially allowed variable injection) to have a variable where the name is a number and the funny thing at the time is that the code was so simple it didn't even need an array. Passing the number in a normal variable was enough. I wondered at the time if someone made a typo of $$var instead of $var and rather than just correcting the typo, they changed the logic of the code to handle it everywhere else. I couldn't understand how someone could have been able to handle something so complex as the solution they created yet not be able to see the more obvious concise solution. That WTF blows nearly every PHP WTF I've seen here out of the water and it is only one of many such WTFs I've seen out there.
Far worse is foreach($arr as &$ele).
Admin
But what you don't know I'm gonna tell you right now That the stutter and the $cat is the same thing Yo, I'm the $cat man Where's the $cat man? I'm the $cat man.
Admin
Some people say PHP developers don't know Agile. This is wrong, they are very agile. If you've every some them flee to the next job before the codebase assplodes up you know what I mean.
(In COBOL they use the waterfall model, or did. I mean it worked fine when they started the project back in 75. If they ever start another project they may well use it again)
Admin
Probably got confused by the word "code" in "source code" and thought it meant something that you'd need an Enigma machine to make head or tail of. (Apologies for the misappropriation of terms and concepts for the purpose of comic effect.)
Admin
Next time you bash a language, maybe learn a bit about it first. JavaScript is prototype based. If you try to write Java-like object-oriented code in it, you are doing it wrong. That's not a problem of the language. A screwdriver is not a bad tool just because someone insists on using it with nails. And if your web developers don't know how to write tests for their JavaScript, find better web developers. The tools exist and when combined properly and sticking to standards (and well-tested frameworks), you can have as much confidence in your JavaScript as in your server-side code.
Admin
You mean exactly like the article says?
Admin
There's a difference between "likes" and "is prepared to use if paid well enough".
Admin
Nope. PHP does not have arbitrary block scoping.
Admin
However, the particular behavior mentioned in the WTF has been around and documented since the very beginning of the language. It's actually explicitly called out in the docs that when you manipulate anything in a foreach, the foreach continues to happily truck along as if nothing happened, whereas manipulating it in a for or while will immediately act upon your changes. It's a nuance of PHP but one that any PHP developer should be completely familiar with even if they never use it, because it's called out in a giant notice box of the farking foreach documentation that everyone has to read. Unless they're writing C in PHP, which is a WTF in itself.
You can foreach your way out of a lot of bull if you love abusing code. I kind of lost my love of that quite a few years ago, though.
All languages have cruft, some just revel in it more than others. Thankfully current PHP no longer even supports a lot of the long deprecated crap code, unfortunately that means most web hosts refuse to upgrade because their customers have so much crap code. Much like the Python 3 problem....
/end rant
Admin
You appear to be terminally hard-of-understanding. It has at no point been established that there is a bug in that code, or that it doesn't do exactly what the developer intended.
How would your magic tests help here?
Admin
Maybe this could suit you better ? [image]
Admin
Unit testing only tests whether the code produces the correct results. It doesn't test whether the code is batshit insane, written by a 14 yr old who has been up for 3 days, or only working by happenstance.
It is entirely plausible that code which passes unit tests is as bollocks as this code is.
Admin
this modern learning astounds me ... explain again how a carpenter (good or otherwise) can make a good mouse with either a rock or a hammer?
also ... can he make bad mice as well?
anyway, presumably the $cat will be happy either way
Admin
Everytime you iterate foreach($cat as $cat) a kitten dies.
Admin
Admin
You let the cat out of the bag!
Admin
Well you are almost there. Not being a PHP developer doesnt infer that you are not a terrible developer. So your statement should have read "At least half ...".
Admin
It's obvious you didn't read the essay, but just skimmed the start. If you had, then you would have seen there are lots of very specific examples. It is much more than a 'poorly-supported opinion piece' and it's clear he has spent time with the language.
I know next to nothing about PHP, having written a grand total of one script using it. But I do know several other languages and am always interested in learning more, so I read the entire (very long) article. What I saw is just plain scary. For specifics, check out the sections on operators, variables, and error handling. If even half of what he wrote is true then PHP is definitely not for me. I prefer my languages' rational features to outnumber their WTF's by a decent ratio. That said, I probably will still try it out for myself at some point when I have the time, but I'm not optimistic.
Admin
Funny to get this far and no reference to useless use of cat, so here it is, just so no one else will have to mention it. You're welcome!
Admin
Admin
TRWTF is PHP specially PHP scoping
Admin
Admin
Say what you want about PHP and its developers, but at least PHP isn't a juxtaposition of tag-based markup and inline scripting interpreted by a program that is running on top of a Java Virtual Machine. Sure, there are a few more options for web-based development, but PHP provides the least barrier to entry. If that attracts more shoddy developers, so be it.
Admin
#undef MC
#endif
#define MC(type, symbol, text) type##_OP
typedef enum {
#include "OpsMC.h"
NUM_OPS
} Op;
(etc.)
You won the unofficial dailywtf obfuscated C contest today. Congratulations!
Admin
It's just sad when people defend PHP. Ignorance must be bliss.
I used to hold the job title "Senior PHP Developer". Learning a proper programming language and looking for a new job was the best thing I ever did for my career.