简体   繁体   English

为什么firefox是用C ++和javascript UI编写的?

[英]Why firefox is written in C++ and javascript UI?

Well..I am learning java now and I am curious to know will this yield a noticeable performance increase ? 嗯..我现在正在学习java,我很想知道这会产生明显的性能提升吗? And If many developers are following similar methodology for windows programming ( C++ back end and Java UI ) or other languages are used like python? 如果许多开发人员遵循类似的Windows编程方法(C ++后端和Java UI)或者像python一样使用其他语言?

*this : C++ back end and other languages for UI instead of using the other language to write the whole program . * this:C ++后端和UI的其他语言,而不是使用其他语言编写整个程序。

Firstly, Java and JavaScript are completely different and unrelated languages. 首先,Java和JavaScript是完全不同且不相关的语言。 Firefox uses JavaScript; Firefox使用JavaScript; it does not use Java at all. 它根本不使用Java。

Secondly, this was not done for performance reasons, it was done to make it simpler to write add-ons and extensions that can be used with Firefox on any platform. 其次,这不是出于性能原因而做的,它是为了简化编写可以在任何平台上与Firefox一起使用的附加组件和扩展。 C++ code needs to be compiled, and once compiled will only run on the platform that it was compiled for. 需要编译C ++代码,编译后只能在编译它的平台上运行。 JavaScript is an interpreted language which runs in an interpreter embedded in the browser, and so the same extensions can generally run on MacOS, Linux, or Windows (or anything else that Firefox runs on). JavaScript是一种解释语言,它运行在嵌入浏览器的解释器中,因此相同的扩展通常可以在MacOS,Linux或Windows(或运行Firefox的任何其他内容)上运行。

And yes, there are other programs that use scripting languages for this sort of purpose (to allow easy customization and extension). 是的,还有其他程序使用脚本语言来实现这种目的(允许轻松定制和扩展)。 For example, Civilization IV's UI and game logic is written entirely with Python and XML for this reason, while the performance-intensive graphics code is still in C++. 例如,由于这个原因,Civilization IV的UI和游戏逻辑完全用Python和XML编写,而性能密集型图形代码仍然在C ++中。

This question really doesn't make any sense unless you're really asking whether you should implement your applications as XUL applications. 这个问题确实没有任何意义,除非你真的在问你是否应该将你的应用程序实现为XUL应用程序。 Javascript by itself doesn't give you anything with which to build a user interface. Javascript本身并不能为您提供构建用户界面的任何内容 A tremendous amount of the code in Firefox is C++ code to provide the Javascript components with a UI framework. Firefox中的大量代码是C ++代码,用于为Javascript组件提供UI框架。

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

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