"Know your roots." — tnC is a systems programming language and toolchain built from absolute zero, with no dependency on C or any C-derived compiler, ever. The entire bootstrap chain is auditable, from raw machine code to a self-hosting compiler.
Every mainstream systems language today — C++, Rust, Go, Zig — was first compiled by a C compiler. Their compilers still depend on C/C++ toolchains to build. This creates an opaque trust chain: you must trust GCC/Clang (millions of lines of C/C++) to trust anything built on top.
tnC breaks this chain.
| Property | tnC |
|---|---|
| Trust root | 313 bytes of hand-written hex (auditable in an afternoon) |
| Stage 0a | hex0 — hex-to-binary converter (hand-written x86-64 ELF) |
| Stage 0b | hex1 — hex with label support (built by hex0) |
| Stage 0c | tnc_asm — x86-64 assembler (built by hex1) |
| Stage 1 | tnc_boot — bootstrap tnC compiler in assembly (built by tnc_asm) |
| Stage 2 | tnc — full self-hosting tnC compiler in tnC (built by tnc_boot) |
| Dependencies on C | Zero. None. Never. |
- Systems-level: Direct memory access, pointer arithmetic, inline assembly
- Modern safety: Optional bounds checking, ownership tracking, defer
- Clean syntax: No preprocessor, no header files, no forward declarations
- Modules: First-class module system with explicit imports/exports
- Generics: Compile-time parametric polymorphism
- Error handling: Sum types / tagged unions with pattern matching
- Zero-cost abstractions: Traits/interfaces with static dispatch
- Cross-platform: x86-64 Linux (primary), ARM64, more planned
# 1. Build the entire bootstrap chain — requires only: a POSIX shell
./build.sh seed
# 2. Or step by step:
./build.sh hex0 # Build hex0 (313 bytes, the trust anchor)
./build.sh seed # Build hex0 → hex1 → tnc_asm
./build.sh stage1 # Build Stage 1 bootstrap compiler
./build.sh stage2 # Build Stage 2 self-hosting compiler
# 3. Verify the trust chain
./build.sh verify # hex0 self-rebuild test + chain verification
# 4. Once you have tnc:
./build/stage2/tnc examples/hello.tnc -o hello
./helloThe trust anchor is hex0: 313 bytes of hand-written hexadecimal that you can
audit by reading it alongside the x86-64 ISA manual.
The source file bootstrap/stage0/hex0_x86-64.hex is fully annotated — every byte
is documented. hex0 can rebuild itself from its own source, proving the hex is a
faithful representation of the binary.
// hello.tnc
mod main;
use std.io;
pub fn main() -> i32 {
io.println("Hello, world! No C was harmed in the making of this binary.");
return 0;
}
tnC/
├── bootstrap/ # The sacred bootstrap chain
│ ├── stage0/ # Trust root: hex seeds and assembler
│ │ ├── hex0_x86-64.hex # THE trust anchor (313 bytes, hand-written)
│ │ ├── hex0.asm # Human-readable reference for hex0
│ │ ├── hex1_x86-64.hex # hex-with-labels (built by hex0)
│ │ └── tnc_asm.asm # Assembler reference implementation
│ ├── stage1/ # Bootstrap compiler (built by tnc_asm)
│ │ └── tnc_boot.asm # Minimal tnC compiler in x86-64 assembly
│ ├── hex0_build.sh # POSIX-only hex0 builder (uses sed + printf)
│ └── build_seed.sh # Full bootstrap chain builder
├── compiler/ # Self-hosting tnC compiler (Stage 2)
│ ├── main.tnc # Compiler entry point & CLI
│ ├── lexer/lexer.tnc # Tokenization
│ ├── parser/parser.tnc # AST construction (recursive descent)
│ ├── sema/sema.tnc # Semantic analysis & type checking
│ ├── ir/ir.tnc # Intermediate representation & optimizer
│ ├── codegen/codegen.tnc # x86-64 code generation & register allocation
│ └── linker/linker.tnc # ELF binary output
├── stdlib/ # Standard library (pure tnC + syscalls)
│ ├── core/core.tnc # Fundamental types (Option, Result, traits)
│ ├── os/os.tnc # Linux syscall wrappers
│ ├── mem/mem.tnc # Memory allocation (brk-based)
│ ├── io/io.tnc # Buffered file & console I/O
│ ├── str/str.tnc # String handling
│ ├── math/math.tnc # Mathematics
│ ├── collections/ # Vec, HashMap, etc.
│ └── test/test.tnc # Test framework
├── tests/ # Test suite
├── examples/ # Example programs
├── docs/spec/ # Language specification & bootstrap docs
├── build.sh # Master build script (POSIX shell only)
└── README.md
┌─────────────────────────────────────────────────────────┐
│ hex0_x86-64.hex (313 bytes, hand-written, annotated) │
│ Audit this file. That's all you need to trust. │
└──────────────┬──────────────────────────────────────────┘
│ POSIX shell (sed + printf) — one-time text→binary
▼
┌─────────────────────────────────────────────────────────┐
│ hex0 — reads hex pairs from stdin, outputs raw bytes │
│ Verified: rebuilds itself from its own source │
└──────────────┬──────────────────────────────────────────┘
│ hex0 < hex1_x86-64.hex > hex1
▼
┌─────────────────────────────────────────────────────────┐
│ hex1 — hex0 + label support (:name and %name refs) │
│ Enables writing assembly without manual offset math │
└──────────────┬──────────────────────────────────────────┘
│ hex1 < tnc_asm.hex1 > tnc_asm
▼
┌─────────────────────────────────────────────────────────┐
│ tnc_asm — full x86-64 assembler │
│ Two-pass, label resolution, ELF output │
└──────────────┬──────────────────────────────────────────┘
│ tnc_asm tnc_boot.asm > tnc_boot
▼
┌─────────────────────────────────────────────────────────┐
│ tnc_boot — minimal tnC compiler (written in assembly) │
│ Compiles a subset of tnC sufficient for Stage 2 │
└──────────────┬──────────────────────────────────────────┘
│ tnc_boot compiler/main.tnc -o tnc
▼
┌─────────────────────────────────────────────────────────┐
│ tnc — full self-hosting tnC compiler (written in tnC) │
│ All language features, optimizer, full ELF linker │
│ Can compile itself: the chain is complete. │
└─────────────────────────────────────────────────────────┘
- Transparency: Every byte is auditable. The bootstrap chain is short enough for one person to verify.
- Simplicity: Orthogonal features. Few but powerful abstractions.
- Performance: Zero-cost abstractions. No garbage collector. Direct hardware access.
- Safety: Optional safety features that can be turned on per-module. Pay only for what you use.
- Independence: No dependency on any C-family tool, ever.
See CONTRIBUTING.md for development guidelines.
See docs/spec/language_spec.md for the full language specification.
See docs/spec/bootstrap.md for the trust chain documentation.
MIT — See LICENSE.
Active Development
- [DONE] hex0 trust anchor (313 bytes, verified self-rebuilding)
- [DONE] Language specification v0.1.0
- [DONE] Stage 2 compiler source (all 7 pipeline modules)
- [DONE] Standard library (8 modules)
- [IN WORK] hex1 assembler (in development)
- [IN WORK] Stage 0 assembler tnc_asm (in development)
- [IN WORK] Stage 1 bootstrap compiler parser/codegen (lexer complete)
- [IN WORK] Integration testing of full bootstrap chain