Understanding and using Streams in JavaScript


Let's take a scenario from Mathematics, how would you model the infinite set of natural numbers? A list? An Array? Or a Stream? Even with infinite storage and time, lists and arrays do not work well enough for this scenario. Why? Assuming the largest possible integer an array can hold is x, then you've obviously missed out onx + 1. Lists, although not constrained by initialization, need to have every value defined before insertion.

Why JavaScript ‘seems’ to get addition wrong


This post was actually motivated by Gary Bernhardt's very popular WAT talk. It aims to provide a deeper understanding of how JavaScript evaluates expressions and operations on primitives and object types.

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.

SICP Section 3.3 – 3.5 : Found a bug in memq


1. Is memq broken? memq is an in-built list search function; it finds the first occurrence of a key in a list and returns a new list starting from that key. Now that you know what memq does, lets look at some weird behaviour Building on that foundation leads to the following conundrum memq tests whether the key exists in the … Continue reading SICP Section 3.3 – 3.5 : Found a bug in memq

SICP Review: Sections 3.1 & 3.2


The deeper I go into the book, the more I appreciate the effort, style, and work the authors put into it. Each section builds on earlier sections, and it is amazing how it forces you to see software development from a new angle. Enjoy... 1. Perception and Design Our perceptions of the real world influence … Continue reading SICP Review: Sections 3.1 & 3.2

SICP Section 2.5


So, four months after I started and more than 90 solved exercises, I can say Alhamdulillaah, chapter 2 is done! Section 2.5 was among the most challenging; the exercises revolved around building large, easily extensible software systems. And here are the thoughts again :) 1. Coercion The section revealed the importance of coercion in software development by creating … Continue reading SICP Section 2.5

SICP Sections 2.3 & 2.4: Thoughts and Ideas


1. Top-Down Design Most of the problems in the SICP book are solved in a top-down way with lower level details deferred until needed. The focus on high-level details makes for expressive, flexible code since implementation is based on well-defined interfaces and not implementations. Consequently, swapping and improving interfaces is a cinch - the dependency on high-level interfaces shields … Continue reading SICP Sections 2.3 & 2.4: Thoughts and Ideas

SICP Section 2.2: New ideas and thoughts about programming


5 things to learn from the SICP book

SICP Section 2.1 : Thoughts


Alhamdulillah, I wrapped up this section a few days ago. Thirteen of the solutions are here (if you are curious enough); the other three need proofs, and I wasn't in the mood for too much interval arithmetic. So, what did I learn? 1. More Scheme This chapter introduced the concepts of cons, car, and cdr for … Continue reading SICP Section 2.1 : Thoughts

3 Ways to start using promises


Continuing from the previous post; lets dive into ways of using promises. First, some helper functions: 1. Pseudo-Observers This involves attaching several handlers to a single promise; all attached handlers are invoked once the promise resolves. I call this the 'pseudo-observer' pattern because each 'observer' gets invoked once (remember promises never leave their resolution state). This explains why promises can't … Continue reading 3 Ways to start using promises

Introduction to JavaScript Promises


A promise is a value that might not exist because the action needed to produce that value has not been carried out. Thus, after the expected action has run, the promise will have a value indicating the success or failure of the action.

SICP Section 1.3 : Thoughts and Concepts


This section exposed me to the full power and beauty of functional programming. The expressiveness of using functions as values is awesome. For example, a sum of cubes function can use a sum function, which itself relies on a reduce function. Think of higher-order differentiation in mathematics, and you do get the idea. An interesting concept involves using lambda … Continue reading SICP Section 1.3 : Thoughts and Concepts

5 things I have gained from SICP: Section 1.2


What I learnt from Chapter 1.2 of the SICP book. A needed pause to reflect on knowledge gained before diving into 1.3.

Reading the SICP BOOK


I have been longing to read the Structure and Interpretation of Computer Programs (SICP) for a long time - a lot of great programmers tout it as one of the 'books' to read. In May I completed JS Allonge (a somewhat challenging read but got to understand the Y-combinator Alhamdulillaah) and I felt it was a good time … Continue reading Reading the SICP BOOK

Understanding Partial Application and Currying


In pure functional languages, functions are not 'invoked', rather a set of arguments is 'applied' to them. Now, if all the arguments are not passed in, then the function is being  'partially' applied. Partial application converts variadic functions (i.e. functions with multiple parameters) into functions of lesser arity by pre-specifying certain argument values.

Understanding Tail Recursion


The biggest advantage of using tail calls is that they allow you to do extensive operations without exceeding the call stack. This makes it possible to do a lot of work in constant space without running into out of memory exceptions; this happens because the frame for the currently executing function is re-used by the newly-executed function call.

Programming Language Type Systems II


Strong/weak typing describes the ease of mixing variables of different types in expressions. Strong typing does not imply static typing just as weak typing does not mean dynamic typing. To put it simply, if a programming language tries to interpret an expression containing variables of varying types at runtime (e.g. adding an int to a … Continue reading Programming Language Type Systems II

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.

5 things I learnt from Code Complete 2


Five lessons learned from reading Code Complete 2

MOOC Review : Machine Learning


My review of the MOOC on Machine Learning

Thesis Stories Ep 3: Research is Hard!


Alhamdulilah I completed my thesis about three weeks ago; if you're interested, you can check out my thesis and presentation. Looking back at the two years I spent at MASDAR, I have a couple of thoughts: Alhamdulilah I learnt a lot, met a couple of wonderful people and matured significantly. There were a couple of not-so-pleasant experiences too but I believe … Continue reading Thesis Stories Ep 3: Research is Hard!

MOOC Talk : And I thought I knew SQL


Massive Open Online Courses (MOOC) became popular early this year with offerings from Coursera, Udacity and EdX. These platforms were inspired by the phenomenal success of the three online courses (db-class, ai-class and ml-class) that ran in late 2011. It has never been so easy to get high-quality knowledge - for example, Coursera has renowned … Continue reading MOOC Talk : And I thought I knew SQL

Thesis Stories : Wrangling with HUGE data


My thesis takes all my time: I have to review papers, write out my thoughts, build a platform, attend classes as well as poke into Big Data; and my blog has been at the receiving end. This story about big data came to my mind while I was thinking about my planned work on the stackoverflow (SO) … Continue reading Thesis Stories : Wrangling with HUGE data

What Endian are you? Big or little?


Have you read Gulliver's travels? If you have then you must have read about endianness.

Book Review: Coders At Work: Reflections on the Craft of Programming


I recently completed reading Coders at work (well, I must have spent approximately 8 weeks trying to complete it; not a record I am proud of but still it's better than nothing!) I think the book is a good read even though some of the interviews dragged on for too long. Peter Siebel, the author, … Continue reading Book Review: Coders At Work: Reflections on the Craft of Programming