Recent Articles

Scratch pad for text with diacritics

Dec 27, 2012   #Diacritics  #Carnatic music 

Roman text with a few choice diacritics are a common need when writing about Indian classical music. Creating unicode text with diacritics that can be ported between applications is in general a pain. So, I made a small in-browser app that serves as a scratch pad for common diacritics.

Read More ...

A critique of Tuna

Nov 9, 2012   #Web Audio API  #Tuna 

Google has open sourced the Tuna set of effects used in their Jam with Chrome project. Here, I collect some thoughts about the code design decisions for their effects framework, since I myself have written Steller.

Read More ...

On eval and evil.

Aug 28, 2012   #eval  #DSL 

“eval is evil” has become a maxim repeated in the Javascript community. Douglas Crockford, in Javascript: The Good Parts, rightly advises against hidden and explicit uses of eval for security and clarity reasons. Now, I find eval useful to implement DSLs in Javascript. The in-browser CoffeeScript compiler wouldn’t be possible without eval (directly or indirectly). So, in this post, I wish to explore what appears interesting about eval that is relevant to building such DSLs.

Read More ...

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 ...