C Cod - FAQ
Compile C on Demand
Eventually Asked Questions Below is a short list of what I think needs to be answered.
General Questions
C Cod is an experimental project that allows for a C source
file to be "Compiled on Demand" prior to being executed.
The source files are compiled and executed on
the fly. This allows for C to be treated like a scripting
language. But, C Cod does not actually do the compiling.
Rather it acts as a front-end and uses
the the C compiler that is installed on the computer. This
is most often the GNU C
Compiler, and therefore designed to be used with GCC.
CSP is a shared library that exposes C Cod source
files to a friendly
CGI API.
It's modelled after
ASP,
and supports features such as
Page Buffering,
File Uploads,
Sessions,
Cookies,
Inline HTML,
and much more.
It is automatically installed along-side
C Cod.
(3) Is this a scripting language?
Yes. It looks and feels like a scripting language, but performs like a compiled application.
(4) Where can I get a copy of C Cod?
There is a download link on the http://ccod.sourceforge.net site.
(5) What Operating Systems are supported?
C Cod is a UNIX compatible application and thus it should compile on all UNIX compatible OS's.
But it has been successfully compiled and tested on:
Download the sources from the http://ccod.sourceforge.net site.
Follows the
./configure && make install "For windows users, download the setup EXE binary. This will setup the MingW environment alongside C Cod and CSP.
Online at http://ccod.sourceforge.net/examples.html.
In the source/binary distribution under the examples directory.
Because you are programming in C.
Your C Cod scripts will be exposed to thousands or more libraries and low level system calls
that many other scripting/interpereted environments may never see.
Because your C Cod script is truly compiled and not interpereted, it has the potential of
running circles around many of the other's.
But all is not perfect with C Cod. Some disadvantages are that C does not have high-level features such as Garbage Collection. And C Cod does not expose a shell environment to the sources such the all-mighty bash; which means that you will not be able to do things like grep ping a find output directly into a variable (though there
are workarounds using the "popen" or "system" calls).
(9) What C compatibility does C Cod provide?
Anything that is available to GNU C is available to C Cod.
(10) Does C Cod actually compile the code?
No.
C Cod reformats the source file to be compatible with the GNU C Compiler.
It hands the compiling process off to GCC.
It caches and executes the compiled binary.
It also make the CSP library available to CGI application.
(11) If it's programmed in C, does this mean it's fast?
Yes. And you can create some tight code and use optimizing flags, it can fly!
(12) Is there a performance hit from the compiling of the source prior to executing?
Yes. This hit will only exist the first time the application is executed, or if the source file is changed.
Each time thereafter, C Cod will execute the cached version of the file.
(13) If the source is compiled and cached, then where is the binary version stored?
There is a directory in the user's home directory named
.ccod .
It contains various files that helps C Cod's perform.
This directory can be deleted at anytime to save space.
(14) Does C Cod support garbage collection?
No. You have the responsibility of freeing the memory you allocate.
(15) I have an old C program I wrote about 10 years ago, can C Cod execute it?
Give it a try.
At the top of the original source file place...
#!/usr/bin/ccode
Make the source file an executable and execute it...
$ chmod a+x myoldfile.c
|