- 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
How did Wayne keep the compiler from simply skipping that code altogether? In 1985, I had a boss who tried to do exactly the same thing for the same reason, but was foiled by the optimizer and never figured out why.
Admin
Say what you want, but this is genious
Admin
Absolutely Brillant!
Admin
I don't know about back then, but today you can turn the optimization process OFF.
Admin
Reminds me of The Programming Antihero.
Admin
God help him if he is ever given a manager who knows his stuff... He'll be out the door so fast your head would spin.
Admin
Well, in the 80s and 90s the compilers were not that smart ... at least not the few that I used in DOS.
Well, what can you expect in 40kB? http://prog21.dadgum.com/116.html
Admin
I love how all the typos are still presant in the reposted version.
CAPTCHA: vindico - Latin for vindicated.
Admin
You can't edit the classics. If you did, then it would be an edited classic and not a classic.
How well do you think it'd go over if Juliet asked, "Yo Ro, where y'at?"
Admin
Admin
Also note that for there to be an "obvious integer overflow",
must be a 16-bit type, so 's type is probably .Admin
Admin
Oh that's just great, monospaced text gets its own paragraph. Serves me right for forgetting to preview first.
Admin
Is there really an "obvious integer overflow"? Isn't the max value of the
-type 2147483647?And can you really use ++ on a
-type?Sorry for my questions, but I'm still a beginner at programming.
(Or am I missing the sarcasm in the text? :-p)
Admin
I think I know where that guy ended up.
A while ago I inherited a web application which uses a shitload of server-side web service requests (with a lot of conversion and validation on both ends) to talk to the same application on the same server, where any sane person would simply implement the necessary function calls directly.
If an average "save customer detail form" action requires over two dozen of those "web service" loopbacks you know it's time to refactor some code.
Admin
Managers aren't always as stupid as you think and one of them would surely notice that the same, easy-to-read line of c code gets changed on a weekly basis but never removed. It was probably assembly to obfuscate it more.
Admin
Is it weird that I'm bothered less by the modern slang and more by the fact that "wherefore" does not mean "where"?
Admin
present
Admin
Nowadays we get these slow downs built in into our frameworks. That's so much easier.
Admin
It's "implementation defined".
On 16-bit machines (I'm sure DOS was mentioned in the article somewhere), an int is probably 16-bit and probably ranges from -32768 to +32767.
Admin
It's a pointer to some memory space defined as Char in size.
The ++ is supposed to increment the pointer to point to the next location in memory. So what this is probably meant to be do is set 1000000 spots in memory to be equal to 0 starting from 0x10000.
Unrolling the loop would give something like: 0x10000 = 0; 0x10001 = 0; ... 0xFFFFF = 0;
1048575 - 65536 = 983039 memory spaces available to zero out before overflow... and the loop goes 1000000 times. I assumed this was the "obvious overflow", not the int declaration.
Admin
The max value of
depends on the architecture.It is a pointer, and yes.
Admin
He's not increment a char (although you can). He's incrementing a pointer to a char.
Admin
Although I enjoyed Shakespeare, we're talking the better part of 25 years since I last studied R&J (high school frosh year). It may have been covered, but I don't recall a discussion about the word "wherefore" and what exactly it meant in this context. And it's not a word I use every day.
But in reviewing the passage, yeah, you're right. Act II, Scene 2, asking him to ignore his family history -- or if he won't, then she will ignore her history so they can be together. First day back to work, anticipating a major run-in with someone from a different team today, less than 6 hours sleep after already having been up late Christmas night . . .
Admin
Admin
Wayne's the kind of genius I would love to have on my team. True genius is only appreciated after it's time has gone.
I once worked with a manager who wanted to add two columns "Extra1", "Extra2" to every table in the database.
Admin
Yes, because no one has ever made a successful modernized adaptation of Romeo and Juliet or any other of Shakespeare's classics, such as, oh, I don't know, maybe The Taming of the Shrew. Such a thing would never be popular with modern audiences...
Admin
From C's perspective is just another integer with the range of -128 to 127, so, sure, ++ works on it just fine.
The story took place in the 80's, and I don't recall a DOS compiler at the time where int=long by default. If you saw 'int' in the code from the period and for DOS, your overflow would be at 32767.
Admin
haha, you are surely imaginative!
Admin
Admin
There IS something in the loop: ; Does that count?
Admin
It's true that you can use ++ on a char. However, the code fragment shown here doesn't do so. The ++ actually affects the pointer.
is the same asSo the effect of this line is to zero the byte p is currently pointing to, and also increment p to point to the next byte.
Admin
Do you also believe in a) tooth fairy, b) santa claus and c) frozen requirements?
Admin
I knew someone who had a shell script that paused for 4 seconds and then printed a "segmentation fault" message.
Whenever the boss asked about progress, he would put on his baffled look and say "I'm still working on that bug, but I can't find where the crash is... I've been debugging it for days now". Then he would run the script to show the "progress", and say "here, it crashes after the initialisation, but I'm still looking".
We would just nod our heads in disbelief (but his lack of progress didn't actually affect anyone).
Admin
Maybe in real life, but tdwtf has a pretty high bar for weird.
Admin
But those are remakes of classics and they exist in and of themselves. I'm saying you can't change a line in "Romeo and Juliet" and have it stay the same, still calling it "Romeo and Juliet." If you even modernized the spelling of the words Shakespeare used, you're changing it because that's not how it was written.
The original statement was that the spelling wasn't corrected on today's classic WTF. I'm saying that if the spelling were corrected, or the grammar cleaned up, it's no longer a classic.
Admin
Modern productions of "Romeo and Juliet" often cut a lot of the play, and still call it "Romeo and Juliet."
Admin
The RWTF is they didn't use OS/2 1.1
Admin
Shakespeare would be a good writer if it wasn't for all those cliche's.
Admin
Speaking of clichés, here's one!
Admin
I once (very briefly) worked with a guy who told me he'd put loops like this all over some industrial resource calculator program because the calcs took under a second to run, but he wanted to delay it to "make it look like it was working hard doing something"
Admin
Anyway.. I just want to say this: the Speed-up Loop is to optimization what the Classic WTF is to TDWTF.
Admin
Thank you all for explaining the int and pointer for me. I didn't know what the * meant in the code, and didn't realize that once upon a time in the 80's a int wasn't the same as a int in the 21th century.
Thank you all for enlightening me. :-)
Admin
Tybalt shot first.
(And Friar Laurence failed to make the Padua run in under twelve furlongs.)
Admin
Your manager can actually understand the code you write. What do you do now?
Also, this may explain what happened with Vista. They added 0s instead of removing one! Think about it, every new version of Windows is supposed to be the fastest, what easier way to do that than with a speed-up loop? It's best practice!
+1 internets to you, good sir!Admin
Back in the 70s, a couple of friends of mine worked as projectionists in an adult movie theater.
They had a speedup loop of their own.
Whenever they got a new movie in, they would watch it looking for scenes where they could cut to the next reel of film. On the last showing of the night, they would cut the movie short.
On a good night, they could reduce an hour of film to about 20 minutes. I've always wondered what the customers thought or if they even noticed.
Admin
Admin
I once encountered code like that for timing delays. Not very portable. On my local system I noticed "wow this code is taking forever", so I took it upon myself to optimize it. It went to the cusomter who had a faster computer and promptly failed.
Admin
I used to have some kind of game on one of the old original IBM PCs that depended on processor speed for timing.
When I got an 80286, I put the game on it and found it to be completely unplayable because human reaction times weren't fast enough to do anything before your game character was knocked off.
Admin