Compilers that compile β€œcommon language X” into portable C

I am looking for two things. The first is terminology.

What do we call compilers that compile one language into another?

Secondly, are there any compilers that compile the generic language X into portable C code?

I just throw the idea there, but I thought that if we create our own interface for our own choice language, but instead of going the full way, the compiler will produce portable C code. Thus, we could add new language features, but still be very compatible with existing C code.

Now there may be a huge flaw in this approach (except that you need to build it), but do people do it?

+4
source share
1 answer

People absolutely do it. In fact, the original C ++ implementation was a program called Cfront , which translated C ++ into C code and then compiled using the C compiler.

Today, when intermediate "bytecodes" such as JVM, CLR, and LLVM prevail, translating languages ​​to C source code is now much less common. This is a much more powerful and less annoying way to generate bytecode directly, rather than generate text source code. These bytecodes (or "bitcodes" in the case of LLVM) are lower than text-based programming languages, but still higher than the source machine code associated with a particular processor or CPU family.

I would call this program a "translator", but it's just me. The "compiler" will also work perfectly.

+6
source

All Articles