The Old New Thing

Practical development throughout the evolution of Windows.

Latest posts

Do you have a Starbucks name?
Aug 17, 2007
Post comments count 0
Post likes count 0

Do you have a Starbucks name?

Raymond Chen
Raymond Chen

Annabelle Gurwitch has found what may be one of the few remaining places where you can be anybody you want: Starbucks. Check out the part towards the end where people on the street are asked to share their Starbucks names. I'm reminded of a time many years ago when Schultzy's Sausage had expanded to a second location in Redmond. (They closed the location after maybe a year, not because business was bad but because it was just too much work for the owner.¹) A group of us stopped in for dinner, and as each of us placed our order, the man behind the counter asked for our names so he could call us when the or...

What are these spurious nop instructions doing in my C# code?
Aug 17, 2007
Post comments count 0
Post likes count 0

What are these spurious nop instructions doing in my C# code?

Raymond Chen
Raymond Chen

Prerequisites: Basic understanding of assembly language. When you debug through some managed code at the assembly level, you may find that there are an awful lot of instructions scattered throughout your method. What are they doing there; isn't the JIT smart enough to remove them? Isn't this going to slow down execution of my program? It is my understanding that¹ this instructions are inserted by the JIT because you're running the program under the debugger. They are emitted specifically so that the debugger can set breakpoints in locations that you normally wouldn't be able to. (For example, they might ...

The Radioactive Boy Scout is back in the news
Aug 16, 2007
Post comments count 0
Post likes count 0

The Radioactive Boy Scout is back in the news

Raymond Chen
Raymond Chen

The Radioactive Boy Scout appears to be back to his old tricks.¹ Nitpicker's Corner ¹Although this statement is written as if it were a fact, it is actually my interpretation of a newspaper article and is not an official position of Microsoft Corporation.

What are these strange cmp [ecx], ecx instructions doing in my C# code?
Aug 16, 2007
Post comments count 0
Post likes count 0

What are these strange cmp [ecx], ecx instructions doing in my C# code?

Raymond Chen
Raymond Chen

When you debug through some managed code at the assembly level, you'll find a whole lot of seemingly pointless instructions that perform a comparison but ignore the result. What's the point of comparing two values if you don't care what the result is? In C++, invoking an instance method on a pointer results in undefined behavior. In other words, if you do it, the compiler is allowed to do anything it wants. And what most compilers do is, um, nothing. They don't take any special steps if the pointer is ; they just generate code on the assumption that it isn't. In practice, this often means that everything seems...

For $15, you can purchase incorrect information, and to prevent people from getting it, you have to renew every three months
Aug 15, 2007
Post comments count 0
Post likes count 0

For $15, you can purchase incorrect information, and to prevent people from getting it, you have to renew every three months

Raymond Chen
Raymond Chen

Given what I know about Naveen Jain, I basically view everything he does with enormous skepticism.¹ I mean, I trust lawyers more than I trust that guy, that's how bad it is. After being booted from InfoSpace, Jain moved across the street and founded Intelius, a company that does basically the same thing: Selling directory information.² Recently, the company launched a cell phone look-up service: For $15 you can obtain the cell phone number of anybody in their directory. Mind you, the information is cobbled together from various private sources, and it can even be wrong, but if the result is incorrec...

C# static constructors are called on demand, not at startup
Aug 15, 2007
Post comments count 0
Post likes count 0

C# static constructors are called on demand, not at startup

Raymond Chen
Raymond Chen

One of the differences between C++ and C# is when static constructors run. In C++, static constructors are the first thing run in a module, even before the function runs.¹ In C#, however, static constructors don't run until you use the class for the first time. If your static constructor has side effects, you may find yourself experiencing those side effects in strange ways. Consider the following program. It's rather contrived and artificial, but it's based on an actual program that encountered the same problem. This program tries to set an invalid event, so the call to is expected to fail with an ...

SIFF 2007 wrap-up: Grandhotel, The Boss of It All, Vacation
Aug 14, 2007
Post comments count 0
Post likes count 0

SIFF 2007 wrap-up: Grandhotel, The Boss of It All, Vacation

Raymond Chen
Raymond Chen

Sorry, SIFF fans, but this article got stuck in the queue. But now it's unstuck. Grandhotel : A sweet story about a shy, innocent, weather-obsessed hotel employee and the even stranger people who surround him. I wasn't quite sure what to expect, but I was quite pleased with what I got. Part comedy, part drama, the movie creates touching moments while remaining true to the quirky nature of its characters. I give it a 3 out of 5. The Boss of It All: A company's founder blames all unpopular decisions on his imaginary boss, but when he enters negotiations to sell the company, he must produce this elusive boss an...

What is the order of evaluation in C#?
Aug 14, 2007
Post comments count 0
Post likes count 0

What is the order of evaluation in C#?

Raymond Chen
Raymond Chen

The C and C++ languages leave the order of evaluation generally unspecified aside from specific locations called sequence points. Side effects of operations performed prior to the sequence point are guaranteed visible to operations performed after it.¹ For example, the C comma operator introduces a sequence point. When you write f(), g(), the language guarantees that any changes to program state made by the function can be seen by the function ; executes before . On the other hand, the multiplication operator does not introduce a sequence point. If you write there is no guarantee which side will be evalu...

Math is hard, let's go shopp—oops
Aug 13, 2007
Post comments count 0
Post likes count 0

Math is hard, let's go shopp—oops

Raymond Chen
Raymond Chen

(The title is another variation on Math is hard, let's go shopping!", which appears to be a popular catchphrase over in Michael Kaplan's neck of the woods. The history of the phrase was researched on Language Log.) Last spring, I was at a local crafts store and paid for a $2.15 item with a $5 bill and two dimes. The teenage salesclerk rang up the sale and began to give me $17.90 in change. "Um, I gave you $5.20." You'd think the salesclerk would notice something strange when the amount of change exceeded the amount of cash tendered! "Oh, right." The salesclerk had entered $20.05 instead of $5.20. But now ca...