• Steve (unregistered)

    Once it isn't undefined anymore (so after the first run) it will always go to the else branch and set it to false (even if it was true the first time).

  • Smithers (unregistered)

    And for a bonus bonus WTF, after caching the result, all subsequent calls will return false, regardless of the originally cached value.

  • Sally (unregistered) in reply to Smithers

    you don't need to worry about cache invalidation if your cache is always invalid

  • predecssor (unregistered)

    You never know, that behaviour could be required for the issue they're working around.

  • Dude (unregistered)

    Am I the only one that doesn't see the issue with checking each property along the chain? The article states it's TypeScript, and if you don't do each check (with the possible exception of the indexOf and/or split), then if the object doesn't have any given property it just dies. The only way I can think of doing it more efficient is to wrap the single accessor in a try/catch, but now you're using exceptions for flow control (which may or may not be appropriate in this circumstance).

    TRWTF is the 'caching' and 11/13, and/or Javascript, but not the accessor block.

  • (nodebb) in reply to Sally

    My cash often seems to be invalid. Too many zeros in front and not enough at the end.

  • Jimmy (unregistered) in reply to Dude

    You're missing the part where split is called three times. It's just...gross.

  • Anon (unregistered)

    TRWTF is caching the OS version. What if the user upgrades their OS while the program is running?

  • a person (unregistered) in reply to Nutster

    Pretty sure the problem arises from not having enough digits between the first nonzero digit and the decimal separator. Zeroes at the end don't help (3.50 is the same as 3.500000000 after all) :-)

  • seebs (unregistered)

    I don't think that's an urban legend, exactly. It was pretty widely reported on at the time.

  • PotatoEngineer (unregistered)

    I dev in TypeScript, and that pattern of "I need to access a deep property in an object that might not exist in the first place" leads to creating helper functions for this. Lodash has _.get, and my own codebase has a similar function that actually keeps the type properly, but the upshot is that you'll only see code like this when you're too lazy to do it right. Which is the WTF, of course.

  • eric bloedow (unregistered)

    i like to play free games that are built on games that use "flash", and i know of at least one that gave a "version too old" error when i installed flash version 10! yes, it thought i had version ONE!

  • sizer99 (google)

    My iPhone reports osversion - if that's showing up as version 11, I think either TypeScript is being weird or that code is being weird. Given that the code doesn't even work, maybe it's the code.

  • Lőrinczy, Zsigmond (github)

    Also GetVersion of Windows API is a very useful function: according to MSDN it returns the version number, or returns something else, or may cease to exist anytime, as it is deprecated. Now you know it.

  • Filippo (unregistered)

    They are not trying to "cache" the value. What it seems they are trying to do there is to work around the bug (or non updated version) of a Cordova/Ionic plugin that detects the iOS version. Not the first time I see it, perfectly legit and sometimes unavoidable. The rest... well, it does look unusual indeed but luckily for me I haven't been working on those devices for over a year now.

  • Grijan (unregistered)

    I'm too lazy to search for the article, but Raymond Chen, of The Old New Thing, confirmed some years ago that the reason Microsoft skipped Windows 9 is, indeed, the one cited in the first paragraph. I don't know if Microsoft has stated that officially, but I wouldn't say it's an urban legend once Microsoft employees have confirmed the fact.

    It's one of the many WTFs which the Windows Compatibility Team (of which Raymond is member of) have to deal with. After all, Windows is known for letting you run 25+ year old applications without a hiccup, something unthinkable in other OSes (Would certain fruit-named company change a version number to have better backwards compatibility? I don't think so...).

  • Gene Wirchenko (unregistered)

    Re: the embedded article comment: Microsoft changing the string to "Windows 0" or something similar could simply break things in another way.

  • Linus (unregistered) in reply to seebs

    Widely reported, but false. There is a windows api for getting the version number, and that doesn't give you an ambiguous result. Given the API, what kind of programmer would instead shell out to a new process and run 'ver' to get the version string? Obviously, an 'open source' 'cross platform' programmer, not a Windows programmer..... And when they did that, Windows XP would reply "Microsoft Windows ....." instead of "Windows 98 (4.xxx,....".

    So to make that kind of mistake, a fairly stupid 'open source', 'cross platform' programmer. Which tells you what kind of person MS was worried about....

  • Smash (unregistered) in reply to eric bloedow

    Not to worry. You just need to wait until Adobe releases Flash 60 or 70, and your game will magically start working again.

  • (nodebb) in reply to Linus

    a fairly stupid 'open source', 'cross platform' programmer. Which tells you what kind of person MS was worried about....

    Which is kind of...a lot of programmers? So good for them really.

  • Gene Wirchenko (unregistered) in reply to Linus

    Someone who did not know about the call? When was the call added? If later, how would earlier programs have handled it?

  • Gnasher729 (unregistered)

    I remember Apple running into problems with MacOS 10.4.10 which was the first ever version with a two digit minor version. The problem: Lots of software did an alphabetical check instead of numerical and thought 10.4.10 was before 10.4.2.

  • Grijan (unregistered) in reply to Linus

    GetVersion() has been available since Windows NT 3.1, and it returns both a string with the OS name and a 32-bit integer which packs version, revision and several flags (such as Windows 9x/NT or 16-bit support). The problem is that many lazy programmers (the kind which blindly copy code from StackOverflow instead of reading the documentation), when they need to know if they are in NT, check if the version string starts with "Windows 9". Because, you know, reading GetVersion()'s documentation to find the right flag is too difficult. Good luck getting those morons to employ the APIs right. In fact, as Raymond explains, when an application doesn't run in a new version of Windows, 99% of the time it's because it missuses an API or uses an undocumented API or memory structure.

  • Ulysses (unregistered)

    Geeze, how dumb of them. MS has put lots of work into compatibility shims, and they were still afraid to name it Win9, smh. Hey, it even rhymes with winmine.

  • smf- (unregistered) in reply to Ulysses

    To make it really confusing they could have called it Windows Nine X.

    A shim would have been a terrible idea.

  • Stuart Longland (unregistered)

    Actually, I think the skip from 8→10 probably has more to do with the City of Munich and their trials with Linux.

    Rumour has it that after a number of years, they had ironed out a lot of the kinks and delivered a truly smooth experience. Visitors would ask "What version of Windows is this?" to which the locals would look quizzically at them reply, "Windows?… Nein!".

  • (nodebb) in reply to Grijan

    The problem (although I don't believe it's ever been officially confirmed) wasn't so much with Windows native calls; it was predominantly with Java applications, where checking the System(os.name) property with the "if (osName.startsWith("Windows 9"))" pattern was rife.

    Though looking at the selection at https://searchcode.com/?q=if%28version%2Cstartswith%28%22windows+9%22%29 I can see several examples where "String osName = System.getProperty("os.name");" comes AFTER the "Windows 9" check, so that probably indicates the average quality of this sort of code.

Leave a comment on “An Updated Version”

Log In or post as a guest

Replying to comment #:

« Return to Article