引导编译器:为什么? [英] Bootstrapping a compiler: why?

查看:159
本文介绍了引导编译器:为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我了解一种语言如何可以自行引导,但我无法在为什么找到许多参考资料。您应该考虑引导。

I understand how a language can bootstrap itself, but I haven't been able to find much reference on why you should consider bootstrapping.

直观的答案是,你编写的语言提供了在编译器的基本语言中找不到的实用程序,语言的功能相对较好

The intuitive answer is that the language you're writing offers utilities that are not found in the "base" language of the compiler, and the language's features are relatively well-suited for a compiler.

例如,引导C ++编译器是有意义的 - 当OOP正确使用时,可能更容易维护编译器,而不是使用简单的C。

For instance, it would make sense to bootstrap a C++ compiler -- it could potentially be much easier to maintain the compiler when OOP is properly used, as opposed to using plain C.

另一方面,MATLAB肯定使矩阵数学比纯C容易得多,但我看不到任何明显的好处在MATLAB中编写MATLAB编译器/解释器 - 似乎会变得更少 可维护性。类似的观点可以应用于R编程语言。或者一个非常极端的例子是引导 Whitespace ,它是用Haskell编写的 - 绝对是一个

On the other hand, MATLAB certainly makes matrix math a lot easier than plain C, but I can't see any apparent benefits from writing a MATLAB compiler/interpreter in MATLAB -- it seems like it would become less maintainable. A similar view could be applied to the R programming language. Or a pretty extreme example would be bootstrapping Whitespace, which is written in Haskell -- definitely a massive superset of Whitespace.

这是引导程序利用新语言特性的唯一原因吗?我知道还有因为我们可以的理由,但这不是我正在寻找的)

Is the only reason for bootstrapping to take advantage of the new language's features? I know there's also the "because we can" reason, but that's not what I'm looking for :)

推荐答案

原则称为吃你自己的dogfood。

There's a principle called "eating your own dogfood". By using a tool, you demonstrate the usefulness of the tool.

通常会问,如果语言X的编译器不是用语言X编写的,为什么应该使用我有风险使用它吗?

It is often asked, "if the compiler for language X isn't written in language X, why should I risk using it?"

这当然只适用于适合编译器编写领域的语言。

This of course only applies to languages suitable for the domain of compiler writing.

这篇关于引导编译器:为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆