- 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
First!
Why is there PHP in .net?
Admin
Funny how the .NET application is all PHPey!
**Note from Mark - Boy, am I a dummy. Ok, fixed. (I blame the uplift project I'm working on at the day job for polluting my brain on this one.)
Admin
Simple - there's PHP because if you want something done slow you palm it off to PHP every time !
Admin
That's not a hack, that's a rather clean and straightforward way to implement a requested feature.
Admin
I´m tired of stupid php jokes.
Admin
WTF #1: Implementing a slow-down in the first place WTF #2: Implementing a loop instead of sleep() WTF #3: Implementing PHP in a supposedly .NET project
Admin
Hahahahaha
Troll fail
(captcha: "decet" (quod licet Iovem, non licet bovem!?))
Admin
The code is supposed to imitate hard work, sleeping just doesn't do it for you.
Admin
Unless I'm mistaken.. the ASP.NET application was crappy so the solution was, evidently, to REWRITE IT in PHP to make it less crappy.
Now THERE'S a WTF.
EDIT: Reading further, it sounds like the old app was ASP (Classic) and the new one was .NET, but the code sample is obviously PHP. Either my assumption above is right and it was ASP.NET rewritten to PHP, or it's an anonymization error.
Admin
Back in the 90s, we needed speed-up loops. Now that it's the future, things happen too fast, so we need slow down loops.
http://thedailywtf.com/Articles/The-Speedup-Loop.aspx
Admin
Ah, those were the days...
Admin
Why is this anything new or strange? For applications doing some heavy data manipulation, the process finishing too fast can make the users feel like it wasn't done properly. Some graphic representation of the know variety to go along with the fake processing time would also be a nice touch.
Just make sure you're shortening the wait time in subsequent releases, while making a lot of noise about "algorithm improvements" and it's a win-win situation for users and developers.
Admin
The true WTF is, and deep down we all know this, that Jones was right. Being a lot faster on saving the data would mean that a significant portion of the users would file duplicates because "the first one went through too fast so it must have failed". Programmers often forget to account for the humans.
Admin
Definitely only a temporary hack. Without knowing too much about PHP, that version of wait($secs) is definitely not 2038-01-19 safe!
Admin
The real WTF with this solution is going to crop up in 10 years when all the original developers has left the company and the new hire gets tasked with improving the performance....
Admin
We are here to remember it!
Admin
Does this not break if you go off the end of a minute? E.g. try to do a 5-second pause starting at xx:xx:58?
Admin
Next step, over the course of a few months, increase the slowdown by a small amount every day, say 50ms.
Admin
The real WTF is users being accustomed to computers being slow.
Every time I upgrade my home PC, I get a version of Windows on it (yeah yeah, "TRWTF is Windows") which is bigger and more unwieldy, yet runs considerably slower, than the previous version. It is impossible, unless you build it yourself out of sources whose provenance may not be 100% reliable, to get hold of a new machine running the previous (perfectly adequate) version of the operating system - you can only buy that new updated version.
I questioned the salesguy on this point once, and he shrugged and said: It's what the buyers want. What?!? How can a slower and less reliable machine be what the buyers want?!? Well, he explained, the user thinks that if the computer isn't spending lots and lots of time thinking hard and racing round and round in circles, then it's not a very good computer. If it responds practically instantaneously to commands to open the email program, open a browser on the screen, find the file you were looking for, typing a character of text into an empty email (a response time of 5 seconds is de rigueur for the latter, apparently), then "it can't be doing much".
And I wonder whether those interminable software updates from MicroSoft deliberately include slow-down loops for machines older than 6 weeks old specifically so as to force users to upgrade when they wouldn't otherwise need to.
Admin
Admin
Admin
The real WTF is getting a pizza lunch as a reward. I mean, the salaries are WAAAAAAAYYY higher than the prize of a pizza. Or aren't they? It's like throwing some alms, except this raises your cholesterol. "Here you go, old chap. Well done."
Admin
I don't know php, but why not something like
instead of
?
Unnecessary temp variables irritate me and breaking simple tasks up arbitrarily just makes everything longer and harder to follow. (Not that this is an extreme example or anything)
Admin
This seems perfectly reasonable to me. Users are morons, and that must be accounted for.
Now, of course, a proper implementation would have used sleep() rather than spinning, and for extra elegance, a descriptive comment should be included along with a simple calculation so that the delay approaches zero over the next five years. That way, even if it's never maintained, the site speeds itself up gradually, without the users worrying.
Admin
Balls, frankly. Windows 7 is faster than Vista on the same hardware, and Windows 8 is faster than 7 (even though it's next to unusable because it mungs a touch-optimised UI into mouse interaction).
Admin
Because you couldn't access an "array" directly from a function prior to the latest version of PHP.
http://www.php.net/manual/en/migration54.new-features.php
Admin
Why write any code at all? Just underclock the server for a few months.
Admin
Ah. Fair enough, then.
Admin
And call it my brief and horrible experiences with functional programming, but I'll take a couple intermediate variables which break a process into several obvious steps rather than a blob of parens and commas nested six levels deep. For that matter, any logic that complex is worth considering moving into its own method/function. Writing for maintainability > writing for conciseness, with a few very narrow exceptions. You have to assume the guy reading it will be dumber than you, especially if it's going to be you-in-six-months.
Admin
I think we should do a workflow change. After the user clicks save, it pops up a dialog that says, "Click here to confirm save". No "Cancel" should be present. When they do that, then it presents another screen that shows their saved data for review, and there's a "Confirm" button on that they have to click to continue.
Then we can have a dialog that says, "Click here to confirm confirmation..."
Admin
This. If I have to think, I want it to be on important things like solving new problems or pondering the problems and possibilities of time travel, not figuring out how problems that were already solved were solved.
Granted, the example here doesn't take much thought and "$temp" is not a particularly helpful intermediate variable name, so it's not exactly a great example of writing clear code.
Admin
Code is easier to fix and easy to ignore. For those not wishing to use the wait function, they don't have to. Unlike underclocking a server.
Admin
/* Wait
Makes the FRIST wait
@access public
function wait($secs) { $temp=gettimeofday(); $start=(int)$temp["sec"]; while(1) { $temp=gettimeofday(); $stop=(int)$temp["sec"]; if ($stop-$start >= $secs) break; } } echo 'FRIST';
Admin
That's certainly a lot more useful than a fucking busy-wait loop.
Admin
(Now with quoting goodness.)
Admin
Waa waa what? php is easier than ASP? Maybe asp from the dark ages but modern MVC stuff? With one of if not the best IDE vs in all likelihood an editor from the 70's. Yeah okay, easier.
Admin
It is not even midnight safe!
Admin
AKA a Speed-up Loop
Why invent a new more boring name?
Admin
Heh, so I'm guessing this excerpt from a personal project of mine wouldn't get me hired in any IT department you were in charge of.
http://img401.imageshack.us/img401/2144/screenshotfrom201306040.png
That's
all in one 16-line statement. IMO judicious indentation makes it perfectly readable.
(maybe this is why I'm unemployed xD)
Admin
Admin
I get a 404.
Admin
Admin
Or just press the Turbo button
Admin
Actually, after poking around, the biggest WTF is that they didn't use usleep(). Why burden the CPU with a delay loop when you can just pause the program?
Admin
Because infrastructure should be invisible. Once you've started down the path of making both hardware AND software changes in order to tweak the user experience, you've introduced a whole other world to your troubleshooting process in the event anything starts behaving unexpectedly. Best practice is to over-test your hardware when you install it and then lock the rack and leave it alone for as long as you possibly can. Whenever possible, decouple hardware functions from one another, again to eliminate components from any troubleshooting procedures. That is why there are SANs, tape robots and network switches even though your server can physically hold ten hard drives, its own tape drive and a deck of NICs.
/maybe the OP was being sarcastic but I've seen it for real too many times
Admin
I must to confess to having been forced to do something similar, however we put in certain protections:
The delay was set to scale down based on the version number; every release would contain "performance enhancements" without any need for developer intervention. This way, if everybody forgot about it, we wouldn't be tanking performance a year from now.
A scheduled task was added to email the ceo, cto, and developer distribution list the total amount of time lost to this delay in a quarterly report. This amount was expressed in terms of time and the amount of money to employ people for that length of time.
Admin
http://php.net/manual/pl/function.sleep.php
Admin
Weird. How about this?
http://tinypic.com/r/2rclo5c/5
(Come on, just post. This isn't spam.....)
Admin
You are obviously not a team player and are an all-around mean and vindictive person. I like that!
Admin
Probably because that is taking a hammer to a problem that required a screwdriver.
Code's easier to work with than re-clocking the CPU; can be done dynamically without fear, and doesn't affect any other programs that might be running on the server.