Recent Articles

Toy language using j-expressions

Apr 30, 2012   #Compiler  #J-expression  #Language  #Scheme 
Posted a “stream of thought” compiler for a toy language based on the idea of j-expressions as a representation for ASTs. Code Docs

J-expressions

Apr 15, 2012   #JSON  #J-expression  #S-expression  #Homoiconic  #Macro  #Scheme 

JSON has become a kind of de-facto standard for sharing data among services on the web. The Lisp folks have enjoyed this luxury ever since … well ever since McCarthy made the language and his student implemented an interpreter for it. What’s more, they have also had the luxury of using the same syntax for sharing logic .. and in fact take it for granted. This post is a proposal to bring that “luxury” to the web programming world.

Status: Draft. Comments welcome.

Read More ...

Creating DSLs in Javascript using J-expressions

Apr 14, 2012   #Scheme  #LisP  #DSL  #Closure  #Function 

Scheme and Lisp have for long had powerful meta-programming abilities due to the syntax of their language being the same as the syntax for the main data structure supported by the language - the humble list. These languages are therefore well suited for inventing smaller special purpose “domain specific languages.

Javascript, on the other hand, has a “full blown syntax” that makes meta-programming not for the faint of heart. One consequence of the lack of such ability is that developers have not had the benefit of the abstraction possible through small special purpose DSLs.

Here, I outline an approach for creating DSLs in Javascript using the now prevalent JSON format that is native to the language. The initial part tries to explain the kinds of scenarios in which one might consider building a DSL, which is important to have an idea about. Later, I get into the actual representation using JSON.

Read More ...

A mental model for variables and closures in Javascript

Apr 13, 2012   #Closure 

Closures and variables have a strained relationship in Javascript that causes much confusion among newcomers and results in hard to spot bugs even for experienced JS coders. It is good to have a clear and accurate “mental model” of this relationship using which you can correctly predict what would happen with any given piece of code.

I came up with such a mental model a while back and posted it on Hacker News … which I reproduce here.

Read More ...

Classes and Javascript

Apr 12, 2012   #Class  #OOP  #Inheritance  #Encapsulation 

If you have been programming in Java and C++ for a while and are used to thinking about problems in terms of classes and inheritance, you may find yourself struggling with Javascript since it has only objects. This post is to – a) provide you with a perspective on why programming with only objects is powerful and b) show you how to translate the class-based concepts you’re used to thinking in into the Javascript world.

Read More ...

Social hash as identity

Jan 3, 2012   #Social  #Hash  #Digital identity 

(This is a “brain-dump” post).

Many write-ups and studies on social networks and privacy issues talk about the risk of using one’s personal information disclosed within social networks for identity theft. That made me think about whether it is really possible for an identity thief to steal my entire social environment and history or whether such theft is simply an indication of how broken the current paper-world identity systems are in the digital age?

Enter the “social hash” – a short identification string that can be generated from the data in your social network’s history that is very highly likely to be unique to you and very difficult to duplicate in a “prove your identity” challenge.

Read More ...

Newcomb's problem and quantum physics

How would Newcomb’s problem look like in the physical world, taking quantum physics into account? Specifically, would Omega need to know quantum physics in order to predict my decision on “to one box or not to one box”?

Read More ...

iPad2 wish ..

Jan 26, 2011   #iPad 
Now that macworld is near, it is time for an iPad wish list. I have only one item on it - and it is the addition of a wacom tablet-like stylus interface on top of the capacitive touch screen. Camera? Nope don’t need. I want a pad where I can draw and scribble with precision, flipping the stylus on its head to turn it into an eraser. Ah! That’ll be a heaven of a tablet with both touch and stylus support. Read More ...

Photon polarization

Jan 5, 2011   #Decoherence  #Polarization  #Quantum physics 

Decoherence as projection discusses photon polarization as a phenomenon that can only be explained quantum mechanically even at the macroscopic level –

Read More ...

The Alternate Reality Kit

Sep 19, 2010   #Smalltalk 
The term “object oriented programming” has degraded to the point where I no longer take self proclaimed OOP enthusiasts seriously. I don’t believe they know what they’re talking about … unless they bring up something … anything … about Smalltalk. If you don’t have a clue about what makes me go soft upon the mere mention of Smalltalk, check out this 1987 video demo of the Alternate Reality Kit. Makes you wish you had that on an iPad today doesn’t it? Read More ...