问题描述
我想要编译语言。我目前正在评估后端。
到目前为止,我正在寻找C,因为它的执行速度,编译和一个小的,易于使用的编译器称为TCC。
阅读讨论这里关于使用它作为一种中间语言,我想想如何使它兼容垃圾收集和处理异常。
以下是我对其他可能的后端的一些想法:
- 装配:不可移植,总体疼痛。
- .NET:感觉真的很慢。 5秒启动,5秒评估1 + 2在Ironpython和Boo。无法在没有大图书馆的情况下运行。
- JVM:感觉有点慢。无法访问二进制库。无法在没有大图书馆的情况下运行。
- LLVM:没有Windows支持。我听说编译的可执行文件大小是16 mb +
- C--:看起来欠发达。
- 找不到一个很好的小自由,我可以捆绑。
任何人都可以改变主意或有更多的添加此列表?
编辑
我最近一直在试验LLVM。我发现他们有预编译的二进制文件,可以编译为本机程序集。
以下是步骤:
- 在LLVM汇编上运行llvm-生成LLVM字节码文件。
- 在LLVM字节码文件上运行llc以生成汇编文件。
- 在汇编文件上运行汇编器以生成目标文件。 (或运行llvm-ld,这似乎取决于外部安装的c编译器)
- 使用gcc等编译为可执行文件。
您是否考虑为?我提到这是为了完整性的缘故 - 只要我知道后端接口是相当复杂,代码库是巨大的,很难理解。
另一方面, GCC是一个成熟的产品,许多专家程序员在其上工作。至少,它可能为所有的选择提供最坚实的基础。
我个人喜欢LLVM(令人兴奋的架构)或.NET的IL:非常,非常易于使用,拥有强大的工具支持(,,和最后但并非最不重要的,.NET反射API)和两个非常有效的实现(即微软的规范实现和单声道)。
但是我不能要求在任何架构的专业知识,所以请把这个答案与一粒盐。
I want to make a compiled language. I am currently evaluating backends.So far I am looking at C because of its speed of execution, compiling, and a small, easy to use compiler called TCC.
Having read the discussions here about using it as an intermediate language, I am trying to think about how to make it compatible with garbage collection, and handling exceptions. So far, I think I can solve both, but with much overhead.
Here are some of my thoughts on the other possible backends:
- Assembly: unportable and a total pain to program in.
- .NET: Feels really slow. 5 seconds to start up and 5 seconds to evaluate 1+2 on Ironpython and Boo. Unable to run without large library.
- JVM: Feels a bit slow. No access to binary libraries. Unable to run without large library.
- LLVM: No windows support. I hear that compiled executable size is 16 mb+
- C--: looks underdeveloped.
- C++: possibly. Can't find a nice small free one I can bundle with.
Can any of you change my mind or have more to add to this list?
Edit
I've been experimenting with LLVM recently. I found out that they have precompiled binaries and that it is possible to compile to native assembly.
http://www.antlr.org/wiki/display/CS652/Generating+machine+executable+binaries+with+LLVM
Here are the steps:
- Run llvm-as on LLVM Assembly, which yields a LLVM bytecode file.
- Run llc on the LLVM bytecode file to yield an assembly file.
- Run an assembler on the assembly file to yield an object file. (or run llvm-ld which seems to depend on an externally installed c compiler)
- Compile to executable with gcc etc.
Have you considered writing a frontend for GCC? I mention this for completeness’ sake only – as far as I know the backend interface is quite complicated and the codebase is huge and hard to comprehend.
On the other hand, GCC is a mature product with many expert programmers working on it. At the very least, it probably provides the most solid basis of all the alternatives.
Personally, I would prefer LLVM (exciting architecture) or .NET’s IL: very, very easy to use, has great tool support (Reflector, Cecil, Reflexil and last but not least, the .NET reflection API) and two very efficient implementations (namely Microsoft’s canonical implementation and Mono).
But I can’t claim expertise in any of the architectures so take this answer with a grain of salt.
这篇关于做一门语言,需要一个好的后端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!