Hacker News new | past | comments | ask | show | jobs | submit login
[dupe] Windows 10: Code that uses 'os.StartsWith(“Windows 9”)' (searchcode.com)
41 points by thomasbachem on Oct 4, 2014 | hide | past | favorite | 31 comments



I don't find this search reliable at all. There are a lot of completely unrelated results. I couldn't find any related match on the 2.000+ Python results, for example. Same with C++. This is being publicized as "proof" of the rumor but it's not representative at all.

The Windows C/C++ API returns a structure with version numbers [1], same with the C# one [2]. Other languages just wrap the native C API call, GetVersionEx.

The most troubled framework is Java: because of some strange design decision, you can only get the version as a string (see [3]), and that makes impressively easy for programmers to screw up version checks. However, as other commenters have said, those apps could run on compatibility mode and Windows would solve the issue itself instead of completely changing an operating system's name.

1: http://msdn.microsoft.com/en-us/library/windows/desktop/ms72... 2: http://msdn.microsoft.com/en-us/library/system.environment.o... 3: http://stackoverflow.com/questions/228477/how-do-i-programma...


I'm sure the API provides the information, that doesn't stop developers from doing crazy things. The rumor, whether true or false, is actually just more evidence of how Microsoft is devoted to binary compatibility. It's a funny bit, yes, but doesn't say anything bad about MS at all.


Never underestimate a programmers ability to fuck shit up



My theory about the "Windows 10" name is that there is an intermediate Windows Phone release coming in early 2015, and they've decided to call that Windows Phone 9. Hence the unified release will be version 10.


I ran into some code a few days ago that wouldn't install because it was checking OS X version as a string and '10.10' < '10.5'. Bad code will always find a way


Any chance it was Matlab? I had to change version to 9 or 90 to run Matlab


It was PyObjC.


Apparently one of the perks to not calling it Windows 9 is that Microsoft doesn't have to deal with poorly written OS detection code that searches for "Windows 9" in expectation of it matching "Windows 95" or "Windows 98".


They could have just ran those apps in compatibility mode, which returns different values for all the GetWindowsVersion calls.

Or they could rename the entire OS.


There are no APIs that return a string of the product name. GetVersionEx gives you numbers. To screw up in this manner, you have to be relying on at least two layers of broken code on top of the really simple API that you should be using directly.

So I don't buy this rumor at all. The number of real applications that 1) remember Windows 9x exist, 2) aren't completely broken on modern Windows anyway, and 3) go out of their way to use some convoluted version checking method has to be extremely small.


This "convulted version checking method" is the default way to do it with Java, I'm not sure if there's any other programming languages that do it as well.


It's insane to check version numbers as strings. I guess the JDK is assuming you're not actually doing anything important with those properties (eg, just writing them to a log).

Python for example wraps GetVersionEx appropriately with sys.getwindowsversion()


Source for that?


Yeah, the OP[1]. A lot of the returned results are Java code, alternatively there's also [2].

[1] https://searchcode.com/?q=if%28version%2Cstartswith%28%22win...

[2] http://docs.oracle.com/javase/tutorial/essential/environment...


No. He said that it was the 'default' way of doing it. Yes, it has happened X times, that does not mean it's the default way of doing it. Maybe there's some other method which is done a lot more often and hence should be considered the 'default' way.


System.getProperty("os.name")


I would go with renaming the entire OS. Let it be FAOSDSACH, as in Formerly Awesome Operating System Destroyed by Suits And Corporate Heads


CP/M/3.1 (Pentium (like 386); Intel AMD) DOS 6.0 Windows/6.4 (NT, like Mac OS X) Windows/95 Windows/10


So, when they get to Windows 19 do they need to skip to 21 to avoid all the 2000 checks?


There won't be a windows 20, or anything closet to that. If we're still using computers the way we are now in 20 years, then we've seriously failed as a species.


We are still using computers now the way we were 20 years ago!

Remember Windows 95? That was 19 years ago!

It's easy to imagine someone like you in 1995 proclaiming there would not be a Windows 2015, or anything close to that.

Nothing has fundamentally changed, Internet and all. Even tablets, smartphones and multitouch interfaces are still basically the same old thing.


I'm quite aware. Make note.


2 digit dates seemed safe enough because lol no one would be using this software in the year 2000.

IPv4 address space seemed plenty enough.

640 k should be enough.


The first wasn't thought about, it was done to save bytes, not because people weren't going to be using the software.

IPv4 was enough, the use case changed.

640K should be enough is an urban legend.

This isn't meant to come across as rude, but you're missing the forest for the trees.

Everyone needs the post office, how else will you be able to send a letter. Everyone needs news, newspapers will be around forever. Everyone needs a travel agent, people like to travel. They'll be around forever. Everyone will always have a land line. Video stores will exist forever... Everyone needs a watch... Etc...

For every example you come up with, I can come up with three in which the majority of the population no longer complies. We progress more than you realize. A commercial windowing computer interface has been around for 30 years next year, it's still in it's infancy. Touch interfaces have transformed digital adoption to numbers greater than I would have ever been able to comprehend back in 92 when I sent my mom, who worked at the University of Calgary while I was at the University of Alberta, an email. It was magical. And yet, in no way did I think it would ever grow to a point where every person would hold not only email, but the internet (which existed, but not really at that point). If you're under 30, it'll be a lot harder to see the rate of increase.


There are no good reasons to check for an OS version anyway. Checking for the platform, ok. Not the version. That can be handled with feature detection.


I generally agree, but I'd amend that to "there are few good reasons". When an API is present but buggy, sometimes there's no good way around a version check. It can still be regarded as a last resort.


Sorry, but this doesn't even come close to working in the real world. If you're on the web, then this makes sense. However, on the metal, you need to know versions.


There's one good reason - sometimes feature detection lies. Or the feature you are looking for is implemented nonstandardly (brokenly).


Oh my!

So that's why they went with 10 - it makes sense now.


Ahhh, come on already with this one. Let it die.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: