• Anon (unregistered) in reply to Deke
    Deke:
    It took half a day to figure that out?

    To be fair, maybe it took them a minute to figure out what it did, another hour to argue over why it was done that way, maybe another 2 hours going off on a tangent arguing about whether a byte is defined as 8 bits in the C standard. And then an hour trying to write something witty about it so they could send it to TDWTF.

  • NiceWTF (unregistered)
    "We had a coder for our project named Clyde," Robert B. writes, "who would have been much happier coding in C, but we had good reasons for choosing VB instead."

    Easily spotted the real WTF: there exists no such thing as a "good reason to use VB instead [of anything]".

  • Andy (unregistered)

    Makes complete sense if this was an "End of month" function, it's just been extrapolated for end of year.

  • Al Dimond (unregistered) in reply to kastein
    kastein:
    * Preprocessor abuse (I should be on death row...) * ?: the best, worst operator on the planet (guilty)

    What about preprocessor abuse exploiting the ternary operator. I've seen something basically like this (I might have the details wrong, it's been a while):

    #define RANGE_START(a) (1?a)
    #define RANGE_END(a) (0?a)
    #define RANGE_SIZE(a) (0?a - 1?a + 1)
    #define VGA 0xa0000:0xaffff
    

    So you could use

    RANGE_START(VGA)
    to get the start of the VGA range. Pretty clever.

  • Lynn (unregistered)

    It's possible the code actually was fiscal-year based, and the fiscal year ended in June, which only has 30 days. One day, administrative changes restructured the fiscal year to end in December and align with calendar year, but nobody bothered to change the code since it still works fine because the programmer took into account that the fiscal year-end date (month) could change someday...

  • (cs) in reply to Ancient_Hacker
    Ancient_Hacker:
    That's nothing. One very-slow SQL app would look up the names of the months, and the names of the days for every web page generated, just in case they changed since the last second.

    Or maybe to support clients with different languages at the same time?

  • (cs) in reply to kastein
    kastein:
    I'll bite: * Preprocessor abuse (I should be on death row...) * ?: the best, worst operator on the planet (guilty) * bitwise vs logical NOT (~ != !) confusion * not checking return values for failure

    You should also be checking for worse than failure.

  • Max (unregistered) in reply to Pim
    Pim:
    The real WTF is that Jake writes "ease of coding in VB".

    Jake, here.

    unsigned int x; if (x>=0xC0000000) {...}

    Translate that into VB please. With ease of coding of course!

    Dim x as UInteger

    If x >= &HC0000000 Then ... End If

  • Ghlitch (unregistered)

    This is a great piece of code, not only will it work on Earth, it'll also work on any planet where his function is used.

  • (cs) in reply to Bobbo
    Bobbo:
    The real WTF (sorry!) is that when I first got to this article a few minutes ago, it said "1 comments".

    Come on Alex, is a pluralisation check that complicated??

    Really. Who cares? By the time you get to see the "1 comments", there are more comments and you don't have that anymore. No matter how complicated it is, there's no payoff. It occasionally prompts a comment like that, which starts a real flurry of activity. And the hit count goes up, and the popularity grows. So why fix it?

    Sorry. Just me feeling peckish this morning. Really!

  • Edward Royce (unregistered) in reply to Simon
    Simon:
    Future-proofing is underrated. In corporate programming it's frequent to have a temporary one month solution operate for a decade.

    Based on that, anything that isn't temporary could be running for millennia.

    I find your confidence in Visual Basic to be ... disturbing.

  • (cs) in reply to Pim
    Pim:
    QuickC.
    that was fast.
  • iToad (unregistered)

    Clyde's code might work for now, but what happens if the world suddenly decides to switch back to the French Republican Calendar?

  • Strilanc (unregistered) in reply to Max
    Max:
    Pim:
    The real WTF is that Jake writes "ease of coding in VB".

    Jake, here.

    unsigned int x; if (x>=0xC0000000) {...}

    Translate that into VB please. With ease of coding of course!

    Dim x as UInteger

    If x >= &HC0000000 Then ... End If

    Isn't &HC0000000 a negative signed integer in VB? You need to put an L on the end so its interpreted as a positive long.

  • (cs) in reply to Al Dimond
    Al Dimond:
    kastein:
    * Preprocessor abuse (I should be on death row...) * ?: the best, worst operator on the planet (guilty)

    What about preprocessor abuse exploiting the ternary operator. I've seen something basically like this (I might have the details wrong, it's been a while):

    #define RANGE_START(a) (1?a)
    #define RANGE_END(a) (0?a)
    #define RANGE_SIZE(a) (0?a - 1?a + 1)
    #define VGA 0xa0000:0xaffff
    

    So you could use

    RANGE_START(VGA)
    to get the start of the VGA range. Pretty clever.
    My god. that's just evil and/or diabolically clever. I am not entirely sure you wrote it right, but I think I get what it's trying to do...

  • Loren Pechtel (unregistered)

    I'm going to say this one is not a WTF.

    Rather, it's a result of an overly-strict rule against no magic values.

  • whatever (unregistered) in reply to jimlangrunner
    jimlangrunner:
    Bobbo:
    The real WTF (sorry!) is that when I first got to this article a few minutes ago, it said "1 comments".

    Come on Alex, is a pluralisation check that complicated??

    Really. Who cares? By the time you get to see the "1 comments", there are more comments and you don't have that anymore. No matter how complicated it is, there's no payoff. It occasionally prompts a comment like that, which starts a real flurry of activity. And the hit count goes up, and the popularity grows. So why fix it?

    Sorry. Just me feeling peckish this morning. Really!

    WTFSupport: Hello, TDWTF Support line Caller: Yeah, your page says "1 comments". Clearly there is something critical wrong. WTFSupport: Ummm, could you try refreshing the page? Caller: Hey it's fixed!

  • Chelloveck (unregistered) in reply to Kermos
    Kermos:
    But seriously, I've yet to come across a C compiler that doesn't support //

    You've obviously not worked in embedded systems. I've come across quite a few C compilers for oddball processors which don't support //. Haven't yet found one where a char is anything other than 8 bits, though.

  • Matt (unregistered) in reply to JJ

    That's just called getting the most out of your tax deductions.

  • Zerbs (unregistered) in reply to SomeDude

    [quote user="SomeDude"]The real WTF is this:

    [quote]we had good reasons for choosing VB instead.[quote]

    [/quote]

    ugh... Why do there have to be so many C bigots in the world?

  • (cs) in reply to Just Sayin
    Just Sayin:
    Long before the sun grows cold, we could develop some common sense and restructure the calendar as 13 months of 28 days each. With the occasional leap day of course. His code will keep running, everyone else has to rewrite. Instant competitive advantage!

    It could happen.

    OK maybe not the common sense part.

    Never mind.

    If you are doing that, than do it right. Why that idiotic 60-based minutes and hours?

    10 months of 36 days, of which the first five have an extra day. 1 week = 10 days (7 days work, 3 days weekend, with a little bit more spare free days to make up) 1 day = 10 dhours (= ~2,5 hours) 1 dhour = 100 dminutes (= ~1,5 minutes) 1 dminute = 100 dseconds (= ~0,9 seconds)

  • (cs)

    My favorite C programmers mistake when writing VB (6) code:

    Dim foo, bar, widgit as Int

    foo and bar are variants, only widgit is an Int. MS fixed in VB 7.

  • Dr_Legacy (unregistered)

    meh, it looks like failed Y2K-handling code.

    the problem appears to be that either iyear or datYrEnd_Dt is suspect somehow, and he wants to validate them against each other.

    but the transmorfation applied ensures only that datYrEnd_Dt is in iyear. it does not ensure datYrEnd_Dt is the last day of iyear.

    left as exercise for reader.

  • Zerbs (unregistered) in reply to jimlangrunner
    Bobbo:
    The real WTF (sorry!) is that when I first got to this article a few minutes ago, it said "1 comments".

    Come on Alex, is a pluralisation check that complicated??

    This isn't that annoying is it? Reminds me of when I used to work at a (U.S.) company that used Lotus Notes as their e-mail, and had an office in Austrailia. A read receipt from an e-mail we sent there in the afternoon would often come back: "Your message has been read tomorrow at 8:03 AM"

  • justsomedude (unregistered) in reply to Deke
    Badastronomy:
    Actually since the Earth's rotation is slowing there will be fewer days in the year which might cancel out the longer year caused by the Earth getting farther away from a reduced mass red giant sun.

    Useless fact: Most of the world's deciduous forests are in the northern hemisphere, and this results in a seasonal variation in the speed the Earth rotates.

    The real wtf is they bothered setting that boolean to it's default value of False before using it...sure it might be a static with a previous value, but I can't see why that would be the case given it's purpose.

  • Tim Rowe (unregistered) in reply to Zerbs
    Zerbs:
    ugh... Why do there have to be so many C bigots in the world?
    It's not C bigots, it's anti-VB bigots. Get it right. Heck, some of us would rather code in INTERCAL than VB.
  • Moe (unregistered)

    I have read 2 pages of comments, out-smarting each other (plus some puns I deeply appreciate ^^), and maybe I'm missing a collective joke, but did it really occur to no one that this is a plain leap-year check?

    In pseudo-code:

    if year-of("01/jan" plus 366 days) == year-of("01/jan" plus 365 days) then leapYear = true;

    Or at least that's what he intended, I guess. I have no idea if the code presented really works like that, but I can see how a former C programmer might think like that.

    Obviously, the author is not a native english speaker and chose to call leap years "skip years". Consequently, bSkipYearCheck = True doesn't mean "please skip some special year check" but "the check for leap year was true".

    Of course, it's a lot of speculation since the code fragment is too small, but this way it actually makes sense (notwithstanding the fact that it is convoluted, probably broken etc.).

    It is sad that people are so fast at jumping on code they don't understand and criticizing it for all the wrong reasons.

  • WTF checker (unregistered)

    The WTF is that the guy didn't write comments.

  • lonely at home (unregistered) in reply to Moe
    Moe:
    I have read 2 pages of comments, out-smarting each other (plus some puns I deeply appreciate ^^), and maybe I'm missing a collective joke, but did it really occur to no one that this is a plain leap-year check?

    In pseudo-code:

    if year-of("01/jan" plus 366 days) == year-of("01/jan" plus 365 days) then leapYear = true;

    Or at least that's what he intended, I guess. I have no idea if the code presented really works like that, but I can see how a former C programmer might think like that.

    Obviously, the author is not a native english speaker and chose to call leap years "skip years". Consequently, bSkipYearCheck = True doesn't mean "please skip some special year check" but "the check for leap year was true".

    Of course, it's a lot of speculation since the code fragment is too small, but this way it actually makes sense (notwithstanding the fact that it is convoluted, probably broken etc.).

    It is sad that people are so fast at jumping on code they don't understand and criticizing it for all the wrong reasons.

    Will you marry me?

  • Zapp Brannigan (unregistered) in reply to YourNameHere
    YourNameHere:
    My favorite C programmers mistake when writing VB (6) code:

    Dim foo, bar, widgit as Int

    foo and bar are variants, only widgit is an Int. MS fixed in VB 7.

    I'm still using VB 6 you insensitive clod!

  • (cs) in reply to Fred
    Fred:
    Obviously they don't want someone who is good at their job. They want someone who is infected with the same meme as they are, to help them further the spread of the infection.

    Wouldn't make much sense. If they person is already infected with the same meme, then converting that person doesn't further the spread of the infection.

    What you want is a person infected with a different, perferably competing meme. Then, converting them not only strengthens your side, but weakens the other. Double word score!

  • (cs) in reply to MrsPost
    MrsPost:
    CaptainSmartass:
    TRWTF on the page today is the job ad for a "Christian professional Senior Systems Engineer". If someone is good at their job, what does it matter what their religion is?
    It's like the various businesses that have the Christian fish symbol. I take it as a warning, kind of like the "Intel Inside" stickers.
    What's the warning sign for internet trolls?
  • (cs) in reply to Max
    Max:
    Dim x as UInteger

    If x >= &HC0000000 Then ... End If

    UInteger? Where did that come from? When did they ... Oh. VB.Net. Right. Yeah.

  • whatever (unregistered) in reply to operagost
    operagost:
    MrsPost:
    CaptainSmartass:
    TRWTF on the page today is the job ad for a "Christian professional Senior Systems Engineer". If someone is good at their job, what does it matter what their religion is?
    It's like the various businesses that have the Christian fish symbol. I take it as a warning, kind of like the "Intel Inside" stickers.
    What's the warning sign for internet trolls?
    [image]
  • (cs) in reply to YourNameHere
    YourNameHere:
    My favorite C programmers mistake when writing VB (6) code:

    Dim foo, bar, widgit as Int

    foo and bar are variants, only widgit is an Int. MS fixed in VB 7.

    You've got that in many languages.

    Mistake that Pascal programmers make when writing C code:

    int* foo, bar, baz;

    Only the first is a pointer to an int; the other two are ints. Microsoft fixed that in C# by removing the pointer type.

  • Anonymously Yours (unregistered)

    You foolish, foolish fools! When Clyde's solar repeller is complete and he pushes the Earth into a new orbit, you'll WISH you had that check to maintain your data with! I will admit that, to some, his evil genius plan might be lacking on the reward side and heavier on the effort side, but what mastermind starts with galactic conquest and works his way down?

    He'll show you all. OH YES, HE'LL SHOW YOU ALL!

  • crap crap crap (unregistered) in reply to jobrahms
    jobrahms:
    Anon Ymous:
    NSCoder:
    I never thought I'd VB that happen.

    I 'C' what you did there.

    Java problem with that?

    (You have to say "Java" like a Canadian)

    jokes are so much funnier when you explain them.

    cuz i was doin her. last... night. when, she, uh... said that...whut, uh... whut she said.

    genitus: we don't post captchas cuz they're funny or appropriate, we just post them to help out the spambots...

  • n (unregistered) in reply to Chelloveck
    Chelloveck:
    Kermos:
    But seriously, I've yet to come across a C compiler that doesn't support //

    You've obviously not worked in embedded systems. I've come across quite a few C compilers for oddball processors which don't support //. Haven't yet found one where a char is anything other than 8 bits, though.

    That is mostly because // is from C++, not C.

  • dan (unregistered) in reply to Chelloveck

    I've seen a char not be 8 bits. Texas Instruments' VC33 processor has 32-bit memory. Bytes are not addressable, and the compiler makes everything be 32 bits.

    Floats, doubles, ints, shorts, chars, it doesn't matter. Every one of them takes up 32 bits, and sizeof returns a 1 for all of them.

    Chars only use 8 of the 32 bits though, which means that constant strings are kinda wasteful.

  • (cs) in reply to Just Sayin
    Just Sayin:
    Long before the sun grows cold, we could develop some common sense and restructure the calendar as 13 months of 28 days each. With the occasional leap day of course. His code will keep running, everyone else has to rewrite. Instant competitive advantage!

    It could happen.

    OK maybe not the common sense part.

    Never mind.

    A lot of things happen at quarters of years, especially in the financial sector. Would be really nice to have 13 months instead of 12.

  • OldCoder (unregistered) in reply to Chelloveck

    Honeywell Level 66 mainframes (later DPS 8, DPS 200) had 9-bit bytes. Yes, the words had 36 bits in them...

  • Max (unregistered) in reply to Strilanc
    Strilanc:
    Max:
    Pim:
    The real WTF is that Jake writes "ease of coding in VB".

    Jake, here.

    unsigned int x; if (x>=0xC0000000) {...}

    Translate that into VB please. With ease of coding of course!

    Dim x as UInteger

    If x >= &HC0000000 Then ... End If

    Isn't &HC0000000 a negative signed integer in VB? You need to put an L on the end so its interpreted as a positive long.

    Indeed. Shucks...thwarted on my first TDWTF post. I suppose x would need to be of type UInt64 as well.

  • (cs) in reply to operagost
    operagost:
    MrsPost:
    CaptainSmartass:
    TRWTF on the page today is the job ad for a "Christian professional Senior Systems Engineer". If someone is good at their job, what does it matter what their religion is?
    It's like the various businesses that have the Christian fish symbol. I take it as a warning, kind of like the "Intel Inside" stickers.
    What's the warning sign for internet trolls?
    Excessive use of /b/ references?

    ba-dumf-tisshhhh

  • OldCoder (unregistered) in reply to operagost
    operagost:
    MrsPost:
    CaptainSmartass:
    TRWTF on the page today is the job ad for a "Christian professional Senior Systems Engineer". If someone is good at their job, what does it matter what their religion is?
    It's like the various businesses that have the Christian fish symbol. I take it as a warning, kind of like the "Intel Inside" stickers.
    What's the warning sign for internet trolls?
    Any posting on a website.
  • (cs) in reply to alegr
    alegr:
    kastein:
    I'll bite: * Preprocessor abuse (I should be on death row...) * ?: the best, worst operator on the planet (guilty) * bitwise vs logical NOT (~ != !) confusion * not checking return values for failure

    You should also be checking for worse than failure.

    This is really only possible with C99, I'm afraid:

    bool fileNotFound = GrobbleDate();
    if (fileNotFound <= FALSE) { ... }
    
    n:
    Chelloveck:
    Kermos:
    But seriously, I've yet to come across a C compiler that doesn't support //

    You've obviously not worked in embedded systems. I've come across quite a few C compilers for oddball processors which don't support //. Haven't yet found one where a char is anything other than 8 bits, though.

    That is mostly because // is from C++, not C.

    It's like waiting for the other shoe to drop, isn't it?

  • Captain Oblivious (unregistered) in reply to Ken B
    Ken B:
    Pim:
    Ken B:
    The C language defines CHAR_BITS to be the number of bits per character, because it's not always 8.

    (And, as far as C is concerned, "byte" does not necessarily mean "8 bits". That's what "octet" is used for.)

    You're not really a C programmer, are you? Neither "byte" nor "octet" are defined C types. A char is not a byte, and nobody has yet tried to say that a char always has 8 bits.
    from the ISO documentation on the C language (I am using ISO/IEC 9899:TC2)

    3.6 byte addressable unit of data storage large enough to hold any member of the basic character set of the execution environment
    C doesn't have a type of "byte", but it does define the term. It also refers to other ISO documents, one of which defines "octet".
    Emphasis mine.

    A machine that only does capital letters (say, a calculator, or other embedded device) doesn't need 8 bits to store a character. The size of the byte is dependent on the target architecture, and the features it supports.

    As another example, an architecture whose addressable units of data storage are 16 bits wide has 16 bit bytes. Yes, these are out there.

    Jebus H. Christ

  • AnotherOldCoder (unregistered) in reply to OldCoder
    Honeywell Level 66 mainframes (later DPS 8, DPS 200) had 9-bit bytes. Yes, the words had 36 bits in them...
    As I recall, they could be 7 bits or 9 bits. With the 7 bit versions, they put 5 characters, and a spare bit, in each 36 bit word.

    I believe old CDC systems had 6-bit and 10-bit characters, with 60 bit words.

    So we had 6, 7, 8, 9, and 10-bit bytes on the various systems.

    Jeez, these youngsters, think a byte is always 8 bits (wonders off mumbling...)

  • Buddy (unregistered) in reply to Bobbo
    Bobbo:
    The real WTF (sorry!) is that when I first got to this article a few minutes ago, it said "1 comments".

    Come on Alex, is a pluralisation check that complicated??

    Technically, it's a non-singular check (zero being neither plural nor singular):

    0 comments 1 comment 2 comments 3 comments ... 10¹ºº comments etc.

  • BJ Upton (unregistered) in reply to Fred
    Fred:
    CaptainSmartass:
    TRWTF on the page today is the job ad for a "Christian professional Senior Systems Engineer". If someone is good at their job, what does it matter what their religion is?
    Obviously they don't want someone who is good at their job. They want someone who is infected with the same meme as they are, to help them further the spread of the infection.

    Holy crap, this is the first time I've seen "meme" used correctly in a long time. Clearly cause for celebration!

  • (cs) in reply to BJ Upton
    BJ Upton:
    Fred:
    CaptainSmartass:
    TRWTF on the page today is the job ad for a "Christian professional Senior Systems Engineer". If someone is good at their job, what does it matter what their religion is?
    Obviously they don't want someone who is good at their job. They want someone who is infected with the same meme as they are, to help them further the spread of the infection.

    Holy crap, this is the first time I've seen "meme" used correctly in a long time. Clearly cause for celebration!

    Are you an animist- or a fruitarian-shit worshipper? And how, pray, might one be "infected" by a "meme," assuming the latter neologism to be "used correctly?"

    If you want a good laugh, borrow Dawkin's book from a friend and look up the footnote where he says he must be right because his wife, the ex-Mrs Dr Who, says so.

    I don't recommend buying it at an airport bookstall, like I did, because then you're stuck on a ten-hour flight with one of the most apoplectically dull and uninspiring books ever written. ("Toad-sexing for Beginners" was unaccountably out of stock when I enquired.) I considered gnawing off my own head as an alternative, but had to settle for organising a gang-rape of the Al-Qaeda operator occupying the window seat, thus staining his honour (amongst other things).

    That's seventy-two less dried white raisins the little bastard'll be sucking on. But it's still ten hours of my life that Dawkins owes me, and I'll bet he welshes on the deal.

Leave a comment on “Foolproof Future-Proofing”

Log In or post as a guest

Replying to comment #:

« Return to Article