Clue is an ANSI C compiler targeting high level languages.
Clue currently supports the following targets:
* Lua 5.1.3
* Perl 5
What do you mean, 'why'?
Apart from pure hack value (I'm hoping at some point to produce a back end that will emit sh script --- just because), Clue is mainly an experiment into the use of dynamic VMs to run static code. Modern JITs can do an astonishing job of producing machine code from dynamic languages, gathering all the necessary type information just from watching the program run. It therefore seems instructive to try taking a statically typed language like C, discarding all the type information, and letting the JIT have a go.
In terms of actual practical value, it may be useful to allow the use of code written for one system to run on another, much more restricted system. For example, using clue you could use off-the-shelf encryption systems like gpg to work inside a web browser.
How well does it work? Well, let's have some numbers. (All these were calculated during a single benchmarking run on my machine. The gcc score is included for reference. The gcc version of the benchmark uses the same source code as the Clue versions.)
Backend Interpreter Whetstone score
lua LuaJIT 1.1.4 140
lua Lua 5.1.3 33
js SpiderMonkey 22.214.171.124 10
js Rhino 1.6 9.0
perl5 Perl 5 1.7
Clue is based on the sparse C compiler frontend. This is plugged into a custom register allocator and code generator, which emits the code.
sparse and Clue are written in gcc-dialect C. It should run on most systems, although it has been developed on Linux, and makes fairly major assumptions about living in a Unix environment --- Windows users will want to use Cygwin and even then you're on your own.
Documentation is provided; currently it's a bit patchy, but reasonably complete. If you have any problems, please join the mailing list.
Clue is experimental software. It's sole purpose is to be interesting, and not necessarily useful. The resulting code takes between 10 and 100 times longer to run as it would if you just compiled the program with gcc (and that's when using the Lua backend with LuaJIT, possibly the fastest dynamic language around; any other target will be slower).
In addition, while Clue supports the ANSI standard, most programmers don't; non-ANSI behaviour such as casting a pointer to an integer and vice versa is very common. This will not work. So stock code is unlikely to run on Clue unless the authors have been particularly disciplined. (However, this can also be seen as an advantage: if your code works with gcc and with Clue, it's probably going to work elsewhere.)
And I haven't even mentioned the bugs.
What's New in This Release: [ read full changelog ]
· This version includes a Java backend.