About¶
Raptor is a metaprogamming environment for C. It is set of preprocessors written in python that extend C with everything practical from new languages. The following features are planned,
namespaces - easier syntax for structs
generics - use jinja, like genny but for C
prototypes - support entity systems and javascript style oo with a custom parser
defer / gc - provide reference counting, gc and defer that transpile plainly
inline functions - use jinja
a build system - integrate with scons
data structures, async / co-routines - write a custom parser and integrate with external libraries libevent and coro
heredocs and regex - write a custom parser and integrate with pcre
universal function syntax and operator overloading - not a priority but a good test about how flexible this approach can be
readable inline assembly - not a priority
While there are many interesting libraries that enhance C with cpp, this project will use a high level language to implement a cohesive set of extensions on C for games and webaps. The main goal is to have C-like syntax unlike Go, Rust, Zig and complete API and ABI compatibility unlike C++. Another goal is to avoid intimidating syntax completely - explicit is better than implicit - and provide good error messages. The priority is also to make C safer, simpler. Performance will always be sacrificed for safety and simplicity. Future versions will be about libraries, linters, supporting other paradigms and perhaps replacing cpp completely. Lua support will also be added.
The primary influences for taking this approach
Coffescript / Babel transpilers - these showed code generation is feasible in production
Lua / Tera
Perl Inline modules, Source filters, Reader Macros from Lisp - C is smaller like javascript, so it should work
Early PHP
Vala, ooc, V that compile to C
As dynamic languages are becoming more static with every release, it also makes sense to explore dynamism on C. A web based chatting app will also be built simultaneously to test and demonstrate feasibility of this approach.
Early attempts included using lisp to write a c2lisp, xml2lisp compilers.