CCons - The C Console

After a smattering of Basic in my childhood, the first real programming language I ever wrote in was C. Why C? Because that’s what they taught in my high school’s programming class. In that class, I believe we got as far as learning for loops and basic printf formatting.

Since then I have been using C (or C++) almost constantly. At times [Python](http://en.wikipedia.org/wiki/Python_(genus) or Java or even JavaScript have threatened to overtake C as my default language, but in the end I kept returning to the world of manual memory management, static typing, and generally inflexible language mechanics. I love it.

Recently, I have been very impressed with the LLVM project. Apple has been using it, along with the clang frontend, as a replacement for GCC. Now, I realized upon seeing this, that there was an opportunity. LLVM offers just-in-time compilation; clang performs parsing of C. These two tools should theoretically be able to be combined into a C interpreter. How cool would that be?

It was not cool enough to motivate me to write it. Luckily, someone had already written it for me. Introducing the absurdity that is ccons.

After setting up all of the prerequisite tools, I could run my own C interpreter:

>>> #include <stdio.h>
>>> size_t j = 6;
>>> printf("Size of size_t: %zu\n", sizeof(j));
Size of size_t: 8
=> (int) 18
>>> printf("hello, world\n");
hello, world
=> (int) 13
As of now I must admit that I have yet to find a use for this, but I can’t stop marveling at it. Perhaps now everyone in love with Erlang and [Scala](http://translate.google.com/#it en scala) can finally start to learn a real programming language thanks to an easy to use interpreter!