问题描述
抛开性能考虑,是否有任何已知的方法可以采用现有的 C、C++ 或 Objective C 代码并直接在浏览器中运行它?例如,一个编译器将所有代码转换成某种可以在浏览器中运行的解释性语言.像 Javascript,或 Actionscript 和 Flash 播放器,或者我想是 Java 和 JVM.
Performance considerations aside, is there any known way to take existing C, C++, or Objective C code and run it directly in the browser? For example, a compiler that converts all the code into some interpreted language that can be run in the browser. Like Javascript, or Actionscript and the Flash player, or I suppose Java and the JVM.
我知道有像 Haxe 这样的高级语言可以编译到不同的目标.另一方面,还有像 Cappuccino 和 GWT 这样的项目,它们试图让 Javascript 开发更像传统的桌面开发.
I recognize there are higher level languages like Haxe that can be compiled to different targets. And on the other side there are projects like Cappuccino and GWT that attempt to make Javascript development more like traditional desktop development.
但我想知道您是否有一个可以在桌面上运行的应用程序或一个用 C、C++ 或 Objective C 完成的现有代码库,是否可以轻松地将其转换为基于 Web 的应用程序?
But I was wondering if you had an application that worked on a desktop or an existing code base done in C, C++, or Objective C could it easily be converted to a web based application?
这方面有工作要做吗?这样做有什么实际理由吗?基本上把浏览器变成操作系统?
Is there work being done on this front? Is there any practical reason to do this? Basically turn the browser into the OS?
除了性能问题和操作系统供应商的根深蒂固之外,是否还有任何技术原因无法实现?能否将这种类似 C 的代码硬塞到浏览器中托管的虚拟机中?
Beside the performance issues, and the entrenchment of OS vendors, are there any technical reasons this couldn't be accomplished? Could this kind of C like code be shoehorned into a virtual machine hosted in a browser?
推荐答案
Google 的 Native Client (NaCl) 使用经过调整的编译器来创建 x86 目标代码,这些代码可以由浏览器验证并在沙箱中运行,而不会对性能造成重大影响 - 非常酷的东西.他们在其下编译了 Quake.
Google's Native Client (NaCl) uses a tweaked compiler to create x86 object code that can be verified by the browser and run in a sandbox, without a major performance hit - pretty cool stuff. They've compiled Quake under it.
这个Matasano 文章 对它的工作原理做了很好的总结.
This Matasano article has a good run-down on how it works.
这篇关于是否可以直接在浏览器中运行 C 代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!