r/programming • • Aug 20 '20

Announcing TypeScript 4.0

https://devblogs.microsoft.com/typescript/announcing-typescript-4-0/
1.3k Upvotes

236 comments sorted by

View all comments

Show parent comments

138

u/[deleted] Aug 20 '20 edited Aug 20 '20

That's an anecdote, ironically originated from another reddit comment.

Windows 95 and 98 reported itself as 3.95 and 3.98 to remain backwards compatible with windows 3 apps. So that prefix check never would have worked.

98

u/kevincox_ca Aug 20 '20

version[2] == '9'

Checkmate.

26

u/everythingiscausal Aug 20 '20

But now you’ve got an index out of range bug on Windows 10!

31

u/kevincox_ca Aug 20 '20

I believe you mean Windows 3.10 🤓👈

(Also assuming a c-string you would get the null byte so perfectly safe anyways)

4

u/SemiNormal Aug 21 '20

Can't wait until Windows 3.11 is out! 😉

3

u/AboutHelpTools3 Aug 21 '20

Better for it to throw an exception rather than doing what it shouldn't be doing.

3

u/lolomfgkthxbai Aug 21 '20

But now you’ve got an index out of range bug on Windows 10!

I think you meant Windows 3.98.10

56

u/sparr Aug 20 '20

Here's some code from the Jenkins CI project (one of their official plugins, to be precise) that would have thrown an assertion for "windows 9" (which wouldn't have had a version starting with "4.1"), and when assertions were disabled would have identified it as windows 98.

https://issues.jenkins-ci.org/secure/attachment/18777/PlatformDetailsTask.java

        if (name.startsWith("windows")) {
            name = "windows";
            if (name.startsWith("windows 9")) {
                if (version.startsWith("4.0")) {
                    version = "95";
                } else if (version.startsWith("4.9")) {
                    version = "me";
                } else {
                    assert version.startsWith("4.1");
                    version = "98";
                }

0

u/[deleted] Aug 20 '20

[deleted]

47

u/funguyshroom Aug 20 '20

Congrats, you found a bug in an 11-16 year old piece of code

6

u/InertiaOfGravity Aug 21 '20

That's an accomplishment

18

u/sparr Aug 20 '20

Good catch. I had not noticed that. I agree, it looks like that bug overrides the one I was pointing out :)

14

u/AboutHelpTools3 Aug 21 '20

When a bug saves you from another bug.

→ More replies (1)

6

u/PaintItPurple Aug 20 '20

Nah, that's a bug. Though it doesn't really invalidate the comment's point, since main source of the bug is just reusing the name variable, so the "windows 9" bug would still exist even if that one were fixed.

24

u/herpington Aug 20 '20

That is one ugly OS version detection.

→ More replies (1)

13

u/chylex Aug 20 '20

The original anecdote was startsWith("Windows 9"), and if you search for that you will find real code that uses this to check for Windows 9x.

5

u/thenextguy Aug 20 '20

That assumes the programmer that is checking the version has a clue how to do it right.

0

u/[deleted] Aug 20 '20

[deleted]

0

u/[deleted] Aug 20 '20

[deleted]

6

u/TheHappySeeker Aug 20 '20

I bet at some point soon they'll just drop the 10 and call it Windows.

6

u/Archon- Aug 20 '20

They already have on the server side, they just include the build number at the end

→ More replies (1)
→ More replies (5)

12

u/IcyWindows Aug 20 '20

Executive wanted it. I've heard there was focus group tests on 9 vs. 10 as well.

3

u/segv Aug 20 '20

would've been funny to call it Windows Nein

→ More replies (1)

6

u/Linkk_93 Aug 20 '20

ask the Xbox numbering team ;)

3

u/Eirenarch Aug 20 '20

Because of the genius marketing team.

→ More replies (1)