Tools for “more humane coding”

The Future Programming Lab envisions a more seamless coding experience.

Software developers, veteran and novice alike, know all too well the common pain points in the coding pipeline. You start a new project, and before you can start testing the code you write, you’re stuck ironing out a dozen minute syntax and type errors, sometimes in completely different parts of the program.

At times, a simple placeholder value might be nice to make sure your code is going the right direction before you spend two hours fixing every bug.

This vision is what motivates the work of the Future of Programming Lab (FP Lab) at the University of Michigan, led by assistant professor Cyrus Omar. The lab’s flagship research project, Hazel, is a live functional programming environment that is able to typecheck, manipulate, and run incomplete programs. 

With Hazel, Omar and his collaborators want to deliver on a simple promise – “there are no meaningless editor states.” It accomplishes this with a technique called structure editing. In contrast to a plain text editor, structure editors have a sense of the underlying structure of a document. This enables them to give a user a sense of what their edits mean for the larger finished product.

Code snippet in Hazel
Hazel allows users to work with incomplete programs thanks to the concept of a hole type – enabling work to continue despite errors or unfinished statements.

“Conventional programming language definitions assign no formal meaning to structures like blank spots, type errors or merge conflicts,” the team write on Hazel’s interactive website, “so we are left without live feedback about the behavior of even complete portions of the program.”

This state of affairs makes it difficult for program editors to provide various useful language services like code completion, type inspection, and code navigation without gaps in service.

Hazel’s approach to closing those gaps is rooted in type theory. The team models incomplete programs as programs with holes. The holes stand for parts of the program that are missing and serve as membranes around parts of the program that are erroneous or, in the collaborative setting, conflicted.

To make this possible, the lab has developed a core calculus that defines a type system for expressions with holes, as well as a language of edit actions to enable the environment to insert holes automatically. 

To make Hazel, and eventually other coding environments, even more intuitive, the FP Lab is working on several related problems to improve the experience of structure editing in general.

The lab’s “Livelits” project integrates graphical interfaces directly into the code, giving developers a way to do things like define a color with a popout picker or adjust a value with a slider. The literals can be defined a number of ways to make development of graphical elements more intuitive – rather than defining everything in plaintext.

They’re also developing an intelligent programming assistant that synthesizes code satisfying specifications provided by human programmers in the form of types, tests, properties, and sketches, and guided by a learned understanding of idiomatic code.

A new tool called tylr explores tile-based editing, a new kind of structure editing that, like text, supports linear token-level editing workflows. Unlike text, tylr ensures your manipulated tokens can always be parsed back into a valid syntax tree. What this means is certain logically-conjoined blocks of text are indicated as tiles. These tell you where you can make changes or interruptions to code without breaking something.

As these and other concepts, ranging from fundamental and theoretical to visual and practical, are folded into the Hazel environment, Omar hopes to see his vision of a completely seamless coding experience grow to fruition.

“I think of the things that we’re doing today as laying the foundations for a much longer future,” Omar says. “We hope that Hazel will influence the design of programming tools more broadly.”

Explore:
Cyrus Omar; Research News