Direct
Generates C, keeps the runtime visible, and lets the normal C toolchain do the final native build.
Transpiles to C
A C-shaped language that transpiles to C, keeps the native toolchain intact, and adds cleaner declarations, monomorphized generics, reflection, and a small standard library.
Generates C, keeps the runtime visible, and lets the normal C toolchain do the final native build.
Monomorphized structs and procedures give you reusable data structures without moving into C++.
Structs and enums produce metadata for fields, offsets, names, sizes, and future tooling.
Syntax Examples
Quickstart
Pull Haikal, tree-sitter, and support scripts.
git submodule update --init --recursive
Builds I.exe and copies the compiler plus src/std into the package folder.
python bunyan.py build debug
Add the package folder to PATH. The compiler finds its sibling std automatically.
C:\devel\i-windows-x64
Bunyan calls I.exe, writes generated C under build\i_gen, then compiles it normally.
python bunyan.py run debug
Features
I is designed as a focused compiler front-end. The generated C remains visible and normal toolchains do the final build.
Variables, types, procedures, and globals use name: type, keeping type information near the symbol being introduced.
Generic structs and procs use <T>. Concrete uses such as Array<i32> emit concrete C names.
Known types in generic positions specialize the body, so print<Payload> is the typed extension point behind printfmt.
Generic procedures can call typed operations such as eq<T>, add<T>, or print<T>; concrete specializations provide the behavior.
if, for, while, do while, switch, break, and continue map directly to C.
Enum values use namespaced dot syntax such as Mode.Attack, while generated C keeps stable concrete symbol names.
Use external for declarations that already exist in C headers and external_emit when I should emit a prototype.
The compiler writes a companion header next to the generated C so imports can type-check against I modules.
Struct and enum output includes reflection records for names, sizes, fields, offsets, and enum values.
Lexer, parser, and semantic errors include source path, line, and column.
C Interop
I emits C includes, defines, declarations, and line directives. The generated C is an artifact you can inspect and debug.
import "math.i"
cinclude "stdio.h"
define("SAHA_IMPLEMENTATION")
import is for I modules. C headers are included through emitted C includes.
puts: proc(text: *const char)->i32 = { external; }
fx_step: proc(dt: f32)->void = { external_emit; }
external type-checks only. external_emit also writes a C prototype.
I.exe compile src\main.i -o build\i_gen\main.c --header build\i_gen\main.h
I.exe check src\main.i --diagnostics=json
Use compile, check, symbols, or lsp. Project-local imports use --importdir; packaged std is found next to I.exe.
Build Flow
Building the compiler repo produces I.exe and copies src/std beside it.
An I project invokes I.exe compile from PATH or a package folder.
I.exe resolves project imports plus its sibling std package.
Generated C and headers are written under build\i_gen.
The normal C compiler links generated I output with any C/vendor sources.