This presentation introduces Coalton, a statically typed, functional programming language embedded within Common Lisp designed to address the challenges of building safe, flexible, and high-performance software in industrial environments. Developed to support mission-critical applications—including quantum computer simulators and real-time autonomous control systems—Coalton leverages a Hindley-Milner type system with multiparameter type classes, similar to Haskell, while maintaining full interoperability with the Common Lisp ecosystem.
The speaker demonstrates that while safety is a primary feature, Coalton’s significant value lies in its ability to generate highly optimized code. By utilizing techniques such as monomorphization, global inlining, and the elimination of runtime type checks, Coalton can achieve performance gains over hand-optimized Common Lisp. A case study involving a Fast Fourier Transform (FFT) implementation illustrates how Coalton resolves the "Lisp Triangle" trade-off between speed, genericity, and simplicity. The talk concludes with a status report on the language’s maturity, acknowledging current limitations in editor support and standard library design while emphasizing its proven utility in large-scale production signal-processing applications.
Toward Safe, Flexible, and Efficient Software in Common Lisp: A Technical Overview of Coalton
0:02 Professional Context: The speaker highlights 15 years of professional Common Lisp experience in domains requiring "firm" real-time control, numerical efficiency (terabytes of memory), and mission-critical reliability where software failure involves financial ruin or loss of life.
3:15 Introduction to Coalton: Coalton is presented as an embedded language in Common Lisp that utilizes Algebraic Data Types (ADTs) and type classes. It features curried functions by default and operates as a Lisp-1, but remains a Lisp macro at its core, requiring no separate toolchain.
7:51 Technical Specifications: Launched in 2018, Coalton is an MIT-licensed, statically typed, impure functional language. Its type system exceeds Haskell 95 by including multiparameter type classes. It is strictly evaluated and fully interoperable with Common Lisp (CL), allowing CL calls within Coalton and vice versa.
12:55 Philosophy of Type Systems: The speaker argues that safety alone is a poor selling point for industry. Instead, type systems should be valued for their contributions to documentation, software longevity, collaboration, and, crucially, performance.
15:16 Performance and Optimization: Coalton acts as a code optimizer that performs data representation selection, escape analysis, and the total elimination of runtime type checks. It includes a "Release Mode" that enables aggressive optimizations when the interactive development phase is complete.
17:37 FFT Case Study: A comparison of Fast Fourier Transform (FFT) implementations reveals that while baseline CL and Coalton perform similarly, Coalton achieves a 10x speed increase (0.1s for $2^{20}$ complex double floats) simply by adding top-level type declarations, whereas CL requires pervasive, "ugly" internal declarations to match that speed.
27:01 The Lisp Triangle: Common Lisp developers often face a trade-off between "Fast," "Generic," and "Simple." While CL often requires macros or complex CLOS wizardry to achieve all three, Coalton’s type system allows for generic code that compiles to specialized, high-speed machine code.
35:11 Support for Exotic Types: Coalton enables the implementation of algorithms (like FFT) over non-standard number systems, such as finite fields (integers mod P) or hyperdual numbers, without rewriting the core logic or sacrificing performance.
38:51 Monomorphization: Highlighted as a "superpower," Coalton can eliminate the overhead of generic arithmetic (dictionary passing) by generating specialized versions of functions for specific types at compile-time, similar to Rust or C++ templates.
46:58 Current Limitations and Roadmap: Future work includes refreshing the standard library, resolving type system soundness issues related to mutation, integrating with the CL condition system (restarts/signaling), and improving editor support for Slime/LSP to display type information in real-time.
52:00 Production Status: Coalton is currently used in production for large-scale signal processing applications (~10,000 lines), where a line-for-line port from optimized Common Lisp resulted in a 10% performance increase and 50% reduction in memory allocation (consing).