back to article 'Just give me any old date and I'll make it work' ... said the VB script to the coder

Is it that time of the week again already? You've reached Line Break, our weekly roundup of terrible code you've seen in the wild. Today, we're going to delve into submissions from reader comments rather than the usual postbag. Line Break article comments are such a rich seam of snippets and anecdotes, it would remiss to not …

  1. Steve Davies 3 Silver badge

    Effing 'Merikans

    with their arse about face way of doing dates.

    The cause of more IT 'DOH!' moments than anything else.

    I worked on a system not that long ago that had THREE yes THREE different date formats in the same message.

    yyyy-MM-dd

    dd-MM-yyyy

    MMM-dd-yy

    What script kiddie thought that one up eh?

    Then their is insitence in usung AM/PM on displays when the rest of the world goes meh and gets on with a 24hr clock.

    1. Anonymous Coward
      Anonymous Coward

      Re: Effing 'Merikans

      Get bent. Not all of us _AMERICAN'S_ (we don't call you "'ritan's" now do we?) use a mm.dd.yy format nor a 12Hour clock. Some of us use a yyyy.mm.dd 24Hour format instead for many reasons. Being a stereotypical twat (calling us a unflattering dimuative & claiming we ALL do something) merely reflects badly upon yourself. Don't be a twat, rise above your bigotry & learn that not all American's are alike, just like all you "Limey Pricks" don't have your head up your ass.

      1. DavCrav

        Re: Effing 'Merikans

        "Get bent. Not all of us _AMERICAN'S_ (we don't call you "'ritan's" now do we?) use a mm.dd.yy format nor a 12Hour clock. Some of us use a yyyy.mm.dd 24Hour format instead for many reasons. Being a stereotypical twat (calling us a unflattering dimuative & claiming we ALL do something) merely reflects badly upon yourself. Don't be a twat, rise above your bigotry & learn that not all American's are alike, just like all you "Limey Pricks" don't have your head up your ass."

        OK, I'll correct his statement: Almost all Americans use mm/dd/yy as their date format. The remaining ones apparently put extra apostrophes in 'Americans'.

        And FYI, the official US system is mm/dd/yy, so it's a bit rich to say that because you personally don't, he's a twat.

        Oh, and by the way, the reason we call you Merkins is that you elected someone, twice, who pronounced your country in that way.

        1. Anonymous Coward
          Anonymous Coward

          Re: Effing 'Merikans

          'Oh, and by the way, the reason we call you Merkins is that you elected someone, twice, who pronounced your country in that way.'

          Well, that and the vaguely amusing association with a pubic wig.

          1. gcla72

            Re: Effing 'Merikans

            Pubic wig? Trump hasn't been elected yet...!

          2. PNGuinn
            Joke

            Re:...vaguely amusing association with a pubic wig.

            But shirley not all 'Septics aspire to be President of the U S of A??

          3. Michael Wojcik Silver badge

            Re: Effing 'Merikans

            Well, that and the vaguely amusing association with a pubic wig.

            Indeed, the contraction 'Merkin as a demonym for a citizen or resident of the USA was widely used on Usenet at least as far back as the early 1990s, presumably well before the individual in question was elected. (It's hard to say for sure to whom the previous poster was referring, since we have many elected officials in the US, and they have displayed a fascinating variety of pronunciations.)

        2. #define INFINITY -1

          My Brevity is Better than Yours

          Whoever thought of using numbers instead of month names?

        3. Indolent Wretch

          Re: Effing 'Merikans

          Surely the point here is it's not that ALL Americans use the month/day arsetitwad or that MOST americans use the month/day arsetitwad or that only SOME Americans use the month/day arsetitwad. The important point is that ONLY Americans use the month/day arsetitwad*

          (Yes, yes I know Belize and Federated States of Micronesia do it that way as well but c'mon).

          1. Prst. V.Jeltz Silver badge

            Re: Effing 'Merikans are closer than us

            obviously the correct format is:

            yyyy/mm/dd

            that way its alphabetical and chronological - and the American format is closer to that than us

            1. Captain Hogwash
              WTF?

              Re: that way its alphabetical and chronological

              Huh?

              1. What_Does_Not_Kill_You_Makes_You_Stronger
                Coat

                Re: that way its alphabetical and chronological

                Capitain Hogwash, you missed that the comment was from a Vogon (See name) and therefore something has obviously been lost in translation. :)

                1. PNGuinn
                  Go

                  Re: that way its alphabetical and chronological @w-d-n-k-y-m-y-s

                  If the comment was from a Vogon it must have been poetic licence, no?

              2. Mark Solaris

                Re: that way its alphabetical and chronological

                He means when you sort it, the dates are displayed in chronological order... because 2016-03-10 is alphabetically (ASCII) greater than 2016-03-09. You can't do that with MM/DD/YYYY, DD/MMM/YYYY etc.

                Using YYYY-MM-DD in log file names is a very useful thing.

            2. Alan Brown Silver badge

              Re: Effing 'Merikans are closer than us

              "that way its alphabetical and chronological - and the American format is closer to that than us"

              FWIW, before being codified as a standard, yyyymmdd was a japanese standard.

              Just as they taught the british how to make motorcycle engines that don't leak oil, they taught the world how to write dates that can't be misinterpreted.

              1. Sgt_Oddball

                Re: Effing 'Merikans are closer than us

                Oh come now, the oil leaks were easy to fix with every packet of cornflakes (use the crankcase with some oil on the edge on the inside, cut out the oil stain and reattach, simples.... Or at least that's what an old biker swore blind did the job).

                As for dates, never trust a none explicit date format, jam it into iso unless your displaying it. Then format to taste.

            3. UKLooney

              Re: Effing 'Merikans are closer than us

              yyyymmdd would be alphabetical, chronological and numerical.

              This is the future!

      2. joeldillon

        Re: Effing 'Merikans

        I'm not seeing that 'Merikan' is any worse than 'Brit' and Americans use that one all the time.

        And I'm pretty sure a vanishingly small proportion of Americans (or anyone else) use the ISO date format day to day.

        1. Shadow Systems

          @Joeldillon, re: dates.

          The U.S. Military uses that format all the time.

          It's just Civilians that tend not to, mores the pity.

          =-J

      3. DiViDeD

        Re: Effing 'Merikans

        " just like all you "Limey Pricks" don't have your head up your ass"

        That's absolutely right!

        WE have our head up our ARSE

    2. Anonymous Coward
      Anonymous Coward

      Not all of them...

      That's why I used to like VAX/VMS - the standard date display format was DD-MON-YYYY,

      It was unambiguous - you couldn't confuse the day with the month (one was a number., the other was text), and you couldn't confuse the year with either of them.

      1. Anonymous Coward
        Anonymous Coward

        Re: Not all of them...

        AC: "That's why I used to like VAX/VMS..."

        I was once asked to start using an application running on VMS, supposed to help generate Functional Test Program 'vectors' based on the circuit board description language. The software package came with a quarter million dollar price tag.

        Within minutes of trying to use it, I was forced instead to start documenting the bugs, as opposed to actually using the software. 30-pages resulted. One observation was three different date formats on one screen. Another bug was reliance on Ctrl-T to perform a key program function, but VMS intercepted this keystroke to display the system Date & Time. Perfect rubbish. Oh, and didn't work, at all.

        Agree that VMS was good. But this $250K software application was (effectively) refunded.

        1. Kubla Cant

          Re: Not all of them...

          On VMS Ctrl-T displays a line of information about the running process, including, IIRC CPU and IO statistics. It's very useful if you think a process might be stalled or looping.

          If you want Ctrl-T to be sent to the program, you can disable this feature with SET NOCONTROL=T.

      2. Schultz

        DD-MON-YYYY

        sucks for sorting dates. I like YYYY-MM-DD -- everything ends up in the right place without any effort.

        1. Mark Solaris

          Re: DD-MON-YYYY

          >Schultz

          >DD-MON-YYYY sucks for sorting dates. I like YYYY-MM-DD -- everything

          >ends up in the right place without any effort.

          How about that, Schultz does actually know something. #tvjoke

        2. Prst. V.Jeltz Silver badge

          Re: DD-MON-YYYY - make your minds up!

          Shultz said

          ". I like YYYY-MM-DD -- everything ends up in the right place without any effort."

          and has 12upvotes

          I said exactly the same and massive downvoting

          is it cos i is green?

          1. Danny 14

            Re: DD-MON-YYYY - make your minds up!

            seconds since epoch. Do what you want to the formatting then.

          2. Charlie Clark Silver badge
            Thumb Down

            Re: DD-MON-YYYY - make your minds up!

            I said exactly the same and massive downvoting

            Nope you said: yyyy/mm/dd

            YYYY-MM-DD is ISO 8601 which is why it gets all the votes. Have another downvote.

          3. PNGuinn
            Pint

            Re: DD-MON-YYYY - make your minds up! @Pr V J

            Yes.

            1. Allan George Dyer

              Re: DD-MON-YYYY - make your minds up! @Pr V J

              All this discussion, and no-one's mentioned the RFC822 date-time standard yet... well-defined, yet a nightmare to use; evil.

              As a public service, the obligatory xkcd:

              https://xkcd.com/1179/

        3. Anonymous Coward
          Anonymous Coward

          Re: DD-MON-YYYY

          You are missing the point.

          For display and entry purposes a date string of DD-MON-YYYY is unambiguous - even in different languages.

          When sorting using the actual date/time value then the internal date/time format will handle the ordering.

          The only problem comes if you insist on trying to do an alpha sort on a text version of the date string. In that case of course you should use YYYY-MM-DD (separaters to taste...).

      3. MiguelC Silver badge

        Re: Not all of them...

        Glad you don't need localization or else you’d have run into problems (Feb is Fev in French, etc.)

        1. Wensleydale Cheese

          Re: Not all of them...

          The first three letters of the month name works in English, but not French.

          Jan, Jan,

          Feb, Fev

          ...

          Jun, Jui

          Jul, Jui -- ooops

        2. PNGuinn
          Trollface

          Re: Not all of them...(Feb is Fev in French)

          Since we seem to be trading insults over the pond, in the interest of being xenophobically inclusive, may I respectfully point out that is the frenchies' problem since they don't speak the Queen's English. (Nor do the 'Merkins for that matter....)

          >>Ducks<<

          1. Anonymous Coward
            Anonymous Coward

            Re: Not all of them...(Feb is Fev in French)

            I genuinely can't think of any relevance for the linked article other than it's hilarious and you mentioned the French.

            http://metro.co.uk/2016/03/16/frenchman-started-fighting-with-cheese-in-waitrose-after-trying-to-steal-it-5756274/

      4. Erebus

        Re: Not all of them...

        "The cause of this problem is a thing called cdate() that lives deep inside the run-time infrastructure"

        Well no, the cause of this problem was the developer not implementing the ISO 8601 date format (which the CDate() function, incidentally, understands perfectly). GIGO.

    3. Anonymous Coward
      Anonymous Coward

      Re: Effing 'Merikans

      SD "...their is insitence in usung..."

      At least 80% of the words in this extract are incorrect in some way.

    4. Alan Brown Silver badge

      Re: Effing 'Merikans

      The only standard date format is yyyymmdd:hhmmss (for storing dates)

      The way it's displayed should be derived from locale. If you must use other formats they should be interpreted according to locale and stored as above.

      Personally, if stuff is on paper I always use MMM to remove any abiguous interpretations.

      1. Androgynous Cupboard Silver badge

        Re: Effing 'Merikans

        ISO8601 or GTFO

      2. Wensleydale Cheese

        Re: Effing 'Merikans

        "The only standard date format is yyyymmdd:hhmmss (for storing dates)"

        You forgot the time zone or offset from UTC

        And for human readability it's better with dashes, No colons in the time field when used as part of filenames please - that causes cross-platform problems.

        /pedant

        1. lowwall

          Re: Effing 'Merikans

          Time Zones and offsets occasionally need to be forgotten. Thanks to a 12-year-old GnuCash bug, if I allow my work computer to use a time zone that has daylight savings time, my transaction dates all shift twice a year. If anyone would like to fix this, here's the bug report: https://bugzilla.gnome.org/show_bug.cgi?id=137017

      3. JeffyPoooh
        Pint

        Re: Effing 'Merikans

        AB "The only standard date format is..."

        'The nice thing about standards is that there are so many from which to choose.'

        The phrase "The only standard date format is..." is clearly nonsense.

      4. Michael Wojcik Silver badge

        Re: Effing 'Merikans

        The only standard date format is yyyymmdd:hhmmss

        I have no idea what "standard" you're referring to, but ISO 8601 uses "T" as the separator between the date and time, not a colon.

    5. Dan 55 Silver badge

      Re: Effing 'Merikans

      The way Access DB files, VBScript, Jet, IIS, and Windows locale work together to confuse dates is incredible. At least the planets align themselves every so often, you need to pointlessly twiddle settings for hours until they all deign to use YYYY-MM-DD.

    6. Anonymous Noel Coward

      Re: Effing 'Merikans

      Japanese also do mm/dd/yyyy.

      That being said, I do use American dates when naming files, as it helps order them better, rather than having the day order everything in an arbitrary way. E.g. 01.04.2016, 07.12.2016, 16.03.2016...

      1. Frumious Bandersnatch

        Re: Effing 'Merikans

        Japanese also do mm/dd/yyyy.

        [Citation needed]

        1. Chairo

          Re: Effing 'Merikans

          Japanese also do mm/dd/yyyy.

          [Citation needed]

          In official documents Japanese dates are stated as EEYY年MM月DD日, with EE being the epoch. Currently we are in "平成 = heisei" Epoch, year 28.

          Ups, my driving licence needs to be renewed until 平成28年10月28日. Still a few months to go, but good I checked...

          In less official documents the Gregorian calender year might be used, but no self respecting Japanese public officer would voluntary relapse to something so mundane.

          Oh, and each epoch starts and ends with the death/inthronation of a new emperor, so some years have two epochs.

          Oh, and sometimes you have to enter the numbers as double byte and sometimes as single byte. Filling in a web form in Japanese can be very frustrating, indeed.

          Regarding [Citation needed] - you can check it up in Wikipedia. Not that Wikipedia is any good as a reference.

          Nothing is ever simple in Japan...

  2. John Robson Silver badge

    I assumed everyone here had heard of...

    The Daily WTF

    1. Michael Wojcik Silver badge

      Re: I assumed everyone here had heard of...

      Sadly, TDWTF is much diminished from its glory days. There are too many editors, and they do far too much editing: submissions are mangled into awkward narratives that are often over-long, stylistically tone-deaf, and (worst of all) technically inaccurate.

      And Discourse is an abysmal commenting system. It's an ideologically-grounded writing environment created by sophomoric technophiles who haven't bothered to study either the theory of writing or any actual research on it, as far as I can tell.

  3. Bc1609

    VBA date handling has taken at least five years off my lifespan

    Eventually I gave in and wrote my own date-handling function - a CDate replacement - which I've tried to make the company standard. It taught me a lot about string handling, though, and all the weird stuff associated with dates and calendars that you almost never see or hear of unless you're a programmer. For example, did you know that in Shanghai the time "1927-12-31 23:54:08" actually happened twice? And that Java will bug out in weird ways if you're using the Shanghai timezone as a result? I didn't. Another fun teaser: why does the UK tax year start on 5th April?

    1. Philip Storry

      Re: VBA date handling has taken at least five years off my lifespan

      The UK tax year starts on the 5th of April because of our transition to the Gregorian calendar from the Julian, doesn't it? We skipped days in the calendar to make the transition, and merchants rebelled against the idea of being taxed for non-existent days... So the end of year date was moved back to placate them.

      Computerphile/Tom Scott made a lovely video on handling time zones, which is relevant to this:

      https://www.youtube.com/watch?v=-5wpm-gesOY

      I'd tend to agree - if it's at all possible, rely on the libraries that already handle this stuff. As you found, if you have to handle this yourself it rapidly becomes a very deep rabbit hole...

      1. Blofeld's Cat
        Pint

        Re: VBA date handling has taken at least five years off my lifespan

        "The UK tax year starts on the 5th of April because of our transition to the Gregorian calendar from the Julian, doesn't it? We skipped days in the calendar to make the transition, and merchants rebelled against the idea of being taxed for non-existent days... So the end of year date was moved back to placate them."

        Correct. The year used to start on 25th March but was moved to 1st January at the same time. Allowing for the 11 days correction for missed leap years we get 5th April.

        1. the spectacularly refined chap

          Re: VBA date handling has taken at least five years off my lifespan

          Correct. The year used to start on 25th March but was moved to 1st January at the same time. Allowing for the 11 days correction for missed leap years we get 5th April.

          But the tax year starts on the 6th April - post transition to the Gregorian calendar it was then advanced another day to make up for the "missing" leap year in 1800. No such amendment was made in 1900 though, and the situation didn't arise in 2000 so it's probably considered fixed to the "new" calendar now.

          Must dash, George is about to say how he's going to sting us this coming 6th April...

        2. Julian Bradfield

          Re: VBA date handling has taken at least five years off my lifespan

          Um, the tax year starts on 6th April.

      2. Doctor Syntax Silver badge

        Re: VBA date handling has taken at least five years off my lifespan

        All this stuff is nothing compared to what you come across in medieval documents which tend to be dated with reference to religious dates such as "Sunday the feast of the decollation of St. John the Baptist". If you're lucky an archivist has already translated the dates (in 1322 that was 29 Aug BTW). Some of them are ambiguous such as "Thursday in Easter week": did they mean before or after Easter?

        1. Bc1609

          Re: Medieval dates

          Oh, tell me about it - I did my BA in Medieval Lit., and made some editions of various manuscripts. In addition to the day/month being determined by religious festivals, very few people used AD and instead went off the regnal year - so "St. Stephen's day in the third year of the reign of X", which means you need to know the date and the year the king was crowned. Oh, and every bloody country (and sometimes just cities) in Europe having a different year system (Iberians counting from the Romans, for example) - such fun.

          I have to say, though, that I never found medieval dates to be too ambiguous. Confusing as hell, yes, but there's not really a way to confuse 03/04 with 04/03 as we have now. To address your example above, "Easter Week" is the week after Easter - the week before is, as every good Catholic schoolboy knows, Holy Week.

          1. Steve Evans

            Re: Medieval dates

            Ah, but which Easter? Even various branches of the Christian religion don't always agree on that!

            1. allthecoolshortnamesweretaken

              Re: Medieval dates

              "Ah, but which Easter?"

              Easy. Context / location.

          2. Anonymous Coward
            Anonymous Coward

            Re: Medieval dates

            Local context still gets confusing. Ask a Belfast man when he's going on holiday and he'll likely tell you "July, I'm taking the 12th week". "How many weeks are there in July over there?!"

            1. Doctor Syntax Silver badge

              Re: Medieval dates

              "July, I'm taking the 12th week"

              Don't forget the Little Twelfth (July 1st). The Boyne anniversary is another one that got shifted 11 days.

          3. Doctor Syntax Silver badge

            Re: Medieval dates

            'To address your example above, "Easter Week" is the week after Easter - the week before is, as every good Catholic schoolboy knows, Holy Week.'

            I'm inclined to agree but what was the usage at the time of the document by the clerk who wrote it? The YAS archivists gave that one a miss.

        2. This post has been deleted by its author

        3. allthecoolshortnamesweretaken

          Re: VBA date handling has taken at least five years off my lifespan

          "Some of them are ambiguous such as "Thursday in Easter week": did they mean before or after Easter?"

          Pagan! The week before Easter is called Holy Week, and it contains the days of the Easter Triduum, including Maundy Thursday, commemorating the Maundy and Last Supper, as well as Good Friday, commemorating the crucifixion and death of Jesus. In western Christianity, Eastertide, the Easter Season, begins on Easter Sunday and lasts seven weeks, ending with the coming of the fiftieth day, Pentecost Sunday. In Orthodoxy, the season of Pascha begins on Pascha and ends with the coming of the fortieth day, the Feast of the Ascension.

          TL;DR: they did mean "after Easter".

        4. Anonymous Coward
          Anonymous Coward

          Re: VBA date handling has taken at least five years off my lifespan

          "<day> in <Sunday> week" always means after the feast, as weeks start on Sunday.

          Even without that, the week before Easter is "Holy Week", never "Easter Week".

        5. Anonymous Coward
          Anonymous Coward

          Re: VBA date handling has taken at least five years off my lifespan

          > All this stuff is nothing compared to what you come across in medieval documents

          Not to mention that at different times in different places different people had different ides as to what date it was or when the year started.

      3. Doctor Syntax Silver badge

        Re: VBA date handling has taken at least five years off my lifespan

        "merchants rebelled against the idea of being taxed for non-existent days"

        I think it was more a case of being able to handle year long contracts. If, for instance, you'd hired a shepherd or borrowed £10 for a year on Lady day 1752 you wanted the arrangement to last the full 365 days.

      4. JeffyPoooh
        Pint

        Re: VBA date handling has taken at least five years off my lifespan

        PS: "...Tom Scott... ...time zones..." (Great video)

        PS: "...rely on the libraries..."

        And yet, a recurring theme in these stories is that relying on libraries (or other people's code) often turns up their foolish errors. That matches my experience; that the people that write code for libraries sometimes aren't even as careful a coder as I can be. Oftentimes, they're awfully sloppy in their coding and even worse in their documentation.

        .: You can't win.

  4. Ambivalous Crowboard

    $userId = cookie('userId');

    I am guilty of this, but not for a client website. I was learning Classic ASP, and I was sixteen, and this was basically how I wrote my login system for my own blog/CMS thing. When I extended it to other users, it was simple; the cookie for the username was already present.

    But at least I had the foresight to realise that after a few weeks that this wasn't the right thing to do (and discovered sessions). And I wasn't being paid to do this. And it wasn't my FT job...

  5. gv

    Visual Basic

    "Finding the bad calls is more or less impossible, given the lack of VB code analysis tools."

    Judicious use of grep (you can even get it for Windows) is encouraged.

    1. I'm Brian and so's my wife

      Re: Visual Basic

      Also MZ Tools - I'd estimate a 20-30% productivity boost using that VBA add-in.

    2. Kubla Cant

      Re: Visual Basic

      I was certainly a grep user at the time, though whether I was judicious I leave to others to decide. Unfortunately, grep doesn't solve this sort of problem.

      Your mission is to find cases where a function or procedure that expects a Date (probably along with lots of other arguments) is passed a String or Variant. The first problem is that the argument list is frequently stacked over several lines, because developers have been encouraged to use long variable names. All grep can do is output the line with the function name (current greps can output several lines of context, but this was 2003). Even if you manage to output the complete call with all its arguments, how do you tell what type they are? They might be local variables, module-level variables, values returned from other functions, or expressions evaluated when the call is executed. Tracing each of them back to the point where the type is defined is a non-trivial task.

      1. Sir Runcible Spoon

        Re: Visual Basic

        If you 'less' a file, I seem to recall you can search within it (which would give you the contextual position of the code).

        Or has my mind finally slipped into senility? :)

      2. Vic

        Re: Visual Basic

        Your mission is to find cases where a function or procedure that expects a Date (probably along with lots of other arguments) is passed a String or Variant

        Ah, so you're an awk man[1].

        Vic.

        [1] I wrote some code a few years back to expose the symbolic constants from C header files as Forth words. The heavy lifting in that was all done in awk. It's worth the effort...

  6. Ben Bonsall

    Fun VB bug.

    We had an ID that was rapidly approaching the max for a 32 bit int in a critical application. VB having no 64 bit long type, the decision was to use the currency type as it was a variant and a 64bit long underneath. We never need to do any operations on this, so it was all fine.

    All good up till the point where we pass the ID to a com object. The com was expecting a 64bit long.

    For no good reason, every time we pass in the ID, by the time it hit the COM code, it was incremented by 1. Tried a few things, make the COM expect a variant and convert to 64bit long, make it expect a currency type and convert to long, to no avail.

    Eventually we ended up passing it as a string and having the COM expect a 64bit long. We still don't know what was happening, probably at some point in the COM interface the currency type was being converted to a float and the conversion to 64bit long was off by one, but we just don't know.

    So now we have an integer ID that is a currency type variant that needs to be passed around as a string, just so it can be recognized correctly as a long on the other end.

    1. Lee D Silver badge

      One of the reasons that I hate loose-typed languages like VB.

      If something's an int, or a string, and you need to make it a long - YOU NEED TO DO IT. Don't just rely on the computer to perform magic guesswork as to what the string intended and interpret it how it sees fit.

      Dates in strings are a classic source of such problems, for exactly the reasons described in the article and comments.

      Yet, even the oldest of languages (C) won't let you arbitrarily convert from some string to some date. It has a highly-specified date structure, and plenty of functions for getting strings OUT of that but nothing for putting strings back INTO it because of the nightmare of various interpretations.

      Sure, when I was younger and toying with VB 1/2/3, it was cool to just throw things at VB and let it convert them to what you intended, But it's the one time that it matters that it won't understand what you intended correctly.

      How many people really turn on Strict typing in VB? And even that's not perfect.

  7. Anonymous Coward
    Anonymous Coward

    You think that's bad?

    All 10Billion lines of spaghetti code was done by a million untrained monkies smashing their fists on a typewriter.

    We were hoping for Shakespeare, instead we got Windows 10.

    -Signed, Microsoft.

    1. Anonymous Coward
      Anonymous Coward

      Re: You think that's bad?

      if you think Windows was written by untrained monkeys, you have not seen some of the code I'm working with ... at least Windows works (even if against the user)

      1. Anonymous Coward
        Anonymous Coward

        Re: You think that's bad?

        If you think the code you're working with was written by untrained monkeys, you haven't seen the code I write. :-(

        1. Anonymous Coward
          Anonymous Coward

          Re: You think that's bad?

          I was trained on magamps. Now I write embedded software. If there's one thing worse than an untrained monkey it's a self taught monkey in the wrong discipline.

          - Anon, because my career depends on my company thinking that I know what I am doing.

  8. Anonymous Coward
    Anonymous Coward

    Finding dates and times in text

    My hobby is trawling the web pages of a few hundred music groups to produce a schedule of their forthcoming performances anywhere in the world. Many of the announcements are in a narrative posting - so a function is needed to identify and extract the possible future date/time from a mass of text.

    It seemed fairly easy on first thoughts - yyyy/mm/dd, dd/mm/yy, mm/dd/yy, dd/mm/yyyy. Then came variants using dots or dashes instead of slashes - and some with spaces too. Some had leading zeroes in their months and days - not to mention regular typos.

    Many leave out the year - or even the month - although they are sometimes in a page/section header. Year changes can be signalled by the order of entries - as the month suddenly jumps backwards. However one page had entries without any year reference, in the random order that the performances were booked.

    The locale of the group is not a tie breaker for the dd/mm mm/dd variants. A European group page might announce a USA tour with US format dates.

    Then there are the month name variants in many languages - and their different ways of expressing that format. 20 January, January 20, 20 de gener. Plus the month abbreviations and different languages' ordinal suffixes like 1st and 1er. "May" and "March" in several languages is the same word as a verb.

    To cater for all the encountered variants and typos there are now functions numbered 1 to 7 - with awkward supplements of 2A, 5A, and 7A. Each caters for many variations on a theme - picking its first match that satisfies the validation criteria. The human eye is then presented with a selection of best guesses - together with part of their surrounding text.

    Times? A sample of 9am/pm 9a.m 9 uhr 9h 9.00 9:00 09:00 21:00 with varying spaces - preceding or succeeding the date.

    No attempt has yet been made to handle relative expressions like "next Saturday", "this Saturday", etc. Too many groups just post an image of the performance poster.

    The code is as rambling as this attempt to describe its requirements.

    1. AndyS

      Re: Finding dates and times in text

      Have you tried training it to play Go yet?

      1. Anonymous Coward
        Anonymous Coward

        Re: Finding dates and times in text

        "Have you tried training it to play Go yet?"

        AI has crossed my mind as an area to revisit for things like neural networks.

    2. Fibbles

      Re: Finding dates and times in text

      there are now functions numbered 1 to 7 - with awkward supplements of 2A, 5A, and 7A.

      Who needs descriptive function names, eh?

      1. Anonymous Coward
        Anonymous Coward

        Re: Finding dates and times in text

        "Who needs descriptive function names, eh?"

        The numbers are only the end of the function name - the text part is very descriptive. "ExtractDateAndTimeFromTextTypenn". They all get called to analyse any piece of text - and the user sees all the apparently valid results. The results always contain the surrounding context and "type" that produced any particular value. That's why there are "nA" versions - for when it was judged that it would impossible in the "n" function to validate for the new variant without invalidating another good variant.

        I once worked on a hardware and O/S legacy upgrade where the constraint was to not have to recompile any of the customer's applications. They had lost the source to some of them. We looked at another one that had been coded according to a mandatory departmental standard.

        All the routines had a name that was constructed from of a set of letters that were determined by its hierarchy in the design. The lower it was - the more letters it had eg "AAA" and "AAB" were both called from "AA". All the JMP and BRANCH labels within the routines were the same letters followed by a number in strict order of use eg AAE14. I suspect the variables were given similarly constructed names.

    3. Anonymous Coward
      Anonymous Coward

      Re: Finding dates and times in text

      > 20 de gener

      Tracking Antònia Font, aren't we?

    4. Charlie Clark Silver badge

      Re: Finding dates and times in text

      Many of the announcements are in a narrative posting - so a function is needed to identify and extract the possible future date/time from a mass of text.

      Well, the

      <time />
      element was supposed to help there but seeing as it does not require the browser to render the value in the user's locale, it was basically just another abortive microformat: worked required by users but only for the benefit of computers.

  9. joeldillon

    Pretty sure it'd be <lf> not <cr> as a line break (ooh, title drop), seeing as it was Unix and not classic MacOS!

  10. Duffaboy
    FAIL

    Sound Problem

    Many years ago I was called out to a problem with a pc which had no sound. Checking all the settings everything was in order and I had no idea what was the cause util i figured that I had to select MUTE yes MUTE, well I nearly jumped out of my chair when the sound blasted out a full Tilt.

    1. Lee D Silver badge

      Re: Sound Problem

      Like the old Start menu, when you wanted to stop the PC.

      Or when you get a message like "Cancel the print job? OK. Cancel." - er... what do I press?

      Human interface designers never solve these things, they just introduce ten thousand tons of junk instead that make them the least of your worries.

      I once spent 20 minutes, with my boss and I trying to work out how to close a full-screen Metro app on a fresh Windows 8 test install, on a touchscreen computer (i.e. designed for Windows 8). We deliberately refused to read the manual (like our user's would have) and honestly never got there (even when we tried all the swipes, because apparently you have to start at the VERY TOP of the screen for it to work).

      In the end, we just installed Classic Shell and set the default to go to the desktop and Windows key to open a Start Menu instead of Metro.

      1. harmjschoonhoven
        Facepalm

        Re: Sound Problem

        Like the old Start menu, when you wanted to stop the PC.

        When I was a student we had Flexowriters - Yes folks, Flexowriters, make a typo today and find it tomorrow. - and offline telex machines. One night I was alone, playing with a telex. But how do you stop that noisy thing? Whatever I tried, nothing worked. Finally it turned out that the telex switched itself off when you did not touch it for a couple of minutes.

  11. Joeman

    People Love to hate VBA

    Everyone complains and moans about VBA, but in reality its a very flexible and powerful language, that's far too often abused by people who think they can code, but cant, and then they blame VBA/Microsoft for their own deficiencies.

    1. Alien8n

      Re: People Love to hate VBA

      My complaints aren't about VBA, when I write VBA it tends to work fine (barring typos, etc). I like that it's (fairly) logical and easy to read (as opposed to C# which to a beginner is a nightmare to debug. I once had to track down a memory leak in C# which none of the actual developers seemed to care about despite it actually being their jobs on the line, quite literally as it happened). My complaints are that they can't keep VBA code consistent between different versions of Office (such as completely changing the way it treats the folder structure on a mac between versions 2011 and 2016) and how they can introduce new bugs in later versions that require putting in pauses in the code to allow the code to work.

    2. Charlie Clark Silver badge
      WTF?

      Re: People Love to hate VBA

      Do you really mean VBA or VB?

      I can think of some nice things to say about VB, or more basically BASIC, as it was the first language I ever came across.

      But VBA is an unmitigated disaster.

    3. david 12 Silver badge

      Re: People Love to hate VBA

      I love to love VBA. But this feature of VB/VBA/VBS, which MVP Michael (michka) Kaplan memorably dubbed "evil date guessing", is a bug that did nobody any favours.

      However, the memory of the original poster is incorrect, because although VB/VBA/VBS had this flaw, it wasn't in the thing called cdate( )

  12. fajensen
    Holmes

    Arrr -back in me day, we didnae have rocks!

    I had to add some extra functions to 4K of hand-assembled, hand-patched, 8085 code in EPROM's.

    To do this properly I decided to disassemble the patch-work of code, using ".origin" directives to carefully insert each hand-crafted patch in the right place in the EPROM set until I could eventually re-assemble an exact 1:1 match of the existing EPROM's. Then get rid of the ".origin", rebuild, fix some timing constants because the code-loop was now 30% smaller and faster.

    Then .... sometimes the parameters for the new functions didn't work properly.

    Hmm. I had an expensive logic analyser, with a hardware debugger for the 8085, so I quickly found out that two memory locations in RAM changed, one of which was a local variable in my subroutines.

    But ... the problem was HOW it changed! I could not find it!! No instruction referenced any of the locations in any way (the logic analyser could see all address pins), no DMA, no IRQ .... and it was not just that board - all of them behaved the same way.

    After 3 weeks I finally gave up and simply defined two 8 bit variables placed over the offending locations so nothing would be placed there. The code still runs ....

    1. Fibbles
      Thumb Up

      Re: Arrr -back in me day, we didnae have rocks!

      Binary bandaids, brilliant!

  13. Alien8n

    That C# code

    For some reason a previous employer wrote their own scanning software. It was created as a test project to see if it could be done with no intention of actually being used in a live environment. It very quickly became a live application, scanning batches of coupons and saving the scans in their own individual folders and storing a reference in a database so they were easy to find. The reference was a barcode on each coupon, associated with a campaign and a person. All worked fine, most batches could be upwards of 20 coupons and everything was hunky dory. Except for one client.

    One client decided instead of a tear-off coupon, or a small complimentary slip sized coupon they'd have full sized A4 coupons. The scanner would fail after 8 or 9 scans. Because of the way the batches were processed they couldn't be split into smaller groups for scanning. They'd been having this issue for several month before it was decided to hand the issue to myself as a "learning exercise" to familiarise myself with C#. So I build in some logging into the code, as it runs it drops a line of text into a text file, the idea being the last line of text should give a clue as to what it's doing when it crashes.

    It crashes at the same point each time, at the point it opens the scanned image and tries to save it. The exact same thing it's done over and over again for every other client's coupons. On the PC we run the code and turn on system monitoring and see a spike in memory usage at the same point it crashes.

    Turns out it's saving the images into an array before saving to file and can't handle the memory usage. A quick re-write and it now scans and saves individual images. It still crashes. A final re-write and some extra code to garbage handle the now orphaned image memory and it's all fixed (and runs a lot quicker due to no longer hogging the PC's memory). For some reason, despite C# supposedly automatically handling memory allocation it wasn't doing so.

    More worryingly for me was why the issue was allowed to continue, then get handed to a complete novice at C#, when they employed a team of 4 experienced developers. That said I could never understand why they were coding entire SQL queries into their code instead of passing parameters to a stored procedure.

  14. Mark Solaris

    If running on a SPARC then I'd wager that the problem was data alignment issues, aligning the structs by rearranging the order and padding where required, it's helped a lot in the past.

    It sucks though when the structs are binary representations such as packets :)

  15. Hero Protagonist

    Anyone else remember?

    The userid anecdote reminded me of the good old days of Unix when the mail command would populate the From field of an outgoing email using the value of the LOGNAME shell variable...but the shell did not prevent you from changing LOGNAME, so you could make the email appear to be from whoever you wanted.

    1. Alien8n

      Re: Anyone else remember?

      Reminds me of the early days of Demon Internet and their DOS news and email software.

      You could update the mail headers to spoof certain things, but the main thing was that it included the computer and drive name within the header. So my C:Drive was renamed Hell and the computer was called Hades

  16. Michael H.F. Wilkinson Silver badge

    The case of the 16 bit signed ints reminds me of something horrible

    I was trying out the AMD C compiler on some parallel code on our 64-core Opteron server to see if it would optimize more than gcc. Indeed, on some of our smaller images (1 Gpixel or so) it worked well, optaining some 10% more speed, which is nice. However, on a 3.6 Gpixel it crashed. Compiling the same code in gcc worked fine. I checked the code (designed to work up to 4Gpixel which is the maximum for GeoTIFF images anyway) and found we were correctly using a type "Pixel" defined as a 32 bit unsigned integer. A counter of type Pixel was used to traverse the (1D) array of pixels in each for loop. On a hunch I created a 2Gpixel image, and ran the AMD compiled code. It worked. Create an image 1 pixel larger and it crashed. Somehow the optimizer turned the 32 bit unsigned integer into a signed counterpart, causing havoc. AARGH. I then changed the definition of Pixel to 64 bit signed integer, and it still crashed at the 2Gpixel + 1 barrier. Turning off various optimizations might have solved the problem but would defeat the very purpose of using the AMD compiler. We decided to stick with gcc.

    Note that this was quite an old AMD compiler, and new versions might have solved the issue.

    BTW

  17. Anonymous Coward
    Anonymous Coward

    Prisoner release dates

    Another interesting, non-standard use of dates I had to code many years ago now was determining prisoner release dates. The basic principles were easy enough: if a sentence was 3 years 2 months then add 3 to the date the sentence was passed, add 2 to the months (wrapping around a year if required) and that's the date. I'm sure you'll have immediately spotted the "what happens if the sentence was passed on the 31st of a month and there aren't 31 days in the release month?" problem but there are plenty of other exception cases to work through as well.

    It was policy not to release on a weekend or Bank Holiday (so that the inmate can go and visit a parole officer or seek housing etc). In such cases the date was brought forward (because detaining them longer might be unlawful imprisonment). But you couldn't calculate once in advance because the Government occasionally throws in extra Bank Holidays, for example, and there is also loss of remission for bad behaviour to be taken into account (which was calculated as days added to the determined release date, not to the sentence, but still before taking into account weekends and Bank Holidays).

    Multiple sentences, for example 6 months for a primary offence and two consecutive 3 month sentences to run concurrently, make things interesting as it is not always obvious which is going to be the longer. The order the judge issues the sentences in also matters: 3 months plus 30 days consecutive is not the same as 30 days plus 3 months consecutive.

    Another goody was prisoners released on parole then committing further offences: they would receive a new sentence but also have to serve some portion of the remainder of their previous sentence and there were lots of rules around this depending on the length of sentence originally, the rules in force when it was first passed (as they changed over time) and so on. One particularly bad case was someone who had around 15 sentences all being served in various combinations of concurrent and consecutive from at least 3 or 4 separate court cases.

    Lastly, escapes were fiddly: they were handled as the sentence 'stopping being served' during the escape and then resuming. So someone escaping 5 days into a 6 month sentence is subsequently calculated as 5 days + the duration of the escape + 5 months and 25 (or 26) days remaining sentence. Again, concurrent sentences make life harder[1]: if you escape exactly at the end of the first, the second doesn't start until recapture which means the 30/31 days in a month business comes into play again.

    Needless to say, the prisoners - having plenty of time on their hands - were expert at doing these calculations and often challenged the dates produced by the prison. So the system had to be able to show its working and do so in a reasonably intelligible way: a Prolog-style back-trace stack wasn't going to cut it!

    [1] Ironically, 'life' sentences are among the easier ones to calculate

    1. Anonymous Coward
      Anonymous Coward

      Re: Prisoner release dates

      I bet you saw the pro-death-sentence camp with a lot more sympathy after that job. :-)

    2. Adam 1

      Re: Prisoner release dates

      I'm not sure that I'm comfortable with someone of your handle writing the code to figure out the release dates...

    3. Vic

      Re: Prisoner release dates

      there is also loss of remission for bad behaviour to be taken into account (which was calculated as days added to the determined release date, not to the sentence, but still before taking into account weekends and Bank Holidays).

      A mate of mine did some time in an Army prison some while back. The approach is, apparently, rather simpler: you are sentenced to n days in prison, but that is "serving under sentence", and you are expected to obey your commanding officer during that time. So if you do something wrong - you are not serving, so that day does not count as one of the days of your sentence. You are, quite literally, wasting your own time...

      Multiple sentences, for example 6 months for a primary offence and two consecutive 3 month sentences to run concurrently, make things interesting as it is not always obvious which is going to be the longer.

      OO programming is your friend...

      Vic.

  18. BenR

    I happened across the hated VB Date format bug myself. Took me an age to work out what was causing the issue in the first place, primarily because I foolishly assumed no-one would be so stupid as to allow random conversions in the first place.

    I then discovered that - in the version of VB i was then using at least - that the system Locale settings make absolutely no difference whatsoever to VBs interpretation of the dates. It carries on doing it's own thing regardless.

    I ended up fixing the issue by wrapping every single date input command in the ConvertDate() (at least i think that's what it's called - the memory is now hazy) to *FORCE* everything into a consistent, known format, and carefully hand-scouring the code, which was thankfully not too long, to ensure it wasn't doing anything odd with strings or anything.

    Worked in the end, but had me pulling my hair out and screaming for a good few days.

    I love the random 8 character .origin issue though. That's just brilliant.

  19. JLV

    Dates are a bitch

    For example, much as I love Python, I find it quite galling that you have to jump through hoops to json-ize a simple datetime. That's one big thing javascript got right, having a native date type.

    Dates are also another subject of frustration in writing cross-db portable SQL. Every single rdbms has its own cruddy take on it, with mssql being one of the worst with their stupid numeric codes for formatting. Heck, even within one database, doing anything more trivial than >, <, = comparisons is much more hassle than necessary.

    That said, the one worse thing than being overly picky with the parameters you accept is being sloppy and inconsistent in your handling of the ones you don't reject. You suck, VB, you suck.

    </rant>

    1. Charlie Clark Silver badge

      Re: Dates are a bitch

      For example, much as I love Python, I find it quite galling that you have to jump through hoops to json-ize a simple datetime. That's one big thing javascript got right, having a native date type.

      Python has had a native date type for a long time now. OTOH the JSON module in the standard library is both slow and cumbersome to extend.

  20. TeeCee Gold badge
    Meh

    cdate()

    A standard *nix C library that one, not just Windows. I suspect MS "borrowed" it.

    The only Y2K bug I actually saw in the wild on the 1st of January 2000[1] was due to the fact that variables cday, cmonth and cyear are available via inclusion of cdate.

    cday is the numeric day of the month.

    cmonth is the numeric month of the year.

    cyear is, er, the number of years since 1900...........

    The number of places sporting the date 1/1/100 was quite scary. My favourite find (once I'd worked out what was going on and told the C monkeys where the bug was in their sodding report headers) was the US Naval Observatory clock on the web........(!!)

    [1] aka 2000-01-01. A day that I spent in the office watching nothing go wrong. Seriously, 1/1/100 was the highlight of the day.

    1. Anonymous Coward
      Anonymous Coward

      Re: cdate()

      > The number of places sporting the date 1/1/100 was quite scary.

      Not a great presentation card, granted, but have you seen any actual date calculations go wrong because of that, as opposed to "mere" display issues (which at least were obviously wrong and so unlikely to go unnoticed by the user)?

      I have seen plenty of display glitches (Perl was the Node.JS of that era, and it did exhibit this bug/feature) but the underlying calculations kept working as per the specification.

  21. Anonymous Coward
    Anonymous Coward

    In the days when a mainframes' memory was often no bigger than 32KB the O/S was kept small. As memory became more affordable then the O/S grew larger.

    That's when all the 32bit instructions using signed ADD instead of logical ADD started to propagate the sign bit of addresses bigger than x8FFF.

    Over 64KB the bugs showed where people had used "halfword" instructions with addresses - and lost the bits above XFFFF.

  22. VinceH

    Blind date

    "Pass in "25/12/2015" and it correctly assumes DMY and returns 25 December, but when it sees "10/12/2015" it returns 12 October!"

    I have the misfortune of having to use a cloudy accounts package for a couple of clients that does exactly the same - and it's bloody annoying. The company behind the package are based here in the UK (Bristol) - so I'm guessing it's a function in a Javascript library they've used.

    That's how the cookie crumbles

    "This reminds me of an online publishing system I used in the early 2000s that allowed the user to control the username of a submitted article comment."

    Drobe?

  23. Stevie

    Bah!

    So improper parameter validation in a user-written subroutine is somehow Microsoft's fault?

    Sorry, Kubla Cant. With the best will in the world I can only shake my head and declare this an own goal by the people you worked for.

    VB had many issues that had to be worked around, but lazily leaning on the VARIANT datatype to stand duty for whatever you needed at that moment in time with no verification and trusting in the good will of the universe was and is an obvious non-starter.

    Azathoth, even in the days of Cobol on the mainframe we knew better than to let a computer take a hint-less guess. That's how so many CS graduates "know" Cobol "doesn't work". They lazily used COMPUTE on mixed numeric types once, got a C- on their course project and never cracked the manual to read the "NEVER DO THIS - because" page included in every version I've ever seen. Thus, they go on to make the same mistake in their beloved language of choice in their first job.

    1. Wensleydale Cheese

      Re: Bah!

      Have an up vote for the Cobol observation.

      Another problem I came across in Cobol days was the amount of folklore around about what constructs were efficient or not, usually gleaned from a previous course for a different compiler written for a different hardware architecture.

      It made sense to benchmark such claims yourself, and it was not uncommon that they turned out to be false for the compiler/hardware combination you were now using,

  24. Peter 69

    Thanks to VB...

    ...since 1995 I've never had any date / time issues. This is due to VB and an Anglo-Merkin working environment. These taught me to enforce a %Y-%m-%d_%H-%M-%S format, which sorts sensibly, however the OS / shell / app may choose to interpret it. Merkins are adaptive and learn.

    I also always encourage the internal use of signed 32 bit integers with a 1970 epoch. This gives me a retirement plan.

  25. factor

    Love the NoSQL databases .. MongoDB

    A 'createdAt' field can perfectly well contain either the Date/Time type or the String type. No problem for it to hold different things in different records.

    What fantastic flexibility! Don't be assuming you can ".stftime" whatever comes out of the database.

  26. This post has been deleted by its author

    1. Charlie Clark Silver badge

      Re: Every tried to write a free text to date converter?

      I'm just a hobbyist coder (which I suspect will be obvious), but not finding what I wanted from the commercial options, I wrote my wife's law firm's client management program back in 2000 using vbscript and ASP. I eventually saw the light and rewrote it in PHP under LAMP in 2007

      So much not to like. The best way for generic conversion of text forms of dates and times always uses regexes: use some heuristics to detect the pattern use and apply it. The relevant patterns exist for almost every language.

  27. Richard 12 Silver badge

    Char isn't 8 bits

    The C and C++ standards don't require it to be, and so you cannot assume that all compilers will actually do that.

    Char also isn't signed or unsigned. The compiler can choose!

    MAX_CHAR and CHAR_BIT exist because the compiler can make char (and int and long) as big as it likes. As does CHAR_BIT.

    C89 was a mess. If you actually need the size to be right then you needed compiler checks to confirm the size of char etc.

    At least C99 fixed that nonsense by adding int8_t and friends.

    Shame that VS2008 didn't support them!

  28. Anonymous Coward
    Anonymous Coward

    The law of unintended consequences...

    Reading this has dredged up memories form a dim & distant past when I wrote code that ran on computers using assembly level language, rather than stuff that tries to run in peoples' brains using PowerPoint:

    I've been deliberately obtuse here. See if you can identify the company & product I'm talking about.

    Case 1: "But it always worked up until now!"

    Back in the 1980's I worked in the third line support unit for the main database product offered by a UK based computer manufacturer. This particular product had been written back in the 1970's as an in house tool on one system, source code translated to run on another, and then finally migrated into the systems I was looking after it on. Additional functionality had been bolted around on the sides, patched into the middle, and some of the worst excesses brought about by automatic code translation had been massaged out by hand, but it was still at core the same stuff bolted together as an in house tool in the early 70's.

    Then one day, one of the core pieces of functionality, a hashing algorithm used for both storage and retrieval of data, started failing randomly when being run in the test labs on a new model of computer with a completely re-designed hardware architecture.

    This architecture had some fiendishly clever pipe-lining built into the CPU design which allowed for pre-emptive execution of code instructions, essentially executing several instructions "ahead" of where they normally would be executed, thereby allowing memory to be shuffled around more effectively. Very clever indeed. Except for the piece of self-modifying code in the guts of that hashing algorithm, which now failed to execute because certain instructions were being executed before they could be modified.

    It's over Thirty years ago, but if I recall correctly, the "fix" was to patch in an exec instruction immediately before the piece of self modifying code in question which instructed the CPU to "Stop pipe-lining", and then another immediately afterwards that said "As you were". Nobody had the guts to touch the algorithm in question. It had remained unchanged since 1972, even down to the bug that failed for certain low address numbers...

    Case 2. "Who put the brakes on?"

    Same company. Same Database. Different family of computer systems.

    So, about five years after the time of the first story I was sitting in the Pub one lunchtime (Still in the 80's then eh?) with a mate who worked on the hardware design side of the company. He was telling me that they were running performance tests on some new multiple node configurations, but that something was slowing them down. In theory, each node should operate independently, running the virtual machines currently resident within it and only synchronizing with the other nodes in the configuration when a special event occurred.

    However these "stop everything an pay attention" instructions were coming along more often than anyone had expected when they started testing customer workloads.

    When I asked what caused the syncs to happen he reeled off a series of circumstances, and one nearly made me bite through the rim of my pint glass. There was a particular low level instruction which returned the system time. I'll call it "Clock". "Clock 0" returned the node time, "Clock -1" returned the system time, and this caused a node synchronization. One of these "Hang on people, let's compare notes" events that was slowing the systems.

    Now, I'd been looking at system dumps for long enough to know that:

    a) We had "Clock -1" scattered through the code all over the show. It was used every time we wanted

    a time stamp for something important, such a s DB log entry, or for something relatively trivial, like a time stamp for a journal file or to return a value used as a seed for a randomization algorithm call.

    b) The "high level" language that chunks of the Operating System, Database, Transaction Monitor, and just about everything else was written in had a "Time" instruction that took no parameters and compiled down to "Clock -1".

    No wonder the multi-node performance was, how to put this, "non-optimal". The sytems were stopping to have a huddle every couple of hundred CPU cycles.

    Suffice it to say that I spent the next month writing an unending series of software patches turning "Clock -1" into "Clock 0".

    We source-cleared the problem by exploiting a little known feature of that "high level" language which allowed the coder to embed snippets of assembler into their module.

    People don't go to the Pub any more. So I guess this sort of problem never gets spotted. Explains a lot...

POST COMMENT House rules

Not a member of The Register? Create a new account here.

  • Enter your comment

  • Add an icon

Anonymous cowards cannot choose their icon