__MODULE_DEBUG_TOOLS__

03/02/2009

Yesterday, at least at the time I am writing this entry, I spoke about the Zune and its time bug that caused so many of the devices to just freeze on boot. It its clear that this bug is the result of poor testing (in addition to a poor implementation of a conversion using loops rather than explicit divisions and moduli) and this week, I’d like to tell you about one of my tricks to debug code.

Read the rest of this entry »


More Bit-twiddling

27/01/2009

This week, two “quickies”: rounding up and down to the next power of two, and converting efficiently a value to exactly 0 or 1.

Read the rest of this entry »


Suggested Reading: Zen Cat

24/01/2009

Judith Adler, Paul Coughlin —Zen Cat— Rodale, 2003, 112 pp. ISBN 0-8759-6923-2

(Buy at Amazon.com)

(Buy at Amazon.com)

I love all solitary places, where we taste the pleasure of believing what we see is boundless, as we wish our souls to be.

— Percy Bysshe Shelly

The longer I live, the more beautiful life becomes

— Frank Lloyd Wright

This short book cointains about sixty short proverbs, quotations, sayings and poems, each accompagnied by an à propos picture of a cat. As many poetry books, to be read in a meditative mood.


Suggested Reading: Google’s PageRank and Beyond: The Science of Search Engine Rankings

24/01/2009

Amy N. Langville, Carl D. Meyer —Google’s PageRank and Beyond: The Science of Search Engine Rankings— Princeton University Press, 2006, 224 pp. ISBN 0-691-12202-4.

Page Rank And Beyond

(Buy at Amazon.com)

Langville and Meyer presents us the mathematics behind Page Rank, Google’s method of rank prioritization as well as other similar methods. If the first few chapters are concerned with the history of search engines and search methods, the remainder of the text is clearly mathematical in nature.

Read the rest of this entry »


Throwing in More Hardware?

20/01/2009

In a recent blog entry, Jeff Atwood makes the case that “hardware is Cheap, Programmers are Expensive”, basically arguing that in a lot of cases, it’s cost-efficient to add cheap, faster, hardware to a performance problem rather than investing time to actually enhance the code at the algorithmic and implementation level.

I do, however, disagree with him on many points.

Read the rest of this entry »


Honni soit le Hongrois

13/01/2009

The original Hungarian notation is due to Charles Simonyi who invented it sometimes while he was working at Xerox Palo Alto Research Center—the Xerox PARC that gave us the mouse and the first graphical user interfaces. The basic principle of Hungarian naming convention is to prefix the variables with one or many particles, encoding alternatively its type or its intend. This lets programmer write prgszNames as a variable name, which is perfectly legible to one well versed in Hungarian; however, but looks mostly like gibberish to just anyone else.

I recently changed my mind about the Hungarian naming convention. I don’t think it’s that stupid anymore.

Read the rest of this entry »


The Zunes Freezes: Update!

05/01/2009

The faulty code was leaked some time last week, and I’ve looked at it, and, well, it’s surprisingly clean (despite the obvious defect and how they should’ve found it before releasing it (see here)).

Have a look at the ConvertDays routine.

Read the rest of this entry »


Cleaning LCD screens

05/01/2009

I’m sure that, like me, you’ve tried all kinds of chemical cleaners to clean LCDs. But, like me, also, you’ve noticed most of them leave smudges that you can’t get rid of. Window Cleaners are also rather bad at this, and they may be too rough for the coating of your LCD screens.

However, I think I finaly found what it takes: 50% isopropyl alcohol. That’s right, common rubbing alcohol you can get for 3$ at your local drugstore. Even better, they sell it with a spray cap, for your convenience. Just spray alcohol on a clean, soft, non-linting rag (like a paper towel) and clean your screen gently. Do not spray at the screen directly, because it may cause some of it to leak into the electronics and cause much mayhem. It may take a few application to remove all of the previous chemical cleaner’s residues… but I haven’t seen my screens that clean in a long time.


The Zune Freezes: A Stupid, Avoidable Bug.

31/12/2008

The few Zune users where alienated today when they discovered that their Zunes just froze during boot. Apparently, a mysterious bug.

The cause of the bug was rapidly diagnosticated. According to Itsnotabigtruck on Zuneboards, the bug can be traced back to a defective date conversion routine. I reproduce here the code for you:

year = ORIGINYEAR; /* = 1980 */

while (days > 365)
 {
  if (IsLeapYear(year))
   {
    if (days > 366)
        {
         days -= 366;
         year += 1;
       }
   }
  else
   {
    days -= 365;
    year += 1;
   }
 }

Can you see what’s just wrong about that code?

Read the rest of this entry »


The True Cost of Calls

30/12/2008

The cost of virtual functions is often invoked as a reason to C++’s poor performance compared to other languages, especially C. This is an enduring myth that, like most myths, have always bugged me. C++ myths are propagated by individuals that did not know C++ very well, tried it one weekend in 1996, used a bad compiler, knew nothing about optimization switches, and peremptorily declared C++ as fundamentally broken. Well, I must agree that C++ compilers in the mid-90s weren’t all that hot, but in the last fifteen years, a lot have been done. Compilers are now rather good at generating efficient C++ code.

However, the cost of calls, whether or not they are virtual, is not dominated by the the call itself (getting the address to jump to and jumping) but by everything else surrounding the call, like the stack setup and argument passing. Let us debunk that myth by looking at what types of calls are available in C and C++, how they translate to machine code, and see how faster or slower they are relative to each other.

Read the rest of this entry »