European Lisp Symposium
Rigid macromolecular channels designed in CANDO achieve ten times the water flux of natural aquaporins and desalt seawater under gravity alone, challenging conventional high-pressure filtration systems.
AI-assisted summary of CANDO: A Compiled Programming Language for Computer-Aided Nanomaterial Design and Optimization — original source. Check the original for full context.
Source published:
Key ideas
- CANDO is a compiled Common Lisp domain-specific language built on the Clasp implementation that integrates 239 first-class C++ chemistry classes and LLVM code generation for macromolecular design. (6:40)
- By replacing flexible peptide backbones with rigid 'spiroligomer' ladder macromolecules, synthetic active sites can achieve precise 3D geometry without relying on unpredictable protein folding. (0:00)
- Simulated bio-inspired aquaporin mimics indicate water flux rates roughly 10 times higher than natural aquaporin channels, operating under minimal hydrostatic head pressure. (24:53)
- Clasp achieves zero-overhead C++ and Common Lisp interoperability by compiling both languages to LLVM bitcode, linking them into a single module, and applying link-time inlining and fastcc calling conventions. (21:13)
Detailed notes
## Background Published on YouTube by the European Lisp Symposium on May 30, 2016, this talk was presented by Christian E. Schafmeister of Temple University at ELS 2016 in Kraków, Poland. The video description details CANDO, a compiled programming language extending the Clasp Common Lisp implementation with an LLVM backend, designed for rapid computer-aided design, 3D coordinate generation, and simulation of macromolecules and nanomaterials.
## TL;DR Chemist Christian Schafmeister introduces spiroligomers—rigid, ladder-like macromolecules designed to bypass the unpredictable folding and instability of natural proteins. Facing a combinatorial design space of up to 10^160 candidate molecules, he built CANDO on top of Clasp Common Lisp to blend dynamic, symbolic Lisp programming with zero-overhead C++ and LLVM native code compilation. Through a live demo in Emacs and SLIME, Schafmeister demonstrates the end-to-end design, energy minimization, and solvation of an artificial aquaporin-like water purification membrane. Computational simulations reveal that this biomimetic channel could achieve an order-of-magnitude higher water flux than biological aquaporins, potentially revolutionizing desalination and municipal water filtration.
## Atmosphere & style The presentation carries the energetic, enthusiastic vibe of an academic hacker bridging deep organic chemistry with cutting-edge compiler engineering. Schafmeister delivers his ideas with candid humor, irreverently dismissing fragile proteins as 'Jell-O like things' and criticizing Python bindings on high-performance C++ libraries as 'putting a jet engine behind a donkey.' Watching him hop interactively into a SLIME debugger mid-optimization makes the talk feel refreshingly hands-on, blending high-stakes scientific ambition—such as averting civilizational water crises—with genuine hacker delight.
## Bulletin - [06:40](https://www.youtube.com/watch?v=5bQhGS8V6dQ&t=400s) CANDO is a compiled Common Lisp domain-specific language built on the Clasp implementation that integrates 239 first-class C++ chemistry classes and LLVM code generation for macromolecular design. - [00:00](https://www.youtube.com/watch?v=5bQhGS8V6dQ&t=0s) By replacing flexible peptide backbones with rigid 'spiroligomer' ladder macromolecules, synthetic active sites can achieve precise 3D geometry without relying on unpredictable protein folding. - [24:53](https://www.youtube.com/watch?v=5bQhGS8V6dQ&t=1493s) Simulated bio-inspired aquaporin mimics indicate water flux rates roughly 10 times higher than natural aquaporin channels, operating under minimal hydrostatic head pressure. - [21:13](https://www.youtube.com/watch?v=5bQhGS8V6dQ&t=1273s) Clasp achieves zero-overhead C++ and Common Lisp interoperability by compiling both languages to LLVM bitcode, linking them into a single module, and applying link-time inlining and fastcc calling conventions.
## Key takeaways - [00:00](https://www.youtube.com/watch?v=5bQhGS8V6dQ&t=0s) Natural proteins are soft, fragile, and difficult to engineer predictably because single-bond flexible chains fold in complex, temperamental ways. - [00:00](https://www.youtube.com/watch?v=5bQhGS8V6dQ&t=0s) Spiroligomers use pairs of chemical bonds between ring building blocks to create rigid ladder-like architectures that position catalytic groups with atomic precision. - [02:04](https://www.youtube.com/watch?v=5bQhGS8V6dQ&t=124s) A proof-of-concept synthetic catalyst modeled after acetylcholinesterase accelerated reaction steps up to 2,500-fold, demonstrating enzyme-like behavior without protein scaffolds. - [02:04](https://www.youtube.com/watch?v=5bQhGS8V6dQ&t=124s) The combinatorial configuration space for designed macromolecules reaches between 10^60 and 10^160 possibilities, making brute-force library screening impossible and demanding native-speed Monte Carlo design loops. - [06:40](https://www.youtube.com/watch?v=5bQhGS8V6dQ&t=400s) CANDO extends Clasp Common Lisp by integrating 155,000 lines of custom C++ and exposing 239 chemistry classes directly into the runtime alongside primitive Lisp types. - [06:40](https://www.youtube.com/watch?v=5bQhGS8V6dQ&t=400s) Tracing garbage collection is essential for computational chemistry software because molecular graphs contain cyclic references that break simple reference counting. - [09:41](https://www.youtube.com/watch?v=5bQhGS8V6dQ&t=581s) CANDO performs symbolic differentiation in Common Lisp and uses LLVM native compilation to generate highly optimized molecular mechanics energy and derivative functions. - [09:41](https://www.youtube.com/watch?v=5bQhGS8V6dQ&t=581s) The platform incorporates a native implementation of SMARTS, functioning like regular expressions for molecular substructures and stereochemistry directly in Lisp. - [10:52](https://www.youtube.com/watch?v=5bQhGS8V6dQ&t=652s) Bio-inspired synthetic water filter channels modeled after aquaporin could theoretically operate up to 1,000 times more efficiently than conventional reverse osmosis systems. - [11:42](https://www.youtube.com/watch?v=5bQhGS8V6dQ&t=702s) CANDO converts 2D ChemDraw topology files into fully minimized 3D coordinate structures using an interactive nonlinear optimization engine within SLIME. - [19:35](https://www.youtube.com/watch?v=5bQhGS8V6dQ&t=1175s) Five grams of designed channel material could form a defect-free filtration membrane covering the area of a football field, permeable under just 27 feet of water head pressure. - [21:13](https://www.youtube.com/watch?v=5bQhGS8V6dQ&t=1273s) Cross-language LLVM bitcode compilation enables Clasp to inline C++ into Common Lisp and utilize the fastcc calling convention with zero interop overhead. - [21:13](https://www.youtube.com/watch?v=5bQhGS8V6dQ&t=1273s) A source code scraper parsing the CL_DEFUN macro automatically generates C++ wrappers, exposing thousands of native functions to the Common Lisp environment. - [23:27](https://www.youtube.com/watch?v=5bQhGS8V6dQ&t=1407s) CANDO serves as a high-level automation platform to construct, vary, and dispatch molecular dynamics simulations across supercomputing clusters running engines like NAMD and OpenMM. - [26:21](https://www.youtube.com/watch?v=5bQhGS8V6dQ&t=1581s) Rigid sub-nanometer channel constrictions reject dissolved salt ions by imposing an insurmountable energetic penalty against stripping their coordinating hydration shells. - [26:21](https://www.youtube.com/watch?v=5bQhGS8V6dQ&t=1581s) Unlike biological aquaporins that degrade within days, synthetic ladder macromolecules offer long-term chemical durability suitable for continuous industrial cross-flow filtration.
## Detailed walkthrough ### [00:00](https://www.youtube.com/watch?v=5bQhGS8V6dQ&t=0s) The Limitations of Natural Proteins and the Invention of Spiroligomers
Christian Schafmeister begins by explaining how natural macromolecular systems function, highlighting biological examples such as antibodies—which adapt and evolve binding pockets when the body faces viral infections—and membrane channels that regulate transport in and out of cells. While these biological structures are exceptionally capable, working with proteins directly presents massive engineering bottlenecks. Schafmeister recalls his background in biophysics and large-protein design:
> “I made one of the first unnatural large proteins by designing it on paper, designing the gene, sticking to bacteria, expressing it, crystallizing it, but the thing was a molecular boat anchor, took me four years to make it, and I didn't know how to make another one, because proteins are horrible to work with.”
Proteins are soft, squishy, "Jell-O like things" that operate reliably only within narrow physiological windows (such as holding them at 37–38 °C for a month to generate organisms like eagles, humans, or trees). Take them out of that environment for even a few minutes, and they turn into something cooked and delicious, but nonfunctional.
To overcome this, Schafmeister invented an alternative chemical strategy roughly 13 to 14 years earlier: building stiff macromolecular scaffolds out of ring-shaped building blocks connected by pairs of bonds (bis-peptides or "spiroligomers") rather than flexible, single-bond linkages. Because flexible chains fold unpredictably, creating rigid ladder-like architectures allows researchers to hang functional groups off the scaffold with atomic-level geometric precision.
```mermaid flowchart LR accTitle: Protein vs Ladder Macromolecule Folding accDescr: Comparison between flexible peptide chains requiring complex folding and rigid ladder oligomers with precise geometry. subgraph NaturalProteins["Natural Proteins"] direction TB A1["Single-bond flexible chain"] --> A2["Unpredictable 3D folding"] A2 --> A3["Soft, squishy active site"] end subgraph Spiroligomers["Rigid Ladder Macromolecules"] direction TB B1["Ring building blocks"] --> B2["Pairs of bonds (rigid ladder)"] B2 --> B3["Fixed spatial catalytic pocket"] end ```
- Flexible peptide chains require unpredictable folding pathways, whereas pairs of bonds force rigid ladder-like geometry without relying on self-folding. - Rigid backbones allow catalytic side chains to be positioned precisely in three dimensions to form artificial enzyme active sites and binding pockets.
---
[02:04](https://www.youtube.com/watch?v=5bQhGS8V6dQ&t=124s) Artificial Enzymes and the Need for a Domain-Specific Language
To demonstrate the capability of this architecture, Schafmeister showcases a small designed catalyst designed to mimic acetylcholinesterase. In the human brain, acetylcholinesterase rapidly hydrolyzes the neurotransmitter acetylcholine between individual nerve pulses to clear the synaptic cleft for subsequent signals. When exposed to organophosphorus nerve agents, this enzyme is blocked, causing neurotransmitter buildup and nervous system failure. With funding from the Department of Defense, Schafmeister’s lab worked on understanding this mechanism and designing synthetic scavengers capable of detoxifying nerve agents.
Their synthetic catalyst fixes three catalytic chemical groups in an exact 3D spatial constellation. When tested, the molecule accelerated its first target reaction step roughly 2,500-fold and the second step about 150-fold, demonstrating genuine enzyme-like catalytic behavior without being consumed. However, natural enzymes accelerate chemical reactions by trillions of times:
> “There's wizardry going on in here, and we haven't achieved that yet, but these are very tiny, and so I need to make larger things to do the sorts of things that our enzymes do.”
Scaling up to larger macromolecules involves connecting multiple modular segments, resulting in systems with astronomical numbers of possible stereochemical and sequence configurations. Schafmeister points out that traditional computational materials design relies on screening virtual libraries through successive computational filters. While viable for small molecules, the configuration space for these macromolecular scaffolds ranges between $10^{60}$ and $10^{160}$ possible molecules—far too large to enumerate, let alone filter exhaustively. Searching such enormous combinatorial landscapes requires starting from a point and running tight Monte Carlo optimization loops on a single processor.
The practical barrier turned out to be the design software itself. Schafmeister initially built custom graphical interfaces and C++ libraries linked through Python wrappers. Every time his synthetic chemistry students introduced a new reaction or attached new building blocks, the rigid software pipeline broke, requiring tedious code rewrites. He concluded that instead of ad-hoc scripts, the field required an expressive programming language:
> “I finally decided what I need is a language; I need a programming language that does for molecules what things like Mathematica or MATLAB does for mathematics or physics.”
- DoD funding supported the development of synthetic enzymes capable of neutralizing chemical nerve agents. - The proof-of-concept catalyst achieved up to a 2,500-fold acceleration on chemical transformation steps. - Exploring a combinatorial design space of $10^{60}$ to $10^{160}$ candidate molecules requires tight, native-speed Monte Carlo loops rather than brute-force library generation.
---
[06:40](https://www.youtube.com/watch?v=5bQhGS8V6dQ&t=400s) CANDO Architecture: Built on Clasp Common Lisp
To solve the architectural challenge, Schafmeister designed CANDO (Computer-Aided Nanomaterial Design and Optimization). CANDO runs as an extension of Clasp, a Common Lisp implementation designed specifically for seamless C++ interoperability using an LLVM compiler backend. While acknowledging with a chuckle that Clasp is essentially the thirteenth active Common Lisp implementation in the world, Schafmeister emphasizes that it uniquely fits his requirements: integrating deeply with massive existing C++ scientific libraries without having to rewrite them.
```mermaid flowchart TD accTitle: CANDO and Clasp Software Hierarchy accDescr: Structural composition of CANDO showing Common Lisp code from ECL, C++ core code, LLVM backend, and domain-specific chemistry classes. subgraph Foundation["Clasp Common Lisp Core"] direction TB ECL["26k lines Common Lisp (from ECL)"] CPP_Core["150k lines C++ Source"] LLVM["LLVM Backend Native Code Gen"] ECL --- CPP_Core CPP_Core --- LLVM end subgraph CandoExt["CANDO Chemistry Extensions"] direction TB CPP_Cando["155k lines CANDO C++ Core"] Classes["239 First-Class C++ Classes\n(Atoms, Bonds, Force Fields, Stereochem)"] CL_Code["CANDO Common Lisp Domain Code"] CPP_Cando --> Classes Classes --> CL_Code end Foundation --> CandoExt ```
CANDO extends Clasp by incorporating 155,000 lines of custom C++ into Clasp’s base (which consists of roughly 150,000 lines of C++ and 26,000 lines of Common Lisp borrowed from Embeddable Common Lisp / ECL). Through template metaprogramming, CANDO registers 239 specialized C++ classes directly into the Common Lisp runtime as first-class, garbage-collected types alongside primitives like `fixnum`, `double-float`, and `hash-table`.
- **First-Class Chemistry Classes**: Atoms, bonds, residues, molecules, stereocenters, and force-field parameters exist natively as garbage-collected objects within Lisp. - **Garbage Collection Needs**: Because molecules are graphs with cyclic structures, reference counting fails and causes memory leaks; a tracing garbage collector is strictly necessary. - **Built-in Physics Optimization**: CANDO integrates non-linear energy minimization directly, allowing researchers to incorporate complex force-field energy functions and leverage symbolic algebra packages like Maxima to derive mathematical energy terms.
[09:41](https://www.youtube.com/watch?v=5bQhGS8V6dQ&t=581s) Chemistry Tooling, Native Code Generation, and Library Integration
Christian Schafmeister outlines the advanced capabilities built directly into CANDO, starting with symbolic manipulation. The system performs symbolic differentiation entirely in Common Lisp, automatically generating fast native code to evaluate molecular energy functions alongside their first and second derivatives. It also features automatic atom type assignment for molecular mechanics energy calculations, stereochemistry handling, and an implementation of SMARTS—a query language functioning like regular expressions for identifying molecular substructures and fragments. Schafmeister emphasizes that although he did not invent SMARTS, implementing it natively in Clasp and CANDO allows users to create powerful, fast, and scalable chemistry tools purely in Common Lisp.
```mermaid flowchart TD accTitle: CANDO Architecture and Integrations accDescr: Diagram illustrating how CANDO combines symbolic math, chemistry rules, and external C++ libraries within Clasp Common Lisp. subgraph LispEnv["CANDO (Clasp Common Lisp)"] A["Symbolic Differentiation"] --> B["Native LLVM Code Gen<br/>(Value, 1st & 2nd Derivatives)"] C["SMARTS Substructure Engine"] D["Stereochemistry & Atom Typing"] end subgraph ExternalLibs["External C++ Libraries"] E["OpenMM (Molecular Dynamics)"] F["Graphics, Docking & Electronic Structure"] end LispEnv <-->|"C++ Template Bindings"| ExternalLibs ```
Beyond its core analytical engine, CANDO is designed to tie into external scientific software written in C++. Schafmeister highlights OpenMM, a high-performance C++ molecular dynamics and modeling package. While OpenMM provides Python bindings, Schafmeister criticizes that architectural pairing, remarking: “they've exposed it to python but it's like putting a jet engine behind a donkey it's just horrible.” His objective with CANDO is to bridge C++ libraries directly into Common Lisp—including graphics engines, docking toolkits, and electronic structure calculation codes—so researchers can drive high-performance computational pipelines natively from expressive Lisp code.
[10:52](https://www.youtube.com/watch?v=5bQhGS8V6dQ&t=652s) Designing Perfect Water Filters: The Aquaporin Mimic
Shifting from language mechanics to practical application, Schafmeister introduces a major research project aimed at designing macromolecular nanostructures. Highlighting the ambition of the initiative, he quips: “this is a little thing that I'm I'm working on right now that I think could Pro you know with further development could help save off the collapse of human civilization so that we have time to fix all of our other products you heard me right I think this is really really important project.” The ultimate goal is to fabricate ultra-efficient synthetic water purification membranes, an effort funded by the U.S. Army Corps of Engineers.
The design is bio-inspired, modeled after aquaporin proteins found in human kidneys that regulate osmotic balance across cell membranes by selectively conducting water while blocking all solutes. In contrast to existing energy-intensive technologies, such as the massive reverse osmosis plants constructed in California, Schafmeister explains that an artificial aquaporin-like channel could theoretically operate up to 1,000 times more efficiently. However, real-world synthesis requires proving and refining the architecture through rigorous computational modeling beforehand.
[11:42](https://www.youtube.com/watch?v=5bQhGS8V6dQ&t=702s) Live Demo: From 2D Sketch to 3D Energy Minimization in SLIME
Schafmeister transitions into a live interactive demonstration using Emacs and SLIME connected to a running CANDO/Clasp environment. He compiles and evaluates initialization code that loads ASDF systems, sets up working directories, and defines Common Lisp helper functions for geometric transformations, line maintenance, unit-cell construction, and degree-to-radian conversions.
The molecular structure originates as a chemical drawing in ChemDraw—a tool he likens to “Adobe Illustrator but for molecules.” CANDO reads the exported XML file from ChemDraw and constructs a molecular graph data structure. At import time, the graph possesses no spatial coordinates, and stereocenters (R/S designations on chiral carbon centers) are configured programmatically.
```mermaid flowchart LR accTitle: Molecular Structure Setup Pipeline accDescr: Pipeline showing the process from 2D ChemDraw XML to a fully minimized 3D coordinate structure. A["ChemDraw XML<br/>(2D Topology)"] --> B["CANDO Graph<br/>(All ~1,000 Atoms at 0,0,0)"] B --> C["Assign Random<br/>Coordinates"] C --> D["Nonlinear Energy Minimization<br/>(Steepest Descent / Conjugate Gradient / Truncated Newton)"] D --> E["Optimized 3D Single Channel"] ```
To establish a 3D conformation for the roughly 1,000 atoms starting at the origin `(0, 0, 0)`: - Atoms are initially assigned random 3D spatial coordinates. - CANDO formulates the molecule's physical constraints as an energy minimization problem, treating chemical bonds and bond angles as mechanical springs with equilibrium lengths, angles, and force tensions. - A nonlinear optimization engine written in C++ minimizes strain using a cascade of steepest descent, conjugate gradients, and a truncated Newton-Raphson minimizer. - Energy evaluation routines rely on CANDO’s JIT code generation from symbolic derivatives for performance. - Schafmeister interrupts the long-running optimization with `Ctrl-C` to demonstrate SLIME’s interactive debugger, inspecting stack backtraces and lexical arguments mid-run before loading the converged 3D single-channel structure.
[16:00](https://www.youtube.com/watch?v=5bQhGS8V6dQ&t=960s) Membrane Array Tiling and High-Performance Lisp Solvation
With an optimized single channel in hand, Schafmeister needs to construct a periodic membrane for molecular dynamics. The channel is designed so that water enters from one side, traverses the pore, and exits the opposite face. In Common Lisp, he tiles these units into an ordered two-dimensional membrane array.
```mermaid flowchart TD accTitle: Assembly of Solvated Membrane Simulation System accDescr: Steps to tile channels into an array, apply external water boxes, and carve out boundary regions in Common Lisp. A["Single Channel Prototype"] --> B["Tile into 2D Membrane Array"] C["Pre-equilibrated Water Box"] --> D["Tile 4x Water Boxes<br/>(Top and Bottom)"] B --> E["Assemble Composite System"] D --> E E --> F["Lisp 'molecule-in-box' Filter<br/>(Carve water layers & remove overlaps)"] F --> G["Simulation-Ready System<br/>(MD Engines: OpenMM/AMBER)"] ```
Simulating biological channels requires explicit solvation: - A pre-equilibrated box of water molecules is imported and replicated in a 2×2 tile (four water boxes total) to encompass the dimensions of the expanded membrane. - The solvent must be trimmed to create water slabs above and below the channel without colliding with the membrane itself. - Schafmeister inspects the trimming logic implemented in functions like `molecule-in-box`, which query a CLOS bounding-box class to filter out solvent molecules outside defined spatial limits. - He notes that while historically such intensive per-atom spatial filtering would have been pushed into C++ for speed, Clasp's performance makes it viable directly in Common Lisp: “I normally couple of months ago I would have never thought to do it anywhere but C++ because this has to be fast but now this is fast enough I can run it in common list”.
[19:35](https://www.youtube.com/watch?v=5bQhGS8V6dQ&t=1175s) Simulation Results and Theoretical Limits of Filtration
Schafmeister presents rendering results from molecular dynamics runs that consumed several days of supercomputer compute time to simulate just a few nanoseconds of physical time. With bulk water rendered invisible, the visualization displays water molecules rapidly filling and moving through the interstitial voids of the membrane matrix. The observation that water easily permeates along both axes suggests that applying low hydrostatic pressure would produce sustained, unidirectional flow.
Schafmeister explains the quantitative implications of this synthetic architecture: - Just 5 grams of this synthesized macromolecular material—an amount small enough to hold in the palm of a hand—could be spread out into an ultra-thin, defect-free membrane covering the area of an entire soccer pitch (football field). - Approximately one-third of that entire surface area consists of open, permeable channels, effectively acting as an unobstructed pipe with a cross-section equal to one-third of a football field. - Instead of requiring the extreme hydraulic pressures needed to drive reverse osmosis, a gentle water column of merely 27 feet under gravity alone would permeate the barrier, providing enough clean drinking water for a whole city.
He concludes by asserting the thermodynamic limits of the design: “there is no theoretically there's no way in this universe to make a better membrane than this and this could be used to purify anything water all sorts of [things]”. While the material remains computational at this stage, his laboratory at Temple University is seeking research funding to synthesize the physical molecules and validate the filtration behavior experimentally.
[21:13](https://www.youtube.com/watch?v=5bQhGS8V6dQ&t=1273s) Clasp, LLVM Link-Time Optimization, and Zero-Overhead C++ Interop
Christian Schafmeister wraps up the presentation by explaining the recent progress in CANDO and Clasp, emphasizing how fresh these results are. The simulation shown on screen is only about four weeks old, representing the point where CANDO has finally become fast enough to build molecules again after several years spent heads-down building the underlying Common Lisp environment.
Turning to implementation details, Schafmeister outlines how Clasp bridges Common Lisp and C++ via LLVM. Clasp compiles its Common Lisp code to LLVM bitcode, while the C++ code is also compiled to LLVM bitcode using Clang. By linking both representations together into a single module, Clasp runs LLVM optimization passes across the language boundary. Code gets automatically inlined wherever it makes sense; when inlining is inappropriate because a function is too large, it gets promoted to the LLVM fast calling convention (`fastcc`) with optimal register matching. As Schafmeister highlights, “Basically I can hook into C++ code with no overhead compared to C++ talking to C++.”
Exposing native C++ libraries to Common Lisp requires minimal manual effort. A developer simply annotates existing C++ code with a custom `CL_DEFUN` macro. Schafmeister's source code scraper parses these annotations, automatically builds the required wrapper glue, and exports the bindings directly into the running Common Lisp environment. The entire Clasp implementation exposes thousands of functions through this automated scraping pipeline.
```mermaid flowchart TD accTitle: Clasp Cross-Language LLVM Compilation Pipeline accDescr: Pipeline showing Common Lisp and C++ compiling to LLVM bitcode, linking, running optimization passes, and outputting native binaries.
subgraph Sources ["Source Code"] CPP["C++ Source Files<br/>(annotated with CL_DEFUN)"] CL["Common Lisp Code<br/>(CANDO / User Code)"] end
subgraph LLVM_Stage ["LLVM Bitcode Generation & Linking"] ClangCompiler["Clang Compiler"] ClaspCompiler["Clasp Compiler"] Linker["LLVM Linker<br/>(Single Module)"] end
subgraph Passes ["LLVM Optimization Passes"] Inline["Full Inlining Across Boundaries"] FastCC["fastcc Calling Convention<br/>(Register Matching)"] end
CPP --> ClangCompiler -->|"Bitcode"| Linker CL --> ClaspCompiler -->|"Bitcode"| Linker Linker --> Inline --> FastCC FastCC --> Native["Optimized Native Code<br/>(Zero Overhead Interop)"] ```
- CANDO reached performance parity to design molecules after a couple of years dedicated strictly to Common Lisp infrastructure development. - Inter-language optimization is achieved by cross-compiling both C++ and Common Lisp down to LLVM bitcode and linking them before running inlining passes. - Functions not inlined are assigned the `fastcc` calling convention for register-level call speed. - The automated `CL_DEFUN` scraping tool manages thousands of wrapped C++ functions across the Clasp runtime without requiring manual Foreign Function Interface (FFI) bindings.
---
[23:27](https://www.youtube.com/watch?v=5bQhGS8V6dQ&t=1407s) Molecular Dynamics Simulations and Scalable Channel Evaluation
Opening the floor to questions, Schafmeister responds to an audience inquiry about simulating membrane function. In these simulations, ions are introduced into the water regions surrounding the designed membrane channels under periodic boundary conditions. The underlying molecular mechanics engine continuously evaluates interatomic forces and moves the atoms by incremental timesteps before recalculating the forces.
Schafmeister points out that molecular dynamics simulations remain inherently compute-intensive: “It's hideously slow; it takes days to simulate nanoseconds of time, but that's what NAMD and that's what all these molecular dynamics engines do very well.” CANDO's distinct value is not replacing these high-performance dynamics engines, but serving as a rapid setup and automation layer. It can generate millions of combinatorial channel variants, dispatch parallel runs across hundreds of thousands of CPU cores on supercomputers, and automate the post-simulation analysis to determine which synthetic channels perform best.
- Molecular dynamics engines like NAMD handle numerical integration of atomic forces over multi-day runs for nanosecond-scale trajectories. - CANDO automates high-throughput setup, variation, and execution across large-scale parallel architectures. - Periodic boundary conditions are used to model infinite membrane lattices in aqueous environments.
---
[24:53](https://www.youtube.com/watch?v=5bQhGS8V6dQ&t=1493s) Water Flux Tracking and Aquaporin Performance Comparisons
An audience member asks about how flow through the channel is quantified. Schafmeister explains that their analysis code tracks the coordinates and trajectories of individual water molecules across the periodic cell over time to compute the total membrane flux. If a synthetic channel pore is packed too tightly, water molecules cannot enter; instead, they strike the constriction point and bounce right back out into the bulk solvent.
When the pore dimensions are tuned correctly, however, the structure behaves like a sieve. Simulated water flux through these engineered channels reaches rates roughly ten times higher than natural aquaporin proteins. Schafmeister mentions that he collaborates with researchers at the University of Illinois—specifically mentioning a student named Karl—who have spent years simulating natural aquaporins and evaluating their transport dynamics.
- Membrane permeability is calculated by directly tracking the displacement vectors of individual water molecules through the pore. - Overly tight pore packing causes water molecules to reflect off the entrance rather than permeate the channel. - Optimized synthetic channels demonstrate water flux rates roughly an order of magnitude (10×) higher than biological aquaporins. - Research collaborators at the University of Illinois provide validation based on their long-term modeling of aquaporin structures.
---
[26:21](https://www.youtube.com/watch?v=5bQhGS8V6dQ&t=1581s) Water Desalination, Ion Rejection, and Membrane Longevity
In response to a question regarding filtering molecules larger than water, Schafmeister details how these channels can be applied to seawater desalination. Seawater consists primarily of sodium and chloride ions dissolved in water, with each ion surrounded by a tightly bound shell of coordinating water molecules. For an ion to pass through a narrow channel, this hydration shell must be stripped away. By engineering the channel constriction to be narrow and rigid, the energetic penalty required to dehydrate the ion becomes too steep for the ion to enter, effectively blocking salt while allowing individual water molecules through.
The separated ions accumulate on the feed side of the membrane, meaning the system cannot run as a dead-end filter where material is simply forced against a blind barrier. Instead, it must operate using a countercurrent cross-flow setup identical to standard industrial reverse osmosis, sweeping feed seawater across the membrane face to concentrate it into brine while pure water permeates to the other side.
Comparing this technology to biological channels and existing polymer systems, Schafmeister highlights membrane durability: - Biological aquaporins denature and lose integrity over timescales of hours to days, requiring living cells to constantly degrade and recycle them. - Synthetic, rigid macromolecular channels are far more robust and could operate for extended lifetimes. - Like all filtration media, the membranes remain susceptible to surface fouling, requiring periodic back-flushing cycles to maintain throughput. - When evaluating the current commercial standard, Schafmeister pulls no punches on the state of the art: “Reverse osmosis membranes are just terrible technology; they're just the best we have.”
The session concludes as the symposium timekeeper intervenes to bring the questions and the talk to a close.
## Notable quotes > [02:04](https://www.youtube.com/watch?v=5bQhGS8V6dQ&t=124s) I need a programming language that does for molecules what things like Mathematica or MATLAB does for mathematics or physics. — Christian Schafmeister
> [26:21](https://www.youtube.com/watch?v=5bQhGS8V6dQ&t=1581s) Reverse osmosis membranes are just terrible technology; they're just the best we have. — Christian Schafmeister
> [21:13](https://www.youtube.com/watch?v=5bQhGS8V6dQ&t=1273s) Basically I can hook into C++ code with no overhead compared to C++ talking to C++. — Christian Schafmeister
## Mentioned Christian E. Schafmeister, CANDO, Clasp, Common Lisp, LLVM, Clang, Embeddable Common Lisp, OpenMM, NAMD, AMBER, ChemDraw, SLIME, Emacs, ASDF, Maxima, SMARTS, Department of Defense, U.S. Army Corps of Engineers, Temple University, University of Illinois
## Video description ELS 2016, 9th European Lisp Symposium, 9-10 May 2016, Department of Computer Science, AGH University of Science and Technology, Kraków, Poland.
Christian E. Schafmeister, Chemistry Department, Temple University, 1901 N. 13th Street Philadelphia, PA.
CANDO is a compiled programming language designed for rapid prototyping and design of macromolecules and nano- meter-scale materials. CANDO provides functionality to write programs that assemble atoms and residues into new molecules and construct three-dimensional coordinates for them. CANDO also provides functionality for searching molecules for substructures, automatically assigning atom types, identifying rings, carrying out conformational search- ing, and automatically determining stereochemistry, among other things. CANDO extends the Clasp implementation of the dynamic language Common Lisp. CANDO provides classes for representing atoms, residues, molecules and ag- gregates (collections of molecules) as primitive objects that are implemented in C++ and subject to automatic memory management, like every other object within the language. CANDO inherits all of the capabilities of Clasp, including the easy incorporation of C++ libraries using a C++ tem- plate programming library. This automatically builds wrap- per code to expose the C++ functionality to the CANDO Common Lisp environment and the use of the LLVM li- brary[1] to generate fast native code. A version of CANDO can be built that incorporates the Open Message Passing Interface C++ library[2], which allows CANDO to be run on supercomputers, in order to automatically setup, start, and analyze molecular mechanics simulations on large par- allel computers. CANDO is currently available under the LGPL 2.0 license.
[Source](https://www.youtube.com/watch?v=5bQhGS8V6dQ)