View Full Version : CO2 - proposal for a C like JIT compiler
Charles Pegge
18-04-2008, 12:32
This mad idea surfaced yesterday: what if C could be embedded in thinBasic? Think of all the C source code out there that could be embedded directly into your project, compiled, assembled and bound to thinBasic variables on the fly?
The initial idea is to develop a C with built-in Basic style strings and maths, but otherwise conforming to the regular C syntax.
CO2 will be able to generate Assembly code with bindings to thinBasic variables and some of the FreeBasic runtime functions wherever they are needed.
The CO2 output will be fed into the Asmosphere of course. :)
Another option is to feed the GNU Gas assembler and ld linker for standalone programs.
ErosOlmi
18-04-2008, 14:16
If there is one able to do this, this is you !
If there will be interaction with script variables ... this will be amazing.
Michael Hartlef
18-04-2008, 14:21
Sounds interesting.
RobertoBianchi
18-04-2008, 14:28
Yes very interesting indeed!
Roberto
Charles Pegge
18-04-2008, 16:29
This is a friendly guide to C programming:
http://www.space.unibe.ch/comp_doc/c_manual/C/cref.html
As it shows, the language is minuscule, but the syntax can be complex and requires intricate parsing to get the context of each symbol.
Petr Schreiber
18-04-2008, 18:31
Charles,
sounds very interesting!
As a FOR/NEXT booster it could be very interesting, although I must admit I prefer thinBASIC syntax over C.
I do not ask you anything as I am having a solid Xmas with SSE instructions now, such a incredible power!
Petr
Charles Pegge
18-04-2008, 19:43
With the exception of C++, C seems to be one of the hardest languages to parse, but I am intrigued by the way it expresses complex ideas with so few symbols, and why it has come to dominate low level programming. The inner structure of C is mathematically very clean, though there are a few unfortunate botches which have discouraged many people from using it.
One of the greatest flaws, (which Basic never suffered from), is to disregard strings as a fundamental data type.
But the Pentium, with its multiple processors and parallelism, surpasses the ability of such languages to use its full potential, so assembly code makes a comeback, and new high level languages will eventually to accommodate this hardware at a more abstract level.
zlatkoAB
18-04-2008, 19:48
That would be like new Aurora!!!! ;D
Petr Schreiber
18-04-2008, 20:00
One of the greatest flaws, (which Basic never suffered from), is to disregard strings as a fundamental data type.
I cannot agree more, this ( and semicolons ) bothers me the most :)
Thanks,
Petr
Charles Pegge
18-04-2008, 20:43
Just taking a look at the Aurora Forum ( I spy Jose online there!);
All those semicolons are necessary because C is line insensitive; but I dont think I have seen
much code where line insensitivity is exploited; It should be possible to make line breaks significant while supporting line continuity for parameters with commas after them; but to preserve compatibility we may have to tolerate them; - {at least they are easier to type than colons;};;;;;
Charles your ideas are as good as the clever names you come up with: ASMosphere and now Co2
zlatkoAB
19-04-2008, 10:02
I also dont like {} signs.uh!!!!
Charles Pegge
19-04-2008, 11:41
The C developers did not like typing but this should be possible:
#define begin {
#define end }
#define sub void
sub main()
begin
print ("Hello World!")
end
Michael Hartlef
19-04-2008, 12:15
The C developers did not like typing but this should be possible:
#define begin {
#define end }
#define sub void
sub main()
begin
print ("Hello World!")
end
And here we are with a perfect PASCAL block embending which I personally like very very much. :)