简体   繁体   English

编程语言演变与底层架构

[英]Programming language evolution vs underlying architecture

Let's say we have a programming language foo . 假设我们有一个编程语言foo foo has a compiler for System A but not for System B . foo有一个System A的编译器,但没有System B的编译器。 Now the System B developer can either write his/her own compiler for foo or write a System A emulator that runs on System B and can make use of the compiler written for System A . 现在, System B开发人员可以为foo编写自己的编译器,也可以编写在System B上运行的System A仿真器,并可以使用为System A编写的编译器。 An obvious advantage of the emulator is that it's not limited to running the compiler and opens up System B to other System A specific programs. 模拟器的一个明显优势是它不仅限于运行编译器,而是将System B打开到其他System A特定程序。 The obvious disadvantage in most cases is performance and complexity depending on the systems. 在大多数情况下,明显的缺点是性能和复杂性取决于系统。

What I'm interested in finding out is which one of these approaches is easier to maintain. 我有兴趣发现这些方法中的哪一种更容易维护。 For example, let php be the language in question and lets assume that phc is the only compiler available for the language. 例如,让php成为有问题的语言,并假设phc是该语言唯一可用的编译器。 This compiler only works on Unix-like environments. 此编译器仅适用于类Unix环境。 So the question is, is it easier to maintain a new compiler for Windows (eg phc-win )? 所以问题是,维护Windows的新编译器(例如phc-win )是否更容易? or maintain a Unix-like environment that works on Windows (eg Cygwin )? 或者维护一个适用于Windows的类Unix环境(例如Cygwin )?

For the System A instruction set, the emulator is easier to write and maintain. 对于System A指令集,仿真器更易于编写和维护。 But you always pay a performance penalty, so you have saved on engineering effort for a small number of people, by making the larger number of users less productive. 但是你总是要付出性能损失,所以你通过减少大量用户的工作效率,为少数人节省了工程费用。

However, systems are not just instruction sets. 但是,系统不仅仅是指令集。 The application runs on a virtual machine consisting of the System A machine instructions it uses directly, and the System A OS calls it makes. 应用程序在虚拟机上运行,​​该虚拟机由直接使用的System A机器指令和它所调用的System A OS调用。 To run System A applications on system B, you have not only emulate system A instructions, but System A operating system calls. 要在系统B上运行System A应用程序,您不仅要模拟系统A指令,还要模拟系统A操作系统调用。 And given the complexity of modern operating systems, this can be a very big effort. 鉴于现代操作系统的复杂性,这可能是一项非常大的工作。

The Linux WINE (WINdows Emulator) does exactly this; Linux WINE(WINdows Emulator)就是这样做的; this runs Windows binaries under Linux (in various forms). 这在Linux下运行Windows二进制文件(以各种形式)。 WINE emulates Windows x86 instructions by virtue of running on x86 only Linux systems which means it lets the CPU do the instruction emulation work. WINE通过仅在x86上运行Linux系统来模拟Windows x86指令,这意味着它可以让CPU执行指令仿真工作。 Then it emulates a lot of Windows OS calls. 然后它模拟了许多Windows操作系统调用。 Its a big program, under continuous development (for over a decade I think), and has to continually change just to keep up with changes in Windows that Microsoft makes. 它是一个大型计划,在不断发展(我认为十多年),并且必须不断改变以跟上微软制造的Windows的变化。 And it still has a wish/bug list for things it does not do well. 对于它做得不好的事情,它仍然有一个愿望/错误列表。

While WINE does pretty well, the effort to build and maintain it are pretty big. 虽然WINE做得很好,但是构建和维护它的努力非常大。 You don't see a lot of competition, which suggests that the effort is daunting. 你没有看到很多竞争,这表明这种努力令人生畏。

I will note that building a compiler doesn't solve the OS emulation problem either; 我会注意到构建编译器也不能解决操作系统仿真问题; source code of the application may now compile to native System B instructions, but the OS calls it makes .... the compiler doesn't handle. 应用程序的源代码现在可以编译为本机系统B指令,但操作系统调用它使....编译器无法处理。 As compiler engineers, you solve the code portability problem by pushing the OS emulation problem on the application owners. 作为编译工程师,您可以通过在应用程序所有者上推送OS仿真问题来解决代码可移植性问题。 That's an easier problem: they only have emulate the aspects of the System A OS calls on which they depend; 这是一个更容易的问题:他们只模拟他们所依赖的系统A OS调用的各个方面; they don't have to emulate every aspect of those calls. 他们不必模仿这些电话的每个方面。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM