CAD026: Convex Lisp
Overview
Convex Lisp is a general purpose, high level programming language for the Convex Virtual Machine (CVM), designed to facilitate effective construction of smart contracts, digital assets and open economic systems.
This document outlines the key elements of Convex Lisp. It is intended primarily as an introduction and programmer's guide for experienced developers wishing to understand the language, its implementation and key features: more detailed specifications for specific aspects of the language and underlying runtime are provided in other CADs.
Key language features
- Pure immutable data structures with highly optimised implementations for usage in decentralised systems based on Convex
- Emphasis on functional programming with support for the lambda calculus
- Powerful macro capabilities, following the expansion-passing style developed by Dybvig, Friedman & Haynes
- Automatic memory management, including memory accounting
- Elegant Lisp syntax largely inspired by Clojure
- On-chain compiler (smart contracts writing smart contracts....)
- Strong dynamic typing - for well defined, consistent behaviour at runtime

(Image courtesy of XKCD)
Motivation
As a platform for decentralised, open economic systems Convex requires a powerful and flexible language for developers to build the next generation of digital assets, smart contracts and services.
While the CVM itself is language agnostic, we chose a Lisp dialect as the first language for Convex for a number of key reasons:
- Productivity: general recognition of Lisp as a productive and flexible language
- The advantages of a homoiconic language ("code is data") for generating code with powerful macros and DSL capabilities
- The ability to create a small and efficient compiler suitable for on-chain code generation and compilation
- Familiarity for developers of existing Lisp-based languages such as Clojure, Scheme, Racket or Common Lisp
Designing a new language is no easy task, so we naturally considered adopting an existing language for Convex. Unfortunately, none of the available options proved attractive for a variety of reasons:
- High level general purpose programming languages (Python, Java, JavaScript, Clojure, C# etc.) are not generally designed for decentralised VM operation. In particular, execution must be deterministic to allow independent execution and validation of the same exact computation by peers in a decentralised network. Cutting down such languages to a consistent deterministic subset (no IO, no randomness, no observable differences across platforms etc.) would itself be a massive task and break compatibility with the majority of existing code, negating most of the value of existing library ecosystems.
- Low level languages (WASM etc.) do not provide the high level capabilities and abstractions needed for productive development of decentralised economic systems. The amount of library support required to provide this would be a significant development and performance overhead. Typically, such languages also lack good support for automatic memory management which is important for developer productivity and essential for the kinds of immutable data structures used in Convex. These languages would also imply complex toolchains and execution infrastructure that would add complexity and inhibit development and maintenance efficiency.
- Existing smart contract languages (Solidity etc.) have significant limitations / design flaws and would not allow us to take full advantage of the power of the CVM (e.g. the improved account model with key rotation, memory accounting, extra CVM data structures etc.).
- Convex performance at global scale depends heavily on very efficient immutable data structures that are not easy to represent in existing languages that were not designed with these in mind. No existing language would be a good fit for these natively, and translating to / from these structures would imply an unacceptable performance penalty: we need to use them directly.