6 ms·
We Are Morons: a quick look at the Win2k source (2004)
- edw519 18y ago"Comments like "UGLY TERRIBLE HACK" tend to indicate good code rather than bad: in bad code ugly terrible hacks are considered par for the course." For Microsoft or for everyone?
- garply 18y agoI agree with his assessment. Sometimes ugly terrible hacks are the best solution given the external constraints (time, 3rd party code beyond your control, whatever). And if you have an ugly terrible hack, you should definitely comment it.
- codemonkey 18y agoYes, but then you should go back and fix it. One can only hope that there were more "ugly hacks" that have since been fixed. The measure of a good programmer is not whether he or she recognizes when they're writing bad code, but whether the final result is free of bad code, and thus more maintainable. I would argue that someone commenting known bad code, but leaving it there in perpetuity is no better than someone unknowingly writing bad code (although the comments could serve as signposts to help someone else find and fix your bad code - but how often has that ever actually happened?).
- sep332 18y agoIt's not a well-worded sentence, but what he means is that if you have to call out an ugly hack, the REST of the code is probably pretty decent. If the code is full of ugly hacks, they wouldn't be worth mentioning.
- blogimus 18y agoI think an important point is that the programmer recognized that what he/she was doing was an ugly hack, (presumably under some serious constraint, like time) and felt compelled to point this out. A mediocre programmer might come up with the same fix, but not recognize that the fix was an ugly hack, and not comment as such.
- frossie 18y agoI agree with the OP that this is a positive sign. The only thing that surprises me it that it seems to be a free-format arrangement of a word that can be used in a positive way. We have a magic comment word ("kludge", if you must know) that we use for code that we wish we had time to write better; that in principle allows us to go back and find things to fix after the fact, or helps troubleshooting since kludges are more likely to break.
- blogimus 18y agoI'm not terribly creative with code I write for others. Since I've been doing a lot of Java recently, using Eclipse, I stick with // TODO: Which has the added benefit (in Eclipse) of creating a tiny blue box in the vertical source error/warning/status bar (I'm not sure what it's official name is) so I have a visual cue to see where I have unfinished business (Kludges are unfinished business that you might get to next day or never, but even if it's a glorious hack, if you think its a hack and not a "proper" way to do it, its still unfinished business. In a prior project we used to use "glorious hack" as a special comment to use as the first places to investigate when something broke.
- far33d 18y agoI don't agree. I think all code of any size, bad or good, has these words in it. The problem with his statement is that "UGLY TERRIBLE HACK" is relative. One man's terrible hack is another man's normal day-to-day style. In bad code, there are just more ugly hacks that aren't commented as such.
- brc 18y agoShow me a programmer who has never implemented an ugly terrible hack, and I'll show you someone who has never shipped any code.
- tptacek 18y agoThis is old news, obviously. It's worth pointing out that as good as the code appeared to these reviewers in 2004, between then and now, Microsoft underwent a sea change in code-level quality control. Windows is now likely to be the best reviewed, most rigidly compliant code shipping on the market: * Virtually every Microsoft senior developer has been trained on software security * All shipping code is checked in-house, including some homegrown static analysis tools * Most shipping products have had line-by-line source code reviews done by at least two different firms (we did some of this work for Vista). During the Summer of Worms in '03, when Microsoft security lapses were front-page material on CNN, Bill Gates told the press that Microsoft was going to totally overhaul security and code quality. They weren't kidding. Microsoft now outspends everybody on that. Note: I'm a Mac person.
- alyx 18y agoAmazing how people can only say anything favorable about Microsoft if they hide behind the guise of a competing company. God forbid a PC guy had this opinion. Up voted none the less. Note: I'm a Mac and a PC person.
- tptacek 18y agoIf I don't say I'm a Mac person, people say I'm a shill. It's also just the truth --- I don't want to imply I like using Windows (although I like Vista more than I like XP).
- lucumo 18y agoTo me it wasn't the "Mac person" comment that convinced me of the point. Just the thoughtfulness that was apparent in the post. There was mention of facts, and it obviously wasn't a rant. Kneejerk "Microsoft rules" or the opposite should be downvoted, even if followed by "I'm a Mac person". I'd like to think that's what would happen as well.
- jacoblyles 18y agoIn any topic that arouses people's passions, I find that if I want to say something nice about hated group X, then if I don't identify myself as a non-X, then people dismiss what I say as another one of those "damn X-ers". It's irrational, yes. But that's human nature for you. What's surprising, and perhaps sad, is that operating systems have aroused people's passions so intensely that it has become one of those volatile topics, like the canonical religion and politics, that one must treat very carefully, and certainly not bring up at dinner.
- maweaver 18y agoWhat's interesting to me is the comments. I worked in a corporate environment that seemed to me at the time to be overly-paranoid about open source (any use of open source software had to be run past a legal team). After seeing people argue that Microsoft's millions of lines of code is in violation of the GPL due to a single Makefile, I have more sympathy for their concerns.
- TheAmazingIdiot 18y agoGood heavens. You mean that people really are claiming copyright violation on a makefile? Egads. Now, i never really got the idea of source pollution if the source is never grabbed to begin with. All projects that rely purely on the GPLv2 have the same 'legal requirement', unless that code generates more code. Then, well, let the lawyers decide that one. I'm thinking of the license from gcc and like.
- Erwin 18y agoAnd even that claim was baseless as it was made based on a filename: GNUMakefile is a filename that GNU Make looks for before "Makefile". This allows the same directory to have a Makefile for traditional make and one used for GNU Make.
- mpk 18y agoConsidering the size of the codebase and the amount of developers that have contributed to it over time, I find the comments to be very mild. Every commercial codebase has hacks and special cases. Limited developer resources, deadlines and idiotic external constraints (hello third party libs/apps!) simply force that. There is an art to capturing stupid stuff that is beyond your control at the integrating level (with checks, logging and exceptions at that level) without allowing this to contaminate the deeper levels of your system. That's another story entirely. If you want to read some highly amusing comments in source, read http://www.jwz.org/doc/censorzilla.html http://www.jwz.org/doc/censorzilla.html - the list jwz published of the stuff that had to be removed from the Netscape source code before it was open-sourced.
- shimi 18y agoI couldn't stand The undocumented Windows API scene. It gave me such a hard time. I find it amusing that the MS guys had to deal with that!!!!
- 10ren 18y agoit's hard to see Microsoft's operating system competitors taking advantage of it. Wine. If I was them, I wouldn't be interested in copying it, but I would be interested in seeing how things were actually done (to confirm inferences as well as resolving puzzles.) But I believe that even seeing code leaves you open to a copyright infringement suit, which is why people do clean room reverse engineering. So, I wouldn't even look at it if I was them - despite my interest :-(.