tags:

views:

2471

answers:

14

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.

+13  A: 

In my opinion python is more than ready for developing complex applications. I see pythons strength more on the server site 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 ontop of appeninge, all in python. And as far as I know they use a lot of python inside google too.

Peter Hoffmann
+4  A: 

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.

Greg Hewgill
In general, if you're checking types in Python then you're doing it wrong. The canonical style in Python is not to ask what type an object is, but what methods it supports. For example, instead of asking "Are you a dog?", you ask "Can you bark?"
Ryan Ginstrom
+5  A: 

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".

cdleary
+3  A: 
Marcin
Compilation time checks aren't a replacement for testing.. I don't quite understand the complaint with python that it "requires lots of unittesting", since all code should.. Just because something compiles, doesn't mean it will work!
dbr
<flameproof on> I'd be game to hear where interfaces thing has actually affected any pyton code you've written.
Gregg Lind
A: 

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.

Martin Clarke
A: 

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

pauldoo
+3  A: 

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".

Hamish Downer
+13  A: 

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.

Giles Thomas
The obvious problem with IronPython of course, is that if you're not on Windows, you lose out on .NET :) But Resolver is cool, and sure looks like a real app :)
Gregg Lind
About a CPython looking professional -- I assume you mean _native_ in this context -- you can try out wxPython.
Kit
+1  A: 

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

Davide
A: 

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.

Andrea Francia
If your still doing python programming I recommend Eclipse with PyDev. Intype (http://intype.info/home/index.php) is nice if you prefer something lighter. Also PEP 8 is the accepted styleguide, but of course it's up to the individual programmer. http://www.python.org/dev/peps/pep-0008/
monkut
What aspect of code convention is missing? I find others' Python code to usually be very readable, because often the "right way" and "the fast way" is the simplest way, syntactically, so people use similar idioms.
Gregg Lind
@Gregg Lind: some standard libraries uses this_naming_convention and some other uses thisNamingConvention for method names. Even in the standard libraries there's not an adopted standard.
Andrea Francia
A: 

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.

John T
A: 

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.

minty
A: 

What is the best way to write Web applications in python?

need PY
A: 

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.

Lawrence Oluyede