• EDS (unregistered) in reply to kastein

    One of my favorite define tricks is an incredibly simple one but fun none the less:

    #define EVER ;;

    for(EVER) { ... }

    :)

  • (cs) in reply to Max
    Max:
    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.

    Actually, you just have to replace &HC0000000 with &HC0000000UI.

  • whatever (unregistered) in reply to AnotherOldCoder
    AnotherOldCoder:
    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...)

    The Texas Instruments TMS320C80 is bit addressable. Boy does that make for some fun addressing code.

    Jeez, these youngsters, thinking the least significant bit of an address always maps to a byte (wanders off mumbling...)

  • IHateTheosupremacism (unregistered) in reply to CaptainSmartass
    CaptainSmartass:
    Sounds like something a bored programmer would come up with, not really a WTF.

    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?

    in fact in the united states (and i imagine many european countries) it is illegal to make religion a selection basis*

    *[unless you're a religious institution such as a church]

  • Roman Kennke (unregistered) in reply to Kermos

    [quote user="Kermos"][quote user="Pim"] Avoid // comments?

    Ugh, I can't even say how much I hate it when people do /* blah */ as it prevents simply commenting out a block of code. Yes, I know, I can just wrap it in a preprocessor #if instead.

    But seriously, I've yet to come across a C compiler that doesn't support //

    [/quote] In my place we have a couple of them, all of them are compilers for (some of them fairly obscure) embedded/realtime OSes though (for example, OS9, NRK, etc).

  • iMalc (unregistered)

    The only WTF I see is that it wasn't commented what the code does.

    It's not too different from the if ((x&(x-1)) == 0) trick for testing for powers of two.

  • v.dog (unregistered) in reply to Schlong

    I see you've played Knifey-WTFy before.

  • the amazing null (unregistered)

    hi, isn't it possible that the way he did this is the best way? it seems that it does not need to assume a given format for the date used (that is the only reason i can think of for using CVDate). this way that C programmer, like all good C programmers, does not have to assume that his input is formatted in a given format. i mean, you don't assume that your code will never leave your culture, right?

    his way, he adds one to the date, then checks the resulting year. this is a better way, i think.

    then again, i am a C programmer at heart.

  • v.dog (unregistered) in reply to Schlong
    Schlong:
    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??

    thats not a WTF, this is a WTF:

    I see you've played Knifey-WTFy before.

  • v.dog (unregistered)

    I'm pretty sure that the Zune uses that code exactly.

  • Anon (unregistered) in reply to pink_fairy
    pink_fairy:
    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.

    Which book? You seem to have left that important point out of your incoherent rant.

  • Joannes Vermorel, from Lokad.com (unregistered)

    Due to moon-earth interactions, it's the daily earth rotation that is getting slower. But (almost) nothing is slowing down the rotation of the earth around the sun. Thus, it's a mistake to think there will be a day when December will have 32 days. It's the opposite actually, in a (very) distant future, December will have only 30 days left.

    But the magic is that the sample code exposed here is also covering this situation. What an insight indeed.

  • fanha (unregistered)

    Not a WTF.

    These "The WTF is that someone thinks it's a WTF" are getting more common. This site seems to be more and more frequently turning into a dumping ground for mediocre programmers to ridicule stuff they don't understand, and is teaching more and more programmers that the proper response to anything they don't understand is to ridicule. It used to be actually providing useful insights into how not to program.

  • (cs) in reply to EDS
    EDS:
    One of my favorite define tricks is an incredibly simple one but fun none the less:

    #define EVER ;;

    for(EVER) { ... }

    :)

    in Rexx, forever is built in

    do forever /* whatever */ end

  • aBrase (unregistered) in reply to Joannes Vermorel, from Lokad.com
    Joannes Vermorel:
    Due to moon-earth interactions, it's the daily earth rotation that is getting slower. But (almost) nothing is slowing down the rotation of the earth around the sun...
    My head spins at your revolting misuse of the term "rotation".
  • (cs)

    Where is the year end date set, and how/why is a year defined in this system / context? What is the nature of the check that is being disabled.

    In Australia, the tax-year runs July 1 to June 30. Companies have different "reporting year"s. My employer's accounting year starts on March 1.

    Everyone thinks gregorian calendar year, but what about Chinese or Jewish?

    Years aint years...

  • Jay (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.

    I presume because of people like this poster.

    I haven't seen the ad, but my guess is that this is a church or some other Christian organization. (Likely contributing factor to that theory: If they're not a religious organization, posting a want ad that specifies religion is generally illegal.) They don't want to hire someone who is totally opposed to the goals of their organization and thinks that anyone who holds their beliefs are a bunch of idiots, no matter how good he is at the job. If Fred got a job as a programmer for a religious organization, surely they would be justified in worrying that at best he would be unethusiastic, and at worst that he might deliberately sabotague them. Not necessarily, of course. He might view his job purely as a set of technical challenges. But it would make me nervous if I was the boss.

    Likewise I would expect the American Atheist Association to be wary of hiring a born-again type. I would expect the National Republican Committee to be reluctant to hire an ardent Democrat and vice versa, or PETA to hire someone who showed up for the interview wearing a genuine fur coat, etc.

  • (cs) in reply to aBrase
    aBrase:
    Joannes Vermorel:
    Due to moon-earth interactions, it's the daily earth rotation that is getting slower. But (almost) nothing is slowing down the rotation of the earth around the sun...
    My head spins at your revolting misuse of the term "rotation".
    Or do you mean "revolving"?
  • IHateTheosupremacism (unregistered) in reply to Loren Pechtel
    Loren Pechtel:
    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.

    ding ding ding ding ding! i had to defend against a code analysis by people who have been drinking at the koolaid bowl of the (fr)Agile Methodology yesterday...

    captcha: conventio

  • Jay (unregistered)

    On the PDP-10, byte size was variable. The machine language instructions that worked with bytes included a field that specified how big a byte was for the duration of the execution of this instruction.

    That said, the world seems to have settled on 8-bit bytes. Sure, that could change. And tomorrow the IT world might decide to abandon HTML in favor of some new markup language. Are you going to code all your web sites to allow for that possibility?

  • (cs) in reply to Buddy
    Buddy:
    C developers are not immune to criticism.

    Common crimes of C developers (not including common mistakes like using = for ==):

    • non-portable assumptions ... sizeof(int) < sizeof(long)
    You must be so new to C programming that you've only ever programmed on 64 bit platforms.
    monica:~ jeremyp$ cat foo.c
    #include <stdio.h>
    

    int main (int argc, char * const argv[]) { printf("sizeof (int) = %d, sizeof (long) = %d\n", sizeof(int), sizeof(long)) ; return( 0 ); } monica:~ jeremyp$ gcc foo.c monica:~ jeremyp$ ./a.out sizeof (int) = 4, sizeof (long) = 4

    (Default compiler settings on OS X.5 are 32 bit)

  • (cs) in reply to Anon
    Anon:
    pink_fairy:
    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!

    <snip my original joke, which apparently died at birth. Clue: Featured Richard Dawkins, without attribution./>

    Which book? You seem to have left that important point out of your incoherent rant.

    (a) I see your troll, and raise you a dwarf. (b) Perhaps you should try a search engine (c) Here's the specific important point. Go ahead, bore yourself silly ... well, go ahead, bore yourself anyway.

    Not really worth wasting any of you good people's time, except that it seems that the words "incoherent" -- hey, I'm deficient in duct-tape, but what the heck; they all stick to other sticky things -- and "rant" are the new Godwin.

  • (cs) in reply to Jay
    Jay:
    I haven't seen the ad, but my guess is that this is a church or some other Christian organization. (Likely contributing factor to that theory: If they're not a religious organization, posting a want ad that specifies religion is generally illegal.) They don't want to hire someone who is totally opposed to the goals of their organization and thinks that anyone who holds their beliefs are a bunch of idiots, no matter how good he is at the job. If Fred got a job as a programmer for a religious organization, surely they would be justified in worrying that at best he would be unethusiastic, and at worst that he might deliberately sabotague them. Not necessarily, of course. He might view his job purely as a set of technical challenges. But it would make me nervous if I was the boss.

    Likewise I would expect the American Atheist Association to be wary of hiring a born-again type. I would expect the National Republican Committee to be reluctant to hire an ardent Democrat and vice versa, or PETA to hire someone who showed up for the interview wearing a genuine fur coat, etc.

    For God's sake, stop trying to make sense. That's not what this forum is for.

    (For those of our brethren who are not religious, feel free to substitute "Talking Heads" for "God" there.)

  • IHateTheosupremacism (unregistered) in reply to pink_fairy
    pink_fairy:
    and "rant" are the new Godwin.

    Possibly you should learn the difference between "is" and "are" and which one it is appropriate to use in situations before you go apopleticly bitchy at Dawkins.

  • ricecake (unregistered) in reply to jeremypnet
    jeremypnet:
    Buddy:
    C developers are not immune to criticism.

    Common crimes of C developers (not including common mistakes like using = for ==):

    • non-portable assumptions ... sizeof(int) < sizeof(long)
    You must be so new to C programming that you've only ever programmed on 64 bit platforms.
    sizeof (int) = 4, sizeof (long) = 4
    I don't get what you are implying. Buddy was saying that assuming that sizeof(int) < sizeof(long) is a non-portable assumption, and your code snippet showed that what he said is true, since on your implementation, sizeof(int) == sizeof(long). The C standard only specifies that sizeof(int) <= sizeof(long).
  • (cs) in reply to jeremypnet
    jeremypnet:
    Buddy:
    Common crimes of C developers (not including common mistakes like using = for ==):
    • non-portable assumptions ... sizeof(int) < sizeof(long)
    You must be so new to C programming that you've only ever programmed on 64 bit platforms. (...snip...)
    sizeof (int) = 4, sizeof (long) = 4
    
    (Default compiler settings on OS X.5 are 32 bit)
    If you would actually have read Buddy's message, you would have seen that this was actually what he was talking about.

    Programmers assuming that sizeof(int) < sizeof(long). whereas in the definition of C, sizeof(int) <= sizeof(long).

    So instead of agreeing with Buddy, as you could have done, you went out of your way to insult him. To try to make a fool of him. Well you didn't succeed. Quite the contrary.

    Edit: awr, I typed too slow. Darn.

  • (cs) in reply to IHateTheosupremacism
    IHateTheosupremacism:
    pink_fairy:
    and "rant" are the new Godwin.

    Possibly you should learn the difference between "is" and "are" and which one it is appropriate to use in situations before you go apopleticly bitchy at Dawkins.

    Apoplectically. FTFY. Hee hee hee.

    Reading Comprehension -101:

    'the words "incoherent" -- hey, I'm deficient in duct-tape, but what the heck; they all stick to other sticky things -- and "rant" are the new Godwin.' What's the matter? You only read sentences that are shorter than your penis length in inches?

    Once more: (a) I see your troll, and raise you a dwarf.

    Which is unfair. Many of my best friends are dwarves. None of them, to the best of my knowledge, are blithering morons.

    And now .. back to our non-ignorant sponsor.

  • I'm not giving my name to a computer (unregistered) in reply to cdosrun
    cdosrun:
    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!

    Even better, make sure that person is of the opposite sex, recreate with them, then infect the child. TRIPLE word score!

  • I'm not giving my name to a computer (unregistered) in reply to IHateTheosupremacism
    IHateTheosupremacism:
    CaptainSmartass:
    Sounds like something a bored programmer would come up with, not really a WTF.

    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?

    in fact in the united states (and i imagine many european countries) it is illegal to make religion a selection basis*

    *[unless you're a religious institution such as a church]

    Yup, my grade school (Catholic) fired a teacher for getting re-married (outside the church) before getting an annulment from the Catholic church.

  • Pummeluff (unregistered)
    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!

    In VB6:

    Dim x As Long if x <= &HC0000000 then ... End If

    EDS:
    One of my favorite define tricks is an incredibly simple one but fun none the less:

    #define EVER ;;

    for(EVER) { ... }

    :)

    In VB:

    do ... loop

  • Pummeluff (unregistered) in reply to Pummeluff
    Pummeluff:
    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!

    In VB6:

    Dim x As Long if x <= &HC0000000 then ... End If

    Ok, wrong. Next try:

    Dim x As Long if (x >= &HC0000000) And (x < 0) then ... End If

    Or

    Dim x As Long if x And &HC0000000 = &HC0000000 then ... End If

  • kyle huff (unregistered) in reply to Lynn

    This is almost certainly the case as the variable in question is datYrEnd_Dt. I don't know why so many stupid people are commenting here.

  • kyle huff (unregistered) in reply to kyle huff
    kyle huff:
    This is almost certainly the case as the variable in question is datYrEnd_Dt. I don't know why so many stupid people are commenting here.

    Yeah, and then I go ahead and forget to quote the original reply I am replying. Nice one, guy.

    Lynn:
    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...
  • Great link for WTF source material buried in this article (unregistered) in reply to snoofle
    snoofle:
    Wait, December doesn't have 32 days?

    Damn discount calendars...

    Yeah, and Christmas isn't Halloween.

  • John Muller (unregistered) in reply to Jay
    Jay:
    On the PDP-10, byte size was variable. The machine language instructions that worked with bytes included a field that specified how big a byte was for the duration of the execution of this instruction.

    That said, the world seems to have settled on 8-bit bytes. Sure, that could change. And tomorrow the IT world might decide to abandon HTML in favor of some new markup language. Are you going to code all your web sites to allow for that possibility?

    Yes.

    http://thedailywtf.com/Articles/Where-the-Wild-Web-Things-Are.aspx

  • The Dark Messenger (unregistered)

    So what you are saying is that checking the day and month is more efficient (faster uses less resources etc) than checking the year as in the original code?

    bSkipYearCheck = False
    If Month(CVDate(datYrEnd_Dt)) = 12 && Day(CVDate(datYrEnd_Dt)) = 31 Then
        bSkipYearCheck = True
    End If

    (Can't remember the exact VB code structure but you get the point)

  • Duke of New York (unregistered) in reply to Anon
    Anon:
    CaptainSmartass:
    Sounds like something a bored programmer would come up with, not really a WTF.

    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?

    Is that even legal? I guess they are not an equal opportunity employer.

    If the employer is a church, and the position involves representing the church, it could be considered a "bona fide requirement." I'm not sure.

    When I was an undergrad, I briefly considered applying to an IT consulting firm in my hometown for the summer. It probably wasn't hiring anyway, but never mind that. The owner of the firm was a deacon at my church, and was such an overbearing fundamentalist that he had been rather significant in my decision to quit the church, although I hadn't told him that. I thought maybe we would be able to get along by focusing on work. My mother said that just wasn't possible. I never applied.

  • Casey (unregistered)

    FISCAl calendars can end on a different day every year.

  • Jai Tan (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.

    Fixed? Like C would be fixed by fixing the operator precedence? Like HTML would be fixed by making it strict?

    No, I see, you mean fixed like discarding the language and keeping the trademark.

    But you're right: that works for wannabees who think that their knowledge of one popular language qualifies them as programmers.

  • Bruce Taylor (unregistered) in reply to n
    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.

    End line comments are from any line oriented language (BASIC, ASM...) that preceded block languages (PASCAL, C, ...)

    End line comments were retrofitted to C at about the same time that C++ was introduced, but they did come from C++.

    I agree that it is primarily an issue with embedded development.

    No old C compiler understands end-line comments except as a compiler extension. Equally important, no old C syntax checker (no old version of LINT or better) understands end-line comments.

  • Bruce Taylor (unregistered) in reply to Lynn
    Lynn:
    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...

    The function [Year] is a standard library function, an although it could be over-ridden, that would be a real WTF.

    On the other hand, the expression is a standard idiom for end-of-month calculations, so it shouldn't have confused anybody.

  • Mad Bob (unregistered) in reply to Badastronomy
    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.

    Unfortunately, when the sun goes red, it also get VERY big, and way too close to the third rock from the sun for comfort, even at reduced temperature.

  • (cs) in reply to JJ
    JJ:
    My brother's original, legal birth certificate lists his day of birth as December 32nd.

    When does he celebrate his birthday? And does he get a lot of hassle when he applies for things like a driver's licence or a passport?

    pink_fairy:
    Anon:
    Which book? You seem to have left that important point out of your incoherent rant.
    (a) I see your troll, and raise you a dwarf. (b) Perhaps you should try a search engine <snip>
    Count the books
  • Mad Bob (unregistered) 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.

    Thats gunna bugger up the seasons quite a bit, don't ya think?

  • guest (unregistered) in reply to Pim
    There are 8 bits in an byte, silly.
    Nope. In an octet yes, but a byte can contain any number of bits.
  • Mad Bob (unregistered) in reply to MrsPost
    MrsPost:
    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??

    I was writing something that also had a singular/plural text issue. I just decided on different wording so it didn't need that particular phrasing.

    You have to look at the value to time ratio. There's ever only going to be one time when the singular is used while there's all kinds of times when the plural is going to be used. Why code for the exception instead of the rule?

    There are two solutions. The first is 'printf ("%d comment%s", n, (n == 1) ? "" : "s");', the second is to autopost a 'FIRST' and 'SECOND' comment whenever an article is created.

  • (cs) in reply to 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.
    Long before the sun grows cold, we'll have 12 months per year, each with 25 days. All it takes is altering the rotation speed of the Earth and the orbit of the moon.

    AND HIS CODE WILL STILL WORK!

  • Gary Wheeler (unregistered) in reply to Pim

    Oh man, that is a blast from the past. I developed an MS-DOS application back in the early 90's, and I used QuickC as a program editor.

  • You're wrong (unregistered) in reply to Buddy
    Buddy:
    C developers are not immune to criticism.

    Common crimes of C developers (not including common mistakes like using = for ==):

    • using gets and strtok - evil
    • using atoi, atol, atof without validating input
    • intimidated by qsort to the point of writing their own sort routines
    • non-portable assumptions - 8 bits per byte, two's complement arithmetic, sizeof(short) < sizeof(int) < sizeof(long), sizeof(signed type) == sizeof(unsigned type), 'A' - 'Z', 'a' - 'z', '0' - '9' are continuous (guilty!)
    • letting system handle memory deallocations (guilty!)
    • not taking advantage of C99 features (guilty!)

    Feel free to add to this list...

    That's true, it's called ASCII.
  • AnonJr (unregistered) in reply to CaptainSmartass
    CaptainSmartass:
    Sounds like something a bored programmer would come up with, not really a WTF.

    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?

    Might be a bad idea for a church to have an Atheist for their sys admin...

Leave a comment on “Foolproof Future-Proofing”

Log In or post as a guest

Replying to comment #:

« Return to Article