Pencil Code Project Ideas

Pre-Project for Visual Debugger

This is a pre-project to submit as part of your proposal if your plan is to create a visual debugger for students.

The idea is to tackle the first step of the debugger: modify the Coffeescript compiler, or create a library that uses the Coffeescript AST, to generate instrumented Javascript code that traces lines (and ideally entering and exiting of user-defined functions) as they are run.


The instrumented compiler should generate code that calls a ide.trace(event) each time a line (or subline expression) is run or a function is entered or exited, where ide.trace is just a function that accumulates a big array of events (maybe dumping them when the program is done).

The event objects could have fields such as the following:

event = {
  line: 15,
  column: 7,
  type: 'enter'

Where type may be blank (to just trace execution of a line), or 'enter' or 'exit' (to trace entering or exiting a function).

Notice that Pencil Code already has a rudimentary visual debugger, but it relies on parsing excpetion stack traces (and mapping them through Coffeescript Source Maps) to get line number information.

The approach taken by this pre-project is a first step towards a more full-featured visual debugger that works on all browsers.


There is some pre-existing work in this space, and it is a good idea to take a look at how Coffeescript has been instrumented in the past. For example, benbria's coffee-coverage project generates instrumented javascript from Coffeescript, for code coverage purposes.

It would be fine to use that code either as inspiration or as a starting point.

If you are interested in contributing to a visual debugger, send a link to your fork along with your project proposal for Google Summer of Code.