C++ Support

Hi all,

I have a bit of an project in mind to write a simple language for
dealing with a rather specific problem domain (high frequency time
series), but using the power of clang to make the language highly
interoperable with C++; e.g. my language's simplified classes will be
valid C++ classes, strings will be std::strings etc.. in order to allow
tricksy parts of a codebase to be written easily in C++, while the
custom language would be a tool to create a tool for non-programmers to
quickly develop strategies and analyses.

I was thinking of hooking into the AST generation stage of clang,
parsing my language into the same AST that clang uses, and then
borrowing the rest of the compilation pipeline in order to JIT compile
the code and run it; does this sound at all feasable? I have made brief
examination of the clang code and it looks like this could work (great
code, by the way; it's like a soothing balm after the stuff I have to
deal with at work). I guess the things that could put a halt or the
breaks on the project are whether or not the code generated by clang is
interoperable with that which gcc belches out (same name mangling scheme
etc..) and the general state of c++ support.

I managed to get a few really basic programs compiled and running, but
as soon as I tried something a bit adventurous like #include<iostream>,
the world appeard to fall apart. Is this expected, or am I doing
something wrong? If need be I am happy to muck in to get this show on
the road; but just so I know roughly how far away are y'all from being
able to compile something like the standard library? (actually for my
purposes being able to parse the headers would be sufficient)

All the best,

Philip

Hi all,

I have a bit of an project in mind to write a simple language for
dealing with a rather specific problem domain (high frequency time
series), but using the power of clang to make the language highly
interoperable with C++; e.g. my language's simplified classes will be
valid C++ classes, strings will be std::strings etc.. in order to allow
tricksy parts of a codebase to be written easily in C++, while the
custom language would be a tool to create a tool for non-programmers to
quickly develop strategies and analyses.

I was thinking of hooking into the AST generation stage of clang,
parsing my language into the same AST that clang uses, and then
borrowing the rest of the compilation pipeline in order to JIT compile
the code and run it; does this sound at all feasable?

It seems feasible. One note of caution: Clang's ASTs are not considered stable, so the ASTs and the interfaces to them are likely to change (maybe significantly) in the future, especially as we ramp up C++ support within Clang.

I have made brief
examination of the clang code and it looks like this could work (great
code, by the way; it's like a soothing balm after the stuff I have to
deal with at work). I guess the things that could put a halt or the
breaks on the project are whether or not the code generated by clang is
interoperable with that which gcc belches out (same name mangling scheme
etc..)

It will be. GCC interoperability is extremely important to us.

and the general state of c++ support.

I managed to get a few really basic programs compiled and running, but
as soon as I tried something a bit adventurous like #include<iostream>,
the world appeard to fall apart. Is this expected, or am I doing
something wrong?

That's expected. We're missing a lot of C++ features needed for the standard library. Our template system, in particular, is still in a relatively early stage of development.

If need be I am happy to muck in to get this show on
the road; but just so I know roughly how far away are y'all from being
able to compile something like the standard library? (actually for my
purposes being able to parse the headers would be sufficient)

I don't know. I hope that we'll be able to parse the standard library within a few months time, but you won't get a time table out of me no matter how hard you try :wink:

Parsing will come first, and code generation is likely to lag by a bit.

  - Doug