<分区>
经过一段时间浏览大型项目的源代码,尤其是像 this 这样的应用服务器,我知道这些项目不是用一种语言开发的。他们中的许多人使用 python 作为第二语言。
现在我有四个问题:
- 为什么使用不止一种语言?
- 为什么python常用于辅助?
- 为什么项目的所有部分都没有用python开发,他们还在用c/c++?
- 哪些项目应该用python开发,哪些项目应该使用c/c++?
<分区>
经过一段时间浏览大型项目的源代码,尤其是像 this 这样的应用服务器,我知道这些项目不是用一种语言开发的。他们中的许多人使用 python 作为第二语言。
现在我有四个问题:
最佳答案
编程语言设计倾向于在“高级”功能和“低级”功能之间进行权衡,高级功能以牺牲速度为代价提高程序员的工作效率,而“低级”功能需要程序员付出大量努力,但生成的代码速度非常快。
因此有时在一个项目中使用两种语言是有意义的:
c2wiki 称之为 HardAndSoftLayers图案:
By virtue of the first rule of optimization, go ahead and write most of your code in the highest level language you can find.
By virtue of the third rule of optimization, when you must, use a profiler and find the slow parts of your program. Take those parts, and write them in a lower-level language.
作为引用,rules of optimisation是:
- First Rule Of Optimization - Don't.
- Second Rule Of Optimization - Don't... yet.
- Profile Before Optimizing
关于c++ - 为什么在应用服务器项目中使用不止一种语言?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10583201/