Skip to content

Repository files navigation

Coraft

Coraft is meta-programming engine for C++, and its DSL, the name comes from "code draft" and "co-craft".

This language resolves both the syntactic complexity of C++ and the hassle of vibe coding at once.

This is inspired by ANPL (by Di Huang et al., repo), cppfront (by Herb Sutter and contributors), and Sugarcpp(by curimit and contributors)

Motivation

We have two motivations.

For Systems Programming

The systems programming ecosystem remains centered around C++, but writing C++ directly is notoriously painful. Coraft provides a cleaner frontend for C++.

For Vibe Coding

LM(Language Model)'s performance has improved dramatically in recent years, but it's still unreliable in the local inference.

ANPL was proposed when LMs were not yet reliable enough — a situation similar to today's local inference environment. Thus, we thus drew inspiration from it.

Furthermore, as long as there is demand for running inference on minimal hardware, reliability will always be a concern — regardless of how efficient LMs become.

Compile Flow

graph TD
	A[Coraft Code] -->|Transpile| B
	A -->|Transpile and Extract Declaration | E
	B[C++ Code with Prompt] -->|Complement by LM| C
	E[C++ Header with Prompt] -->|Complement by LM| F
	F[Completed C++ Header] -->|Compile| D[Binary]
	C[Completed C++] -->|Compile| D
Loading

Why Complement Code After Transpilation?

LM is better suited to handling existing languages ​​than to unknown new languages.

In the future, if this language will no longer be "unknown new languages" to LMs, we may revisit a recursive complementation.

Sample Code

fn fizzbuzz(index i32) str
?{
	Write fizzbuzz function. 
}? // inline-prompt

fn main(args vector<str>) i32
{
	// # is annotation for AI
	var text str = ""; # string for printing.
	
	?{ Assign "Hello Coraft" to the variable `text`. }? // inline-prompt

	cout(<<, text, endl); // operator-chain, expanded to `cout << text << endl`

	for(var i = 0; i < 51; i++)
	?{
		output return value of `fizzbuzz(i)` to console. // This is in-prompt comment. LM can't read this.
	}?

	return 0;
}

Components

  • Dace - Coraft to C++ Transpiler
  • Opah - LM Code Complementer
  • Hake - Project Builder
  • Isaki - Package Manager
  • Tilapia - LSP Server
  • Cor - Transpile Pipeline Driver

About

LLM-Integrated metaprogramming DSL for drafting C++ codes.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages