Dal Segno

Dal Segno sign from music notation

See the effect of code changes instantly

Try changing a number. Can you make the ball move faster? Try lines 4 and 5. For more space, go fullscreen.

Dal Segno rewinds back to the last execution of a modified function.

As this program runs snapshots are saved each time a function is called. When a user makes changes to the code, the program rewinds back to the most recent time the function that was modified was run so the changes are immediately evident.

Dal Segno means "from the sign," and is used in musical notation (where it is typically abbreviated to D.S.) to instruct a musician to repeat a section of music from an earlier point denoted by the curly little symbol with two dots shown below.

Dal Segno sign from music notation

Language Overview

Try adding a method from the browser window or console, like (alert "hello"). Open fullscreen for more space.

The language is a bit like Scheme, with the addition of a (defn name (arg1 arg2 ...) body) special form that defines global functions. Calling a global function causes the interpreter state to be saved, while calling a function defined by (lambda (arg1 arg2 ...) body) does not. Lists are immutable, but scopes aren't: the values referred to by variables in namespaces can be updated with (set! name).

JavaScript values are accessed via name lookup: after the local and enclosing scopes are searched for a name, the interpreter checks several JavaScript objects for that name. In these examples a canvas context is included in this lookup chain for drawing, along with the JavaScript browser objects window and console, as well as objects with methods for getting mouse position and pressed keys.

You can read the language documentation in the readme on GitHub.

Dal Segno sign from music notation

Let's play golf

Try changing (fire) after taking a shot, or play with terrain generation. For more space go fullscreen.

Dal Segno sign from music notation

This game is too hard

Use spacebar and the mouse to avoid the hidden asteroids.

Try tweaking the size and shape of the floodlight. Open fullscreen for more space.

Write your own at dalsegno.ballingt.com/fullscreen

Dal Segno sign from music notation

Stepping through program execution

Start the program then use the slider to scroll through history and step through the code forwards or backwards.

Dal Segno differs from other live-reloading systems I've seen in that it rewinds to the most recent invocation of the modified function (a state created by older code) instead of replaying the new code through from the beginning or redefining the code only for future executions, as in a REPL environment. This provides the user with the most recent situation in which this new code might have made a difference, at the cost of putting the program in a possibly unreproducible state. Dal Segno actually saves copies the execution state instead of replaying the program from an initial state. At the cost of some space and time, this makes seeking to given program execution state faster.

Want to use Dal Segno for something, fix it, add things to it, or find out more about it? Let me know! I'd love to hear from you at @ballingt on Twitter or by email. I'd like to write more about this project and it would be very helpful for me to discuss it informally first. Beyond state rewinding, Dal Segno has been a playground for interpreter and live programming interface ideas like friendlier runtime errors, batched drawing operations, and running a program forwards and backwards. Thanks to Mary Rose Cook for the great discussions about how to make a programming environment more interactive and discoverable that led to this project.

Follow @ballingt ballingt.com Dal Segno sign from music notation