• Mario Goebbels (unregistered)

    You broke my brain. Not appreciated!

  • Ben Von Handorf (unregistered)

    I'll always remember my first experience with VB. I had come from Pascal and C, so I was used to variable types (what a concept). A colleague asked me to figure out what was wrong, because a variable he had just assigned to 1 was failing an if x = 1...

    The wonders of the Variant.
    I think the part I like most about this wtf is that since the And and Or in VB don't short circuit (like any real grown-up language), it's all evaluated all the time.

  • DCD (unregistered)

    1,2,8 are all powers of 2 which makes me believe that this whole if/else statement could be simply written as a bitwise operation. I bet that this is originally a bitwise operation and someone tried to recreate it in VB.

  • Chad Grant (unregistered)
  • Jeff Darcy (unregistered)

    I keep looking at the first fragment and discovering new ways in which it's wrong. First it's obvious that the bulk of it should be in a loop within a function. Then I started looking at the redundancy of checking both (x = READ_ACCESS) and (x <> FULL_ACCESS) . . . until I realized that the first part is all And operators instead of Or. Even if that's what was intended, which seems doubtful, then the (mintOperationMode = OP_NEW) checks are redundant. Then I started wondering if the second part is correct with respect to And/Or precedence, but I don't know the language so I can't say for sure. If I keep looking will I find even more wrong with it?

    As for the second fragment, that's just a true WTF. What could possibly be behind that? The only thing I can think of is that it's generated code, and the person who wrote the code-generator was as dumb as the person using it.

  • Muhammad Haggag (unregistered)

    I think I've got to go change my pants now

  • David Cumps (unregistered)

    Could it be me, or does this always return false? If it really is what the second if says.

  • Matt K (unregistered)

    Where's the function that just returns 8? That's got to be a WTF all on it's own.

  • Miles Archer (unregistered)

    It's not really all that bad. At some time in the future 8 may no longer equal 8.

    ;-)

  • Algol Fan (unregistered)

    Remember y'all the time and place that you first saw this code fragment : a date surely as significant as the Kennedy assasination - verily you witnessed the proof that formal logic is dead. Bow your heads and offer a prayer to the rapidly rotating corpse of a certain George Boole.

    As a public ervice I'll publish the accompanying test strategy for this snippet: ''.

    As I'm a methematicain I won't even comment on the and/or precedence comment above.

  • Tim Smith (unregistered)

    -- It's not really all that bad. At some time in the future 8 may no longer equal 8. --

    To be totally safe I would create a global variable or a #define to define "eight" as 8 in some universal place. You never know, the value 8 might change in the future.

  • Lex (unregistered)

    A "methematicain"? I guess that's what the people who fail English major in, eh? :P

  • Matthew W. Jackson (unregistered)

    if(8 != 8)
    {
    throw new TheSkyIsFallingException("Sinners, repent!");
    }

  • linuxfood (unregistered)

    But doesn't he know that 42 is the binding for of the universe? He should be testing for that, not 8. sheesh

  • Neil (unregistered)

    Damn you linuxfood! I was just going to drop the 42 joke! :)

  • Nick D (unregistered)

    Can't agree more with Ben. Evaluating everything all the time is infuriating. e.g.

    If you wan't to make sure a value is not null, and then you want to check if it's greater than 2, you might think you could do this:

    If Not IsNull(aVariable) and CInt(aVariable) > 2 then .....

    Nope. That's gonna blow up, because despite aVariable NOT being null, it evaluates the rest anyway (hey, why not! It has nothing better to do!) so you end up with loads of embedded 'if' statements where they really aren't necessary.

  • Alfred (unregistered)

    What a bad programming style?

    Damn..

  • Andy (unregistered)

    VB has both non-short-circuting (And, Or) and short-circuting (AndAlso, OrElse) operators.
    And, of course the Variant has been dropped....

    A good coder can write good code in any language. An idiot can write WTFs in any language.... I've seen C++ that boggles the mind in it's WTF-ness, and VB that's as consise and elegant as any code could be....

    That said, VB's easy-to-read syntax, and the use of VBA in MS Office tools for a scripting language produces a whole lot of idiots who think they can code because they can tweak a recorded Excel macro....

  • Nick D (unregistered)

    The problem is, somehow VB does not inspire you to write elegant/good code. It lets you get away with too much bad practice stuff. Yes, it is possible to write very elegant code in VB, but I've been coding for many, many years, and I've seen it... ooh, once. And that was by a hardcore C++ coder. That's gotta mean something!

  • foxyshadis (unregistered)

    I wonder if this could be a workaround for the pentium fdiv bug. ^_~

  • Matthew W. Jackson (unregistered)

    Ha! The FDIV bug! One could blame it for all bad code, theoretically, since I'm sure most non-programmers don't understand the problem. Besides, the VB compiler already had a de-optimization to work around the FDIV bug.

    Incidentally, our team just recently made the decision to start compiling without the FDIV workaround when releasing updates to our old software. Basically, we're saying "Screw you, the two people in the world still running a buggy Pentium in production!"

    We've also decided to compile with "Favor Pentium Pro" turned on. It took me a while to convince everyone that Pentium 2 and up would also benefit from the Pentium Pro optimization (how many people even have Pentium Pros anymore?) Slow memory speeds have caused us to switch from favoring fast code to favoring small code. That was an easy decision, as benchmarks even back this one up almost all of the time.

    Soon we'll drop support for Windows 98. I was ready to do that the day the public Windows 2000 Beta came out, but my peers said that was a bit premature. I never envisioned Microsoft would do something boneheaded like release a new 9X operating system (WinME).

  • josh (unregistered)

    Andy: I challenge you to find someone who can write good code in Malbolge. ;)

  • Ray S (unregistered)

    Ah Matthew, so it's because of you that your product now crashes on all 1000 of my production P1-60 machines eh? Screw you! :-P


    As for that if 8=1 or 2=8 nonsense - wow. I don't know who's more ignorant - the idiot that wrote that bizarre monstrosity, or the anti-VB zealots with their religious VB bashing. Oh well.

  • Phil Harvey (unregistered)

    The author has obviously had a vision of the future where man has evolved 3 digits on each hand, and hence the counting system has followed suit. 1,2,3,4,5,6,10,11,12,13.
    Therefore 8 != 8, in fact 8 == 11. Throw that exception, throw it loudly.

  • KoFFiE (unregistered)

    My guess is that the author of this piece of art had to port some kind of bitmask rights-managment system like in *nix filesystems, but never really understand it... That's the only thing I can make from it.
    Unless the mintAccessLevelForm is NO_ACCESS, I don't think he'll ever see the no access message :) Typical example of really testing all the possibilities extremely well :D

  • Raymond Lewallen (unregistered)

    Dude, you gotta warn us before posting stuff like this. This isn't your normal WTF.. this goes way beyond the normal screw ups.

  • Chris Craft (unregistered)

    Please note: That for very large values of 8, 8 may not equal 8.

  • Ben Von Handorf (unregistered)

    Yes, VB NOW has both short-circuiting and non-short circuiting. As a consultant, about 3% of the people I encounter KNOW about AndAlso and OrElse.


    The default operators are non-short-circuiting, as Nick D described... which makes for that elegant nested If for the 97% of people who don't use AndAlso.

    VB often has good answers to questions... but it hides them behind bad ones. That's my problem with this language

    If Not VBFlaws Is Nothing Then
    If VBFlaws.Length > 0 Then
    Whine_About( VBFlaws )
    End If
    End If

    (Not the Ben who submitted this WTF, BTW)

  • JeffS (unregistered)

    If the compiler accidently tips the 8 sideways, it then becomes infinity, and that certainly isn't equal to 8. So you have to watch out for stuff like that.

  • Joshua Bair (unregistered)

    A few projects ago, we ran into some VB6 code in a Very Large application that contained the following statement:

    public const ONE as String = 1

    And everywhere there were lines like:

    If usemf610 = ONE then avgrtg = avgrtg + rtg

    I figured that the developer overheard someone mention that using constants were faster than variables, and decided to etch this into his brain permanently.

    However, others believe that this value may have been changed to 0 every afternoon before leaving, and changed back to 1 when he returned in the morning, just in case...

    Of course, this application also contained a 10 line rounding function named "fnrw()". Still haven't figured that one out.

  • Stefan (unregistered) in reply to Matthew W. Jackson
    Anonymous:
    if(8 != 8)
    {
    throw new TheSkyIsFallingException("Sinners, repent!");
    }
  • (cs)

    If you're working in a non-Euclidean geometry, the effective value of pi will change. In fact it will be a function of the size of the circle. It could even be zero - the south pole is a circle with centre at the north pole and diameter equal to the polar circumference of the Earth.

  • (cs) in reply to m0ffx
    m0ffx:
    If you're working in a non-Euclidean geometry, the effective value of pi will change. In fact it will be a function of the size of the circle. It could even be zero - the south pole is a circle with centre at the north pole and diameter equal to the polar circumference of the Earth.
    Wow. That must be the single stupidest thing I ever read regarding spacial concepts.

    I don't know how you leapt to this absurd conclusion. Starting by the basic premise that it is a POINT and thus have NO AREA (or even worse - volume), it is quite easy to see you drifted away from reality.

    But let's assume for a moment that that concept could be ignored. Then you say the south pole is centered at the north pole (!). Get a globe and draw a small circle around the north pole; you'll see it doesn't get anywhere near the south pole.

    "Why, the circle is obviously too small"

    Then let us enlarge it until it touches the pole and... surprise! It surrounded the whole Earth. The WHOLE planet is the south pole, according to your dummy statement.

  • (cs) in reply to Smash King
    Smash King:
    m0ffx:
    If you're working in a non-Euclidean geometry, the effective value of pi will change. In fact it will be a function of the size of the circle. It could even be zero - the south pole is a circle with centre at the north pole and diameter equal to the polar circumference of the Earth.
    Wow. That must be the single stupidest thing I ever read regarding spacial concepts.

    I don't know how you leapt to this absurd conclusion. Starting by the basic premise that it is a POINT and thus have NO AREA (or even worse - volume), it is quite easy to see you drifted away from reality.

    But let's assume for a moment that that concept could be ignored. Then you say the south pole is centered at the north pole (!). Get a globe and draw a small circle around the north pole; you'll see it doesn't get anywhere near the south pole.

    "Why, the circle is obviously too small"

    Then let us enlarge it until it touches the pole and... surprise! It surrounded the whole Earth. The WHOLE planet is the south pole, according to your dummy statement.

    As stupid as replying to a comment that's very nearly 2 YEARS old?

  • tharpa (unregistered) in reply to Zagyg
    Zagyg:
    As stupid as replying to a comment that's very nearly 2 YEARS old?

    What's stupid about that? Or is your comment projection?

Leave a comment on “... if, and that's a real big if, ...”

Log In or post as a guest

Replying to comment #23810:

« Return to Article