为什么Quora使用Python语言开发?听听Quora创始人怎么说

为什么Quora使用Python语言开发?Quora是国外知名的SNS问答社区,Quora创始人是Facebook前雇员,而Facebook使用PHP开发,为什么Quora使用Python作为语言开发呢?听听听听Quora创始人怎么说:

Quora创始人来说说为什么Quora使用Python开发

Quora是国外的问答社区(类似中国的知乎),Quora是由Facebook前雇员查理·切沃(Charlie Cheever)和亚当·安捷罗(Adam D' Angelo)创建的,众所周知,Facebook使用PHP作为开发语言,为什么Quora却使用Python作为开发语言呢?

有人在Quora上对此提出疑问,得到了Quora创始人Adam D' Angelo的回复,听听Quora创始人Adam D' Angelo怎么说:

为什么Quora使用Python语言开发?听听Quora创始人怎么说_第1张图片

Quora为什么使用Python语言开发


码笔记翻译:

 

  • 关于为什么不使用PHP

Adam D'Angelo(CEO at Quora)明确表示不会使用PHP,由于Facebook历史遗留问题而不得不使用PHP,他在Facebook任职期间明白了一个道理:“选择变成语言非常重要,变更语言成本十分昂贵”。Adam D'Angelo和另一位Quora创始人对Python对比较熟悉。

  • 关于C#的选择

最初C#也是非常值得考虑的编程语言,但是如果选择C#,就意味着未来会被捆绑在微软的技术栈上,而他们想要尝试新的技术方案。
虽然,微软的SQL服务也是很好的,但是他们要集成很多开源代码,而这些开源代码对.NET平台支持很差,而且他们大部分的工程师都已经习惯使用开源产品。

除此之外,他们还有些担心Mono(C#和.NET的开源实现),不清楚这个项目会持续多久,另外可能还会有一些性能问题。

  • 关于Java和Scala

Java相对于Python而言,代码过于冗长,而且很难与非Java代码交互。Scala语言比较新潮,可能会隐含不必要的风险。

  • 关于OCaml和Haskell

Quora也考虑过OCaml和Haskell,但是OCaml和Haskell没有足够的生态和标准库支撑,这对于程序员来说太难了。

  • 为什么选择Python

Python语言的最大局限是速度和类型检查,单经过对比和分析,Quora创始人认为Python的速度足够应付(对性能关键影响的部分使用C++);对于类型检查,他们编写了完善的单元测试,以确保不会出问题。除去Python的这两个缺点,他们很愿意选择Python作为Quora的开发语言,并且Quora的员工对于选择Python也是非常满意。

Python 2.6发布后,Quora使用的大部分库都对该版本兼容,因此很快就迁移到新版本Python上;Tornado Web开发框架正式开源,Quora则将实时更新网络服务迁移到了Tornado上;PyPy发展迅速,最终应该可以正式用于生产,相信以后会大幅提高性能;Adam D'Angelo表示自己对Python语言和Python生态系统的未来充满了信息。

注意:以上翻译内容仅供参考,可能不准确,请以Quora上的问题为准,地址在文章底部。

Adam D' Angelo回复原文:

We were sure we didn't want to use PHP. Facebook is stuck on that for legacy reasons, not because it's the best choice right now.[1] Our main takeaway from that experience is that programming language choice is very important and is extremely costly to change.

Python was a language that Charlie and I both knew reasonably well (though I know it a lot better now than I did when we started). We also briefly considered C#, Java, and Scala. The biggest issues with Python are speed and the lack of typechecking.

C# seemed pretty promising. As a programming language, it's great, but:
We didn't want to be on the Microsoft stack. We were up for learning something new, and MS SQL Server actually seemed pretty good, but we knew we'd need to integrate with lots of open source code that has only second-class support for .NET, if it supports it at all. Also, most of the best engineers these days are used to open source stuff.
We didn't want to take the risk of being on Mono (an open source implementation of C#/.NET). It's not clear how long funding will be around for that project, and I'd heard of various performance problems. Plus, it seemed like everything else in the C# ecosystem would assume we were on the Microsoft stack.

For a lot of little reasons, Java programs end up being longer and more painful to write than the equivalent Python programs. It's also harder to interoperate with non-Java stuff. Scala had a lot of the downsides of Java and the JVM, although it wasn't quite as bad. The language seemed a little too new and like it would bring some unnecessary risk (for example, who knows how good support will be in 10 years).

Two other languages we very briefly thought about were OCaml and Haskell (neither had big enough ecosystems or good enough standard libraries, and both were potentially too hard for some designers/data analysts/non-engineers who might need to write code).

We decided that Python was fast enough for most of what we need to do (since we push our performance-critical code to backend servers written in C++ whenever possible). As far as typechecking, we ended up writing very thorough unit tests which are worth writing anyway, and achieve most of the same goals. We also had a lot of confidence that Python would continue to evolve in a direction that would be good for the life of our codebase, having watched it evolve over the last 5 years.

So far, we've been pretty happy with the choice. There's a small selection bias, but all of the early employees who'd been working with other languages in the past were happy to transition to Python, especially those coming from PHP. Since starting the following things have happened:

Python 2.6 got to the point where enough of the libraries we used were compatible with it, and we made a very easy transition to it.
Tornado (web framework) was released as open source, and we moved our live updating web service to that.
PyPy got to the point where it looks like it will eventually be usable and will give us a significant speedup.

All together, these give us confidence that the language and ecosystem is moving in a good direction.

[1] What are the horrors of PHP? and Do Facebook engineers enjoy programming in PHP? and Why hasn't Facebook migrated away from PHP? and What are some of the advantages of PHP over other programming languages? for more on that.

原文地址:https://www.quora.com/Why-did-Quora-choose-Python-for-its-development-What-technological-challenges-did-the-founders-face-before-they-decided-to-go-with-Python-rather-than-PHP

你可能感兴趣的:(为什么Quora使用Python语言开发?听听Quora创始人怎么说)