C - a pseudo-interpreter of the C programming language
In order to write one-liners in C, I created a tiny wrapper for GCC.
C (pronounced large-C) is a pseudo-interpreter of the C programming language.Without the need of manual compilation, developers can rapidly create scripts or write one-liners using the C programming language that runs at native-code speed.
C, the pseudo-interpreter, has several advantages over other scripting languages, such as perl.
- very fast (100x faster than perl when calculating fib(40))
- easy handling of binary data
- good for testing system calls and C APIs
To install,copy the downloaded file to /usr/bin, and chmod 755.
Below are some examples.
% C -e 'printf("hello world\n")'
hello world% C -cO3 -e 'int fib(int i) { return i > 2 ? fib(i-1) + fib(i-2) : 1; } printf("%d\n", fib(40))'
102334155% C -e 'int t, sum = 0; while (fread(&t, sizeof(int), 1, stdin) == 1) sum += t;printf("%d", sum)' < data
31289% cat hello.C
#! /usr/bin/Cprintf("hello world\n");
% ./hello.C
hello world
Comments
I wonder how this compares to Inline::CPR. Maybe soon I'll have some time to compare them myself...
Posted by: Akhasha
|
January 9, 2006 11:36 AM
The only reason I used perl to implement the initial version of large-C, is that it was easier for me than using C to do so. Although Inline::CPR do look very interesting, I do not have any intension to adding that kind of rich features to large-C.
My current interest is in re-implementing large-C in C, so that I can execute large-C itself in large-C... :-p
Posted by: kazuho
|
January 9, 2006 02:30 PM
I wonder if you've seen CINT by Masaharu Gotoh. If you just need a C/C++ interpreter to embed into an application, that already does what you want. If this is for 'self education' or for fun, then never mind.
CINT is used in a very large-scale project called Root at the international high energy physics lab CERN. Root is a framework for analyzing high energy physics data.
While Gotoh-san wrote CINT while working for H.P. Japan, maintenance and development of CINT has been taken over by Rene Brun's group at CERN and can be gotten at:
http://root.cern.ch/root/Cint.html
Ron Fox (fox at nscl dot msu dot edu
NSCL
Michigan State University
East Lansing, MI 48824-1321
[Unix] is not necessarily evil, like OS/2. - Peter Norton
Posted by: rfoxmich
|
May 19, 2006 08:24 PM