Guaranteeing software behaviour

My foremost goal while building software is to build stable self-healing systems with deterministic behaviour. I want to ensure my code continues to work even when unexpected events occur. In the event of unknown unknowns, the expectation is a graceful degradation in the worst case. This requirement is even more important when implementing high-risk projects. … Continue reading Guaranteeing software behaviour

Adventures with XOR

I recently ran into a code puzzle; the question asked for the finding the unique element in a list of integers given that every integer appears twice except the single special element. My first solution You could use an array to hash elements to buckets (sort of like counting sort) and then flip their values … Continue reading Adventures with XOR

Why you should not use isNaN in JavaScript

I was on a video streaming site recently and moved the play point to the far right. It was amusing to see the hover details show NaN:NaN - ahah, some mathematical operation had NaN-ed and the code didn't cater for that. If you have read Why JavaScript ‘seems’ to get addition wrong; you would have seen … Continue reading Why you should not use isNaN in JavaScript

Why JavaScript has two zeros: -0 and +0

Do you know there are two valid zero representations in JavaScript? In pure mathematics, zero means nothing and its sign doesn't matter. +0 = -0 = 0. Computers can't represent value well enough and mostly use the IEEE 754 standard. Most languages have two zeros! The IEEE 754 standard for floating point numbers allows for … Continue reading Why JavaScript has two zeros: -0 and +0

Understanding Bit masks

Bit masks enable the simultaneous storage and retrieval of multiple values using one variable. This is done by using flags with special properties (numbers that are the powers of 2). It becomes trivial to symbolize membership by checking if the bit at a position is 1 or 0. How it works Masking employs the bitwise OR … Continue reading Understanding Bit masks

How to implement the Y-combinator in JavaScript

This post provides a very simple step-by-step implementation of the Y-combinator in JavaScript. You should be able to implement the Y-combinator in your language of choice after reading this post; as you'll see - it's that easy. What is a combinator? According to wikipedia, A combinator is a particular type of higher-order function that may be used … Continue reading How to implement the Y-combinator in JavaScript

Understanding Tail Recursion

A tail call is the last call executed in a function; if a tail call leads to the parent function being invoked again, then the function is tail recursive. In the first function - foo; the baz() function is a tail call while in foo2, the baz and biz are tail calls because both are the … Continue reading Understanding Tail Recursion

Programming Language Type Systems I

Static, dynamic, strongly-typed and/or weakly-typed; the terms we routinely use to describe typing in programming languages. However, these terms (especially the last two) have more to them than is generally assumed. There is actually no widely-agreed upon definition for strong and weak typing – there are way too many contradictory views. Good news is that everyone agrees … Continue reading Programming Language Type Systems I

What Endian are you? Big or little?

Have you read Gulliver's travels? If you have then you must have read about endianness. The Lilliputians were divided into two factions over what end of an egg to break – the big end or the small end. Isn't it interesting that such a petty and seemingly trivial issue caused both parties to become embroiled in … Continue reading What Endian are you? Big or little?


One of the recent trends in IT is virtualization and it has caught on fast. There is hardly any person in computing that has not heard about it. Some are more familiar about its intricacies but everyone doesn't have to be an expert in this seemingly esoteric field to use it. Here is an introduction … Continue reading Virtualization

Cloud Computing, the future of computing?

Cloud computing has been touted to be the future of computing. Trends suggest a move towards web-based software applications and services. The claim has been further strengthened by the emergence of companies offering cloud-based services to computer users. (e.g. Google Docs). The underlying principle of cloud computing is to have servers offering access to computing … Continue reading Cloud Computing, the future of computing?