- 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
Am I the only one who had the strong feeling that this story is really special somehow?
After a lot of pondering, I now know what's so striking about it: Those people have working code!
I mean - lucky Ben does not have to dig through the ugliest of all codes, he does not even have to do a lot of maintenance, that sounds like really nice code!
Other facts that are quite uncommon here on theDailyWTF:
TRWTF is that today, there is none.
Admin
int = -2^16 to 2^16 (-1) 100000 > 2^16
Admin
I thought it meant rewriting 80% of the shitty outsourced code by the 20% of original staff left with jobs...
Admin
A lot of what is sorta ETF in here is really just a perversion of good practices.
Padding a time estimate is always the best option. Being able to go to a client/boss and say "Hey, we got done early!" is a lot better than "oh shit, we need more time!". The problem, of course, is the extreme abuse of this.
KIRK: Scotty, "Do you always multiply your repair estimates by a factor of four?"
SCOTTY: "How else to maintain my reputation as a miracle worker?"
Admin
But the first mainstream 32-bit* OS (for PCs) didn't arrive until 1995. Up until them 386's (and 486's) spent the vast majority of their time emulating slightly improved 286's.
*Windows 95 was more of a 16/32-bit hybrid, but it ran 16-bit code in V86 mode, meaning that the processor spent most of it's time in a mode that was at least partially 32-bit.
Admin
I hate to break it to you, but any competent project manager would have realized long ago that you over-estimate ridiculously, and would not take that into account when planning entire projects
Admin
Where I used to work we used to joke doing this very thing!
Admin
GCC will not optimize away the empty loop. It is documented as such, because GCC assumes that such a loop is purely for delay purposes, so optimizing it away is undesirable.
Admin
You're right, I looked it up in C99. But the point is still true, isn't it?
Admin
80/20 Rule, otherwise known as the Pareto Principle: http://en.wikipedia.org/wiki/Pareto_principle
Interesting take on job security. Of course now-a-days, I don't think you could find a programming job in the US that you're not on a team that is completely understaffed for the project or projects it has.
Admin
The real WTF is.... that there is no WTF, this guy is a genius!
Admin
That would be great:
A: Hey how long does it take to count to 10 seconds? B: Oh, about 20 minutes, why?
Admin
Hmmmm.
This is why I always include something very obviously wrong in the UI of any application I'm trying to get accepted by management. For some odd reason management types simply cannot accept a program as-is. Instead they all absolutely must make some sort of change to the program or else the program simply isn't "theirs".
So I include obvious UI defects that they can easily see and order changed. Otherwise they'll really muck up a program and make life a lot harder.
Admin
Admin
Unless, of course, the "app" is just a cheap mock-up. Then management is immediately convinced the product is perfect-as-is and ready to ship, regardless of how buggy and unstable you try to convince them it is.
Admin
The Real WTF:
Why was he in such a giant hurry to hire this fellow, when things were so...calm.
Captcha: oppeto, Pinocchio's little sapling?
Admin
Admin
No.
Admin
Now calm down, friend. It's not you. Everyone else seems to be posting in TLDR mode (default on /.). I've read about three or four different comments ten times over when reading the posts here.
Admin
I'm not a DOS guy, but wouldn't it default to a signed short - ie MAX_INT will be 0XEFFF (2^15 - 1)?
Admin
No, the 80/20 rule is that 80% of your resources will be consumed by 20% of the project. Or, 80% of your sales will come from 20% of your products. Etc.
Admin
80/20 rule.
The first 80% of the project takes 80% of the time. The Last 20% of the project takes the other 80% of the time.
Unless it's a TCP/IP port allocation scheme involving the universal firewall hole, and the HMP port.
Ex
Admin
This is NOT a WTF. This is actually one of the most beatiful, creative and intelligent way for techies to manage higher levels.
This should be put on a poster on all the office walls. Would remind managers that they are essentially inept at understanding developers and that the most important thing they need to build with its team is trust.
Admin
Virginia Tech had a required "professionalism in computing" class that was supposed to cover that.. but it was more focused on ettiquette lessons like "'Business casual' dress code does not include sweatpants".
Admin
It's a circular argument. Everybody else on the team overestimates, so they assume you do to. Say it'll take 2 weekss? They think it'll take 5 minutes, and will therefore allocate 3 minutes to the project plan.
The worst is when they have a fixed deadline without enough time allocated to get it done, then they ask you for estimates. "Well, I'll either have it done by Thursday or I won't be working here anymore, so I'd say Thursday is my estimate. Now you wanna stop wasting my time so I can get back to work?"
Admin
80/20 is the pareto rule.
http://en.wikipedia.org/wiki/Pareto_principle
Admin
Not quite. For example:
If I don't define any weird macros then the loop is useless.
If you want busy wait, just use the volatile modifier.
Admin
I was always told that 80/20 rule means that in any given project the first 80% of the work only takes 20% of the time. It takes a lot longer to do that last 20% of the work that gets the project working at 100%
Admin
I disagree. This loop does not "do nothing" - it prevents the execution of the code following it until some condition is met. In this case, the condition is !(someThreadVariable != 500), or someThreadVariable == 500 for short. If Visual C++ removes the loop in Release configuration, this breaks the semantics.
Others have - incorrectly - claimed that the compiler may do this because someThreadVariable is not volatile. The lack of volatile allows the compiler to make assumptions about the state of someThreadVariable in the absence of threads, interrupts or other sorts of state change not effected by local code flow (in one word: asynchronous change). But in the case of your example, this only means that the compiler may replace the loop condition by "true", turning the loop into an infinite loop as without asynchronous changes of someThreadVariable, the condition will always be true.
Changing the loop condition to "false", which is equivalent to what Visual C++ does, is, however, invalid with or without a volatile qualifier on someThreadVariable.
Admin
Admin
No bull shit, it's how everything in the world is distributed, from water in drops (80% of the water is in 20% of the drops), to income distribution, customers (20% of your clients probably generate 80% of your profit) etc....
http://en.wikipedia.org/wiki/Pareto_principle
Admin
I would be very surprised if there was a compiler in the world that does that optimization. Lots of people use loops like that for delays. It would be a big presumption on the part of the compiler to disallow it.
Not only that, the loop changes the value of i.
Admin
Damn. I concede.
Admin
The 80/20 rule applies like this: 80% of the profit in my store comes from 20% of the items sold. 80% of the work done with my app excercises 20% of the code. 80% of the population owns 20% of the wealth. In most companies 80% of the work is done by 20% of the staff...
Admin
afaik Java is one of the only language to do the sort of loop optimisation where you remove "ineffective" loops and even then it doesn't do it anymore.
And the .NET comparison isn't really correct, because a lot of optimisation goes on in the JIT compiler (as Java's did in this case). All you're doing is comparing the CIL which is only half optimised.
Admin
There is an ENORMOUS difference between slowing things down for the sake of making you and your department look better, and slowing things down to let the user know something happened.
Admin
You must be kidding...
Admin
GCC 4.1 (and possibly earlier versions) does optimize away loops which can be proven to have no side effects visible to standard-compliant programs from outside of the loop. This can remove significantly non-empty loops if the compiler can prove the optimization has no semantic effects visible from within the program but outside the loop (obviously the optimizer doesn't take into account execution time, heat and EMI from the CPU, etc so any such effects will be lost).
I found this out the hard way when trying to compare the execution time of various algorithms for calculating a simple idempotent function by calling the function millions of times in a loop. Unless I dereferenced a pointer within the function, the optimizer would determine that it was necessary to call the function at most once, ruining my test.
Admin
...if used with -O2 (maybe -O1 as well). Without a -O flag, or with -O0, GCC won't do any optimizations at all, not even trivial ones.
Admin
There's something fiendishly brilliant about it... >:)
Admin
That evening after he left, I thought of another approach to solving the problem that would accomplish the same thing but was substantially simpler to program. So I went ahead and did it. It took about an hour or two to finish using this approach.
The next day, my boss came up to me and told me to go ahead and do it. He was a bit ticked off when I told him I finished it the night before and explained the way I did it.
I think he waited two weeks to show the results to his boss.
Admin
I agree with you, to be truly ethical such loops (without another purpose like synchronisation, interfacing with a human, etc) shouldn't be used as a general rule of thumb.
On the other hand, if your boss is milestone minded and only pays attention to say runtime (or other very small minded and limited statistics) techniques like the above can be useful to show that progress is being made. To be ethical in this case you actually need to have made progress with program faults/refactoring/scaffolding.
It would also be useful in punishing your bosses for a really crappy design decision, you can simply slow the program down.
boss: Why is the system so slow? tech: Well you know those changes to the xyz runtime... boss: yes? tech: They don't fit there, we need to move them to abc (the right place) boss: Will that speed it all up again? tech: Pretty sure.
(Note: you really only should punish them, if you are very certain it won't work/work well. You shouldn't use it when your simply not getting your way, doing something your uncertain of/don't want to do)
Sometimes you need to get people to respect your knowledge and skill. Sometimes you can only do it by hitting them - even though we don't really want to. , it's the difference between being paid to make a crappy house, and being paid to make the house they really will like and need.
Admin
Well, I don't know how common this is, but I'm majoring in Computer Science and at my university we're in the College of Engineering. Second semester senior year, we're required to take an Ethics course.
Admin
I've read the discussion on whether or not an empty loop would be optimised away by a modern compiler, but surely a loop such as
for (i=0; i<10; i++) {;}
would be optimised to NOP x 10 by most compilers set to 'unroll loops'? And would they then remove redundant NOPs?
(10 minutes passes)
Well, after some testing, it seems that gcc won't optimise out loops like this, but Sun Workshop cc (also known as Sun Pro cc) WILL optimise out loops like this with -fast.
I guess the thing is, if you're inserting bogus delay code to make yourself look better a few months down the line when you 'optimise' the code, use usleep(). :)
Admin
um, the story takes place in 1990. November 1989, plus ~(3) months, makes it ~February 1990. :-)
Admin
Speed-up loop. It's.... it's... insurance, and pure genious!
Admin
Admin
Assuming that i is an int (-32768 .. 32767), then thanks to integer overflow, when they drop the first zero off that they'd blow all their future speedup ability in one hit. 100000 is 0x186A0 in hex, which will get stored as 0x86A0, which as a signed int just happens to be negative since the high-bit is set. So, since zero is not less than a negative number, the loop will terminate immediately.
Then they'd have to do some real optimisation work next time!
Admin
Someone wrote "xor eax, eax" instead of "mov eax, 0". Damn, I love it. You save a cycle!
Admin
I love the idea of Windows 2.11, having worked at Philips on a add on toolset for Windows 2, that was released a month before Windows 3 made it obselete by implementing all the features we had carefully crafted to get round the limitations that were no longer there.