What's the easiest way to experience TCR in DrRacket?

Is there a neat way to try out the TCR (Test & Commit or Revert) in Dr Racket?

TCR test && commit || revert is an alternative programming workflow similar to TDD. Run the tests after every change. If they pass, commit. If they fail, revert to the last passing state. As you'll see, this means that changes that don't work just poof disappear. Putting changes at risk creates a powerful incentive to make changes in teensy tiny steps.

Here's Kent "XP" Beck demo-ing TCR in Python (and Vim?) with the desired behaviour: https://www.youtube.com/watch?v=Aof0F9DvTFg

Maybe a small plugin?

The traditional way would involve a version control system, but for trying-it-out-purposes all that would be necessary is to alter the behaviour of Run to:

  1. Run (traditional behaviour)
  2. Detect: did any errors occur?
  3. Yes: Revert (from file)
  4. No: Save (to file)
1 Like

The editor in that video is VS Code (not Vim, sadly :P).

I watched the linked video. He never runs into the obvious failure mode of trying something, having it fail & revert due to a typo, and having to type it all over again instead of just fixing the typo. And at around the 16min mark he admits that he practiced running through it a few times before recording. Maybe he demonstrates what that’s like in Part 2 or 3?

2 Likes

The File menu in DrRacket includes Revert which would support the simplified process you describe.

  • Revert : Re-loads the file that is currently in thedefinitions window. All changes since the file was last saved will be lost.

https://docs.racket-lang.org/drracket/Menus.html#(part._menu~3afile)

To support the full TCR test && commit || revert workflow you might be interested in the following DrRacket plugins:

Drrackgit by Bradley Busching

“A git plugin for DrRacket.”

https://pkgs.racket-lang.org/package/Drrackgit

See also https://github.com/bbusching/libgit2

DrSync by Grant Rettke

“DrSync reverts your files when DrRacket’s frame activates and saves them when it deactivates”

http://planet.racket-lang.org/package-source/grettke/drsync.plt/2/8/planet-docs/drsync/index.html

http://planet.racket-lang.org/display.ss?package=drsync.plt&owner=grettke

Best regards

Stephen
:beetle: