13 ms·
Why was Pinball removed from Windows Vista?
- randomdrake 14y agoThis is an excellent example of why comments in code are so very useful, helpful and in my opinion, necessary. ... nobody at Microsoft ever understood how the code worked (much less still understood it), and that most of the code was completely uncommented, we simply couldn't figure out why the collision detector was not working. Heck, we couldn't even find the collision detector! To all those folks out there who keep finding reasons to try and be clever with their language, or omit comments from their code: now you can remember Pinball. It's very possible that with some minimal commenting about what functions did, or what the intentions of block of codes were, Pinball could have lived on. Heck, we could have even seen a Modern UI version of Pinball.
- mikeash 14y agoIt's an argument for clear code that's readily understandable by other people. It's not an argument for any particular technique for achieving that goal. I've never seen any programmer seriously suggest that code should be deliberately made difficult to understand.
- h2s 14y agoI can't agree with you emphatically enough about this. Cargo cult commenting is one of the easiest ways to damage the readability of a codebase. Comments should be an edge-case solution for explaining unusual quirks, not the go-to approach for explaining the entire codebase. Using comments to explain what the code is up to is like using exceptions for flow of control. A large proportion of the comments I see should actually be function or method names for a more well factored version of the block of code that follows.
- randomdrake 14y agoI agree that comments should not be the "go-to approach for explaining the entire codebase." I hope you didn't think I was insinuating that in my comment. I was only trying to illustrate that in the absence of clear code, which many developers are guilty of sometimes, comments can be very helpful.
- h2s 14y agoNah I didn't think that at all, it was clear from the way you said "minimal commenting". I just have an axe to grind when it comes to comments of the form // assign the integer value 10 to the variable x x = 10
- miahi 14y agoWhat's really annoying is that most of the time you see this kind of comment there is no explanation why 10 was chosen.
- dhimes 14y agoAnd that's what comments really need to do: tell 'why.'
- Pyrodogg 14y agohttp://xkcd.com/221/ http://xkcd.com/221/
- MetallicCloud 14y agoThat's why you should use constants. Still self documenting without the need for comments (usually).
- adamzegelin 14y agoconst TEN = 12;
- mjbellantoni 14y ago"A large proportion of the comments I see should actually be function or method names for a more well factored version of the block of code that follows." I share the same experience.
- RegEx 14y agoThis point gets brought up a lot, but I'm not going to complain at all. In fact, just 5-6 months ago I used to be one of those programmers who would do # gets the xml def get_xml(): It took comments like this to help me realize just how silly the whole thing was. Now I write as much self-documenting code as I can, but comment as needed.
- bonch 14y agoIt's all subjective, but that comment could be expanded to, for example, explain where the XML is assumed to be coming from or what kind of XML is expected. If the code makes no assumptions about those things, that is also something to write a comment about.
- Funnnny 14y agoSure. Comment should be "why I did this", and code should be "how I did this", some people just write in "what did I do" and walk away thought they have comment Code took from a project I'm working with: #End of package
- StavrosK 14y agoI generally become aware that I should leave a comment whenever I write something that is less than trivial (but exactly less than trivial) to write/understand. Longish list comprehension? Summarize what it does. Nested function calls? Summarize why. Etc.
- chii 14y ago> Comment should be "why I did this", and code should be "how I did this" the problem starts when the 'why' doesn't match the 'how'...which one is "correct"?
- ozgung 14y agoThis may be a valid argument for modern languages like Ruby or Python. For 90s' coding standards however comments are even MORE important than the code itself. For Assembly and C programming and for low level graphics and physics algorithms proper naming of variables and functions are never enough for readable code.
- mgkimsal 14y ago"I've never seen any programmer seriously suggest that code should be deliberately made difficult to understand." Then you've not worked with some of the people I've worked with. The clever "it was hard to write, it should be hard to read" mantra has been thrown out by a few ex-colleagues trying to be clever, and a couple of them really meant it. Whether it was a hatred for others, or a misguided attempt at "job security", I'll never know, but some of these people do exist. Often, however, the same effect is had under the guise of "clever hacks" - look how clever and awesome I am! What? Of course everyone else can read and understand this (they just have to understand that I compiled this with my own custom-built compiler I rolled myself on gentoo so I could squeeze out an extra .0001% improvement!)
- bunderbunder 14y agoOne guy I worked with would do it to protect his bailiwick. He was intensely territorial, and knew that writing code so ugly that nobody wanted to even look at it, much less take the time to understand it, was an effective way to make sure that nobody else on the team would ever touch anything he wrote.
- damian2000 14y agoSounds like "mortgage code"... code that is intentionally so complex that noone in the company other than yourself can maintain it, hence you end up with a job for life that pays your mortgage.
- bunderbunder 14y agoHa. Unfortunately for him, it became clear that most of his code was all sound and fury, calculating nothing. Well, that and he took forever to fix bugs because he couldn't really understand it either. He was soon out on the street, and the rest of the team's policy of just rewriting bits instead of debugging them (it never took very long, and frequently resulted in 1/10 as many lines of code doing twice as much) had soon swept away most of his footprints.
- mikeash 14y ago
- hoka 14y agoyeah, +1. In this religious war, I side with "if anyone who has a reasonable level of competence with my code can't grasp it at first reach, I have failed in writing it." Or, famously, "Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." --Brian Kernighan
- stephengillie 14y agoRespectfully, commenting code and making it easily readable don't usually add to the bottom line. So while we all miss playing Pinball, it would be a waste of money to the shareholders. This game was another casualty of maximizing value towards shareholders and away from all other stakeholders.
- NoPiece 14y agoI would suspect the programmer was lazy or rushed, and wasn't considering shareholder value.
- corin_ 14y agoRushed is really the same thing, even if the words "shareholder value" weren't in their minds at the time.
- jsaxton86 14y agoI disagree. Sure, in the short term, taking on that technical debt may have made sense, but in the long term, this is a perfect example of how technical debt added significant maintenance costs to a project. What if dropping Pinball was not an option? The cost to the shareholder would have been much higher than it needed to be.
- shabble 14y agoThere's some commonly repeated (and likely even true to some extent) that ~60-70% of the cost of a software system is in maintenance. Which to me, sounds like if you're the contractor providing the system, that means 60-70% of the value is in the maintenance. It does mean taking something of a hit upfront so make things maintainable, but with the right billing structure you can be adding to the profits by Doing It Right as you go. It's certainly still a gamble though; you might not get the maintenance contract. You might be billing hourly and thus don't see any extra cash for your timesavings (and indeed, might see less).
- randomdrake 14y agoI haven't heard the argument about making code deliberately hard to understand either. I agree that clearer code and/or commenting would have been suitable. I only latched on to the example because they specifically mentioned that the code wasn't commented. In this case, a few lines of comments might have helped them find what they were looking for. Even if they original programmer was one of those people who just can't stop writing code like: $a = ($b)?($ab):$c; d($a); Maybe some amount of convincing could lead them to leave a comment every once in a while so we can at least get: // Detect collision $a = ($b)?($ab):$c; d($a); Since it seems like both clear code and comments were absent, either one would have been helpful.
- jrajav 14y agoI don't think comments are any kind of substitute for clear, well-structured code. In your example, "Detect collision" still doesn't give me any kind of epiphany about the code. At best, it gives me a slight hint about where to go to get more information. Chances are I'm trying to fix a bug or change the behavior, so I still need to figure what $a, $b, $ab, $c, and d are and what their purpose is. In other words, I have nothing against good comments, especially on obscure code, but I think they're only marginally useful even in those cases.
- randomdrake 14y agoDefinitely. I wasn't trying to say that they were a substitute. I specifically said both could have worked. In the example they cited, they couldn't even find where to begin. A small comment could have done something about it. When you can't have both clear code and commenting, you could at least try to do one every once in a while. How can that be a bad thing?
- deleted 14y ago[deleted]
- klibertp 14y agoWhat other technique do you have at your disposal in a code originally written in assembly and then translated to C, and then refactored several times without rewrite? I personally didn't hear of one that would be usable in this case. Also, I'm starting to think I should write a script to cut out every comment here that has "code" and "comments" in it - among with several other phrases that signify neverending debates.
- joezydeco 14y agoThis is also a great example of what happens during acquisitions. Space Cadet was developed by Cinematronics (apparently no connection to the classic arcade game manufacturer) and published by Maxis. Maxis eventually bought Cinematronics. Then (according to Wikipedia) "The studio was closed and the employees were laid off when Maxis was acquired by Electronic Arts in 1997." So someone out there knows how to fix it. I bet Microsoft called EA looking for a quick/free fix, EA called the employee (or lost track of them, more likely), and the employee told them to stick it.
- TeMPOraL 14y agoThere is no reason not to "be clever with your language", as long as you separate the "cleverness" behind a clear interface.
- bunderbunder 14y agoThere are some readability problems that stem from a lack of comments, and there are other readability problems that stem from exceedingly poorly-written code. Heck, we couldn't even find the collision detector! This sentence tells me that the big problem here comes from the latter, much worse, source of of readability problems. The fact that they couldn't find the collision detector implies that the code had no class named CollisionDetector, no procedure named DetectCollisions, nothing of the sort. Which implies (if not conclusively) that there was a whole lot spaghetti code floating around in there. Or at least a whole lot of very poorly-factored code. I do think that comments are an important part of making code readable and maintainable. But comments are there to handle less drastic readability concerns. Documenting what units a parameter should be in, for example, or saying, "The following code implements X algorithm with Y and Z optimizations applied." Comments should never just be a substitute for using language-level code organizational and structuring constructs to organize and structure one's code.
- deleted 14y ago[deleted]
- viraptor 14y agoTo me that fragment says that the story is a bit more colourful than what really happened. This quote comes from Raymond Chen. The guy who includes ISA bus, interrupts and starting up a debugger in one post (http://blogs.msdn.com/b/oldnewthing/archive/2007/01/30/1557491.aspx http://blogs.msdn.com/b/oldnewthing/archive/2007/01/30/15574...); or analysing chip issues and software workarounds for them (http://blogs.msdn.com/b/oldnewthing/archive/2011/01/12/10114521.aspx http://blogs.msdn.com/b/oldnewthing/archive/2011/01/12/10114...). Maybe the code was really messy and hard to work with... but it's hard to believe that he couldn't find the collision detector ;)
- shmageggy 14y agoA programmer from the original game commented on the article and said much of it was done in asm then later ported to C by msft, so it probably was really that messy.
- MichaelApproved 14y agoThis is an excellent example of why comments and well documented code should be part of the licensing agreement.
- eps 14y agoIf they weren't able to find the collision detector, I seriously doubt the comments would've been of a usable quality.
- kamjam 14y agoI read that comment and immediately thought of this HN post and why i disagreed with everything in that article. http://news.ycombinator.com/item?id=4934417 http://news.ycombinator.com/item?id=4934417
- augustl 14y agoI usually argue that version control history is often as useful as code comments. In this case, though, I suppose comments would have been better than some arcane 15 year old VCS :)
- shabble 14y agoI'm pretty sure I saw a library somewhere that could be purchased in both "raw code" and "commented, documented code" forms. Which I can only assume meant they had the comments/documents and were intentionally stripping them out for the cheaper version. The difference in price was also actually quite significant as well, as I recall. That, along with the fact that the person doing the purchasing is not necessarily the person who would be using the product, makes this IMO a particularly nasty sales tactic. I've also heard war stories from Big Company folks about contracting out for a large software project, and per contract receiving the full source for the app, but none of the (particularly convoluted) build scripts or Makefiles. Lessons Learned are why BigCo has a 900 page specification document including glossary of what the word "means" means.
- dfox 14y agoComments under the article seem to imply that most of the relevant code was somehow hand converted from (probably well commented) assembly to C which I only assume was done by someone who had no interest in how or why the code actually works, which seems to perfectly explain the lack of comments (or meaningful structure for that matter).
- moepstar 14y agoHeh, 's nice to read about that and as a pinball-enthusiast i'm a bit saddened for it to be gone, even if it is more for retro-reasons as opposed to it being special in some way... Maybe MS should team up with someone who understands making (digital) pinballs, like the guys that created Zen Pinball?
- streptomycin 14y agoToo bad it wasn't open source, then someone would have fixed it for free.
- MatthewPhillips 14y agoSomeone asked that in the comments, and he responded that it was licensed from a 3rd party company.
- ben0x539 14y agoTake the argument a step further: Microsoft "should" have required the 3rd party to provide the code under an open-source license.
- glanch 14y agoI'm surprised they didn't. Why would MS trust 3rd party code enough to include it in their OS? Seems like quite an unnecessary risk.
- kstenerud 14y agoIn 1995? Things were VERY different back then. Open source was Microsoft's mortal enemy.
- Firehed 14y agoOpen source wasn't exactly a huge priority for Microsoft in 1995 when the application came into existence. In fact I think it's a testament to their backwards compatibility that pinball survived for as long as it did with little or no maintenance.
- crescentfresh 14y agoWait, can't 64-bit windows run 32-bit programs?
- zspade 14y agosame question was asked and answered in the comments of the original article.
- deleted 14y ago[deleted]
- missing_cipher 14y agoAnswer is in the article: [That would have been even more work, because there was at the time no infrastructure in Setup for having 32-bit-only components. (And then automatically uninstalling it when WOW64 was disabled.) And besides, all the people who criticized Windows 96 as "not really a 32-bit operating system because it has some parts in 16-bit" would use the same logic to say that 64-bit Windows is "not really a 64-bit operating system." -Raymond]
- chimeracoder 14y agoMan, if that's the case, does using a BIOS mean I'm still running a 16-bit operating system? If so, then I guess I've got to marvel at how popular "16-bit" Linux is - I can run 64-bit only applications, watch Flash, Netflix... whoever knew a 16-bit OS could be so powerful!
- dmlorenzetti 14y agohttp://software.intel.com/en-us/articles/collection-of-examples-of-64-bit-errors-in-real-programs/ http://software.intel.com/en-us/articles/collection-of-examp...
- bunderbunder 14y agoYup. All you've got to do is copy it over from a Windows XP machine, if you have one laying around. Aside from the explanation others have quoted, I'm guessing some of it was also an aesthetic decision. They could probably still go and bring it back using WOW64, but it still looks like a Win95-era program, whereas all the other games have been replaced with better-looking rewrites. That and I think it only supports a resolution of 640x480.
- tolos 14y agoargh > The source code was licensed from another company. If you want the source code, you have to go ask them. Twice this mystery company is referenced, but never a name is mentioned.
- bunderbunder 14y agoGoogle to the rescue! http://en.wikipedia.org/wiki/Full_Tilt!_Pinball http://en.wikipedia.org/wiki/Full_Tilt!_Pinball
- barbs 14y agoLook for Danny Thorpe's comments, he mentions that it was created by a company called "Cinematronics", which was later acquired by Maxis, which was then acquired by EA.
- isabre 14y agoI used to play Pinball at school whenever I was in the Computer Lab. I also spent the bulk of my time in the computer lab at recess. Brings back old memories.
- cjensen 14y agoTo me, the lesson is: Do not duplicate code! and keep it simple stupid When implementing Unicode, MS said "hey let's copy all of our API functions to new names". Now they have two problems. When implementing 64-bit, MS said "hey let's have a completely different OS for 64-bit." Now they have four problems. Compare this to Unix/Linux/MacOS where Unicode is just implemented as a standard way (UTF-8) of encoding characters into the existing API. And there need only be one shipping OS which supports both 32-bit and 64-bit process types equally since there are only a handful of kernel APIs compared to thousands for Windows.
- barrkel 14y agoMS implemented NT, which only worked in Unicode. They had to add a compatibility layer to run Ansi apps. Which is MS's separate OS for 64-bit? OS APIs are distinct from kernel APIs. You're comparing a kernel (Linux) with a distribution (Windows).
- eridius 14y agoWhich is MS's separate OS for 64-bit? I believe you'll find it to be Windows <insert version here> 64-bit Edition. A quick googling suggests that Windows 7 retail copies have both 32-bit and 64-bit editions, but I'm guessing you still have to pick the right edition when you go to install it. And if you don't have a retail disc, then you probably only got one of the two architectures. Compare this with Mac OS X, where there is no "32-bit edition" or "64-bit edition", there is just "Mac OS X". Everybody installs the same OS, and it transparently works for both 32-bit and 64-bit machines. The only time when you really have to care is if you're installing a 3rd-party kext (kernel extension), as 32-bit kexts won't work on a 64-bit kernel, but that's pretty rare and any kext that's still being maintained today will support both architectures.
- shinratdr 14y ago> but I'm guessing you still have to pick the right edition when you go to install it. And if you don't have a retail disc, then you probably only got one of the two architectures. Good guess. They are separate versions, and only retail includes both.
- shmageggy 14y agoThe best part of this article is in the comments. An original programmer on the game explains the reason that the bug was occurring and also why the code was unreadable (hint: they did it in assembly) Ah, the quantum tunneling pinball! We ran into this while writing the original code at Cinematronics in 1994. Since the ball motion, physics, and coordinates were all in floating point, and the ball is constantly being pushed "down" the sloped table by the gravity vector in every frame, we found that floating point error would gradually accumulate until the ball's position was suddenly on the other side of the barrier! (To simplify collision detection, the ball was reduced to a single point/vector and all barriers were inflated by the ball radius. So, if the mathematical point got too "close" to the mathematical line barrier, a tiny amount of floating point rounding or truncation error could push the point to the other side of the line) To mitigate that, we added a tiny amount of extra bounce to push the ball away from the barrier when it was nearly at rest, to keep the floating point error accumulation at bay. This became known as the Brownian Motion solution. Since much of the original code was written in x86 asm to hand tailor Pentium U/V pipelines and interleave FPU instructions, but wiki says Microsoft ported the code to C for non-Intel platforms, I'm sure the code had passed through many hands by the time it got to you. The Brownian Motion solution may have been refactored into oblivion. http://blogs.msdn.com/b/oldnewthing/archive/2012/12/18/10378851.aspx#10379160 http://blogs.msdn.com/b/oldnewthing/archive/2012/12/18/10378...
- Evgeny 14y agoI'm so happy you posted that - otherwise I would not read down more than a couple first comments and would miss this!
- shmageggy 14y agoMy procrastination from studying for finals says "you're welcome"
- bcoates 14y agoMaybe the reason the Brownian motion stopped working was a shift from 80-bit x87 intermediaries to 64-bit SSE in x64, and the removal of long double support from MSVC.
- zwieback 14y agoI have a virtual machine running XP for testing installers of internal tools (many engineers at HP are still running XP). Just played a round of pinball. Despite having used Windows since 2.0, I didn't even know Pinball existed before.
- forgotAgain 14y agoSo now we know how insecure XP was (is).
- barbs 14y agoApparently, you can just copy the folder across to an installation of the later versions of windows and it's "fully functional" http://mspinball.weebly.com/ http://mspinball.weebly.com/ I can't try this right now, since I don't currently have access to a Windows machine, but can anyone confirm/deny this? Do you get the floating-point gravity bug?
- Wingman4l7 14y agoAnother good comment that's buried near the bottom, written by one of the authors of the game, regarding the ownership of the code: http://blogs.msdn.com/b/oldnewthing/archive/2012/12/18/10378851.aspx#10379245 http://blogs.msdn.com/b/oldnewthing/archive/2012/12/18/10378...
- robomartin 14y ago> nobody at Microsoft ever understood how the code worked (much less still understood it), and that most of the code was completely uncommented, we simply couldn't figure out why the collision detector was not working. Heck, we couldn't even find the collision detector! This continues to be one of my pet peeves, particularly with code samples and a lot of what is posted on Github, even major libraries. Almost no comments, background or guidance on the intent and structure or the code. No, I am not suggesting that something like this is necessary: // Iterate through all elements for(int i=0; i < count; i++ { // Check that velocity isn't above threshold if(velocity[i] > THRESHOLD) { // Limit velocity velocity[i] = THRESHOLD; ... That's ridiculous. However, something like this is useful: // Bounds-check velocities for(int i=0; i < count; i++ { if(velocity[i] > THRESHOLD) { velocity[i] = THRESHOLD; ... Anyhow, dumb example I pulled out of thin air. I've heard some say "I just write self-documenting code". That's a myth but for the simplest of structures. Any non-trivial piece of work is far from being self-documenting. Code is self-documenting for the guy who wrote it. I guarantee you that anyone else reading it has to reconstruct a stack in their head to understand what the hell is going on. That's not self-documentation. I shouldn't have to think to understand what a chunk-o-code is doing. The same for functions and/or methods. The myth of self-documenting code is easy to demonstrate if I show you a piece of code in a language you don't know. I am going to assume that most programmers these days don't know assembler, Forth or Lisp. (defun GetPolylineEndEntities ( plename / plends cvcenter cvsize oldcmdecho pt1 pt2 endss outlist) (setq plends (GetPolylineEnds plename)) (setq cvcenter (getvar "viewctr") cvsize (getvar "viewsize") oldcmdecho (getvar "CMDECHO") ) (setvar "CMDECHO" 0) (foreach point plends (progn (setq pt1 (add2d point '(-0.0125 -0.0125))) (setq pt2 (add2d pt1 '(0.025 0.025))) (command "zoom" "c" point 2) (setq endss (ssdel plename (ssget "C" pt2 pt1))) (setq outlist (append outlist (list (ssname endss 0)))) ) ) (command "zoom" "c" cvcenter cvsize) (setvar "CMDECHO" oldcmdecho) outlist ) I wrote this twenty years ago. Even if you understand Lisp you'd have to think it through. However, this is not how I wrote it. This is what I actually wrote: ;===================================================================================================== ; GetPolylineEndEntities ; ; Argument: Polyline entity name ; Return: Two element list containing the first (if any) entity found at the end of the polyline. ; The polyline itself is excluded. ; If nothing is found at a particular end, that element in the list is set to nil. ; (defun GetPolylineEndEntities ( plename / plends cvcenter cvsize oldcmdecho pt1 pt2 endss outlist) (setq plends (GetPolylineEnds plename)) ;Get the endpoints (setq cvcenter (getvar "viewctr") cvsize (getvar "viewsize") oldcmdecho (getvar "CMDECHO") ) (setvar "CMDECHO" 0) (foreach point plends (progn ;Examine what connects at each end (setq pt1 (add2d point '(-0.0125 -0.0125))) (setq pt2 (add2d pt1 '(0.025 0.025))) ;Zoom to the end being analyzed to have better selection accuracy ; **** Have to figure out a way to do this without zooming **** (command "zoom" "c" point 2) ;Eliminate the original cable from the resulting selection set (setq endss (ssdel plename (ssget "C" pt2 pt1))) ;Add the first entity found to the output list (setq outlist (append outlist (list (ssname endss 0)))) ) ) (command "zoom" "c" cvcenter cvsize) (setvar "CMDECHO" oldcmdecho) outlist ) Even if you don't know Lisp you now have an idea of what this code is doing. My style has changed over the years. This isn't my best example, but it is here to drive a point home. The use of an unfamiliar language serves to illustrate the point that the idea of self-documenting code is, again, a myth. I wrote that code myself and without the comments I'd have to mentally reconstruct every step to even begin to understand what's going on and what the intent was. I haven't touched Lisp in quite some time. I've looked through so much code in Github without a single comment that it makes me wonder if this is what is being taught in schools these days. Accurate in-code documentation is, as far as I am concerned, part and parcel of becoming a professional programmer. It recognizes that the work represents a huge investment in time, money and intellectual effort and it ensures that this effort and expense doesn't have to be duplicated in order to maintain, evolve or migrate the product as the Microsoft example clearly demonstrates.
- shmerl 14y agoThey should include Xbill by default: http://xbill.org http://xbill.org
- zaroth 14y agoApparently, someone has actually FIXED it and put it online. Although hard to know if the linked EXE isn't just a trojan. Anyone have a clean room they can test it in? http://mspinball.weebly.com/index.html http://mspinball.weebly.com/index.html See: http://blogs.msdn.com/b/oldnewthing/archive/2012/12/18/10378851.aspx#10379299 http://blogs.msdn.com/b/oldnewthing/archive/2012/12/18/10378...
- AndreyKarpov 14y agoPerhaps it would help to quickly find bugs - http://www.viva64.com/en/viva64-tool/ http://www.viva64.com/en/viva64-tool/ :)
- jfreak53 14y agoAhh gotta love Wine! Runs everything :) http://i.imgur.com/ekhiY.jpg http://i.imgur.com/ekhiY.jpg What ever you do DO NOT press F4 for fullscreen, it botches dual-monitors on Gnome. Took me 20 min. to get back up and running again. BUT, Pinball works :)