Programming languages ​​that compile into C / C ++ source code?

I use CoffeeScript to simplify JavaScript development. This is a pure syntax language that compiles in JavaScript.

So, what are the installed programming languages ​​that compile into C / C ++ source code to simplify the syntax and / or improve the functionality?

+48
c ++ c programming-languages code-translation
Jun 27 2018-11-11T00:
source share
14 answers

Haxe can be output in C ++, C #, Java, JavaScript, Python (experimental), PHP, Flash, and NekoVM.

+12
Jul 08 2018-11-11T00:
source share

Vala and Genie are languages ​​that use a system like GObject and compile with C code. I have never used them, but they look interesting. GObject is the type system used by GTK, but I believe that it is separate from GTK.

+9
Jul 07 '11 at 20:38
source share

Here's HipHop , which converts PHP programs to C ++.

+8
Jun 27 2018-11-11T00:
source share

OOC is very new, but quite pleasant.

+8
Jul 12 2018-11-21T00:
source share

GHC (Glasgow Haskell Compiler) used the ( -fvia-c ) option to compile in C.

I believe that starting with version v7, LLVM is used to generate native code instead of going through an external C compiler.

+7
Jul 11 '11 at 9:40
source share

Quote Qt documentation:

The meta object compiler, moc, is a program that processes Qt C ++ extensions. The moc tool reads the C ++ header file. If he finds one or more class declarations containing the Q_OBJECT macro, he creates a C ++ source file containing metaobject code for these classes. By the way, a meta-object code is necessary for the mechanism of signals and slots, information such as runtime and dynamic system of properties. The C ++ source file generated by moc must be compiled and linked to the class implementation.

So, this is similar to C ++ turning into C ++, I'm not sure if it matches what you are looking for.

+6
Jun 27 2018-11-11T00:
source share

The IBM Informix 4GL programming language goes through a multi-step conversion to C code, which is then compiled and linked to its own runtime library, ESQL / C (Embedded SQL in C) runtime libraries, and C system libraries.

  • program.4gl - source code
  • program.4ec - C code with built-in ESQL / C and advanced input operations
  • program.ec - C code with built-in ESQL / C
  • program.c - pure C code
  • program.o - object code
  • program - executable file

The .4ec phase is a kind of historical accident; The ESQL / C compiler initially handled both advanced input operations and ESQL / C, but when the extended operations were removed from the ESQL / C compiler (when the library and ESQL / C compiler were significantly rewritten), the extended input operations were processed by cutting the code, which handled this from the original ESQL / C compiler.

A fair number of people have written code generators that write I4GL source code from another language, or that preprocess closely related source code in I4GL before it is sent to the I4GL compiler.

+4
Jul 08 '11 at 0:40
source share

Embedded Common Lisp (ECL) can compile Common Lisp in C.

+4
Jul 10 '11 at 16:44
source share

I suppose you could write a C backend for LLVM, then you could translate almost anything to C, but the deeper question would be “why?”. The reason is that there are no tools that do this today, because if you are going to compile to C, why not go all the way and point to some kind of intermediate machine code language? (E.g. LLVM or JVM)

Now in the old days the idea of ​​compiling to C was a little more justified, since there were no decent vm languages, but today there are not many good reasons for this. However, you can still find many projects around which you can take certain interpreted languages ​​and try to compile them in C / C ++. For example, here is the python for the C ++ compiler:

http://shed-skin.blogspot.com/

+2
Jun 27 '11 at 21:05
source share

I heard that clang can compile C ++ to C. I doubt it will "simplify" anything.

+1
Jun 27 '11 at 20:59
source share

It can be argued that, since most of the main programming languages ​​are Turing-complete , they are actually equivalent, and the programs written in them can be translated into each other.

However, as other people have noted, there are quite a few languages ​​for which there are (or were previously used) their designs that create C code, since this eliminates the difficulties associated with generating binary code from a language implementation. This in no way means (unintentional pun) that the indicated code is really readable - it was simply more readable than its compiled form.

As for my contribution to the list, lex and yacc “programs” (if you can think of them like that) are usually converted to C code - a terrible, confusing mess, but C code nonetheless ...

+1
Jul 07 2018-11-21T00:
source share

Most languages ​​can be used to generate C code, but it really depends on what you are trying to do. Do you really want to be able to read the code? Are you just trying to create Windows applications?

If you are looking for a universally useful language that is easy to learn, Python is always a good choice, and it can do whatever C / C ++ can do.

0
Jun 27 2018-11-21T00:
source share

Oracle PRO * C / C ++ is an embedded SQL language. It allows you to include SQL queries in C / C ++, which are processed by the precompiler, which replaces the built-in SQL statements with function calls to the necessary C / C ++ SQL libraries. Exiting the precompiler is standard C / C ++, which can then be compiled for the executable.

http://en.wikipedia.org/wiki/Pro*C
http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14407/toc.htm

0
Jun 27 '11 at 21:05
source share

A subset of Matlab (Embedded Matlab) can be compiled for C. You need an embedded encoder toolbar.

0
Jul 07 2018-11-11T00:
source share



All Articles