April 19, 2013

Local Variable Debugging with see.js

Modern Javascript debuggers are fun to use because you can inspect the program state at any time without stopping at a breakpoint. The problem is, you can only inspect global state. What if you want to see local variables? Then you're back in 1980, setting breakpoints each time you want to see your closure state again.

This is a problem that strikes Coffeescript programmers in particular, since all variables in Coffeescript are local variables wrapped in anonymous closures. All program state that has not been explicitly been made global becomes invisible to debugging consoles.

The solution is see.js. It is a simple debugger that I have written that lets you interact with an eval closure that you can insert at any scope you want to view. In Javascript it is pretty common to use closures to encapsulate a lot of state - even your whole program. With see.js, you can write clean code like this without losing the ability to debug.

More details below.

Continue reading "Local Variable Debugging with see.js"
Posted by David at 10:17 PM | Comments (0)