Is Python good for big software projects (not web based)?

Question:

Right now I’m developing mostly in C/C++, but I wrote some small utilities in Python to automatize some tasks and I really love it as language (especially the productivity).

Except for the performances (a problem that could be sometimes solved thanks to the ease of interfacing Python with C modules), do you think it is proper for production use in the development of stand-alone complex applications (think for example to a word processor or a graphic tool)?

What IDE would you suggest? The IDLE provided with Python is not enough even for small projects in my opinion.

Asked By: martjno

||

Answers:

In my opinion python is more than ready for developing complex applications. I see pythons strength more on the server side than writing graphical clients. But have a look at http://www.resolversystems.com/. They develop a whole spreadsheet in python using the .net ironpython port.

If you are familiar with eclipse have a look at pydev which provides auto-completion and debugging support for python with all the other eclipse goodies like svn support. The guy developing it has just been bought by aptana, so this will be solid choice for the future.

@Marcin

Cons: as a dynamic language, has way
worse IDE support (proper syntax
completion requires static typing,
whether explicit in Java or inferred
in SML),

You are right, that static analysis may not provide full syntax completion for dynamic languages, but I thing pydev gets the job done very well. Further more I have a different development style when programming python. I have always an ipython session open and with one F5 I do not only get the perfect completion from ipython, but object introspection and manipulation as well.

But if you want to write second Google
or Yahoo, you will be much better with
C# or Java.

Google just rewrote jaiku to work on top of App Engine, all in python. And as far as I know they use a lot of python inside google too.

Answered By: Peter Hoffmann

I really like python, it’s usually my language of choice these days for small (non-gui) stuff that I do on my own.

However, for some larger Python projects I’ve tackled, I’m finding that it’s not quite the same as programming in say, C++. I was working on a language parser, and needed to represent an AST in Python. This is certainly within the scope of what Python can do, but I had a bit of trouble with some refactoring. I was changing the representation of my AST and changing methods and classes around a lot, and I found I missed the strong typing that would be available to me in a C++ solution. Python’s duck typing was almost too flexible and I found myself adding a lot of assert code to try to check my types as the program ran. And then I couldn’t really be sure that everything was properly typed unless I had 100% code coverage testing (which I didn’t at the time).

Actually, that’s another thing that I miss sometimes. It’s possible to write syntactically correct code in Python that simply won’t run. The compiler is incapable of telling you about it until it actually executes the code, so in infrequently-used code paths such as error handlers you can easily have unseen bugs lurking around. Even code that’s as simple as printing an error message with a % format string can fail at runtime because of mismatched types.

I haven’t used Python for any GUI stuff so I can’t comment on that aspect.

Answered By: Greg Hewgill

Python is considered (among Python programmers 🙂 to be a great language for rapid prototyping. There’s not a lot of extraneous syntax getting in the way of your thought processes, so most of the work you do tends to go into the code. (There’s far less idioms required to be involved in writing good Python code than in writing good C++.)

Given this, most Python (CPython) programmers ascribe to the “premature optimization is the root of all evil” philosophy. By writing high-level (and significantly slower) Python code, one can optimize the bottlenecks out using C/C++ bindings when your application is nearing completion. At this point it becomes more clear what your processor-intensive algorithms are through proper profiling. This way, you write most of the code in a very readable and maintainable manner while allowing for speedups down the road. You’ll see several Python library modules written in C for this very reason.

Most graphics libraries in Python (i.e. wxPython) are just Python wrappers around C++ libraries anyway, so you’re pretty much writing to a C++ backend.

To address your IDE question, SPE (Stani’s Python Editor) is a good IDE that I’ve used and Eclipse with PyDev gets the job done as well. Both are OSS, so they’re free to try!

[Edit] @Marcin: Have you had experience writing > 30k LOC in Python? It’s also funny that you should mention Google’s scalability concerns, since they’re Python’s biggest supporters! Also a small organization called NASA also uses Python frequently 😉 see “One coder and 17,000 Lines of Code Later”.

Answered By: cdleary

You’ll find mostly two answers to that – the religous one (Yes! Of course! It’s the best language ever!) and the other religious one (you gotta be kidding me! Python? No… it’s not mature enough). I will maybe skip the last religion (Python?! Use Ruby!). The truth, as always, is far from obvious.

Pros: it’s easy, readable, batteries included, has lots of good libraries for pretty much everything. It’s expressive and dynamic typing makes it more concise in many cases.

Cons: as a dynamic language, has way worse IDE support (proper syntax completion requires static typing, whether explicit in Java or inferred in SML), its object system is far from perfect (interfaces, anyone?) and it is easy to end up with messy code that has methods returning either int or boolean or object or some sort under unknown circumstances.

My take – I love Python for scripting, automation, tiny webapps and other simple well defined tasks. In my opinion it is by far the best dynamic language on the planet. That said, I would never use it any dynamically typed language to develop an application of substantial size.

Say – it would be fine to use it for Stack Overflow, which has three developers and I guess no more than 30k lines of code. For bigger things – first your development would be super fast, and then once team and codebase grow things are slowing down more than they would with Java or C#. You need to offset lack of compilation time checks by writing more unittests, refactorings get harder cause you never know what your refacoring broke until you run all tests or even the whole big app, etc.

Now – decide on how big your team is going to be and how big the app is supposed to be once it is done. If you have 5 or less people and the target size is roughly Stack Overflow, go ahead, write in Python. You will finish in no time and be happy with good codebase. But if you want to write second Google or Yahoo, you will be much better with C# or Java.

Side-note on C/C++ you have mentioned: if you are not writing performance critical software (say massive parallel raytracer that will run for three months rendering a film) or a very mission critical system (say Mars lander that will fly three years straight and has only one chance to land right or you lose $400mln) do not use it. For web apps, most desktop apps, most apps in general it is not a good choice. You will die debugging pointers and memory allocation in complex business logic.

Answered By: Marcin

I know I’m probably stating the obvious, but don’t forget that the quality of the development team and their familiarity with the technology will have a major impact on your ability to deliver.

If you have a strong team, then it’s probably not an issue if they’re familiar. But if you have people who are more 9 to 5’rs who aren’t familiar with the technology, they will need more support and you’d need to make a call if the productivity gains are worth whatever the cost of that support is.

Answered By: Martin Clarke

Refactoring is inevitable on larger codebases and the lack of static typing makes this much harder in python than in statically typed languages.

Answered By: pauldoo

One way to judge what python is used for is to look at what products use python at the moment. This wikipedia page has a long list including various web frameworks, content management systems, version control systems, desktop apps and IDEs.

As it says here – “Some of the largest projects that use Python are the Zope application server, YouTube, and the original BitTorrent client. Large organizations that make use of Python include Google, Yahoo!, CERN and NASA. ITA uses Python for some of its components.”

So in short, yes, it is “proper for production use in the development of stand-alone complex applications”. So are many other languages, with various pros and cons. Which is the best language for your particular use case is too subjective to answer, so I won’t try, but often the answer will be “the one your developers know best”.

Answered By: Hamish Downer

We’ve used IronPython to build our flagship spreadsheet application (40kloc production code – and it’s Python, which IMO means loc per feature is low) at Resolver Systems, so I’d definitely say it’s ready for production use of complex apps.

There are two ways in which this might not be a useful answer to you 🙂

  1. We’re using IronPython, not the more usual CPython. This gives us the huge advantage of being able to use .NET class libraries. I may be setting myself up for flaming here, but I would say that I’ve never really seen a CPython application that looked “professional” – so having access to the WinForms widget set was a huge win for us. IronPython also gives us the advantage of being able to easily drop into C# if we need a performance boost. (Though to be honest we have never needed to do that. All of our performance problems to date have been because we chose dumb algorithms rather than because the language was slow.) Using C# from IP is much easier than writing a C Extension for CPython.
  2. We’re an Extreme Programming shop, so we write tests before we write code. I would not write production code in a dynamic language without writing the tests first; the lack of a compile step needs to be covered by something, and as other people have pointed out, refactoring without it can be tough. (Greg Hewgill’s answer suggests he’s had the same problem. On the other hand, I don’t think I would write – or especially refactor – production code in any language these days without writing the tests first – but YMMV.)

Re: the IDE – we’ve been pretty much fine with each person using their favourite text editor; if you prefer something a bit more heavyweight then WingIDE is pretty well-regarded.

Answered By: Giles Thomas

Nothing to add to the other answers, besides that if you choose python you must use something like pylint which nobody mentioned so far.

Answered By: Davide

I had only one python experience, my trash-cli project.

I know that probably some or all problems depends of my inexperience with python.

I found frustrating these things:

  1. the difficult of finding a good IDE for free
  2. the limited support to automatic refactoring

Moreover:

  1. the need of introduce two level of grouping packages and modules confuses me.
  2. it seems to me that there is not a widely adopted code naming convention
  3. it seems to me that there are some standard library APIs docs that are incomplete
  4. the fact that some standard libraries are not fully object oriented annoys me

Although some python coders tell me that they does not have these problems, or they say these are not problems.

Answered By: Andrea Francia

And as far as I know they use a lot of python inside google too.

Well i’d hope so, the maker of python still works at google if i’m not mistaken?

As for the use of Python, i think it’s a great language for stand-alone apps. It’s heavily used in a lot of Linux programs, and there are a few nice widget sets out there to aid in the development of GUI’s.

Answered By: John T

Python is a delight to use. I use it routinely and also write a lot of code for work in C#. There are two drawbacks to writing UI code in Python. one is that there is not a single ui framework that is accepted by the majority of the community. when you write in c# the .NET runtime and class libraries are all meant to work together. With Python every UI library has at’s own semantics which are often at odds with the pythonic mindset in which you are trying to write your program. I am not blaming the library writers. I’ve tried several libraries (wxwidgets, PythonWin[Wrapper around MFC], Tkinter), When doing so I often felt that I was writing code in a language other than Python (despite the fact that it was python) because the libraries aren’t exactly pythonic they are a port from another language be it c, c++, tk.

So for me I will write UI code in .NET (for me C#) because of the IDE & the consistency of the libraries. But when I can I will write business logic in python because it is more clear and more fun.

Answered By: minty

Try Django or Pylons, write a simple app with both of them and then decide which one suits you best. There are others (like Turbogears or Werkzeug) but those are the most used.

Answered By: user210733
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.