explaingit

panshaogui/l2c

Analysis updated 2026-05-18

3LuaAudience · developerComplexity · 5/5LicenseSetup · hard

TLDR

A compiler that turns a typed subset of Lua into garbage-collector-free native C, for trading systems and embedded devices.

Mindmap

mindmap
  root((L2C))
    What it does
      Lua to C transpiler
      No garbage collector
      Ahead of time compile
    Tech stack
      Lua
      C
      Docker
      ZeroMQ
    Use cases
      HFT strategies
      Embedded firmware
      Predictable latency
    Audience
      Systems programmers
      Trading engineers

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Write high frequency trading strategy logic without garbage collector pauses.

USE CASE 2

Compile Lua-like code into firmware for Raspberry Pi Pico or ESP32.

USE CASE 3

Build small, fast standalone executables with predictable memory use.

What is it built with?

LuaCDockerZeroMQSQLite

How do you get it running?

Difficulty · hard Time to first run · 1h+

Requires Docker and cross-compilation toolchains for embedded targets.

In plain English

L2C is a compiler that turns a strict, typed subset of the Lua programming language into native C code with no garbage collector. It is built for two very different but equally demanding worlds: high frequency trading systems, where even a tiny pause to clean up memory can cost money, and small embedded devices like the Raspberry Pi Pico or ESP32, where there is barely any memory to spare in the first place. The core idea is that Lua's friendly, script like syntax is easy to write, but its usual garbage collector introduces unpredictable pauses. L2C removes that garbage collector entirely and forces the programmer to use fixed, pre-allocated blocks of memory instead. It supports things like fixed size buffers, a pool of memory that can be instantly reset between processing steps, and direct ways to read raw bytes as structured data without the usual conversion overhead. In exchange for this control, L2C deliberately refuses to support features that need a garbage collector, such as joining strings on the fly, flexible dictionaries, closures that capture variables, or coroutines. The project also ships a small standard library of ready made connectors to popular C and C++ tools, covering fast networking, lightweight databases, JSON parsing, asynchronous event loops, and bare metal operating systems for microcontrollers. To build a program, developers write their logic in this typed Lua subset, then use Docker based build environments to compile it into either a small standalone program for a regular computer or firmware for a microcontroller. This is a niche, opinionated tool aimed squarely at experienced systems programmers working on trading software or embedded firmware who want Lua's simpler syntax without giving up the speed and predictability of hand written C. It is not meant as a general purpose Lua compiler, and the maintainer states plainly that requests to add garbage collection support will not be accepted.

Copy-paste prompts

Prompt 1
Help me write an L2C strategy file that connects to a ZeroMQ market data feed.
Prompt 2
Explain how L2C's tick-level arena allocator avoids garbage collection.
Prompt 3
Show me how to cross-compile an L2C program for the ESP32.
Prompt 4
What Lua features can't I use in L2C's strict subset?

Frequently asked questions

What is l2c?

A compiler that turns a typed subset of Lua into garbage-collector-free native C, for trading systems and embedded devices.

What language is l2c written in?

Mainly Lua. The stack also includes Lua, C, Docker.

How hard is l2c to set up?

Setup difficulty is rated hard, with roughly 1h+ to a first successful run.

Who is l2c for?

Mainly developer.

Open on GitHub → Explain another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.