Sign up ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free.

In choosing a technology for internet applications where the number of users may scale over time, which one should we consider: Java or Python? What are the considerations in choosing one and not the other? If speed and scalability is our main criteria, which one should we use?

We have looked around and it seems that there are more websites that use Python [i.e : Quora, digg, reddit, bitbucket and disqus] than Java. Based on that, can we say that Python is more suitable for internet applications where speed and scalability is the main criteria?

However we have browsed around and found some comments saying that Java is actually faster than Python.

Thank you for your insights.

share|improve this question

closed as off topic by Thomas Owens Nov 3 '12 at 17:54

Questions on Programmers Stack Exchange are expected to relate to software development within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

Why only Java and Python? What about Ruby, C#, PHP, or others? –  Anna Lear Apr 10 '11 at 4:52
@anna lear: He might be in love with Java or Python :) –  Ant's Apr 10 '11 at 5:00
Why not Jython? –  Mahmoud Hossam Apr 10 '11 at 6:37
Jython does not seems to be a serious project. How many sites use it in real life? –  Joshua Partogi Apr 10 '11 at 6:41
@jpartogl - Jython is a pretty serious for those of us who embed python environments into our java/eclipse applications. It may be behind the CPython main line, but it is perfectly usable and gives you the best of both java & python worlds. –  Mark Booth Apr 10 '11 at 18:19

4 Answers 4

up vote 26 down vote accepted

Python wins over Java on speed of development, and conciseness of code. This generally makes Python a better choice for small startups for whom speed to market, and ability to implement new features matters most. All of the sites that you mention chose Python when they were small startups. Only later did they have to scale. Websites tend to be horizontally scalable, meaning that for a surprising range of volumes of traffic you can just throw more webservers at it and the bottlenecks will be at other layers (for instance the database).

Java wins over Python on speed of execution, the toolchain, availability of developers, and the ease of having a lot of people working together on a large project. For many established corporations, this set of features matters more than speed of development, and so there are a lot of Java jobs out there.

Addressing the points that Anna brought up:

  1. Ruby is similar to Python, except with worse performance and different aesthetics. Twitter is a good example of a site that uses Ruby. (They've moved away from it for internal batch jobs because of performance problems. But as far as I know, they still use it for webserving.)
  2. C# can be thought of as another iteration of Java that is fairly closely tied to the Microsoft technology stack. This site is developed on top of C#. (Yes, you can run C# on top of Mono, but grab 10 random C# developers and the odds are good that all 10 are running on Windows.)
  3. PHP has similar trade-offs to Ruby or Python. However PHP has the dubious distinction of being a poorly designed language that appeals to people want to get stuff done with as little programming knowledge as possible. Facebook is far and away the biggest site written in PHP. Many popular web applications (like Wordpress) are written in PHP.
share|improve this answer
Thanks @btilly. Well explained. I've also heard that with Java you need large RAM preferably 1GB to start with. What do you say about that? –  Joshua Partogi Apr 10 '11 at 6:22
+1 well said and good explanation.. –  Ant's Apr 10 '11 at 7:00
1GB is large ram? –  Carson Myers Apr 10 '11 at 8:15
@jpartogi: Sorry about being slow to get back to you. Java does like to take up more RAM than it really needs. However you can then run multiple threads at once so the RAM/thread is not so bad. However if you want to maintain low latency, you should think about how to handle gc pauses. –  btilly Apr 11 '11 at 18:31

The pool of available and trained staff with knowledge of Java is far larger than that of staff with equivalent knowledge of Python. If the site needs to be maintained and/or hosted reliably, that's a major factor to consider.

share|improve this answer

There is one thing that may be important in the long run.

Java EE is designed to allow applications to spread over more than one computer. This is very important when you need your application to be scalable since you will at some time reach the point where you cannot buy a bigger box anymore.

I do not know if a similar framework is available for Pyton, but in that case Jython may be exactly what you need.

share|improve this answer
Thanks. would you recommend full blown java ee or springframework is also as scalable? –  Joshua Partogi Apr 10 '11 at 22:46
@jpartogi, I am not recommending it as such - just mentioning a thing that may be important. –  user1249 Apr 11 '11 at 1:10
@jpartogi: no framework is "scalable", but neither JEE or Spring prevent you from building scalable applications (and I mean massively scalable, think running hundreds of concurrent servers). –  jwenting Apr 11 '11 at 7:25

Why not get the best of both worlds? I work in a mixed Java/Jython environment and find they really complement each other.

For anything I might want to develop, I can chose to use either Python, Java or a mixture of the two. Need a quick hack class to test something, make a python class derived from your java class. Need to optimise some bits or make them more type safe, re-factor those classes into java.

The great thing about Jython is that you have access to the java class heirarchy as well as the Jython libraries.

share|improve this answer
and nowadays, you can use Python as a scripting language inside Java. Never tried it, but could be handy for things like a reporting engine where the data collection and manipulation algorithms are liable to change on the fly but the code to display that data doesn't. –  jwenting Apr 11 '11 at 7:27
Yes, that's precisely what we do. We have an Open source Eclipse RCP application which includes a Jython console and script PyDev scripts perspective, where users can write and run their own scripts using all of the facilities of our back end server. –  Mark Booth Jun 20 '11 at 9:54

Not the answer you're looking for? Browse other questions tagged or ask your own question.