Back to portfolio

Experimental native compiler · Rust · Linux · alpha

Nacre

How do you compile a Java-like language without a JVM?

Nacre is an alpha native-language compiler for Linux, implemented in Rust with Java-like syntax. Its default path generates C11 and uses GCC or Clang; an optional direct LLVM backend is also available.

At a glance

Project
Experimental native compiler · alpha
Implementation
Rust · Java-like source syntax
Default backend
C11 → GCC or Clang
Alternative backend
Optional direct LLVM
Target
Linux · pre-1.0

Two routes to a native executable

The usual route translates the program to C11 before native linking. The --direct option emits LLVM for user functions and main; the C runtime and required library support are still compiled separately and linked with the LLVM module.

From source to executable

Nacre’s compilation pipeline

  1. Nacre source

    The frontend collects files, resolves modules, and checks types, ownership and borrowing.

  2. C11 generation

    The default backend generates C11 and compiles it with GCC or Clang into a native executable.

  3. Linux executable

    Native compilation uses the system C toolchain and Nacre’s supplied runtime.

--direct option. User functions and main are emitted as LLVM; the runtime and library support are compiled separately to bitcode and linked with llvm-link before Clang links the executable.

README.md · docs/ARCHITECTURE.md
  1. 01 · Familiar syntax, native compilation

    Nacre is an experimental compiler written in Rust for a language whose syntax is reminiscent of Java. It does not translate programs to a JVM: its stated native target is Linux executables.

    By default, the compiler generates C11 and lets GCC or Clang build the executable. The --direct option provides another route: user functions and main are emitted as LLVM, while the C runtime is compiled separately to bitcode and linked with the user module.

  2. 02 · Affine ownership and explicit borrowing

    Ordinary owning values are affine: moving a value transfers its cleanup responsibility. The language distinguishes shared and exclusive borrows, and the compiler checks their conflicts as well as moves.

    This model uses no garbage collector, JVM or implicit reference counting. It describes the language rules, not a general safety guarantee: the C runtime is part of the native trusted base, and programs are not sandboxed.

  3. 03 · A standard library and working examples

    The standard library is injected into programs. It includes affine collections, UTF-8 Text, binary buffers, options and results, plus APIs for files, processes, threads, explicit synchronization, regular expressions, time and TCP/UDP sockets.

    The repository includes fuller examples such as a contact book, lending desk, Sudoku, Game of Life and an HTTP server. They exercise collections, borrowing and native APIs; their presence does not make the alpha a stabilized release.

  4. 04 · A Linux alpha with explicit limits

    Linux is the only stated native target. The project is pre-1.0 and does not guarantee language or standard-library compatibility between versions.

    Lifetime parameters and escaping borrowed iterators are not supported; general FFI, class inheritance, GUI applications and JVM execution are outside the current language. The repository also states that Nacre is neither a sandbox nor a security certification.

Code, documentation and development status

  • Nacre repository

    README.md: overview, default backend, optional LLVM mode, standard library and examples.

  • Architecture and ownership

    docs/ARCHITECTURE.md and docs/BORROWING.md: compiler pipeline, native representation and borrowing rules.

  • Roadmap

    docs/ROADMAP.md: current capabilities, experimental scope and known limits.