Lean C is a sugar-coated C DSL (Domain-Specific Language) designed not to replace C/C++, but to serve as a lightweight, fully transparent transpiler. It allows developers to enjoy high-level language conveniences while producing clean, native C code.
Due to personal considerations, I rarely write C code anymore and have decided not to continue development of Lean C. The project remains as a prototype and reference. If you are interested in the DSL’s syntax features, feel free to implement or extend them independently.
Writing standard C often forces a trade-off between safety and control. Lean C bridges this gap by introducing modern safety features without sacrificing low-level performance or predictability.
Every line of Lean C code closely resembles native C. The transpiler acts with total transparency—apart from the core guard syntaxes, all other C code is printed verbatim.
Lean C strictly adheres to three core disciplines:
- Zero Auto Malloc/Free: No implicit or hidden dynamic memory allocation. Memory is only allocated when you explicitly call
malloc. - No Black Box: The code remains fully transparent. What you see is exactly what the compiler expands into predictable C code.
- As Simple as Possible: We avoid syntax bloat. Lean C does not introduce Object-Oriented Programming (OOP) or asynchronous runtimes. Instead, it focuses exclusively on eliminating C’s biggest pain points: out-of-bounds memory access and resource leaks.
- Native Boolean Type: Seamless
boolsupport without header management headaches. - Safe String Type (
c_string_t): Built-in bounds checking and safer string manipulations. - Generic Array Type (
c_array_t<T>): Type-safe, dynamic, or fixed-size array wrappers. deferStatement: Elegant, Go-like modern resource cleanup and RAII-lite patterns.- Static Reflection: Compile-time metadata without runtime performance overhead.
Lean C focuses on being a lightweight syntactic sugar coat, not a new heavyweight language. The following features are explicitly out of scope:
- A Complex Generic Template System: No heavy template metaprogramming or C++-style bloating.
- A Standard Container Library: We do not provide heavy built-in collections; we complement existing C solutions.
- A Full OOP Class System: No complex inheritance or virtual tables (v-tables).
- Garbage Collection: Zero implicit runtime overhead; resource management remains explicit and deterministic.
Copyright (c) 2026 ByteBard. Licensed under the MIT License.