Menu

Home

Anonymous Aaron Marcuse-Kubitza

C^2: bringing other languages to C

Features

C^2 is a public domain library for C that provides proofs-of-concept for popular features of other programming languages:

  • exception handling (object-oriented)
    • else blocks that run if no exception was thrown
    • stack traces planned
    • thread safe (doesn't use global variables)
  • object-oriented programming (currently messy, but this is C)
    • with blocks that ensure stack objects are destructed
    • runtime type identification (RTTI)
    • multiple inheritance (C++-style) planned
    • reference counting to garbage collect heap objects planned
  • nested functions (closures)
  • templates (C++-style, with instantiation) (currently messy, but there are cleaner ways)
  • generics (Java-style, with type erasure) planned
  • coroutines (cooperative multithreading) planned
  • generators (functions that store state) planned
  • continuations (restartable functions) planned

It complies with ANSI C89 and thus can be used on any platform with a C compiler, including embedded systems. It may also be usable with C++ (some C^2 features are not already present in C++), but this has not been tested.

Why public domain?

Public domain is the only licensing method that gives the user complete freedom to do whatever they want with the software. In addition, it is the "universal donor": the only method that allows code to be incorporated into any software under any license. This quality maximizes the benefit to society, by allowing the widespread use of something intended to be useful.