charlie's blog

Saturday, July 17, 2010

Process Priority utility

As discussed on StackOverflow and ServerFault, here is a utility that can query and set the CPU, memory, and IO priority of a Win32 process (runs on XP and higher).


To see the command line usage information, run the program without any arguments.

Enjoy!

Sunday, February 28, 2010

Coders at Work

I just finished reading Coders at Work, by Peter Seibel, and it was awesome. The book is a collection of interviews with some of the most respected and well-known programmers of our time. These are Turing Award winners, inventors of languages and operating systems that have touched millions of people, and authors of the most widely known and respected computer science literature you can find.

I kept a list of notes as I read through the book, things that resonated with my own years of experience in the field. There isn't any particular theme here, but I wanted to capture these ideas before they got away from me.

Working programs are a given

Bernie Cosell, who helped develop Arpanet (predecessor of the Internet), made a great point about the responsibilities of a professional programmer:
You don't get credit because the program works. We're going to the next level. Working programs are a given.
What he's saying is that when you work as a programmer, you job isn't done just because the program works. You need to generate something of high quality that you and your coworkers will understand six months from now, and which can evolve as the customer's requirements change. Professional musicians don't just play the notes, race car drivers don't just drive around the course, and serious programmers shouldn't be content with an ugly program just because it works.

Magic is dangerous

Guy Steele had a great way to sum up why programming is hard:
[Being] able to get a machine to do what you want is the closest thing we've got in technology to adolescent wish-fulfillment. And if you look at the fairy tales, people want to be able to just think in their minds about what they want, wave their hands, and it happens. And of course the fairy tales are full of cautionary tales where you forgot to cover the edge case and then something bad happens.
For example, take the story of King Midas, who wished that everything he touched would turn to gold; when granted in its most literal sense, this wish became a terrible curse.

Unfortunately for programmers, computers are the epitome of the fickle genie, interpreting us at our most literal and wreaking havoc when we don't clearly specify what we want. Therefore, as programmers our job is to provide such excruciatingly detailed instructions that the computer can't possibly misinterpret us and do the wrong thing. This can be one of the most frustrating things to communicate to non-programmers; it's not magic, and translating a simple idea into code is far from mechanical.

Microsoft's tools are awesome

Say what you want about Microsoft, but their developer tools are world-class. Most of the interviewees in this book come from the non-Microsoft parts of the programming world, and often bemoaned the lack of good quality debugging tools. In fact, it sounds like many of them do their debugging with little more than print statements. This is one of the oldest and most basic forms of debugging, and it has its place, but to paraphrase one of my favorite Despair posters, just because you've always done it that way doesn't mean there isn't a better way. A good interactive debugger is worth its weight in gold for a lot of problems, and I'm glad to be working with one of the best there is: Microsoft's Visual Studio.

Names matter. A lot.

Programs are nominally a set of instructions for the computer to follow, but they also have to be understood by humans who come along later and want to understand or change things. A program whose code can't be understood is in fact nearly useless, like a book written in a forgotten language.

One of the most crucial elements of legibility is using good names for things. If you write a procedure that flushes program data to the hard drive, and you call it FlushDataToDisk, a reader can immediately understand the basic purpose of the function, and might be able to skip reading all of the gory details of how it works. On the other hand, if you call it WriteStuff, the name tells the reader nearly nothing, and forces her to read the whole thing to discern its purpose. The problem is that when you're writing the code it's easy to just use the first name that comes to mind, without considering the impact that choice may have a few months or years later.

I've only recently started to take this issue so seriously, but given how many programmers in this book seem to feel the same way, I think I'm on the right track. I now regularly consult a dictionary and thesaurus as I write, and you should too.

Labels:

Monday, December 7, 2009

a fool's errand

I've decided to write a compiler, something I've wanted to do for a long time. Compilers are the tools that take the gibberish programmers write and turn it into programs you can use for writing email, twittering, and doing your taxes (you may or may not actually do any of these, but you've at least heard of them). This compiler will be for Google's new language Go.

Anyway, hopefully it won't really be a fool's errand, but right now it feels like one. Compilers for real programming languages are pretty complicated affairs, easily many thousands of lines of code. The specification for the language runs to 55 printed pages, which is actually pretty short for an entire programming language, but it's still pretty daunting. I'm not going to get paid for this, so I'll be doing it in my free time; half an hour here, an hour there. At that rate I have no idea how long it will take, but if I had a working prototype within six months I'd be thrilled. Really I guess it doesn't matter how long it takes, though, since I'm doing it for fun.

So that's the plan - write a compiler and try to have it working before the language gets retired. We'll see how it goes...

Labels:

Wednesday, October 21, 2009

new words

This post is long overdue, but things have been busy. Here's a new batch of words, which as usual are either ones I've never seen before or ones I had to 'fess up to not knowing. The words came from various places, including Antarctica, Avenue Q (highly recommended), Anvil of Stars, The Prefect, and The Steel Remains.

quiddity - the essence or inherent nature of something (or, a trifling or academic distinction)
schadenfreude - pleasure derived from the misfortune of others
indolent - habitually lazy or slothful (I somewhat knew this one already)
eleemosynary - relating to alms, charity, or charitable donations
nacreous - iridescent, resembling mother-of-pearl
quincunx - an arrangement of five objects, with four of the objects forming a square around the fifth object
onomastics - the study of proper names
orrery - a clockwork model of the solar system
pangolin - a type of scaly anteater
rubicon (as in "cross the rubicon") - to undertake an action that cannot be reversed
snarge - the remains of a bird after it has collided with an airplane (wow, there's really a word for this?)
otiose - serving no useful purpose or having no effect
acrostic - a verse in which certain letters (e.g. the first letter of each line) form another word or phrase
sesquipedalian - a very long word, or a person prone to using such words
garrulous - wordy or talkative, possibly to an extreme
horology - the art of designing and making clocks
lagniappe - an extra or unexpected gift or benefit ("luh-nyapp")
oneiric - relating to or suggestive of dreams
tergiversation - to verbally evade or equivocate, or to change sides
pellucid - transparent or clear
gestalt - a configuration or pattern of elements that as a whole exceeds the sum of its parts
quotidian - something which is common or occurs daily
insipid - bland, boring, lacking in flavor
integument - something that covers or encloses
sinecure - a position that requires no work but still gives payment

My favorites from this list are "sesquipedalian" (which literally translates as "a foot and a half"), "lagniappe", and "snarge", mostly because I like how they sound.

"Rubicon" and "insipid" both caught me by surprise. I thought I had a vague idea what "rubicon" meant, but my vague idea was totally wrong. As for "insipid", I was quite sure that it was meant to describe a person or food that was really horrible, but no. Mom gets credit for setting me straight on this one.

Labels:

Sunday, July 19, 2009

when a person wants to be neutral, what words should she use?

A while ago, I picked up an introductory book on statistics, so that I could better understand some of the jargon being used by the engineers I work with and the biologist I'm married to. I wanted to know what chi-squared analyses are (I now know) and what ANOVAs are good for (I've already forgotten). However, one of the most interesting finds in the book had nothing to do with math or science, but instead had to do with culture and language.

What I noticed was that the book used "he" and "him" as gender-neutral pronouns, e.g. "When a scientist chooses a statistical method, he must consider...". This was quite surprising to me the first few times I ran across it, and the surprise itself was meta-surprising, since the use of male pronouns as gender-neutral is far from new. In fact, it has been the norm for a long time (you can consult Wikipedia or your favorite historian/linguist/etc. for details).

The reason this caught me off guard is that most of the nonfiction books I read, specifically computer books, use female pronouns as gender-neutral. I've never had a chance to ask anyone in the computer-book publishing industry about this, but it seems quite consistent; I will boldly claim (without gathering any proper data) that well over half of the computer books I've read follow this pattern. I've read so many books like this that it actually stops me in my tracks when I find a more "traditional" one, such as that statistics book I mentioned.

Anyway, I don't have that much to say about this, but I thought it was noteworthy. If nothing else, I'm hoping that it counts as evidence that we're making some progress on unseating "he", "him", "mankind", and their brethren from the role of "neutral".

This post is dedicated to my mom, who taught me to pay attention to things like this. Thanks, mom!

Labels: ,