Cello is a library that introduces higher level programming to C.

  • Interfaces allow for structured design
  • Duck Typing allows for generic functions
  • Exceptions control error handling
  • Constructors/Destructors aid memory management
  • Syntactic Sugar increases readability
  • C Library means excellent performance and integration
/* Example libCello Program */

#include "Cello.h"

int main(int argc, char** argv) {

  /* Stack objects are created using "$" */
  var int_item = $(Int, 5);
  var float_item = $(Real, 2.4);
  var string_item = $(String, "Hello");

  /* Heap objects are created using "new" */
  var items = new(List, int_item, float_item, string_item);

  /* Collections can be looped over */
  foreach (item in items) {
    /* Types are also objects */
    var type = type_of(item);
    print("Object %$ has type %$\n", item, type);

  /* Heap objects destroyed with "delete" */


For more examples please take a look at the quickstart documentation section:

Or some articles about the creation:

Or a longer example:

/* Another Example Cello Program */

#include "Cello.h"

int main(int argc, char** argv) {

  /* Tables require "Eq" and "Hash" on key type */
  var prices = new(Table, String, Int);
  put(prices, $(String, "Apple"),  $(Int, 12)); 
  put(prices, $(String, "Banana"), $(Int,  6)); 
  put(prices, $(String, "Pear"),   $(Int, 55));

  /* Tables also supports iteration */
  foreach (key in prices) {
    var price = get(prices, key);
    print("Price of %$ is %$\n", key, price);

  /* "with" automatically closes file at end of scope. */
  with (file in open($(File, NULL), "prices.bin", "wb")) {

    /* First class function object */
    lambda(write_pair, args) {

      /* Run time type-checking with "cast" */
      var key = cast(at(args, 0), String);
      var value = cast(get(prices, key), Int);

      try {
        print_to(file, 0, "%$ :: %$\n", key, value);
      } catch (e in IOError) {
        println("Could not write to file - got %$", e);

      return None;

    /* Higher order functions */
    map(prices, write_pair);



The high level stucture of Cello projects is inspired by Haskell, while the syntax and semantics are inspired by Python and Obj-C. Cello is not about Object Orientation in C. Instead it provides tools that turn C into something of a dynamic and powerful functional language. A path it may have gone down in an alternate reality.

Although the syntax is pleasant, Cello isn't a library for beginners. It is for C power users, as manual memory management doesn't play nicely with many higher-order concepts. Most of all, Cello is a fun experiment to see what C would look like when hacked to its limits.


Cello is licensed under BSD3.

Contributions are welcomed via github.

For queries please visit the IRC channel #libcello on Freenode.

Or send them to contact@theorangeduck.com.