views:

151

answers:

3

I am a "high-level" scripting guy. All my code is Class-based PHP or JavaScript. However, I want to know if there is any form of useful interpreter projects for "low-level" compiled languages like C or C++ (strange sounding huh?).

This all came about when I stumbled upon http://g-wan.com/ and was fascinated by the fact that you could setup C code to run as server scripts. However, that project is all but useless because it is run by one guy and is closed source.

So, is there anything out there for "low-level" languages that would enable them to be easier to run by compiling them at runtime. OR is this just a bad accident waiting to happen which explains why that was the only project I could find about this?

Being able to dump PHP/Ruby/Python for C scripts would really speed up our sites.

+1  A: 

There are products like Beanshell for Java. They aren't intended to replace scripting languages but instead to allow an easy unit testing and debug capability to an existing language. In my opinion you should use a language for what it was designed for.

Pace
+3  A: 

Im not sure I understand what you want to achieve, but tcc (tiny c compiler) allows you to run C programs as scripts.

http://linux.die.net/man/1/tcc

TCC can be invoked from scripts, just as shell scripts. You just need to add "#!/usr/local/bin/tcc -run" at the start of your C source:

#!/usr/local/bin/tcc -run
#include <stdio.h>

int main()
{
    printf("Hello World\n");
    return 0;
}
Tom
Well, PHP is so slow just like all the other scripting languages. With bytecode caching it is still much faster than others - but way far away from c code.
Xeoncross
I'm not sure I agree. C code would invoke process creation overhead which in many scripting based applications would render it slower than something like a servlet which can remain in memory.
Pace
Really? For example, for each index you load on the wordpress PHP system it takes 8MB to render the page. If you only have 256MB memory you can hit a brick wall very quick. Also, since it has been built on C (or C++ I can't remember) I would assume that it would be much slower than straight C/C++. Do you have any info I can read about this?
Xeoncross
+1  A: 

I recently stumbled upon something called BinaryPHP in which you code normally in php and then convert the script into C++ to be compiled on your favorite tool. That should be a nice learning curve for someone already in touch with php.

F.Aquino
Facebook has released HipHop, or at least promised to, which does much the same thing.
Duncan
Thats the one I was looking for! but my brain keyword sucked and I googled c++ php compiler and only BinaryPHP came up, thanks for the addition!
F.Aquino
Sweet! Converting PHP *into* C++ is even better! Can't wait for HipHop !
Xeoncross