CC Shell
| About | News
| Download
| Examples
| TODO
| Development
| Authors
|
#!/usr/bin/ccsh
[ About ]
CCSH is a scripting language that is intended to be
powerful and easy to use for people already familiar with the C
language.
[ Features ]
|
setuid bit on the script will (or should?) do nothing, so there
should be no setuid problems.
|
|
|
|
Shell scripts such as bash, tcsh, etc., are all interpretive. And as
such, they incure a lot of run-time overhead. For small scripts, this
is fine, but the overhead becomes noticeable in larger scripts.
Languages like Perl compile the language into an internal
byte-code, which executes significantly faster than pure interpreters.
The overhead cost is a little high on initial execution, but runtime
performance is greatly increased. Perl, therfore can handle mid-sized
scripts very efficiently.
CCSH actually compiles the script into machine
code. It therefore has a lot more overhead on initial execution, but
runtime performance is exactly the same as any other compiled program.
So CCSH can handle large/complex tasks much more
effectively than most scripting languages.
|
|
|
|
Sites with a minimal administrative workforce don't have to worry
about maintaining binary and source files. CCSH takes
care of when the file is compiled. An RCS/CVS on your source file is
all you need (for sites that care to even have that much source
management). Simply execute it as you would any other shell script.
|
|
|
|
Everybody knows C, therefore there's little need to learn yet another
language. :-) It's also a powerful language, so you can get lots of
wonderful things done.
|
|
|
|
C is everywhere. Therefore your script should work everywhere.
|
|
|
[ Who would use it? ]
- If you find you frequently make little C test programs that don't
need Makefiles, and you don't like the many compile/run steps that
you have to make, I suppose this might be of some use.
- If you for some reason don't like maintaing seperate source and
executable. (Of course, that's why we have package managers)
- Perhaps you have a heterogenious computing environment with a
shared filesystem. This will give you a way to run the same "code"
on both machines, again not having to maintain the binaries.
- You want to tell your friends/newbies the funny things that Unix
people do.
[ How it works ]
By harnessing the power of the C compiler (which should have been
installed on your system with the rest of your OS), CCSHwill turn your lines of code into bytes of data that the CPU can run
directly. Since no intermediary interpretation is done (like bash,
csh, etc.), your code can run hundreds of times faster!
Okay, fine. It's a stupid little program that strips the first line
of your code, compiles and executes your code via gcc, and creates and
removes temp files along the way. And yes, it compiles and executes
your code each time you run the script. In the TODOs, I've outlined
how I'd implement a caching system to deal with this. But, it's
rather complicated (especially in a heterogeneous environment). So
I've opted to release this code as more of an amusement piece. I have
no serious plans to release new versions. (But may decide to if I get
bored. :-)
[ Motivation ]
I worked somewhere once where their reason for using scripting
languages instead of C was because they didn't want to maintain 2
files (source and binary) where they could just deal with 1 (a
script). Of course, this led to extremely contorted lines in csh,
until I learned Perl. Of course no one else there knew Perl, so I
don't know how that helps the maintenance issue.
That, and I figured this'd make a cool April Fool's joke. The first
public release was on Freshmeat
on April 1, 1999. But it's no longer a joke. A friend pointed out
that it can easily be made "useful" by simply having a caching system.
And I realized that this caching system could also handle
heterogenious computing environments, sharing the same source (or
script) base off a networked drive. In such environments, this would
probably decrease administration work by quite a bit.