When the spell checkers attack

Today Boing Boing had a post about the Cupertino effect in which spell-checkers erroneously change valid words. I had worked on Adobe Acrobat and Adobe FrameMaker‘s spell checking feature and do happen to appreciate the headache with getting them right. I face Cupertino effect most often while typing in Indian names because most word-processors don’t…


Is interlocked increment followed by comparison thread safe?

Sorry about the blog title, my imagination failed me :(. In our internal alias someone asked the question "Is the following thread safe" if(Interlocked.Increment(ref someInt) == CONSTANT_VAL) { doSomeStuff(); } My instant reaction was no because even though the increment is done in a thread safe way using System.Threading.Interlocked class, the comparison that follows is…


C/C++ Compile Time Asserts

The Problem Run time asserts are fairly commonly used in C++. As the MSDN documentation for assert states "(assert) Evaluates an expression and, when the result is false, prints a diagnostic message and aborts the program." There is another type of asserts which can be used to catch code issues right at the time of…


Taking my job more seriously

I generally take my work very seriously. However, the following from SICP was still my favorite quote "I think that it’s extraordinarily important that we in computer science keep fun in computing. When it started out, it was an awful lot of fun. Of course, the paying customers got shafted every now and then, and…


Silverlight on Nokia S60 devices

In many of my blog posts (e.g.here and here) I refer to .NET Compact Framework and Symbian OS (S60) and obviously folks keep asking me via comments (or assume) that we are porting .NETCF on S60 devices. So I thought it’s time to clarify The short answer is that we are not porting .NETCF to…


Who halted the code

Today a bed time story involving un-initialized variable access and a weird coincidence. Couple of weeks back I was kind of baffled with a weird issue I was facing with the .NET Compact Framework Jitter. We were making the Jitter work for Symbian OS (S60) emulator. The S60 emulator is a Windows process and hence…


Hex signatures

Frequently in code we need to add bit patterns or magic numbers. Since hex numbers have the alphabets A-F folks become creative and create all kinds of interesting words. Typical being 0xDEAD, 0xBEEF, 0xFEED or various combination of these like 0xFEEDBEEF. However, someone actually used the following in a sample 0xbed1babe No naming the guilty


Back To Basics: Finding your stack usage

Handling stack overflow is a critical requirement for most Virtual Machines. For .NET Compact framework (NETCF) it is more important because it runs on embedded devices with very little memory and hence little stack space. The .NETCF Execution Engine (EE) needs to detect stack overflows and report it via StackOverflowException. To do this it uses…


Tail call optimization

I had posted about tail call and how .NET handles it before. However there was some email exchanges and confusion on internal DLs around it and so I thought I’d try to elaborate more on how .NET goes about handling tail calls Let’s try to break this down a bit. a) A piece of C#…


A* Pathfinding algorithm animation screen saver

I’m trying to learn WPF and IMO it is not a simple task. Previously whenever I upgraded my UI technology knowledge it had been easy as it build on a lot of pre-existing concepts. However, WPF is more of a disruptive change. I decided to write some simple fun application in the effort to learn…