Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I just started learning Python, and I'd like to get some more context on the language.

I realize that, in many cases, Python is a slow language relative to C or C++. Thus, Python is probably not the best choice for applications that need to run as quickly as possible.

Outside of this, it seems like Python is a great general purpose language that is easy to read and write. The available libraries give it a huge amount of functionality. Outside of performance critical applications, where is it a bad choice to use Python (and why)?

share|improve this question

closed as primarily opinion-based by MichaelT, Ixrec, gnat, GlenH7, Kilian Foth Feb 16 at 10:47

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise.If this question can be reworded to fit the rules in the help center, please edit the question.

8  
There is no such thing as a great general purpose language. Every five years or so, a new one replaces the old one which survives only in niche markets. Lisp, Fortran, Pascal, Basic, Ada, Perl... – mouviciel Nov 23 '11 at 8:58
3  
@mouviciel: Pascal a niche language? Ok, its name was changed to Delphi to match the Borland/CodeGear/Embarcadero IDE, but Delphi is still (based on) Pascal and though it has lost marketshare, I wouldn't exactly call it a niche language. And neither Basic for that matter. Visual Basic is still Basic. Both Delphi and Visual Basic are used in many companies... – Marjan Venema Nov 23 '11 at 9:20
7  
"Python is a slow language relative to C or C++". You should back this up with the specific benchmark you used. In a some of cases (I/O bound programs that make a lot of system calls) Python is as fast as C because it's just a wrapper around the C library. – S.Lott Nov 23 '11 at 16:37
    
@S.Lott True, and PyPy may sometimes rival the JVM or even C/C++ – yati sagade Mar 11 '12 at 14:38
    
Pascal used to be the teaching language of choice when I was at university. Then a few decades flew past and now it seems to her Java. I code several languages professionally (half a dozen or so), but still code Delphi for fun. – Mawg Feb 15 at 15:47

Software aimed at embedded targets with their limited resources. Most of the processors on this planet either cannot run Python due to insufficient resources, or nobody has ported a version to that architecture. Most processors, even now, come with less than a megabyte of memory.

share|improve this answer
    
…that is until someone makes a Python port of Arduino. Oh wait! – Spoike Nov 23 '11 at 10:06
5  
@Spoike that link is for actually running python on the computer and only communicating serially to arduino. Arduino is not running python code – basarat Nov 23 '11 at 10:19
1  
@BasaratAli: Disclaimer - I wrote my comment in jest. ;-) – Spoike Nov 23 '11 at 11:13

The two places that jump to mind are things that require a lot of concurrency, for which I would use Erlang. Or Heavy duty numeric computation, which I would probably try to use Fortran.

share|improve this answer
1  
Is Fortran still ahead of C/C++ in numerical computation?... – Sardathrion Nov 23 '11 at 10:29
1  
You know I don't know. It is not an area I have much experience. But I do know that the fortran folks have spend 30+ years making their tools go really fast. – Zachary K Nov 23 '11 at 13:50
    
@Sardathrion - It's hard to say. Only natural, you understand. But, a few months ago, Mr. Lionel of Intel Fortran fame stated that their fortran line outsells every other product in their development line (which is not so narrow). – Rook Nov 23 '11 at 17:41
    
@Idigas: Indeed, I know that Fortran is extensively used but that could be due to legacy code and not optimisation constrains. Maybe I should ask that as a question... – Sardathrion Nov 23 '11 at 17:51
    
Also remember that a lot of the folks who do numerical computation know Fortran really well and it is their tool of choice. So When they have to that kind of task they will reach for Fortran. – Zachary K Mar 11 '12 at 16:52

Since Python is a dynamically-typed language, without compile-time checking, refactoring a large Python project that doesn't have extensive unit tests will be difficult.

So if you have a large project that needs to be maintained and modified for a long time, and your team is not committed to creating automated tests for everything, then you may do better to use Java or C#.

share|improve this answer
16  
Refactoring any large project without unit tests is very hard. – Sardathrion Nov 23 '11 at 10:30
8  
True, but much harder without type safety. – Eric Wilson Nov 23 '11 at 11:01
3  
@Eric Wilson - Even then, strong typing can give you a false sense of security... It compiles, ship it! – Mark Booth Nov 23 '11 at 13:05
2  
This might not be 100% on topic of the question but still a valid point. Tooling support especially refactoring for dynamically typed languages is lacking compared to languages like Java or C#. Just renaming stuff can be an exhaustive exercise in large Python projects. – OliverS Nov 23 '11 at 13:55
    
Does Python require a separate runtime or VM, or can it generate a single self-contained executable? – Jim In Texas Mar 11 '12 at 2:41

If the main focus is windows GUI development, then I'd recommend against CPython as there's a shortage of good form designers (compared to using .Net).

However, IronPython runs on .Net and you there are two IDEs with Form designers to choose from: Visual Studio and SharpDevelop. In fact the Python Tools for Visual Studio can be used for CPython as well as IronPython, which is pretty neat though I haven't tried it yet...

share|improve this answer

This really depends on what you mean by "bad choice".

If you mean applications where using Python is very difficult, then there are relatively few: the main one that comes to mind and hasn't been mentioned yet is code requiring high levels of correctness where languages with sophisticated types systems (Haskell, dependently typed languages) are better options.

If you mean applications where Python is sub-optimal (that is, there are better choices) then there are more but they are also more subjective. For example, in my admittedly limited experience, working on compilers and interpreters is much easier with algebraic data types, pattern-matching and more functional features than Python has. However, exhaustively listing applications like this is impossible as they vary per person.

share|improve this answer

It's ideal for scripting something quickly because of its expressive capability and wide variety of support libraries.

Dynamic type checking and lack of explicit variable declaration make it a poor choice for large projects involving hundreds of thousands, or even millions of lines of code. The same thing goes for mission critical or safety critical systems. In an avionics system, for example, it would be completely unacceptable for a system to fail due to an error that could have been caught at compile time.

share|improve this answer

Well, just like you, I am also just starting with Python. But for me in the context of machine learning and data science.

I also just acquired all the fresh knowledge in Java 8 and its new stream oriented libraries.

I really loved the fluid feel of the new Java 8 stream libraries, and how close it felt I owing Apache spark libraries. When I went into Python, I expected the same and more.

I did see more. But a lot less. Poor documentation, although there was plenty of it; no fluidity, and as a matter of fact I was left guessing whether a method was reigning a new object, or operates on this; nothing close to a map/reduce etc. I was surprised to be left disappointed.

From the beginning however, I did not have great expectations of how easy it was going to be to learn to language. I was found to be right: inconsistent, un-intuitive, hard to learn. But that was just my experience of being pretty good at everything Java like.

share|improve this answer

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