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,

  1. namespaces - easier syntax for structs

  2. generics - use jinja, like genny but for C

  3. prototypes - support entity systems and javascript style oo with a custom parser

  4. defer / gc - provide reference counting, gc and defer that transpile plainly

  5. inline functions - use jinja

  6. a build system - integrate with scons

  7. data structures, async / co-routines - write a custom parser and integrate with external libraries libevent and coro

  8. heredocs and regex - write a custom parser and integrate with pcre

  9. universal function syntax and operator overloading - not a priority but a good test about how flexible this approach can be

  10. 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

  1. Cello

  2. Coffescript / Babel transpilers - these showed code generation is feasible in production

  3. Lua / Tera

  4. Perl Inline modules, Source filters, Reader Macros from Lisp - C is smaller like javascript, so it should work

  5. Early PHP

  6. 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.