quora两位创始人选择python的原因

wape_yang 发布于 2014/09/17 00:22
阅读 784
收藏 0

question:

Since Adam D'Angelo, the founder, had worked for Facebook, which heavily uses PHP. I am trying to understand the technical challenges the founders of Quora faced before they decided to go with Python rather than PHP.

Adam D'AngeloAdam D'AngeloQuora Founder

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.

Charlie Cheever Charlie CheeverOne of the founders of Quora
846 upvotes by Yang WeipengJR IgnacioAdam D'Angelo(more)
A few things to add to Adam's answer:
  • There were a bunch of pretty good frameworks for Python available with good debuggers and reloaders.  (Django, Pylons, and others)  Most of these are well supported and also keep getting better.  Since the main thing we were building to start was a website, this was appealing
  • Python data structures map well to JavaScript data structures so marshaling data between the browser and the server is straightforward and easy.  This is really nice since Quora involves a lot of interactions between the client and server that aren't page loads.
  • Python code tends to be very readable and since we wanted to be able to work on the site with a bunch of people, this was important.
  • There are lots of other libraries that are written in Python so its easy to incorporate things like custom mail servers, task queues, etc. into the rest of our codebase.

Ruby is the other choice that I think would have been reasonable since it has many of the same advantages that Python has but Adam and I both knew Python better than we knew Ruby.


原文链接:http://www.quora.com/Why-did-Quora-choose-Python-for-its-development


quora 两位创始人为什么选择python开发,两位创始人都是从 facebook出来的

python 在国外相比php 是不是比国内更流行呢

加载中
1
wape_yang
wape_yang

Quora上有人问了这样的问题:

 

作为Quora的创始人,Adam曾经在Facebook工作(按:Facebook的前VP),大家都知道Facebook就是个PHP作坊。 我想知道Quora为什么选择了Python而不是PHP作为开发语言?这样的选择又面临什么样的技术挑战?

 

 

Adam 站出来回复了:

 

PHP显然不在考虑之列。Facebook继续使用PHP完全是因为历史原因,并不是因为PHP现在是最好的选择。这件事让我们明白两个道理,那就是:

 

1.       开发语言的选择极其重要

2.       更换开发语言成本高昂。

 

Charlie(按:Quora的另一位创始人)和我都很熟悉Python(尽管我现在对Python的理解远比以前更加深刻)。事实上我们也曾经考虑过其他选择,比如C#, JavaScalaPython最主要的的问题是运行效率不高和缺乏类型检查机制。

 

C#看起来是不错的选择。作为一门程序语言,它非常棒,但是有以下顾虑:

 

1.       我们不想依赖于微软的技术链。 我们乐意学习新东西,MS SQL看上去也很不错。不过我们知道我们将集成很多开源程序,而这些开源程序对.NET顶多也就是提供二手的支持(如果有的话)。另外,现在最棒的程序员都习惯于使用开源的东东。

 

2.       我们也不想冒险去使用Mono(C#/.NET的开源实现)。 Mono项目的资金支持能持续到什么时候还是个未知数,而且也听说过它存在一些性能问题。另外一个很大的问题是,一旦你使用C#,它便假定你所有的东西都是基于微软的生态系统实现。

 

至于Java,也有一些并非根本的因素导致我们不乐意选择它。Java程序通常比同等Python程序要长,编写起来更加麻烦。如果需要集成非Java实现的东东,那就更头大了。Scala尽管会好一些,但还是从JavaJVM哪里继承了很多这样那样的毛病。同时Scala也太新了些,这会让我们冒不必要的风险(比如,天知道未来10年它会得到什么样的支持)

 

另外我们还考察过其它两种语言:OCamlHaskell。但二者都缺乏足够大的生态系统,标准库也不够完善。而且对于有时不得不写代码的设计师/数据分析师/非程序员来说,它们实在是太难于学习。

 

Python的性能已经能够满足我们绝大部分需要,而涉及性能关键的代码我们都尽可能使用C++实现,运行在后端服务器。至于缺乏类型检查的不足,我们通过详尽的单元测试来弥补,这非常有效,完全达到了目的。同时,过去5Python演进的方向也让我们对其未来的发展充满信心,这对我们的codebase非常有益。

 

到目前为止,我们很满意当初的选择。我们的选择或多或少有一些个人偏见,不过值得高兴的是,所有过去使用其他语言的团队成员都非常乐于转换到Python,特别是那些PHPer。还有一些值得一提的是:

 

1.       Python2.6发布时,我们用到的绝大部分库都保持了兼容,这是我们非常容易的完成升级。

2.       Tornado(web framework)开源了,我们马上把实时更新部分的web service迁移到Tornado实现。

3.       PyPy 看上去终于具有可用性了。这将给我们带来极大的性能提升。

 

所有这一切,都让我们相信Python及其生态系统在向好的方向发展。

 

 

另外一位创始人,Charlie,对Adam回复的一些补充,

 

1.       Python有许多很酷的框架,它们拥有很棒debuggerreloader,比如Django, Pylons等等。大多数框架都有良好的社区支持并变得越来越好。因为我们主要做的是web应用,所以这非常有吸引力。

2.       PythonJavascript的数据结构匹配得非常好(Python标准库内置对json的支持),因此browserserver间序列化和交互数据简单直接。由于Quora除了页面加载外, clientserver还有很多数据交互,所以这非常棒。

3.       Python代码有良好的可读性,这很重要,因为我们需要和很多人一起协作。

4.       Python有丰富的开源程序库,所以要集成mail servertask queue之类的到我们的codebase非常容易。

 

我想Ruby也是一个合理的候选,它同样具备很多Python具备的优点。只是Adam和我更熟悉Python

返回顶部
顶部