Vincent Gable’s Blog

May 27, 2008

Readable Colors

Filed under: Accessibility,Design,Usability | , ,
― Vincent Gable on May 27, 2008


…the most readable color combination is black text on white background; overall, there is a stronger preference for any combination containing black. The two least readable combinations were red on green and fuchsia on blue.

Also, in every color combination surveyed, the darker text on a lighter background was rated more readable than its inverse (e.g. blue text on white background ranked higher then white text on blue background).

I wish Columbia Blue and Red were tested in the survey. They were my high school’s colors; and they were terrible. The worst permutation was blue text on a red background.

Question for all you who prefer light source-code on a dark background: why do you like it?

Bad Design = Bargain?

Filed under: Design,Quotes
― Vincent Gable on May 27, 2008

..the eBay design model. My theory is that eBay was a success due to its crappy design because it gave it that flea market feel and when you went there you felt like you getting a deal. Go to Tiffany & Co. and you don’t get the feeling that you are getting a bargain because you shouldn’t.

Paul Scrivens

May 24, 2008

memcopy, memmove, and Speed over Safety

Filed under: Design,Programming | , ,
― Vincent Gable on May 24, 2008

“We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil.”

–Knuth, Donald. Structured Programming with go to Statements, ACM Journal Computing Surveys, Vol 6, No. 4, Dec. 1974. p.268.

If you’ve programmed in C, you’ve seen memcpy (pronounced “mem-copy”). It’s the preferred way to copy a block of memory somewhere. There is a safer and equally easy to use alternative, memmove. But it has never gained traction, in spite of it’s advantages. As we will see, this is unfortunate, and may be an example of a programming culture that values (superficial) speed over safety.

The Difference

The difference between memcpy and memmove is simple: when the source and destination blocks of memory overlap (for example, if they are the same), memmove works, but memcpy‘s behavior is undefined. It might work. It might crash. It might corrupt data. It might behave differently during debugging.

memmove is safer.

memcpy can be faster, and usually is. There are less restrictions on it’s implementation, so more can be done to optimize it. But not necessarily a lot more — in fact, it could even be slower then memmove, and sometimes this is the case. On some systems, memcpy may just be memmove.

Faster

So how much faster can memcpy be then memmove? They both take O(N) time to copy N bytes of data. So in some computer-science circles, memcpy wouldn’t be considered faster then memmove.

Algorithmically, memmove needs one extra if-statement before it starts to copy; to determine if it needs to copy front-to-back, or back-to-front. (See this reference implementation for an example.) The only other advantage memcpy may have are esoteric processor-specific instructions that assume restricted pointers. So unless there is a “memcpy instruction”, we can expect the difference in speed to be pretty small.

But the real proof is in the pudding and … memmove is faster then memcpy! At least on my laptop, with this test; basically copying 4MB of memory 100 times. See for yourself:

$ gcc -O0 memcpy_memove_lab.c && ./a.out
   Surprise!
   memmove is 1.404409 times faster then memcpy

gcc -O3 memcpy_memove_lab.c && ./a.out
   Surprise!
   memmove is 1.054571 times faster then memcpy

“This must be an unfair test!”, you’re probably thinking. Yes, it is. Or at least it’s a dangerously narrow test. But it is also an honest and simple test. By that I mean, it is the first code I hammered out to just get some numbers for this article. Proper benchmarking is very difficult. I’m not going to attempt it.

The real lesson from this naive benchmark is that you must measure your code before concluding that an optimization is really faster. I would never have guessed that memmove would be up to 40% faster, at copying 4MB. But it was — in this particular instance.

On a related note, a significantly faster memcpy (say 2x) won’t have an appreciable impact on an application’s performance, unless the application spends a surprisingly large portion of it’s time copying memory (Amdahl’s law). For example, let’s say that 1 out of every 20 seconds is spent copying memory with memmove. (That’s a lot of time just moving bits around! Programs should do something with bits, not just move them.) So we replace memmove with memcpy, and this memcpy is a full 2x faster then memmove (which is optimistic). Surprisingly, we only get a 2.5% speedup! Remember that 1 in 20 is only 5% of the program’s total time. Cutting this time in half eliminates 2.5% of the program’s total execution time. If we can find an optimization that speeds up the other 95% of the program by just 2.7%, we get better performance overall.

So memcpy is unlikely to make a large difference to program performance, in general. Switching memcpy implementations is a “local optimization”, that has much less value then changing the algorithm that’s requiring all that duplication. It may even suddenly become slower when hardware is upgraded.

Safer

How much safer is memmove? This is a hard dimension to quantify, and I don’t have a satisfying answer. My instinct tells me that it isn’t dramatically safer. I don’t have any data to support this, but I believe it’s very rare to be copying memory into itself; compared to other memory-management errors, like a double-free().

But the bottom line is that, there are less ways your program can fail if you use memmove over memcpy. Period. Since memcpy‘s behavior is undefined when the source and destination overlap, it can be a vicious bitch to debug.

Speed over Safety

memcpy is preferred by a significant majority of C programmers. I don’t know exactly how many. But a google fight shows that memcpy is almost 6x more talked about then memmove (as of 2008-04-11). Anecdotally, memmove is mostly unheard of in my experience. It seems like the call of “faster” really is a siren’s-song for developers; luring them into dangerous code.

I think this is very unfortunate. Especially, because the performance advantage of memcpy just isn’t that big in general! (Sometimes it’s even harmful). Given the unreliability of software, anything that elements bugs is a Very Good Thing.

I wish I knew the full story of memcpy winning the popularity contest with memmove. By accident or design, it has left us with a programming culture that values superficial speed over safety.

For Further Reading:

Optimizing memcpy — includes some graphs showing the tradeoffs between optimizing for large chunks of memory (say copying pictures), and small data structures.

Why aren’t my optimizations optimizing? — “Optimizing code is a tricky business.”

memcpy_memove_lab.c — The naive benchmark from this article, plus a reference implementation of memcpy and memmove.

May 22, 2008

Design is Not Just Skin Deep

Filed under: Design,Quotes
― Vincent Gable on May 22, 2008

Most people make the mistake of thinking design is what it looks like. People think it’s this veneer — that the designers are handed this box and told, ‘Make it look good!’ That’s not what we think design is. It’s not just what it looks like and feels like. Design is how it works.

   –Steve Jobs, CEO, chairman and co-founder of Apple Inc. in a 2003 New York Times magazine interview.

May 18, 2008

Intuitive Considered Harmful

Filed under: Accessibility,Design,Programming,Quotes,Research,Usability | ,
― Vincent Gable on May 18, 2008

intuition
noun
the ability to understand something immediately, without the need for conscious reasoning.

“Intuitive” sounds like a great property for an interface to have, but in The Humane Interface (pages 150-152), Jeff Raskin calls it a harmful distraction:

Many interface requirements specify that the resulting product be intuitive, or natural. However, there is no human faculty of intuition…When an expert uses what we commonly call his intuition to make a judgment … we find that he has based his judgment on his experience and knowledge. Often, experts have learned to use methods and techniques that non-experts do not know… Expertise, unlike intuition, is real.

When users say that in interface is intuitive, they mean that it operates just like some other software or method with which they are familiar.

Another word that I try to avoid in discussing interfaces is ‘natural’. Like ‘intuitive’, it is usually not defined. An interface feature is natural, in common parlance, if it operates in such a way that a human needs no instruction. This typically means that there is some common human activity that is similar to the way the feature works. However, it is difficult to pin down what is meant by ‘similar’. … the term ‘natural’ (can also equate) to ‘very easily learned’. Although it may be impossible to quantify naturalness, it is not to difficult to quantify learning time.

The belief that interfaces can be intuitive and natural is often detrimental to improved interface design. As a consultant, I am frequently asked to design a “better” interface to a product. Usually, an interface can be designed such that, in terms of learning time, eventual speed of operation (productivity), decreased error rates, and ease of implementation, it is superior to both the client’s existing products and competing products. Nonetheless, even when my proposals are seen as significant improvements, they are often rejected on the grounds that they are not intuitive. It is a classic Catch-22: The client wants something that is sigificantly superior to the competition. But if it is to be superior, it must be different. (Typically, the greater the improvement, the greater the difference.) Therefore, it cannot be intuitive, that is, familiar. What the client wants is an interface with at most marginal differences from current practice — which almost inevitably is Microsoft Windows — that, somehow, makes a major improvement.

There are situations where familiarity is the most important concern, but they are rare. One example is a kiosk at a tourist attraction. Millions of people will use it only once, and they must be able to use it as soon as they touch it (because they will walk away rather then spend their vacation reading a manual). And in such cases, mimicking the most promiscuously used interface you can find, warts and all, makes sense — if that means more people will already know how to use it.

Outside of rare exceptions, software that people use enough to justify buying is used repeatedly. The value of the product is what people make with it, not what they can do with it the moment they open the box. Designing for the illusion of “intuitiveness” is clearly the wrong choice when it harms the long-term usefulness of the product.

This is not an excuse for a crappy first-run experience! The first impression is still the most important impression. By definition, the less familiar something is, the more exceptional it is. And an exceptionally good first impression is what you are after — so unfamiliarity can work to your advantage here. It is more work to design an exceptional first-run experience, but good design is always more work.

This is not a rational for being different just to be different. It is a rational for being different, when different is measurably better. For something to be measurably better, it first needs to be measurable. That means using precise terms, like “familiar” instead of “intuitive”, and “quick to learn” not “natural”.

May 12, 2008

Trademarking Shape

Filed under: Design,Quotes
― Vincent Gable on May 12, 2008

The Wall Street Journal on Apple trademarking the shape of the iPod (emphasis mine):

These nontraditional marks are difficult to obtain. But unlike more commonly used utility and design patents, which exist to cover functions and the ornamental look and feel of products and expire after a set number of years, trademarks can remain in force potentially forever.

…While competitors may eventually appropriate the iPod’s inner workings, as utility patents expire, they will risk litigation if their products come too close to the trademarked shape of the iPod, including its popular circular-touchpad interface.

Moreover, trademark law allows the holder to sue not only manufacturers but also distributors of competing products whose attributes so resemble those of the protected mark that they create the likelihood of confusion in the marketplace.

…The key to obtaining nontraditional trademarks is to convince an examiner in the U.S. Patent and Trademark Office that the average consumer associates the design attribute in question exclusively with the company seeking the trademark; in Apple’s case, this meant proving that the average shopper for a media player identifies the shape of an iPod with Apple.

That sounds like a pretty big sue-stick.

Intellectual-property laws haven’t interested me much. Partly because the zelots and freetards are such a turn off. But mostly because it turns out that patent law hasn’t actually been a barrier to me writing code (*gasp*). I just don’t see evidence that what we have today is an irredeemably broken system (although there are compelling historical anecdotes worth reading that says differently). Maybe that’s just my ignorance talking, but at least it’s been bliss so far.

It’s a little sad to read that the “design” in “design patents” apparently means “the ornamental look and feel of products” to most business folks.

Most people make the mistake of thinking design is what it looks like. People think it’s this veneer — that the designers are handed this box and told, ‘Make it look good!’ That’s not what we think design is. It’s not just what it looks like and feels like. Design is how it works.

–Steve Jobs, CEO, chairman and co-founder of Apple Inc. in a 2003 New York Times magazine interview.

May 10, 2008

Richard Stallman Does Bizarre Things

Filed under: Design,Quotes,Usability
― Vincent Gable on May 10, 2008

For personal reasons, I do not browse the web from my computer. (I also have not[sic] net connection much of the time.) To look at page[sic] I send mail to a demon which runs wget and mails the page back to me. It is very efficient use of my time[sic], but it is slow in real time.

Richard Stallman, 15 Dec 2007

How in touch with regular people do you think that guy is? How well do you think a system he designed would server their needs? How well do you think it would serve your needs? (I mean I think it’s pretty fair to say you use the internet a bit more … shall we say … functionally.)

Apparently GNU/Linux can’t even meet a hardcore nerd’s needs.

May 9, 2008

The Back Button is Now #3

Filed under: Accessibility,Design,Quotes,Research,Usability
― Vincent Gable on May 9, 2008

Among other things, (this study) found that the Back button is now only the 3rd most-used feature on the Web. Clicking hypertext links remains the most-used feature, but clicking buttons (on the page) has now overtaken Back to become the second-most used feature. The reason for this change is the increased prevalence of applications and feature-rich Web pages that require users to click page buttons to access their functionality.

Jakob Nielsen’s Alertbox, May 6, 2008:

April 28, 2008

WARNING!

Filed under: Design |
― Vincent Gable on April 28, 2008

A collection of warning signs. Some are quite funny; my favorite so far.

There’s also a book (unrelated to the flickr group), but disappointingly it does not give bibliographical information on where the signs came from.

Here’s a blog of safety graphics.

Hardware is a Commodity. Software is not.

Filed under: Design,Programming,Tips
― Vincent Gable on April 28, 2008

…it’s easy for software to commoditize hardware (you just write a little hardware abstraction layer, like Windows NT’s HAL, which is a tiny piece of code), but it’s incredibly hard for hardware to commoditize software. Software is not interchangeable, as the StarOffice marketing team is learning. Even when the price is zero, the cost of switching from Microsoft Office is non-zero. Until the switching cost becomes zero, desktop office software is not truly a commodity. And even the smallest differences can make two software packages a pain to switch between. Despite the fact that Mozilla has all the features I want and I’d love to use it if only to avoid the whack-a-mole pop-up-ad game, I’m too used to hitting Alt+D to go to the address bar. So sue me. One tiny difference and you lose your commodity status. But I’ve pulled hard drives out of IBM computers and slammed them into Dell computers and, boom, the system comes up perfectly and runs as if it were still in the old computer.

Joel on Software

« Newer PostsOlder Posts »

Powered by WordPress