Python 对于大型应用程序是否足够好?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3700413/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Is Python good enough for big applications?
提问by Ilian Iliev
From the moment I have faced Python, the only thing I can say for it is "It is awesome". I am using Django framework and I am amazed by how quick things happen and how developer friendly this language is. But from many sides I hear that Python is a scripting language, and very useful for small things, experiments etc.
从我面对 Python 的那一刻起,我唯一能说的就是“它太棒了”。我正在使用 Django 框架,我对事情发生的速度以及这种语言对开发人员的友好程度感到惊讶。但是我从很多方面听说 Python 是一种脚本语言,对于小事、实验等非常有用。
So the question is can a big and heavy loaded application be built in Python (and django)? As I mainly focus on web development, examples of such applications could be Stack Overflow, Facebook, Amazon etc.
所以问题是可以用 Python(和 django)构建一个又大又重的应用程序吗?由于我主要专注于 Web 开发,因此此类应用程序的示例可以是 Stack Overflow、Facebook、Amazon 等。
P.S. According to many of the answers maybe I have to rephrase the question. There are several big applications working with Python (the best example is You Tube) so it can handle them but why then it is not so popular for large projects as (for example) Java, C++ and .NET?
PS根据许多答案,也许我必须改写这个问题。有几个使用 Python 的大型应用程序(最好的例子是 You Tube),所以它可以处理它们,但为什么它在大型项目中并不像(例如)Java、C++ 和 .NET 那样流行?
采纳答案by Luper Rouch
Python is a pleasure to work with on big applications. Compared to other enterprise-popular languages you get:
在大型应用程序中使用 Python 是一种乐趣。与其他企业流行语言相比,您可以获得:
- No compilation time, if you ever worked on a large C++ project you know how time consuming this can get
- A concise and clean syntax that makes reading code easier, also a big time saver when reading someone else's code or even yours when it was written long time ago
- Portability at the core level, if it's important for your app to run on more than one platform it certainly helps
- It's fast enough for most things, and when it's not, rewriting hot spots in C is trivial with tools such as Cython and numpy. People advocating against dynamic languages for speed reasons have forgotten the 80-20 rule (or never heard about it). The important thing to consider when choosing a language for a performance-critical application IMHO is how easily you can gain access to the C level when needed, and Python is great for that
- 没有编译时间,如果你曾经参与过一个大型 C++ 项目,你就会知道这会花费多少时间
- 简洁干净的语法,使阅读代码更容易,在阅读别人的代码甚至很久以前编写的你的代码时也能节省大量时间
- 核心级别的可移植性,如果您的应用程序在多个平台上运行很重要,那肯定会有所帮助
- 对于大多数事情来说,它已经足够快了,如果不是,则使用 Cython 和 numpy 等工具在 C 中重写热点是微不足道的。出于速度原因而反对动态语言的人们已经忘记了 80-20 规则(或者从未听说过)。在为性能关键型应用程序选择语言时要考虑的重要事项恕我直言是您在需要时可以轻松访问 C 级别,Python 非常适合这一点
It's not a magic language however, you need to use the same techniques used for big projects in other languages: TDD (some may argue that it's more important than in other languages because of the lack of type checking, but that's not a win for other languages, unit tests are alwaysimportant in big projects), clean OO design, etc... or maintaining your application will become a nightmare.
然而,它不是一门神奇的语言,您需要使用其他语言中用于大型项目的相同技术:TDD(有些人可能会认为它比其他语言更重要,因为缺乏类型检查,但这对其他语言来说并不是胜利)语言、单元测试在大项目中总是很重要)、干净的 OO 设计等……否则维护您的应用程序将成为一场噩梦。
The main reason for its lack of acceptance in enterprise compared to .NET, Java et al. is probably not having herds of consultants and "certified specialists" bragging about their tool being the best thing on Earth. I also heard Java was easily accepted because its syntax resembled C++... that may not be such a silly idea considering C# also chose to take this route.
与 .NET、Java 等相比,其在企业中缺乏接受度的主要原因。可能没有成群的顾问和“认证专家”吹嘘他们的工具是地球上最好的工具。我还听说 Java 很容易被接受,因为它的语法类似于 C++……考虑到 C# 也选择了这条路线,这可能不是一个愚蠢的想法。
回答by Preet Sangha
Google tend to use python for a lot, so I assume its ready for big time. We use python as glue for our products so we're happy with it.
谷歌倾向于使用 python 很多,所以我认为它已经准备好了。我们使用 python 作为我们产品的胶水,所以我们很满意。
回答by Manoj Govindan
In general, yes you can.
一般来说,是的,你可以。
I am mainly focused on the web development so for examples I can give Stack Overflow, Facebook, Amazon etc.
我主要专注于 Web 开发,因此我可以提供 Stack Overflow、Facebook、Amazon 等示例。
Reddit.comis written in Python. It has a large user base and receives a fair amount of traffic and seems to be doing well. Reddit doesn't use Django though.
Reddit.com是用 Python 编写的。它拥有庞大的用户群,获得了相当多的流量,而且似乎做得很好。不过 Reddit 不使用 Django。
回答by Matt Joiner
Python is ideal for web development. It's light, easy, and excels at gluing other bits together, and working with high level interfaces. If and when I do "web" development, I wouldn't use anything else.
Python 是 Web 开发的理想选择。它轻巧、简单,并且擅长将其他位粘合在一起,并使用高级接口。如果并且当我进行“网络”开发时,我不会使用其他任何东西。
Update0
更新0
It's also a superior language for scripting, small cross platform applications and prototyping. It only really starts to crumble when extreme performance requirements are stringent. That is, it's holding things up in a big way. I also find it's difficult to refactor (a property of dynamic typing), and to utilize platform specific bindings. These things can be worked around (quite easily, due to Python's C implementation, and numerous modules for this purpose), just as in most other good languages.
它还是一种用于脚本编写、小型跨平台应用程序和原型设计的高级语言。只有当极端性能要求非常严格时,它才会真正开始崩溃。也就是说,它在很大程度上阻碍了事情的发展。我还发现重构(动态类型的属性)和利用特定于平台的绑定很困难。这些事情可以解决(很容易,因为 Python 的 C 实现以及为此目的提供了大量模块),就像在大多数其他优秀语言中一样。
Python is the best high level language, the only language it can't replace is C.
Python 是最好的高级语言,它唯一不能替代的语言是 C。
回答by John La Rooy
Performance wise - Yes, certainly for web frontends. The performance bottleneck is alwaysthe database.
性能明智 - 是的,当然适用于 Web 前端。性能瓶颈始终是数据库。
回答by codea
See by yourself :
自己看:
http://en.wikipedia.org/wiki/List_of_Python_software
http://en.wikipedia.org/wiki/List_of_Python_software
I think it can handle big apps.
我认为它可以处理大型应用程序。
回答by Dave Kirby
The back end of YouTube is almost entirely in Python. Hereis a talk by Cuong Do Cuong, the engineering manager on the YouTube scalability team that goes into a lot of detail of the issues they faced and how they solved them. He points out that lanaguage speed is almost never a bottleneck.
YouTube 的后端几乎完全使用 Python。 这是 YouTube 可扩展性团队的工程经理 Cuong Do Cuong 的演讲,其中详细介绍了他们面临的问题以及如何解决这些问题。他指出,语言速度几乎从来都不是瓶颈。
I suspect that YouTube has a significantly higher load that whatever you are working on will.
我怀疑 YouTube 的负载要高得多,无论您在做什么。
回答by Rakis
The answer to your question really boils down to what you have in mind when you say "big application". The simple answer will be "yes". Python serves as the backbone for incredibly complex systems and it does so elegantly (just take a look at how large yet well designed Twisted & Django are). However, it's a tool like any other. It contains performance tradeoffs that may or may not be well suited to your application domain.
您的问题的答案实际上归结为您在说“大应用程序”时的想法。简单的答案是“是”。Python 作为令人难以置信的复杂系统的支柱,它的表现非常优雅(看看 Twisted & Django 有多大但设计得很好)。然而,它是一个和其他任何工具一样的工具。它包含可能适合或不适合您的应用程序域的性能权衡。
If you're looking to build a high-performance flight simulator that must run complex calculations at over 1000Hz... then Python probably isn't the right choice for the whole project. If, on the other hand, single-CPU performance isn't a predominant factor or the application will be spread out over multiple servers to achieve scalability requirements, Python will likely be a good choice.
如果您希望构建一个必须以超过 1000Hz 的频率运行复杂计算的高性能飞行模拟器……那么 Python 可能不是整个项目的正确选择。另一方面,如果单 CPU 性能不是主要因素,或者应用程序将分布在多个服务器上以实现可扩展性要求,那么 Python 可能是一个不错的选择。
It's amazing how easily people forget just how expensive development time is. Python is well known for the incredible speed with which production quality applications can be developed. For almost anything non trivial, the development time saved will faroutweigh the cost associated with tossing a few extra servers into the pool.
令人惊讶的是,人们多么容易忘记开发时间是多么昂贵。Python 以开发生产质量应用程序的惊人速度而闻名。对于几乎任何重要的事情,节省的开发时间将远远超过将一些额外的服务器投入池中的相关成本。
回答by ferran87
In fact, Python give you all of the best power of programming. Easy, powerful and quick! Enjoy it in big your projoect!
事实上,Python 为您提供了编程的所有最佳功能。简单,强大,快速!在您的项目中尽情享受吧!
回答by Kilon
There two very important factors with python:
python有两个非常重要的因素:
1) Easy to use
1) 易于使用
2) Easy to interface with other programming languages
2) 易于与其他编程语言交互
FACTOR 1
因素 1
Because python a language that emphasizes , simplicity , readability of code both for its own syntax and libraries, that equal to writing less code. And for software that is big this is very important. Your is simple, easier to understand by someone else, easier to debug , easier to recode , rewrite and modify. Easy to exchange between a team of many people.
因为 python 是一种强调代码的简单性和可读性的语言,因为它自己的语法和库,这等于编写更少的代码。对于大型软件来说,这非常重要。你的很简单,更容易被别人理解,更容易调试,更容易重新编码、重写和修改。多人团队之间容易交流。
FACTOR 2
因素 2
Why reinvent that wheel ? You want to use a C/C++ library ? How about a Java or .NET library ? Python will let you do exactly that and will even spoil you with allowing you to enjoy the experience without ever leaving python's syntax comfort zone. Jython, Ironpython, Cython, ctypes ,pyrex etc are excellent tools making python limitless with its capabilities let you code in all those diffirent languages/frameworks/runtimes always with python syntax. What more could you ask for ?
为什么要重新发明那个轮子?您想使用 C/C++ 库吗?Java 或 .NET 库怎么样?Python 会让你完全做到这一点,甚至会让你享受这种体验,而无需离开 Python 的语法舒适区。Jython、Ironpython、Cython、ctypes、pyrex 等都是出色的工具,让 Python 无限使用其功能,让您始终使用 Python 语法在所有这些不同的语言/框架/运行时中进行编码。你还能要求什么呢 ?
In the end its python flexibility that makes it accelerate in the gain of its popularity, always hand in hand with the ease of use . Power and ease of use is a huge temptation too hard to resist for small,big or huge developers alike.
最终,它的 Python 灵活性使它加速普及,始终与易用性相辅相成。强大的功能和易用性对于小型、大型或大型开发人员来说是一个难以抗拒的巨大诱惑。

