Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

Over on SO I came across a question regarding which platform, Java or Python is best for developing on Google AppEngine. Many people were boasting of the increased productivity gained from using Python over Java. One thing I would say about the Python vs Java productivity argument, is Java has excellent IDE's to speed up development where as Python is really lacking in this area because of its dynamic nature.

So even though I prefer to use Python as a language, I don't believe it gives quite the productivity boost compared to Java especially when using a new framework. Obviously if it were Java vs Python and the only editor you could use was VIM then Python would give you a huge productivity boost but when IDE's are brought into the equation its not as clear cut.

I think Java's merits are often solely evaluated on a language level and often on out dated assumptions but Java has many benefits external to the language itself, e.g the JVM (often criticized but offers huge potential), excellent IDE's and tools, huge numbers of third party libraries, platforms etc..

Question, Does Python/related dynamic languages really give the huge productivity boosts often talked about? (with consideration given to using new frameworks and working with medium to large applications).

share|improve this question
2  
Check out the PyCharm IDE. But also, I believe there's some new framework for GAE that converts Java code into JavaScript for use on the front end, which could be a big productivity gain. –  Andrew M Mar 4 '11 at 14:20
12  
IDE or not, you still have to write 10 lines of Java for some things that can be done (well) in one line of Python. –  delnan Mar 4 '11 at 15:51
1  
Don't be ashamed of your love for Java. You've learned a few tricks (IDE, libraries, and frameworks) that let you kick the butts. Embrace it. You don't need permission from us to be awesome. If Java makes you productive, then that's enough. –  Scant Roger Mar 5 '11 at 6:10
1  
1) JVM potential is very limited. Deliberately. It is not "bad", it is just, well, limiting. 2) IDEs can only help if all you do is integrating hundreds of the existing components (which is a valid and honoured kind of programming, but not the only one). When it comes to implementing complex algorithms, Python is so much more productive than Java (even things like lambda functions and list comprehensions makes a huge difference). –  SK-logic Dec 26 '11 at 13:01
1  
If your productivity is significantly increased by your IDE, then the chances are that there is something terribly wrong with you, or your programming platform. (Smalltalk is the exception this, because it creates a wholly reflective system for programming). –  Marcin Dec 26 '11 at 19:03

7 Answers 7

up vote 16 down vote accepted

One of Python's major advantages is its "batteries included" philosophy: an extensive and simple to use standard library. In Java, just reading a text file requires several lines of code, nested readers and such. In Python it's f.read(). This will definitely be a huge productivity boost especially in quick prototyping. Python the language is also generally less verbose, which is not a bad thing (although I think the importance of verbosity vs. conciseness is often overemphasized).

However, if you're already working on some framework, such as GAE, then I would expect the differences to be much smaller, and mainly up to one's personal fluency in the language. You'll be mostly just wiring the framework together with the syntax of your choice, and there Python's great standard library helps little.

share|improve this answer
    
I really need to learn how to use the GAE. Any online tutorial series you would recommend? I'm familiar with Python, but don't have a clue about GAE. Thanks! –  Sergio Mar 4 '11 at 15:14
    
@Sergio: code.google.com/appengine/docs :-) –  Joonas Pulakka Mar 4 '11 at 15:32
3  
Or you can add Apache Commons IO with a line of Maven config and then read files in one line too. The batteries included approach is a double-edged sword to me. –  jiggy Dec 26 '11 at 22:21
    
@jiggy: I agree to some degree; Python's batteries are almost always useful and often sufficient, but obviously the standard library can't cater for all possible purposes, so you have to fall back to libraries sometimes. –  Joonas Pulakka Dec 27 '11 at 7:18
1  
Reading a text file in java: List<String> lines = Files.readAllLines(Paths.get("file.txt"), Charset.forName("UTF-8"));. Not too bad! (This is java 7 which was not released yet in March 11). –  assylias Jun 6 '13 at 22:29

Here are my 2 cents. In my experience Python is good for small to middle-sized projects whereas for larger projects I am more productive with Java.

In general, I can use a dynamically typed language like Python (or PHP) for smaller projects: it is not too complex, you want to get it done fast and there is not too much that can go wrong. In this case, I find that Python can be more practical to use.

However, when I have to develop a larger piece of software, I prefer a statically typed language like Java because I prefer the compiler to perform as many checks as possible for me. My experience is that in larger projects I have to spend more time fixing bugs with Python than with Java, so I do not bother if it takes a bit more to write the code in Java because this will save time later.

share|improve this answer
2  
+1, fully agree. I love using Python and similar languages on smaller projects where I can wrap my head around their entire scope without much trouble. The problem comes in larger projects where you have to infer interfaces between components. This, combined with weaker refactoring support makes me less confident in producing large, stable, maintainable systems. Lots of tests have to be written and maintained, just to make up for the lack of static analysis that the compiler performs. When it gets to this point, the benefit of the quick initial iteration is lost in mainenance. –  bunglestink Dec 8 '12 at 4:27
    
I use both, and I like both. I fully agree with you. –  Daniel Baktiar May 8 '13 at 11:54

I am much more productive in more powerful languages like Python or Ruby. It doesn't matter if some of the Java code can be generated by an IDE. There is more code to read and maintain. It takes more time to wade through repetitive code and find the important parts, and more time to change it. It's fine that Eclipse can convert

private Date dateOfBirth;

to:

private Date dateOfBirth;
public Date getDateOfBirth() { return dateOfDeath; }
public setDateOfBirth(Date d) { dateOfBirth = d; }

but every time I open the class I will see that junk and have to skim past it to find the interesting parts. Also, during maintenance, errors can be introduced into generated code.

I would much rather see:

attr :date_of_birth

To me, the need for an IDE to work effectively with Java is a good reason to choose another language.

Perhaps more powerfully, compare this Ruby code:

avg = people.filter { |p| p.height > 200 }.collect(:weight).average

against similar Java code:

List<Double> weights = new ArrayList<Double>();
for (Person p: people) {
  if (p.getHeight() > 200) {
    weights.add(p.getWeight());
  }
}
return Stats.average(weights);

The Ruby code is a direct translation of the specification: the average weight of people taller than 200 (cm). A comment would be utterly redundant.

The Java code requires considerable work to both write and read.

Paul Graham makes a convincing argument for brevity in programming languages in this essay. Having done some graduate level mathematics, I find his argument compelling, and the arguments against brevity weak. Certainly a single line in a high level language may be harder to understand than a single line in a low level language, just as a partial differential equation is harder to comprehend than a simple addition. But a single line in a powerful language is easier to comprehend than the five or ten lines it replaces. Imagine reading a math text that was written using words instead of symbols.

share|improve this answer
    
I've not used Python, but have used C# which has auto properties. How much work is it in Python to add logic into that (say firing an event or validation logic)? –  mlk May 20 '11 at 14:11
    
@mlk -- The "attr" statement is from Ruby. In Ruby it is very simple to attach behavior when a property is set. –  kevin cline May 21 '11 at 3:39
    
In python, all class attributes are automatically public, so most of the time you will access them directly. –  Zhehao Mao Jun 18 '11 at 15:08
3  
Python doesn't need getters or setters - just make dateOfBirth public. If logic needs to be added to it later on get or set, add a _dateOfBirth to store the data, then create a property named dateOfBirth with both get and set methods. The calling code doesn't need to change at all in Python. Java only uses accessors because it doesn't have the concept of "property"s. –  Izkata Jan 6 '12 at 22:58
    
While I agree that features like properties can make code more concise thus (slightly) improving productivity, in my experience the real productivity boost comes from good design: code is understandable when it has a clean, clear structure. Of course you need a language that supports programming-in-the-large (modules, encapsulation, etc), so productivity also depends on the language you are using, but such features as properties, lambdas (in a non-functional language), and other syntactic sugar stuff have a small impact on productivity compared to being able to produce a good design. –  Giorgio Dec 10 '12 at 9:24

I moved from Java to Python a few years ago and personally feel that I am more productive. As @Joonas points out, a lot of the productivity comes from the packaged library. But some of it is from the language itself. I can't imagine not having dictionaries, list comprehensions, higher order functions & a shell.

Keep in mind that if you already known Java it'll take awhile to become fluent in Python.

share|improve this answer

This is a bit of an old question but I'd like add my $.03. I think that it depends a lot on the way you think as well. I for one really can't stand dynamic, interpreted languages. I am, on the other hand, a huge fan of statically-typed languages. Sure, using Java can be more verbose but I find it easier to read and maintain once it's all said and done. I find Python, Ruby, and Perl to be extremely difficult to read (for me). I just can't wrap my head around it even though I've tried. That said, I can write code in Scala just fine and it's no big deal. I think it depends on what you are comfortable with. At the end of the day Java is going to be a lot more powerful; more so than Ruby, Python, or Perl. The JVM is a compelling piece of technology and learning to harness the power of it could prove very beneficial for you.

share|improve this answer
1  
Agreed, sure you can hack away with Python really fast but it can become a nightmare to debug later or to add new features, thats why its often called a "prototyping language" and thats just what I feel its useful for (or for ad-hoc type of scripts) –  programmx10 May 20 '11 at 19:27
2  
when is the end of that day going to come? We have been waiting about 20 years and Java still doesn't have first-class functions or any meta-programming facility. In the meantime C# has advanced tremendously. Over the past year I started writing Groovy code instead of Java and my productivity increased tremendously. The Groovy code is much smaller and easier to understand than the corresponding Java code because the noise is gone. –  kevin cline May 21 '11 at 3:50
    
@Kevin Cline - I know what you're saying - I've been a .NET developer for the last like six years or something. I am not talking about just productivity but sheer compile time, concurrency, and multicore type stuff. Java and JVM (Groovy, Scala, etc.) JVM is what is the most important thing here not necessarily Java itself. –  Steven Ellliott Jr May 21 '11 at 17:42
2  
@programmx10 The maintainability of your Python code depends on how you've written it. If you made it all one big kludge then of course you won't be able to debug it. If, on the other hand you've organized your code well and separated your functionality into modules and classes, then it can be just as easy to maintain (if not easier) than Java code. –  Zhehao Mao Jun 18 '11 at 15:12

I find that Python, Ruby, Javascript and SQL are much more productive than compiled languages such as Java because those languages have a very quick feedback loop. You can run a few lines of code on a command line and immediately know if the code is correct or not. If it throws exceptions, you know immediately. With Java you have to compile, package and deploy which can often take minutes for large systems, and this results in a very slow feedback cycle.

The fast feedback cycle lets you quickly iterate to a good solution, and that is what makes dynamic languages more productive.

share|improve this answer
    
great application of the term feedback loop –  amphibient Nov 13 at 22:25

I've been doing a lot more python recently and have been a java programmer for a long time, and for brand new development, I think I'm quite a bit more productive in python. a lot of fairly simple things in java can be a bit tedious, like file/stream processing, reading stuff from a URL, serializing XML, etc. by "tedious", I mean what takes you 5 lines of code in java often seems to take only one in python. using the right tools, like guava or another collections API, can really help with this however.

I guess I'm saying that one advantage of python is it ships with many features that you need to use a 3rd party library in java to get.

all that said, for certain things I would be far more productive in java than I could be in python, particularly when it comes to refactoring and working with large codebases, etc.

share|improve this answer
1  
Java is all about libraries though, with Python they have a bunch of methods, sort of like PHP does, to where it can be hard to remember them all, with Java you just search for the appropriate library and then you at least have choices as to what you use –  programmx10 May 20 '11 at 19:28
1  
@programmx10 What are you talking about? Python has plenty of libraries for all sorts of things. Just look at the documentation for the standard library. Python libraries are separated into modules, just as Java libraries are separated into packages. –  Zhehao Mao Jun 18 '11 at 15:15

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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