开发者

Which general purpose programming languages/implementations compile to C [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.

Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.

Closed 8 years ago.

Improve this question

I'm currently using Eiffel (SmartEiffel/ISE Eiffel) which is compiling to c.

I found it much easier to extend the language yourself with new features or tool support if the output is going into the 开发者_运维知识库portable assember language also known as C.

Which general purpose, non functional language have this feature too.

I know that there have been outdated C++ precompilers and i even found an old one for Objective-C.

(I also heared about ((Scheme and Lisp) compilers) but i don't like this (language)).

Please list only FOSS (free open source) projects, as i need to study them.


Nim is a very modern language that compiles to C
http://nim-lang.org


Well, there are some caveats dealing with things like exceptions and floating point numbers, but llvm can output C (though no one uses it in production so it often lags the main release). That means any LLVM based language that can be statically compiled can output to C, including all llvm-gcc frontends:

  • C++ (llvm-gcc/DragonEgg and Comeau)
  • Fortan (llvm-gcc/DragonEgg)
  • Ada (llvmgcc)
  • Ruby (MacRuby)
  • D (LDC)
  • Lua (LLVM-Lua)
  • PHP (Roadsend PHP)

Not all of these have necessarily been tested, and may require some tweaking to make work, but they should all work without too much trouble.


Vala, a language similar to C# which is part of the Gnome project.


Sather, Mercury, Felix, Seed7 and many others... It is quite common for a compiler to generate C (or C++), often seen as "portable assembly language", which has the additional advantage of relying on the experience of C compiler writers to do the optimizations.


haXe.org: a language that compiles to various languages, including C++.


Fortran (http://en.wikipedia.org/wiki/F2c) COBOL (http://sourceforge.net/projects/open-cobol/) Perl (http://www.xav.com/perl/lib/B/C.html) Matlab

I once knew a guy who wanted to study how to write a parser, but did not want to bother with code generation at that point. So, he got his parser to print out simple statements, expressions and gotos in C. So, that would be a C compiler that compiles to C (albeit very bad C) :-)


ooc (http://ooc-lang.org/), Virgil (http://compilers.cs.ucla.edu/virgil/overview.html), was old version of Algol-to-C translator (abandoned)


Cython claims to compile Python to C

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜