“Use the Stock Theory of Decluttering to Clean Your House”

I’m a horrible packrat. I’m not holding onto things for their earlier value, like this article suggests, but because they might be useful someday — in my youth, I had one too many instances of throwing something away after a couple years of disuse, only to discover that I needed it the next week.

Nevertheless, the article does provide a useful decluttering point: concentrate on how useful a particular thing is now, to decide whether to keep it or not. As an example, I had a large stack of 5.25″ floppy disks until a couple years ago, when GoddessJ (exasperated with my packrat ways) pointed out that they were not only obsolete, but that I’d be hard pressed to find a machine that even had a 3.5″ drive these days. I was keeping them in case someone wanted me to fix an old computer that only had a 5.25″ floppy drive, something that had happened to me more than once in the past, but she was right… they could be described as museum pieces at this point, but only if you’re talking about the dusty storage rooms of museums.

A Rant About Computer Books

I really, really wish that computer book authors would pay more attention to their work.

I know that I’ve mentioned the Montgomery reduction algorithm here before, and the sad state of nearly all of the few things that describe it. I finally got it to work properly a while back, thanks in part to the book Cryptography in C and C++, but it was slower than the standard raiseToPowerMod function I’d implemented. It was supposed to be significantly faster, so I started looking for tweaks I could do. There were several in that book, and implementing them one at a time helped, until I got down to the last piece.

The last piece was intended to quickly calculate the inverse of a number, and the heart of it was described as:

If x < ny mod x, set yy + x.

The only problem is, that statement is logically impossible. Regardless of the value of x, ny mod x will always be, at most, one less than x, so x can never be less than it. I puzzled over that line for many hours, trying to figure out what was wrong with it. It didn’t help that the German-to-English translator that they’d gotten for that book was either not a native English speaker, or didn’t understand the subject matter… reading it was easier than reading a machine translation, but the original German is still painfully obvious, obscuring many of the details. I finally dug into the example code for the book to figure it out.

It takes a lot of experience to write code that’s easy for another human to understand, which in large part is why reading code is considered significantly harder than writing it. (Book authors almost never have that level of experience, which is why I avoid their code whenever possible.) It took me nearly two decades of practice to reach the point that my code can be easily understood by anyone familiar with the language, rather than something that only the compiler could parse. It requires a clean design, carefully-chosen and descriptive variable and function names, and comments that explain why something is being done, possibly in addition to exactly what is being done if it’s not clear.

This guy doesn’t do any of that.

His code works, so far as I can see (and that alone is a major improvement over some computer books!), but he leans heavily toward old-school C — short and often cryptic variable and function names, and his comments are few and far between. The need for programming like that went out before 1200-baud modems arrived, but you’d think that he suffered the agonies of the damned over every byte that wasn’t absolutely necessary to compile the program.

On the plus side, every function that he provides does have a header comment that describes what it’s intended to do, and its syntax, inputs, outputs, and return value. And every macro has a one-line comment explaining (in terse but readably English) what it does. That goes a long way toward making the overall design understandable, even if the functions themselves take a lot of deciphering.

In any case, I discovered the problem. That line should read:

If x < ny mod 2x, set yy + x.

It’s a small change, but it makes a huge difference.

My raiseToPowerMod function, using the Montgomery reduction, is now significantly faster than it was before. Timing is difficult, but it looks like it’s 25% to 50% faster than without the Montgomery stuff. 🙂 But getting to that point felt like walking barefoot over a bed of broken glass.

It’s really no wonder that good software developers can command such large salaries… anyone less stubborn persistent than I would have given up long before getting this to work, let alone making it work quickly.

“Yes. Another Backup Lecture.”

This article is good. Read it. Do it. Now. Your life (or at least your data) depends on it.

I can’t count the number of times that I’ve seen people lose vital data to a dead hard drive, and it’s just as painful for me to have to tell them that it’s gone for good as it is for them to hear it. Yeah, there’s always the option of a data-recovery company, but most people can’t afford that, and they offer no guarantees even if you can.

Don’t subject your favorite computer nerd, or yourself, to that kind of torture. Back up your data, regularly and often. Please.

“A Celebration of Duct Tape”

Ah, the infamous duct tape.

How is duct tape like The Force from Star Wars? They both have a light side and a dark side, and they bind the universe together.

A roll of duct tape and a can of WD-40 is all you really need for most household repairs. If it moves and it shouldn’t, use the duct tape. If it doesn’t move and should, use the WD-40.

I could probably find a dozen other humorous (and true!) statements about this wonderful product, but the people at Lifehacker have done one better — they’ve got an entire list of the uses that people successfully put duct tape to, including a number of them that I’d never have thought of — honestly, healing warts?!

(I saw my first roll of actual “duck tape” — duct tape’s ancestor — in a hardware store last week. Neat.)

Catastrophe at Fake Electronics Plant!

GoddessJ and I recently visited an Ikea store to get some furniture for our new house. As always, my attention was drawn to the fake computers and TVs they have in their display rooms.

You’ll be as sad as I to learn that one of the manufacturers of such props (I think it’s the one that the Ikea store we visited uses) suffered “a major catastrophe” recently. Fortunately, it sounds like they’re still in good financial shape, and will be making new fake electronics in short order.

(Via Boing Boing)

Windows 7

Last Friday, I discovered that I needed a 64-bit version of Windows for development purposes. I had a 64-bit version of Windows XP on a spare machine, but I haven’t set it up since the recent move, and until we get more stuff organized, I frankly don’t have the room. But it occurred to me that I’m running a 64-bit machine now, so at least in theory, I should be able to install a 64-bit version of Windows in a virtual machine under VMware Fusion. So I figure, what the heck, let’s give it a try. And while I’m at it, I might as well finally take a look at Windows 7 too.

MSDN supplied a 64-bit copy of Windows 7 “Ultimate”, and a key for it. When I created a virtual machine for it, VMware Fusion obligingly recognized the downloaded ISO file and installed it for me with no further instruction on my part. After the obligatory round of updates and reboots, I settled down to figure out how to use it.

In any new Windows OS, I have to figure out how to change a few things immediately. The “don’t show hidden files” option has to come off, and especially the “hide extensions on known files types” option — I’m a big boy, I can stand seeing file extensions and files that Microsoft thinks are too dangerous or scary for delicate eyes. I do not want it to automatically reboot if it crashes — I want to see that it has crashed, and any diagnostics that it produces, before I (manually!) reboot it. And turn off those damned animations, I don’t care about them and you’re running in a virtual machine so don’t waste the CPU cycles.

Since Microsoft always moves the settings around between versions, I had to poke around awhile to find them, and I got a good look at the OS as I did so. And I have to say, I’m impressed. The user interface is a lot better than it was before — easier to use, easier to navigate around, and it mostly stays out of your way until you need it. The system is pretty responsive, something that you couldn’t always say about earlier incarnations. It’s using roughly half of the one gigabyte of memory that VMware Fusion allocated to it, leaving half a gigabyte of memory for programs to use without swapping. Even the security stuff didn’t cause me much trouble, I just had to tell it that it was okay to run programs from a network drive without panicking and warning me about them each time.

But it wasn’t until I installed Visual Studio that I really saw the biggest difference. All of my programs compiled 33% to 50% faster! I’d anticipated that the compiler would be a little faster under a 64-bit operating system, despite the fact that it’s only a 32-bit program itself, but that’s a lot more than I’d expected!

All told, it was one of the most painless Windows installs I’ve ever done, and it didn’t take me too long to decide that this was going to be my new development VM. 🙂 I did run into one minor but baffling glitch, which I still haven’t determined the cause of (could be Windows 7, could be Visual Studio 2005, might even be something else entirely), but I found a work-around for it, so everything is working fine now.

I’m still not going to use Windows for anything Internet-related, only for games and software development. Linux is a lot safer on the ‘net at present. But for the foreseeable future, when I use Windows, I’ll definitely be using Windows 7.