Now for the Counter challenge (just a quick one):
As the goal is to show the expresiveness of the languages in respect to there usability I think that a more real world example is in order.
The example I would like to propose is a simple minimal Recursive Decent compiler implemented in the target language without using external tools for an integer only limited subset of C.
For this I propose only these atomic datatypes:
Where
int,
long, and
short are all 32-bit integers, and char is an 8 bit unsigned only integer.
I would only include the
unsigned modifier for the atomic datatypes.
Also include support for structured datatypes of the form:
Code: Select all
struct structname {
//structure members.
} varlist;
And arrays.
As for binary operators include support only for '+', '-', '*', '/', ',', '&', '|', '&&', '||', '=', '==', '+=', "-=', and '*='. This will simplify the recursive decent parser.
For unary operators we only should have '!', '*', '~', '-', '[]', and '()'
Support keywords should include only the above mentioned type releated and:
We should of course have support for function declaration and definition in the standard way.
For this quick example I would recomend only supporting the preprocessor directive include, we do not need the others for a quick and minimal integer only subset C.
Follow the APCS convention for all calls.
And as this is for the Raspberry Pi output should be in ARM assembly using the syntax of ObjASM/asasm. Asasm is easilly installed on Linux, and is a standard part of the gcc distribution for RISC OS.
If everyone agrees that this is a reasonable comparison then we can possibly each get started in our language of choice for comparison.
I pick ARM BASIC.
I would like to ask Heater to do a ground up implementation in C.
And someone to do one in FreeBASIC.
Then we will need someone to do one in Python (rounding out the list).
This is a real world kind of application that is simple enough to implement for a challenge of this nature, and is not going to require anyone to do just a translation. I would also encorouge the implementation of others in the same languages so we can see how much a difference the choices of the implementor make on the expressivness of the program even given the same language.