Bootstrapping a compiler: why?

前端 未结 11 1466
花落未央
花落未央 2020-12-01 02:55

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 int

11条回答
  •  青春惊慌失措
    2020-12-01 03:29

    Compilers solve a wide variety of non-trivial problems including string manipulation, handling large data structures, and interfacing with the operating system. If your language is intended to handle those things, then writing your compiler in your language demonstrates those capabilities. Additionally, it creates an exponential effect because as your language includes more features, you have more features you can use in your compiler. If you implement any unique features that would make compiler-writing easier, you have those new tools available to implement even more features.

    However, if your language is not intended to handle the same problems as compilation, then bootstrapping will only tempt you to clutter your language with features which are related to compilation but not to your target problem. Self-compilation with Matlab or SQL would be ridiculous; Matlab has no reason to include strong string manipulation functions and SQL has no reason to support code generation. The resulting language would be unnecessary and cluttered.

    It's also worth noting that interpreted languages are a slightly different problem and should be treated accordingly.

提交回复
热议问题