Proto REPL – Updates to the Clojure REPL for Atom

Clojure

Web Development

2016-02-04Jason Gilman

Proto REPL is a Clojure REPL for the Atom Editor that I introduced in a blog post last October. When I introduced Proto REPL, I wrote “The future of interactive development is going to be visual.” and that “ATOM is at its heart a web browser that means you can use the combination of HTML/CSS/Javaillegalscript right in your editor for visualizations”. Proto REPL was only barely scratching the surface of what you could do to enhance interactivity or provide visualizations in your editor. A lot has changed since then to give Proto REPL a better Clojure development experience.

Fundamentals

Proto REPL now uses nREPL for communication with the Clojure process. Originally, communication was entirely via standard input and output. It would send code to the Clojure process the same way you would type Clojure code into a terminal based Clojure REPL. It was very basic but it worked surprisingly well for the initial version. The change to use REPL brings with it a few new features like the ability to connect to a remote Clojure process, interrupt long running commands, and capture the value of executed code and redirect it for other purposes. That last feature is especially important in fulfilling one of the original goals of integrating visualizations. Another improvement to Proto REPL was making its REPL display area act more like a real REPL. Proto REPL took the initial shortcut of directing all output to an Atom text editor window. You could modify anything and there was no place to enter new code for evaluation. The REPL display portion of Proto REPL has been updated to behave more like a traditional REPL. You enter new forms for evaluation at the bottom area. The results are displayed above that. It supports a history of your past evaluations as well.

Visualizations

Proto REPL has had some internal changes that make it easier to extend. Another package can now register itself with Proto REPL via Code Execution Extensions. This allows the creation of packages that extend Proto REPL and add visualizations or other new capabilities. Proto REPL Charts is a new Atom package that uses that feature to display tables and graphs of results from executed Clojure Code.

Proto REPL Charts supports scatter graphs, line graphs, bar charts, other custom graphs, and tables of data. Once Proto REPL Charts is installed you can execute code like this …

Enhanced Interactivity

Proto REPL added some improvements to interactivity through integration with Atom Ink, an Atom package for building interactive IDE components in Atom. Proto REPL currently uses it for displaying results of executed operations inline (next to the code that was executed). The pretty printed version of the result is available by expanding the inline display.

The inline display becomes very useful when combined with Automatic Evaluation Mode. Automatic Evaluation Mode evaluates every top level form in a specified file as you type. When you work in Clojure you typically move around a file making changes and sending various forms to be re-evaluated at the REPL. Automatic evaluation removes the need for the extra step of manually re-evaluating blocks of code. You just write the code and you immediately see the results. Most Clojure code can be stateless with zero side effects so it’s safe to run over and over. Code with side effects can be run in the traditional way.

See the following gif for a demo. You can even combine Proto REPL Charts with this so your graphs are immediately updated as you type.

Inline display of results, automatic evaluation, and Proto REPL Charts are all about removing the impediments when coding. They’re attempts to make it easier to see what you’re building.

Community Feedback

I’ve been really pleased with how much positive feedback and support Proto REPL has received. The

Proto REPL page at Atom reports more than 2,400 downloads so far. There have been many suggestions for improvement, issues filed, and some quality improvements submitted as pull requests including the ability to remotely connect to another nREPL server.

What’s next?

This is still just the beginning. The foundation is there for being able to use Proto REPL to do real development work but there are still many areas in which the experience could be improved. These are some of the future possibilities.

Increased integration with Atom Ink. Atom Ink is in the early stages of development. As Atom Ink improves so will Proto REPL.

Adding the ability to save and view values captured across the execution of an algorithm.

More visualizations and ways to visualize algorithms or different kinds of data.