Posted 23-08-2013
JavaScript Nonsense

The above is valid JavaScript code. I generally enjoy programming in JavaScript, mainly due to it’s accessibility and immediate feedback. These are very compelling advantages of the language that are largely unparalleled by any other language. Because of these advantages, JavaScript makes an excellent language for working on quick projects, and it also provides an excellent resource for people new to programming: all you need to do is open a browser and type!

JavaScript does have a number of peculiarities, however. Among these is the crazy weak typing. This system lets you perform operations on data which may make no sense in terms of the operation. For example, I would expect that adding 1 to the empty object, such as 1 + {}, would result in a type error… Nope! Surprise! According to JavaScript this equals “1[object Object]“. Fine, what is 1 + +{}. JavaScript tells us the answer is none other than NaN. Well, that makes sense. Whatever the answer to that would be, it’s certainly not a number. Thanks JavaScript! So 1 + +[] should also be NaN as well, right? Right?? Nope, this is in fact a number: 1 to be precise.

Posted 01-08-2013
1 Comment
Writing Literate Haskell with Code Block Notation

A few nights ago I wrote a very simple “parser” for Literate Haskell files that use a TeX-like notation for denoting blocks of code. The format expected by the program is: {code} -> begins a block of code {endCode} -> ends a block of code Both blocks of code and Bird Beak lines are converted to Bird Beak notation to be compiled. All other lines are considered comments.


There are many advantages to using a block notation rather than ‘>’ on each line, especially for larger blocks of code. To read a few reasons against standard Literate Haskell, see this post by Matt Giuca. While I quite enjoy Literate Programming, many of the arguments he puts forth address troublesome aspects of literate programming, but they are mostly tightly coupled to the notation used.

Posted 27-07-2013
Haskell Chess

This is my first attempt at writing a useful Haskell program. I am currently reading the wonderful “Haskell School of Expression” Book by Paul Hudak of Yale. I am finding Haskell extremely intriguing and thought I would take a stab at creating a Chess application (console-based) in Haskell. The application works via the honor system. I’ve decided to put this project on hold while I learn more so that I can more effectively implement an AI and a move validator.

In any case, here is my first attempt at Haskell…

Posted 25-10-2012
Linux IPC: Shared Memory
Interprocess Communication

Shared memory provides a way for a process to share data with other processes in a system. This process-to-process communication is commonly called interprocess communication, or IPC. In Linux, there are several forms of IPC. Those that have used Linux in a productive manor are likely familiar with one of the most simple forms of IPC in Linux: pipes. Pipes provide an extremely useful way of passing the output of one program as the input to another.

The “|” character is used to create a pipe. For example, we could use the programs wc _and _grep to quickly find the total lines of code in a source directory. First using the wc program with the -l flag, we can get the number of lines of code in each source file in the current directory. Issuing this against a directory of C++ files outputs the following,