Skip to main content


ERROR_SUCCESS. This macro would be familiar to all those who have done some programming in WIN32. It is the output of the GetLastError() function to check the thread's last error state when no error has occurred. Weird, isn't it? I mean, if it is a success, then why is it marked as an error in the macro?

This is one example of a badly made API. APIs are considered bad when programming in them becomes non-intuitive. Software is said to be bad (or said to suck) when it seems counter-intuitive to the user. There is one very simple example of this.

Start notepad. Type in any text. Click on close. The message that you see is:

Notepad dialogue: Do you want to save changes to Untitled?

This makes no sense to me as a user. Of course, the programmer follows the approach that he creates a temporary file called Untitled, and in that file he allows the user to make all his changes. But how am I, as a user to understand that?

A similar disconnect occurs even between two different programmers. That is why it takes a whole lot of effort to make a programme using a different API than what one is used to. But by far, the most difficult and non-intuitive API that I have used is the WIN32 API.

CreateThread() looks pretty intuitive as a function to create a thread. But there is a deep catch. If the programmer uses any of the C++ stdlib functions, then CreateThread shall lead to memory leaks. Now this sure is not clear from the function description. Similarly, to end a thread in a clean fashion, the programmer must make the thread return a value. If the thread is forcefully terminated by means of the TerminateThread() function, then the destructors for the objects within the thread are not called, which causes the thread to waste memory. Further, there is no automatic garbage collection, as there is with Java or C#. Perhaps this shall tell why it does not make sense to forcefully terminate any programme via the task manager. If the programme does not have a good garbage collection mechanism, then the programme shall eat up memory and waste space.

Another annoying thing I found was about the way any object must be created/used. In WIN32, there may be a large number of errors that may occur when any object is used. The error catching codes go larger than my basic code. So it happens that my code for a simple multi-threaded application would be around 50 lines, around 100 lines get added in handling errors. Well, what happens if you miss out any particular error? In that case, you are a bad programmer.

Till we meet again. Keep coding. A toast for all your errors which are actually successes.

Popular posts from this blog

Progressive Snapshot: Is it worth it?

I turned 25 last year, which in the highly mathematical and calculating eyes of the US insurance industry meant that I had suddenly matured into a much more responsible driver than I was at 24 years and 364 days of age. As a result, I expected my insurance rates to go down. Imagine my surprise when my insurance renewal notice from GEICO actually quoted a $50 increase in my insurance rates. To me, this was a clear signal that it was time to switch companies.Typically, I score really high on brand loyalty. I tend to stick with a brand for as long as possible, unless they really mess up. This qualified as a major mess up. As a result, I started shopping for insurance quotes.Two companies that quoted me significantly lower rates (30%–40% lower) were Progressive and Allstate. Both had an optional programme that could give me further discounts based on my consenting to the companies tracking my driving habits. Now, I am a careful driver – I hardly ever accelerate hard. I hate using the brak…

Cornell Graduate Students United: At What Cost?

On Monday and Tuesday, we graduate students at Cornell will be voting on whether or not we want to unionise. Actually, scratch that, only graduate students who hold a TA, RA, or GRA appointment can unionise.This is a shitty arrangement, and I will be voting against it.For those of you who are not aware of how graduate school works at Cornell, you could be on one of many appointments.FellowshipA graduate student on a fellowship gets a stipend and tuition paid without associated teaching or research opportunities. Graduate students on a fellowship typically work towards their own theses, but will be excluded from the unionGraduate research assistantshipsA GRA gives a graduate student stipend and tuition without teaching responsibilities. However, this money comes out of a specific project grant, and the students typically work on their own theses. Students on GRAs magically qualify to join the union, whereas there is virtually no difference between a GRA and a fellowship for the most pa…

Reading List, April 2017

Adam Carroll, When money isn’t real: The $10,000 experiment, in TEDxLondonBusinessSchool, 9 July 2015. [Online]: Carroll presents an interesting point – we have abstracted away money through the use of a number of instruments, such as credit and debit cards, NFC payment systems on our phones, and in-app purchases, when we don’t realise how much we are actually spending. Carroll spends some time showing how his kids, aged 7–11 played monopoly differently when they were playing with real money. He goes on to lay his premise, that financial literacy must be taught to children at a young age, when they should be allowed to fail and learn from their failures at a small scale, not at the hundreds of thousands of dollars when they are in student loan debt and just out of college.Carroll’s talk hit a lot of notes with my own experiences with money, and I’m sure that it would resonate with your experiences as well.Brett Scott, If plastic replaces cash, much tha…