rant

Code Reuse Is Not Lazy

Stack Overflow is an amazing resource for computer programmers. I've asked a lot of questions there, and answered a lot of questions there, and I've found the answers to lots and lots of questions that someone else has already asked. Participating in Stack Overflow has been great.

However, there have been a few cases where I've asked a question in this form:

I need some code that will [...]. Can someone point me to some existing code that does this?

And then I have received responses and comments like these:

We aren't here to do your homework for you.

You can't expect help without doing a little bit of work on your own.

You mean "Plez sir send me the codez?"

I don't understand why my questions provoke these responses. It is possible that I am asking the question in a way that the readers interpret as demanding or rude. But I also wonder if some people think that looking for existing code to solve a problem is a dishonorable thing to do, and Real Programmers write everything they need from scratch.

What if I had asked this:

I am new to C. I need to format some printed output in my C program. What's the easiest way to do this?

I hope someone would respond with

There is a standard function called "printf()" that will do what you want.

and not

Why can't you just figure out how to write your own formatting function It's the best way to learn C. Or are you just too lazy to spend time learning things?

Appropriate reuse of already written and debugged code is the mark of a professional, and time spent in research of existing implementations of algorithms you need is time well invested. If you want to write the millionth from-scratch implementation of Quicksort in your favorite programming language, go right ahead, but those of us who have real work to do are going to look for a library or a code snippet.

Do We Still Need Programmers?

When reading descriptions of how software is produced, I often wonder what role programmers play. Programmers used to be the people who made software, but now a lot of other people are involved and claim credit for doing the work.

There has to be an "architect" who guides the overall structure of the system. Often architects are former programmers, but they are far too important to write any code anymore.

Then there is the "user experience" designer, who decides how the software should interact with its users. We used to call this "user interface design", but the UX people have redefined UI design to be the monkeywork of laying out controls and fields on forms. Programmers can't be trusted with any important design decisions.

There is the database administrator (DBA), who ensures that the programmers can't screw up the database schema.

There are testers who tell the programmers whether they have done their jobs well enough.

With all these other people making the important decisions, what does a programmer do? Apparently programmers are glorified typists who transcribe specifications written by architects and UX designers into code that is verified by testers.

Of course, that's not how things are.

While there are teams and organizations that operate as described above, a lot of software is created by solitary programmers. The boss says "We need feature X," and a programmer then designs the user experience, updates the database schema, implements the new functionality, tests it, creates some new icons in Photoshop, adds a couple of pages to the user manual, and deploys the new software to the customer.

Somehow a programmer is able to do this without help from all those people who are too important to write code.

Those other people aren't useless. Software is certainly better when a good architect and good DBA maintain its structure, and when a talented UX designer makes it easy to use, and when good testers find the problems. But software is still made by programmers. Those other people don't make software—they make wishes.

UTF-8

Matt Gallagher's "User interface strings in Cocoa" post is good for its overall purpose (telling people how to use NSLocalizedString()), but I especially like this little embedded rant:

A quick swipe at almost everybody: UTF-8 has been around since 1993 and Unicode 2.0 since 1996; if you have created any 8-bit character content since 1996 in anything other than UTF-8, then I hate you.

I weep to think of the years of programmer time that are still wasted attempting to support non-Unicode formats without characters getting garbled because people are still creating content using ancient encodings without useful identifiers to indicate what nonsense encoding they're using (or worse, people creating content that explicitly uses the wrong encoding for an encoding-specific text field).

MacRoman? Atrocious. Big-5? I hope you want to see garbage output. Windows Latin? You suck. If you're creating new content using anything other than UTF-8, UTF-16 or UTF-32 then you should be forced to serve prison time with whatever idiot monkey decided that UTF-16 should be allowed little-endian and big-endian variants instead of a single authoritative encoding.

Yeah, seriously. If you call yourself a programmer, but you don't understand what all this Unicode, UTF-8, and UTF-16 business is about, please read Joel Spolsky's The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!).

The Apple Store Needs a Checkout Counter

The Apple Store is a great place to go if you want to play with new Apple products or get help at the Genius Bar. But if you go there to buy something, the experience is confusing and humiliating.

Everyone knows how the process of buying something at a store is supposed to work:

  1. You pick up the product(s) you want to buy.
  2. You go to the end of the line at the checkout counter.
  3. When it's your turn, you step up to the counter, transact your business, and go on your way.

In contrast, here is how things work at the Apple Store:

  1. You pick up the product(s) you want to buy.
  2. You stand there like a child who has lost his mommy, looking around for a friendly Apple associate who can help you.
  3. As the Apple associates are always busy helping other customers, you pick one and stand nearby, hoping to catch their attention when they are finished with the current customer.
  4. Eventually, after helping the current customer, and maybe a few others who are also standing nearby, the associate asks how they can help you. You say you want to buy the things you have been holding. The associate says, "OK, I'll find someone to help you", and goes to look for one of the associates who has one of the magic credit-card-reading devices. You stand there looking lost again for a while.
  5. Eventually, a person with a magic device arrives to let you make your purchase. You fumble around, juggling products between your armpits, your crotch, and under your chin while you present each item for scanning. Then you drop all the items while you dig out your wallet and credit card.
  6. While you pick up the items you have dropped, the person swipes your card, then hands the little device back to you so you can check some boxes and sign your name. Again, your items have to go into your armpits and onto the floor.
  7. While you pick up your items again, the person goes to one corner of the store to get your printed receipt, then to the opposite corner of the store to get you a bag, then back to you. You help the associate put your items into the bag, and then you go on your way.

Wouldn't this all be easier if there was a checkout counter?

Sometimes the old ways are best.

Why I Loved The Social Network

I'm writing this the night before the Oscars, but that is not why I'm writing. I only saw three of the films nominated for Best Picture: The King's Speech, True Grit, and The Social Network. While I enjoyed The King's Speech and True Grit,, I haven't thought about them since I saw them. In contrast, I still think about The Social Network every day.

For some, The Social Network is just a story about how an arrogant jerk became a billionaire by screwing over his friends and business associates. I didn't see it that way. To me, it is a story about the nature of creativity and invention.

The iTunes UI Sucks

I like most of Apple's products, but iTunes is a very dark corner of the Mac universe.

For example, here is what you have to do to download updates to your iPhone apps:

  1. Click the Applications link in the upper-left corner of the navigation pane.
  2. Move the mouse over to the lower-right corner and click the tiny, tiny Check for updates button.
  3. Move the mouse to the upper-right corner and click the Download All Free Updates button.

Three steps, requiring moving the mouse pointer all the way across the screen between each. There is no automatic-update feature.

There is probably some way to write an AppleScript to automate this, but AppleScript sucks too.

Do a web search for "iTunes sucks", and you'll find a lot more examples.

To paraphrase Bjarne Stroustrup: There is software everyone complains about, and software nobody uses. One could chalk up the iTunes hate to the simple fact that so many people are forced to use it whether they like it or not. But iTunes really does suck. I wish Apple would do a complete re-design of its UI, and make it act like an Apple product.

Know Your Programming Languages

I am often amazed at how little some of my colleagues know or care about their craft. Something that constantly frustrates me is that people don't want to learn any more than they need to about the programming languages they use every day. Many programmers seem content to learn some pidgin sub-dialect, and stick with that. If they see a keyword or construct that they aren't familiar with, they'll complain that the code is "tricky."

What would you think of a civil engineer who shied away from calculus because it had "all those weird math symbols?"

I'm not suggesting that we all need to become "language lawyers." But if you make your living as a programmer, and claim to be a competent user of language X, then I think at a minimum you should know the following:

  • What are all the keywords of the language?
  • What are all the valid syntactic forms?
  • How are memory, files, and other operating system resources managed?
  • Where is the official language specification and library reference for the language?

The last one is the one that really gets me. Many programmers seem to have no idea that there is a "specification" or "standard" for any particular language. I still talk to people who think that Microsoft invented C++, and that if a program doesn't compile under VC6, it's not a valid C++ program.

Programmers these days have it easy when it comes to obtaining specs. Newer languages like C#, Java, Python, Ruby, etc. all have their documentation available for free from the vendors' web sites. Older languages and platforms often have standards controlled by standards bodies that demand payment for specs, but even that shouldn't be a deterrent: the C++ standard is available from ISO for $30 (and why am I the only person I know who has a copy?).

Programming is hard enough even when you do know the language. If you don't, I don't see how you have a chance.

Booleans Shouldn't Be Complicated

Warning: Geeky programmer content below.

While learning a new codebase, I was a little disturbed when I saw this:

  enum IsVerifying {
    IsVerifyingFalse,
    IsVerifyingTrue
  };

  enum IsVerified {
    IsVerifiedFalse,
    IsVerifiedTrue
  };

  enum IsEnabled {
    IsEnabledFalse,
    IsEnabledTrue
  };

  enum IsActive {
    IsActiveFalse,
    IsActiveTrue
  };

  enum IsOnline {
    IsOnlineFalse,
    IsOnlineTrue
  };

  /* etc. (There are about a dozen more of these.) */

And there was a lot of verbose code for dealing with these types, such as

  if (Verified()) {
    verified = IsVerifiedTrue;
  }
  else {
    verified = IsVerifiedFalse;
  }

  if (Enabled()) {
    enabled = IsEnabledTrue;
  }
  else {
    enabled = IsEnabledFalse;
  }

  /* etc. */

What's wrong with using plain-old-Boolean values false and true, or 0 and 1?

Well, after poking around the code more, I did find the reason that the original programmer did this. He has a lot of functions that take several flags as parameters, and something like this:

  SetStates(IsVerifyingFalse,
            IsVerifiedTrue,
            IsEnabledTrue,
            IsActiveFalse,
            IsOnlineFalse);

is easier to understand than something like this:

  SetStates(false, true, true, false, false);

But still, yyeeaagghh is the proper reaction to seeing something like this.

Science, Evolution, and Creationism

The National Academy of Sciences has issued a report that documents the methods of science and the overwhelming evidence in support of the theory of evolution. It also presents the arguments against the teaching of creationism and Intelligent Design in public-school science classes. However, it also clearly outlines the reasons that a belief in evolution is not incompatible with a belief in God or with other religious beliefs.

It is available for download (PDF) from http://www.nap.edu/catalog.php?record_id=11876.

I personally find it repugnant that some religious fundamentalists are trying to erode this country's science-education programs. They have convinced a large number of people that there is a large body of scientific evidence against evolution and that there is a debate in the scientific community about its validity. They use fallacious arguments to present Intelligent Design as a logical "scientifically based" alternative. They say that "good Christians" need to support inclusion of these teachings in our kids' science classes. They want us to embrace ignorance.

Those people are dishonest and evil. The information in this book can help us fight them.

Slower Traffic Keep Right

Having driven a few thousand miles over the holidays, I decided I'd like to present the following message to all the drivers of America:

If you are driving in the left lane on an interstate or other multi-lane highway, please check the following:

  • Are there cars right behind you, but no cars in front of you?
  • Are you driving well below the posted speed limit?
  • Are people passing you on your right side?
  • Have you been driving dead even with the car to your right?
  • Are you talking on the phone, eating, fixing your kids' hair, or engaging in any other activity that may distract you?
  • Is there no possibility that you will pass anyone, ever?

If you answer Yes to any of the above questions, then please get out of the left lane. You don't belong there.

And please, don't speed up when someone tries to pass you. Highway driving is not a NASCAR-sanctioned event, and you won't lose any Winston Cup points if you let somebody get in front of you.

Syndicate content