Skip to content

MayaFlux/lilacode

Repository files navigation

LilaCode

Also available for Neovim: lila.nvim

Live C++ Coding in VS Code

LilaCode is a VS Code extension for real-time, interactive live coding of C++ directly in your editor. It connects to the Lila REPL server, an incremental Clang/LLVM JIT compiler, and evaluates code with near-zero latency (~1ms, designed for 1 buffer/frame cycle).

Overview

Lila is MayaFlux's embedded live coding engine: an LLVM 21+ backed C++ JIT interpreter that compiles and executes arbitrary C++ code at runtime with sub-buffer latency. LilaCode brings this into VS Code, closing the gap between writing code and running it.

Why Live Coding in C++?

  • Instant feedback : execute code in milliseconds without recompiling
  • Exploratory development : iterate on algorithms, DSP, and graphics pipelines interactively
  • Deterministic latency : 1 buffer/frame cycle, designed for real-time systems
  • Full C++ capability : execute any valid C++20 code, access all linked libraries
  • Persistent state : modifications layer onto previous evaluations; your session accumulates

Live coding is a fundamentally different way to work, closer to the exploratory, feedback-driven workflows of Lisp and SuperCollider, but with C++'s performance and MayaFlux's real-time guarantees.

Features

  • Evaluate Line : execute a single line (Ctrl+Alt+E)
  • Evaluate Selection : run highlighted code (Ctrl+Alt+S)
  • Evaluate Buffer : execute the entire file (Ctrl+Alt+B)
  • Evaluate Node : run semantic code blocks, experimental (Ctrl+Alt+N)
  • Eval Highlight : sent code flashes in the editor so you always know what was dispatched
  • MayaFluxHost : connect directly to a host process without lila_server
  • MayaFlux Docs : Ctrl+Alt+D opens the Doxygen page for the symbol under cursor
  • Live Output : see compilation results, errors, and output in the integrated console
  • Real-Time Status : monitor connection state at a glance
  • Session Persistence : state accumulates across evaluations

Installation

LilaCode Extension

Search for "LilaCode" in the VS Code Extensions marketplace and install, or download the .vsix from Releases and install via Ctrl+Shift+P > "Extensions: Install from VSIX...".

MayaFlux and Lila

Lila ships as part of MayaFlux. The easiest way to install MayaFlux and get a project set up for live coding is Weave, the MayaFlux installer and project creator.

Install MayaFlux:

Download and launch Weave from Releases and choose Install MayaFlux. Weave handles the full installation including dependencies and environment setup.

Create a project with live coding:

Once MayaFlux is installed, open Weave again and choose Create Project. Check Enable Live Coding (Lila) before creating. This configures your project's CMake to link MayaFlux::MayaFluxHost, which is what enables the Lila JIT in your process.

After building your project, lila_server will be available and LilaCode can connect to it.

Quick Start

Basic Workflow

1. Open a C++ file

int x = 10;
int y = 20;

2. Send code to Lila

Evaluate line by line with Ctrl+Alt+E, or select multiple lines and press Ctrl+Alt+S.

3. See results

The "Lila" output panel shows successful evaluations, compilation errors with Clang diagnostics, and any printed output.

State Persistence

State persists across evaluations within a session:

int counter = 0;  // Evaluate once
counter++;
std::cout << counter << std::endl;  // Prints: 1

This lets you build up complex systems incrementally.

Connecting to MayaFluxHost

Projects created with live coding enabled link MayaFlux::MayaFluxHost, which embeds the Lila JIT directly in your running process. You can connect LilaCode to that process instead of using a separate lila_server binary.

Run Lila: Connect to MayaFluxHost from the command palette and enter host:port. This is the typical workflow for MayaFlux projects, letting you evaluate code against your live audio/visual state:

#include "MayaFlux/MayaFlux.hpp"

auto sine = vega.Sine(200) | Audio[{0, 1}] ;
sine->set_frequency(300);  // Change pitch while the process is running

Commands

Command Shortcut Description
lila.startServer Start the Lila REPL server
lila.stopServer Stop the server and disconnect
lila.restartServer Restart the server
lila.connect Manually connect to a running server
lila.connectHost Connect directly to a MayaFluxHost at host:port
lila.disconnect Disconnect from the server
lila.evalLine Ctrl+Alt+E Evaluate the current line
lila.evalSelection Ctrl+Alt+S Evaluate selected code
lila.evalBuffer Ctrl+Alt+B Evaluate the entire file
lila.evalNode Ctrl+Alt+N Evaluate a semantic code block (experimental)
lila.showOutput Show the Lila output panel
lila.clearOutput Clear the output console
lila.showStatus Display connection and server status
lila.openDocs Ctrl+Alt+D Open MayaFlux docs for symbol under cursor

Access all commands via Ctrl+Shift+P and type "Lila".

Configuration

{
  "lila.host": "127.0.0.1",
  "lila.port": 9090,
  "lila.serverPath": "lila_server",
  "lila.autoStartServer": true,
  "lila.autoConnect": true
}

If lila_server is not in your PATH, set the full path in lila.serverPath.

Server Options

lila_server -p 9090 -v -l DEBUG
  • -p, --port <port> -- server port (default: 9090)
  • -v, --verbose -- enable verbose logging
  • -l, --level <level> -- log level: TRACE, DEBUG, INFO, WARN, ERROR, FATAL
  • -h, --help -- show help

MayaFlux Documentation

On activation, LilaCode fetches the MayaFlux symbol index from the documentation site. Place your cursor on any MayaFlux symbol and press Ctrl+Alt+D to open its Doxygen page in your browser. Works in standalone .cpp files without a full project setup.

Architecture

How It Works

  1. Extension Activation : loads on command or when opening .cpp files
  2. Server Launch (optional) : start lila_server via Lila: Start Server, or skip if using MayaFluxHost
  3. Client Connection : establishes a TCP connection (default: 127.0.0.1:9090)
  4. Code Submission : sends C++ code over TCP
  5. JIT Compilation : server uses Clang's incremental compiler
  6. Execution : compiled code runs in-process with access to all linked libraries
  7. Result Return : output, errors, and results stream back to VS Code

Connection States

  • Disconnected (○) : not connected
  • Connecting (○) : attempting connection
  • Connected (✓) : ready to evaluate
  • Error (✗) : connection failed

Session Model

Each Lila session maintains a symbol table, compiled code history, and execution context. State from one evaluation is available to the next, enabling incremental development.

Performance

  • Compilation latency : ~1ms per evaluation (LLVM JIT cached)
  • Execution latency : typically under 1ms for simple operations
  • Buffer cycle : designed for 1 buffer/frame timing (~21-42ms at typical buffer sizes)
  • Memory : incremental compilation minimizes allocations; restart server to reset state

Troubleshooting

Server fails to start

Check that lila_server is in your PATH:

which lila_server

If not found, set lila.serverPath in VS Code settings, or run manually to check for errors:

lila_server -v -l DEBUG

Connection times out

  1. Run Lila: Show Status
  2. Verify lila.host is 127.0.0.1
  3. Try a different port if 9090 is in use
  4. Run Lila: Restart Server
  5. Check View > Output > Lila

Code does not evaluate

  1. Check the Lila output console for error messages
  2. Verify C++ syntax (Clang reports diagnostics directly)
  3. Ensure required headers are available
  4. Try a minimal test: int x = 42;
  5. Restart the server and reconnect

Compilation errors

Common causes:

  • Missing includes : add #include directives or check PCH setup in server logs
  • Undefined symbols : symbols from prior evals should persist; restart server if not
  • Type errors : verify C++20 syntax and template instantiations
  • Linker errors : ensure libraries are linked to the Lila server binary

Limitations

  • Local connections only (127.0.0.1)
  • No persistent sessions between editor restarts (state resets when server stops)
  • No debugger integration yet (planned)
  • No symbol introspection UI yet (planned)
  • Large evaluations may have noticeable compile time
  • Output console does not render ANSI color from server responses

Roadmap

  • Breakpoint debugging
  • Symbol introspection with hover
  • REPL history browser
  • Multi-file sessions
  • Performance profiling output
  • Remote and collaborative sessions

Contributing

Issues, feature requests, and contributions welcome on GitHub.

License

GNU General Public License v3.0. See LICENSE for full terms.


LilaCode: Live C++ coding without barriers. Execute, iterate, explore.

For more on the MayaFlux philosophy and vision, see the main project README.

About

VSCode client plugin for Lila Live Coding JIT Server (MayaFlux)

Resources

License

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors