• (cs)

    VB programmers criticising a C programmer - and with just cause. I never thought I'd see that happen.

  • (cs) in reply to java.lang.Chris;

    I never thought I'd VB that happen.

  • (cs)

    Wait, December doesn't have 32 days?

    Damn discount calendars...

  • (cs) in reply to NSCoder
    NSCoder:
    I never thought I'd VB that happen.

    I 'C' what you did there.

  • Badastronomy (unregistered)

    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.

  • Simon (unregistered)

    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.

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

    So C-loving Clyde still wins. 32 day December or 30 day December (possibly introduced by NYE hating puritans) and his code still works!

  • (cs)

    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??

  • Schlong (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??

    thats not a WTF, this is a WTF:

  • Just Sayin (unregistered)

    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.

  • Ancient_Hacker (unregistered)

    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.

    Another app very carefully defined BitsPerByte = 8, just in case that ever changed. Of course none of the code was prepared for the change, but ....

  • laoreet (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??

    Alex didnt make the software. ;)

  • Alex (unregistered)

    The real WTF is that it took them half a day to figure out what was going on. It was obvious within 30 seconds what the code does.

  • Alan (unregistered)

    All he has done is ensure he doesnt get any juicy contract work when the Pope does add that extra day on.

  • (cs)

    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?

  • (cs)

    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!

  • Warren (unregistered)

    You're not being fair, are you?

    The requirements must have clearly stated "check if it is the last day of the year". Implemented as required.

    What about a switch to a different calendar, maybe one that doesn't have twelve months, let alone 31 days in the last. Maybe one day the leap day will be added on at the end, like leap seconds are.

  • Buddy (unregistered)

    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...

  • SomeDude (unregistered)

    The real WTF is this:

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

  • someguy (unregistered)

    Write code to match your thought process, not just to match "what it's eventually doing anyway."

    This code reads as "If, as of tomorrow, 'last year' would in fact be what 'this year' currently is". I probably would have written it "If tomorrow is 'next year'", but I can't criticize that.

    Coding-style wise, I'd probably have assigned to a temporary variable instead of nesting function-calls, but that's also more "style" than something which can be validly criticized.

    All the "future proofing" comments are just stupid, it's obviously /not/ what happened here.

  • Anonymous Coward (unregistered) in reply to Pim

    Pim:

    Dim x as Currency

    If x > 3221225472 then ... End If

    BTW wouldn't this be more efficient: bSkipYearCheck = Year((CVDate(datYrEnd_Dt) + 1)) - 1 = iYear

  • Fred (unregistered) in reply to CaptainSmartass
    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.
  • D C Ross (unregistered) in reply to laoreet
    laoreet:
    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??

    Alex didnt make the software. ;)

    So that means it is complicated?

  • Davy (unregistered)

    That's a perfectly acceptable way to do it, and the fact that it took you half a day to work it out is something you should be ashamed of. The same algorithm could also be adapted slightly to work for last day of the month, decade, and so on.

  • (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 ==):

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

    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
  • Just me (unregistered)

    I'm one of those lucky guys who never had anything to do with VB, so I may be wrong, but maybe it has something to do with a test on the ISO year, which is not always the same as the calendar year of a date (see http://meta.wikimedia.org/wiki/Template:Isoyear). Maybe iYear is the ISO year, or the Year function converts it to the ISO year, or, er, I don't know, just some wild random guessing...

    And otherwise, just ignore this, it's Friday afternoon, time to go home ;-)

  • Anon (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?

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

  • Ken B (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??

    Just add the number of comments to the next-to-last day of the year, and see if the year changes.

    Wait, that doesn't work for "zero comments", so first, subtract the number of comments from the first day of the year to see if the year stays the same.

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

    I guess this is relevant:

    Title VII of the Civil Rights Act of 1964 and the Americans with Disabilities Act (ADA) cover all private employers, state and local governments, and education institutions that employ 15 or more individuals. These laws also cover private and public employment agencies, labor organizations, and joint labor management committees controlling apprenticeship and training.

    So with <15 employees, it's legal (in the US at least).

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

  • Ken B (unregistered) in reply to Ancient_Hacker
    Ancient_Hacker:
    Another app very carefully defined BitsPerByte = 8, just in case that ever changed. Of course none of the code was prepared for the change, but ....
    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.)

  • (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 ==):

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

    There are 8 bits in an byte, silly. Don't tell me you confuse bytes with chars?

    But OK, for the balance, I have been guilty of assuming ASCII, even though I do know about EBCDIC and others. And I assume that sizeof(unsigned) == sizeof(signed). You mean it doesn't have to be? "not taking advantage of C99 features" Why is that a crime? If I have to program in C (not C++), I try to be as generic as possible, deliberately avoiding features like // comments and on-the-fly var declarations like for (int i = 0;....

  • Ken B (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 ==):

    [...]

    • 'A' - 'Z', 'a' - 'z', '0' - '9' are continuous (guilty!) [...]

    Feel free to add to this list...

    Umm... '0'-'9' are guaranteed to be contiguous in C.

    I'd add "assume the character set is ASCII".

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

  • Anonymous Coward (unregistered) in reply to Warren
    Warren:
    You're not being fair, are you?

    The requirements must have clearly stated "check if it is the last day of the year". Implemented as required.

    "Requirements"? "Clearly stated"? You've never done Rapid Application Development before, have you? (That, or I gets a woooosh.)

  • (cs) in reply to Pim
    Pim:
    There are 8 bits in an byte, silly. Don't tell me you confuse bytes with chars?

    But OK, for the balance, I have been guilty of assuming ASCII, even though I do know about EBCDIC and others. And I assume that sizeof(unsigned) == sizeof(signed). You mean it doesn't have to be? "not taking advantage of C99 features" Why is that a crime? If I have to program in C (not C++), I try to be as generic as possible, deliberately avoiding features like // comments and on-the-fly var declarations like for (int i = 0;....

    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 //

  • (cs)

    QuickC.

  • Ken B (unregistered) in reply to Pim
    Pim:
    Buddy:
    C developers are not immune to criticism.

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

    [...]

    • non-portable assumptions - 8 bits per byte, [...]
    There are 8 bits in an byte, silly. Don't tell me you confuse bytes with chars?
    No, there are not necessarily 8 bits in a byte as far as C is concerned. A byte is defined as:
    byte addressable unit of data storage large enough to hold any member of the basic character set of the execution environment
    In fact, C defined CHAR_BITS specifically because it may be more than 8.
  • (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.

    Ethiopia has such a calendar now. In fact, their Ministry of Culutre and Tourism uses the slogan "13 Months of Sushshine."

    Of course 13 x 28 = 364 so JustSayin's "occasional leap day" would likely have to occour every year, but that's another matter.

  • Ross Presser (unregistered)

    What happens at the End of Days, when there IS no tomorrow to test the year of?

    CATCHPA: "verto", which my Unabridged Dictionary states is a disorder where your toes are permanently vertical.

  • (cs) in reply to Davy
    Davy:
    The same algorithm could also be adapted slightly to work for last day of the month, decade, and so on.

    That's what I was thinking. It's overkill in the example given and legitimately a WTF, but I've used a similar pattern of letting the system time libraries do the hard work of figuring out the end of the month for me. It's quite possible that's where the WTF came from -- he was thinking of cases where there are lots of date-time gotchas and instead applied it to a case where the date rules are quite simple.

  • JJ (unregistered)

    My brother's original, legal birth certificate lists his day of birth as December 32nd.

  • (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??

    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?

  • (cs)
  • (cs) in reply to CaptainSmartass
    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.
  • Ken B (unregistered) in reply to Pim
    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".
  • IByte (unregistered) in reply to Bobbo

    A little threadjack (a WTF of my own)...

    Bobbo:
    [...]pluralisation check that complicated??
    You might want to be careful with that spelling... When I wanted to suggest my favourite feature to Gmail today, I was told "We are unable to provide email support in your language at this time". They did offer me the choice of switching from British (which apparently their support team can't read) to American, though...
  • blindman (unregistered) in reply to Anon Ymous
    Anon Ymous:
    NSCoder:
    I never thought I'd VB that happen.

    I 'C' what you did there.

    A vblbuttic joke.

  • (cs)

    (frantically searching through my bookcases now... where did I leave my K&R? I must have it somewhere! Don't tell me I put it in a box in the cellar... Oh look, the Quick C programmer's guide! Aw, that can wait. K&R, where are you hiding?)

  • Deke (unregistered)

    It took half a day to figure that out?

Leave a comment on “Foolproof Future-Proofing”

Log In or post as a guest

Replying to comment #:

« Return to Article